java package - money
- From: "java_nut" <gingercrock@xxxxxxxxxxx>
- Date: 26 Oct 2006 16:04:32 -0700
good evening guys,
i am finding a piece of work extremely tough going at the moment and
wondered if i could get any hints/help on where im going wrong. i am
aiming to produce a package (money.java) which could be used in order
to produce arithmetic calculations on sums of money.
The code i have at the moment is:
MONEY.JAVA:
package java;
public class money
{
private int data1, data2;
public money()
{
data1=0;
data2=0;
}
public money(int value1, int value 2)
{
data1 = value1;
data2 = value2;
}
public void addMoney(int value1, int value2)
{
return value1 + value2;
}
public void subtractMoney(int value1, int value2)
{
return value1 - value2;
}
public void divideMoney(int value1, int value2)
{
return value1 / value2;
}
public void multiplyMoney(int value1, int value2)
{
return value1 * value2;
}
}
MONEYTEST.JAVA
import java.money;
public class MoneyTest
{
public static void main(String [] args)
{
money p = new money(10,20);
System.out.println("The total is " + p.addMoney());
}
}
I think i may need a 'toString' method? and also, is there any way of
covering errors? im sorry if these problems are trivial. I have various
books, but can't seem to use them in this case.
Thank you for any feedback.
Jess
.
- Prev by Date: Re: java package - money
- Next by Date: java package - money
- Previous by thread: java package - money
- Next by thread: java package - money
- Index(es):
Relevant Pages
|