Question: JAVA ONLY PLEASE Step 1 : Use the array of Student references we went over in lecture to help . Write an Invoice class. The

JAVA ONLY PLEASE

Step 1 : Use the array of Student references we went over in lecture to help . Write an Invoice class. The fields for the Invoice class for this lab are:

String invoiceID String description double amount boolean isPaid Write two constructor methods, a toString( ) method, a compareTo( ) method and an equals( ) method, in addition to the set( ) methods for isPaid and amount.

The e q uals( ) method should use the invoiceID field and the compareTo( ) methods should use the amount field. Be sure this Invoice c lass has all of the above methods.

Crea te a Driver that has main( ). In main( ) create an array of ten Invoice references reading the data from a file stored in the same directory as your project. The data file is a comma delimited file named invoicedata.t xt can be downloaded from Canvas .

Us e a loop to create the ten Invoice objects and store their address es in the array. Then, write a separate loop to print the Invoices using the toString( ) method of the Invoice class. The driver then must compare the first Invoice instance to the last Invoice object to determine which has a higher amount due. Then determine if the second and fifth Invoice objects are equal, based on the invoice id using the equals( ) method of the Invoice class.

-------------------------------------------------------- ---------------

Step 2: Create a class named Card (this will represent a standard playing card). The fields for the Card are the suit, the face (what you see, ie: 2,3 K) and a value. The Jack, Queen and King have a value of 10, the Ace has a va lue of 11.

Write an equals( ) method based on the suit and face , a compareTo( ) method based on the value field and a toString( ) method along with the constructor method , that takes a value for each of the three fields, and get( ) methods.

Then write a class named Deck. This class will represent a deck of 52 playing cards. The constructor method must create 52 Card instances to populate the array. Write a toString( ) method that returns the contents in a textual form at of the entire deck of cards. Use t he StringBuilder class to build the string, then convert to a String by using the constructor of the String class that accepts a StringBuilder reference.

Test your class by writing a short driver that creates a Deck instance and prints the contents of the Deck instance by calling its toString( ) method.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!