Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- zad 1
- class Account {
- final public int SAVING = 0;
- final public int CHEQUE = 1;
- final public int FIXED = 2; //Portuguese currency
- private int accountType;
- private double balance;
- public double getInterestRate(...) { // Some method;
- ...
- }
- public Account(int accountType) {
- this.accountType = accountType;
- }
- public double calcInterest() {
- switch (accountType) {
- case SAVING:
- return balance * getInterestRate();
- case CHEQUE:
- return 0;
- case FIXED:
- return balance * (getInterestRate() + 0.02);
- }
- }
- }
- zad 2
- class ParticipantsInDB {
- Connection conn;
- final String tableName = "participants";
- void addParticipant(Participant part) {
- PreparedStatement st = conn.prepareStatement("INSERT INTO " + tableName + "
- VALUES( ? , ? , ? , ? , ? )
- ");
- try {
- st.setString(1, part.getId());
- st.setString(2, part.getEFirstName());
- st.setString(3, part.getELastName());
- //...
- st.executeUpdate();
- } finally {
- st.close();
- }
- }
- void deleteAllParticipants() {
- PreparedStatement st = conn.prepareStatement("DELETE FROM " + tableName);
- try {
- st.executeUpdate();
- } finally {
- st.close();
- }
- }
- void deleteParticipant(String participantId) {
- PreparedStatement st = conn.prepareStatement("DELETE FROM " + tableName + "
- WHERE id = ? ");
- try {
- st.setString(1, participantId);
- st.executeUpdate();
- } finally {
- st.close();
- }
- }
- }
- zad 3
- class Form1 extends JDialog {
- JComboBox comboBoxReportType;
- Form1() {
- comboBoxReportType = new JComboBox();
- comboBoxReportType.addItem("r1");
- comboBoxReportType.addItem("r2");
- ...
- comboBoxReportType.addItem("r31c");
- }
- void processReport1() {
- //print some fancy report...
- }
- void processReport2() {
- //print another totally different fancy report...
- }
- ...
- void processReport31c() {
- //print yet another totally different fancy report...
- }
- void printReport(String repNo) {
- if (repNo.equals("r1"))
- processReport1();
- else if (repNo.equals("r2"))
- processReport2();
- ...
- else if (repNo.equals("r31c"))
- processReport31c();
- }
- void onPrintClick() {
- printReport((String) comboBoxReportType.getSelectedItem());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement