P
psmith
Could somebody please explain how to use the main() method properly.
I have read numerous books but none seem to help.
I have two classes - Payment and TestPayment.
In TestPayment I have the following code:
public class TestPayment
{
public static void main(String[] args)
{
// Create four Payment instances
Payment p1 = new Payment(2490, "Euros");
Payment p2 = new Payment(2490, "Euros");
Payment p3 = new Payment(2491, "Euros");
Payment p4 = new Payment(2490, "Pesos");
Payment p5 = new Payment(49, "Pesos");
Payment p6 = new Payment(9, "Pesos");
Payment p7 = new Payment(10, "Pesos");
}
}
In the Payment class I have the following method to create:
public boolean equals(Object o)
{
}
In here I have to check if the payments are the equal to each other,
firstly the amount, followed by the currency.
The amount is an int value(anAmount) and the currency a String value
(aCurrency)
How do I iterate through each Payment to see if they are equal or not?
Thanks in advance,
Paul
I have read numerous books but none seem to help.
I have two classes - Payment and TestPayment.
In TestPayment I have the following code:
public class TestPayment
{
public static void main(String[] args)
{
// Create four Payment instances
Payment p1 = new Payment(2490, "Euros");
Payment p2 = new Payment(2490, "Euros");
Payment p3 = new Payment(2491, "Euros");
Payment p4 = new Payment(2490, "Pesos");
Payment p5 = new Payment(49, "Pesos");
Payment p6 = new Payment(9, "Pesos");
Payment p7 = new Payment(10, "Pesos");
}
}
In the Payment class I have the following method to create:
public boolean equals(Object o)
{
}
In here I have to check if the payments are the equal to each other,
firstly the amount, followed by the currency.
The amount is an int value(anAmount) and the currency a String value
(aCurrency)
How do I iterate through each Payment to see if they are equal or not?
Thanks in advance,
Paul