Hi i have the next task to solve.
A bank holds different types of accounts for
its customers:
– Deposit accounts
– Loan accounts
– Mortgage accounts
Customers could be individuals or
companies. All accounts have customer,
balance and interest rate (monthly based).
Deposit accounts are allowed to deposit and
withdraw money. Loan and mortgage
accounts can only deposit money.
All accounts can calculate their interest
amount for a given period (in months). In the
common case its is calculated as follows:
number_of_months * interest_rate.
Loan accounts have no interest for the first 3
months if are held by individuals and for the
first 2 months if are held by a company.
Deposit accounts have no interest if their
balance is positive and less than 1000.
Mortgage accounts have ½ interest for the
first 12 months for companies and no interest
for the first 6 months for individuals.
Your task is to write a program to model the
bank system by abstract and concrete
classes. You should identify the classes, base
classes and abstract actions and implement
the calculation of the interest functionality.
Implement a test program that shows how
different types of accounts have different
interest rates.
Because i`am new and classes are still hard for me can u explain to me where am`i doing mistakes and how should i finish the task.
How can i do that part with setting and getting separate inviduals and company balances, and how can i do the part with "no interest for companies for X many months" and "no interest for inviduals for X many months".
Here is my creation so far.
I hope someone will take the time to see it all. Thanks in advance.
package zadacha_6;
public class customer {
private String name;
public customer (){
}
public customer(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package zadacha_6;
public class Inviduals extends customer{
private String personName;
public Inviduals() {
super();
// TODO Auto-generated constructor stub
}
public Inviduals(String name) {
super(name);
this.personName = name;
// TODO Auto-generated constructor stub
}
public String getPersonName() {
return personName;
}
public void setPersonName(String personName) {
this.personName = personName;
}
}
package zadacha_6;
public class companies extends customer {
private String companyName;
public companies() {
super();
// TODO Auto-generated constructor stub
}
public companies(String name) {
super(name);
this.companyName = name;
// TODO Auto-generated constructor stub
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
}
package zadacha_6;
public class accounts extends customer {
private double balance;
private double rate; //towa tr da e monthly rate
public accounts() {
}
public accounts(String name, double balance, double rate) {
super(name);
this.balance = balance;
this.rate = rate;
// TODO Auto-generated constructor stub
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public double getRate() {
return rate;
}
public void setRate(double rate) {
this.rate = rate;
}
}
package zadacha_6;
public class deposit_accounts extends accounts{
private double deposit;
private double depositRate = (double)20/(double)100;
private int months;
private double withdraw;
public deposit_accounts() {
super();
// TODO Auto-generated constructor stub
}
public deposit_accounts(String name, double balance, double rate) {
super();
// TODO Auto-generated constructor stub
}
public void deposit (String name, double deposit){
setBalance(getBalance() + deposit);
}
public void calcRate (double balance, double rate){
if (getBalance()>0 && getBalance() <1000){
rate = 1;
}
else {
rate = (getBalance()*depositRate)*months;
}
}
public void withdraw (String name, double withdraw){
setBalance(getBalance() - withdraw);
}
}
package zadacha_6;
public class loan_accaunts extends accounts {
private double loanRate = (double)5/(double)100;
private double desposit;
private int months;
public loan_accaunts() {
super();
// TODO Auto-generated constructor stub
}
public loan_accaunts(String name, double balance) {
super();
// TODO Auto-generated constructor stub
}
public void deposit (String name, double deposit){
setBalance(getBalance() + deposit);
}
public void calcRate (double balance, double rate){
rate = (getBalance()*loanRate)*months;
}
}
package zadacha_6;
public class morgage_accounts extends accounts {
private double morgageRate = (double)10/(double)100;
private double deposit;
private int months;
public morgage_accounts() {
super();
// TODO Auto-generated constructor stub
}
public morgage_accounts(String name, double balance) {
super();
// TODO Auto-generated constructor stub
}
public void deposit (String name, double deposit){
setBalance(getBalance() + deposit);
}
public void calcRate (double balance, double rate){
rate = (getBalance()*morgageRate)*months;
}
}