Tutorial 7
This commit is contained in:
parent
42c22c106b
commit
d50223dc4d
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
|
@ -0,0 +1,23 @@
|
|||
public class Bank {
|
||||
private CheckingAccount account;
|
||||
|
||||
public Bank() {
|
||||
account = new CheckingAccount();
|
||||
}
|
||||
public double cashCheck(Check check) {
|
||||
double amount = check.getAmount();
|
||||
double balance = account.getBalance();
|
||||
if (balance < amount) {
|
||||
account.addInsuficientFundFee();
|
||||
account.noteReturnedCheck(check);
|
||||
return -1;
|
||||
}
|
||||
int checkNumber = check.getCheckNumber();
|
||||
account.addDebitTransaction(checkNumber, amount);
|
||||
account.storePhotoOfCheck(check);
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
private void returnCheck(Check check) {}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
public class Check {
|
||||
public double getAmount() {
|
||||
return 100.0; // any valid double
|
||||
}
|
||||
|
||||
public int getCheckNumber() {
|
||||
return 1234; // any valid int
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
public class CheckingAccount {
|
||||
public double getBalance() {
|
||||
return 100.0; // any valid double
|
||||
}
|
||||
|
||||
public void addInsuficientFundFee() {}
|
||||
|
||||
public void noteReturnedCheck(Check check) {}
|
||||
|
||||
public void addDebitTransaction(int checknumber, double amount) {}
|
||||
|
||||
public void storePhotoOfCheck(Check check) {}
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello, World!");
|
||||
Bank bank = new Bank();
|
||||
Check check = new Check();
|
||||
bank.cashCheck(check);
|
||||
System.out.println("Compiled successfully!");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
|
@ -0,0 +1,7 @@
|
|||
public class Bank {
|
||||
public double cashCheck(Check check) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
private void returnCheck(Check check) {}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
public class Check {
|
||||
public double getAmount() {
|
||||
return 100.0; // any valid double
|
||||
}
|
||||
|
||||
public int getCheckNumber() {
|
||||
return 1234; // any valid int
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
public class CheckingAccount {
|
||||
public double getBalance() {
|
||||
return 100.0; // any valid double
|
||||
}
|
||||
|
||||
public void addInsuficientFundFee() {}
|
||||
|
||||
public void noteReturnedCheck(Check check) {}
|
||||
|
||||
public void addDebitTransaction(int checknumber, double amount) {}
|
||||
|
||||
public void storePhotoOfCheck(Check check) {}
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello, World!");
|
||||
Bank bank = new Bank();
|
||||
Check check = new Check();
|
||||
bank.cashCheck(check);
|
||||
System.out.println("Compiled successfully!");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue