Need help with objects please

I have an array that stores 3 objects in it. The object uses a getInvoiceAmount method in a seperate class to multiply two variables that have been declared in a previous method. Now what I want to do is make a getInvoiceTotal method that gets each objects seperate getInvoiceAmount method total, and adds them together. How would I go about doing this?

Here is my code

publicclass Invoice

{

private String partNumber;

private String partDescription;

privateint quantity;

privatedouble pricePerUnit;

public Invoice()

{

partNumber = ("");

partDescription = ("");

quantity = 0;

pricePerUnit = 0;

}

publicvoid setPartNumber(String strPartNumber)

{

partNumber = strPartNumber;

}

public String getPartNumber()

{

return partNumber;

}

publicvoid setPartDescript(String strPartDesc)

{

partDescription = strPartDesc;

}

public String getPartDescript()

{

return partDescription;

}

publicvoid setQuantity(int num)

{

quantity = num;

}

publicint getQuantity()

{

return quantity;

}

publicvoid setPricePerUnit(double num)

{

pricePerUnit = num;

}

publicdouble getPricePerUnit()

{

return pricePerUnit;

}

publicdouble getInvoiceAmount()

{

return quantity * pricePerUnit;

}

}

Question 2

How would I got about aligning a some text in a system.out print statment, so that it prints out aligned , like you would see in a table?

Cheers

Message was edited by:

Prime08

[3382 byte] By [Prime08a] at [2007-11-27 4:16:11]
# 1

> Question 2

>

> How would I got about aligning a some text in a

> system.out print statment, so that it prints out

> aligned , like you would see in a table?

Use System.out.printf.

http://java.sun.com/javase/6/docs/api/java/io/PrintStream.html#printf(java.lang.String,%20java.lang.Object...)

Kaj

kajbja at 2007-7-12 9:22:40 > top of Java-index,Java Essentials,New To Java...