|
-
May 11th, 2009, 03:02 AM
#1
getter setter
class calculate {
private int profitRate=20;
public long i;
customer obj=new customer("Mr.Stevens",189745329,40000000);
public void CalculatedMoneyAmount(){
i=( obj.getmoney() +( obj.getmoney()*profitRate)/100);
obj.setmonney(i);
}
}
class customer{
private String customerName;
private int accountNumber;
private long money;
public customer(String name,int number,long amount)
{
this.customerName=name;
this.accountNumber=number;
this.money=amount ;
}
public customer()
{
}
public long getmoney(){
return money;
}
public void setmonney(long i){
this.money=i;
}
public void calmoney() {
calculate obj=new calculate();
obj.CalculatedMoneyAmount();
}
}
public class Main {
/** Creates a new instance of Main */
/**
* @param args the command line arguments
*/
public static void main(String[] args){
customer o=new customer("Mr.Stevens",189745329,40000000);
o.calmoney();
System.out.println (o.getmoney());
}
}
It must retuern and show to output 48000000
But only shows 40 000000
-In the main mehtod I careate an instance of customer class
-After that I call calmoney
-calmoney calls CalculatedMoneyAmount in calculate class
-CalculatedMoneyAmount call getmoney
-CalculatedMoneyAmount send the profit to money variable by setmoney
-Now this line System.out.println (o.getmoney()); must print 48 000 000
But I see 40 000 000 !!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|