Question
In Java Please Create an Invoice class. The fields for the Invoice class are: String invoiceID, String description, double amount, boolean isPaid Customer cust, nb:
In Java Please
Create an Invoice class. The fields for the Invoice class are: String invoiceID, String description, double amount, boolean isPaid Customer cust,
nb: this will not compile until you have written the code for the Customer class.
The Invoice class must have two constructor methods,a toString( )method, compareTo( ) method (based on the amount field) and equals( ) method( based on the invoiceID field), in addition to methods to change the amount due and isPaid.(set methods) The toString( ) method for the invoice must call the toString( ) method from the Customer class.
You also need to write a Customer class definition. A Customer has the following fields: String lastName String firstName String id The Customer class must have a default constructor, a constructor that accepts arguments and a copy constructor.
The Customer class must also have a toString( ) method. Create a Driver that has main( ). In main( )create three Invoice instances. In order to create an Invoice object, you must first create Customer objects.
Create at least two Customer objects. Print the two Invoice objects to the screen using the toString( ) method of the Invoice class. The driver will compare the two Invoice instances using the compareTo( ) method, to determine which has a higher amount due. Then determine if the two Invoice objects are equal, based on the invoice id using the equals( ) method of the Invoice class.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started