Results 1 to 2 of 2
  1. #1
    checho is offline Member
    Join Date
    Jan 2010
    Posts
    14
    Rep Power
    0

    Default Help with classes and inheritance task.

    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.

    Java Code:
    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;
    		}
     
    }
    
    Help with Code Tags
    Java Syntax (Toggle Plain Text)
    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;
    	}
     
     
     
     
    }
    Java Code:
    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;
    	}
     
     
     
     
    }
    Java Code:
    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;
    	}
     
     
    }
    Java Code:
    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); 
    	}
     
     
    }
    Java Code:
    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;
    		}
     
    }
    Java Code:
    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;
    		}
    }
    Last edited by checho; 01-27-2010 at 09:45 AM.

  2. #2
    checho is offline Member
    Join Date
    Jan 2010
    Posts
    14
    Rep Power
    0

    Default

    what i changed is that account doesnt extend customers.
    how can i seprate the diferent rates for inviduals and companies?

Similar Threads

  1. Help with a task.
    By checho in forum New To Java
    Replies: 5
    Last Post: 01-14-2010, 11:29 AM
  2. Task Scheduler
    By fabs in forum Threads and Synchronization
    Replies: 3
    Last Post: 04-21-2009, 11:17 AM
  3. Need some help with a task, constructors.
    By JKM in forum New To Java
    Replies: 1
    Last Post: 02-01-2009, 10:09 PM
  4. Scheduling a task
    By bugger in forum Advanced Java
    Replies: 3
    Last Post: 12-04-2007, 12:32 PM
  5. Task Blocks 0.5
    By johnt in forum Java Software
    Replies: 0
    Last Post: 08-08-2007, 08:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •