Browse Source

still working on object orientation

Jennifer Chao 5 years ago
parent
commit
7855411cd6

+ 1
- 1
src/main/java/rocks/zipcode/quiz5/objectorientation/account/BankAccount.java View File

@@ -8,7 +8,7 @@ public class BankAccount extends Account implements Transactable {
8 8
     private Double balance;
9 9
 
10 10
     public BankAccount() {
11
-
11
+        this.balance = 0.0;
12 12
     }
13 13
 
14 14
     public void setBalance(Double val) {

+ 7
- 3
src/main/java/rocks/zipcode/quiz5/objectorientation/account/Employee.java View File

@@ -7,14 +7,18 @@ public class Employee implements Worker, Transactable {
7 7
 
8 8
     private BankAccount bankAccount;
9 9
     private Double hoursWorked;
10
-    private Double moneyEarned;
10
+    private Double hourlyWage;
11 11
 
12 12
     public Employee() {
13 13
         this.bankAccount = new BankAccount();
14
+        this.hoursWorked = 0.0;
15
+        this.hourlyWage = 35.0;
14 16
     }
15 17
 
16 18
     public Employee(BankAccount bankAccount) {
17 19
         this.bankAccount = bankAccount;
20
+        this.hoursWorked = 0.0;
21
+        this.hourlyWage = 35.0;
18 22
     }
19 23
 
20 24
     public BankAccount getBankAccount() {
@@ -37,12 +41,12 @@ public class Employee implements Worker, Transactable {
37 41
 
38 42
     @Override
39 43
     public Double getHourlyWage() {
40
-        return this.moneyEarned / this.hoursWorked;
44
+        return this.hourlyWage;
41 45
     }
42 46
 
43 47
     @Override
44 48
     public Double getMoneyEarned() {
45
-        return this.moneyEarned;
49
+        return this.hoursWorked * this.hourlyWage;
46 50
     }
47 51
 
48 52
     @Override