Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ITSC 1213 Lab 8 Purpose: to practice working with one-dimensional array of references(addresses). To use aggregation in a class definition. Step 1: use the array

ITSC 1213 Lab 8 Purpose: to practice working with one-dimensional array of references(addresses). To use aggregation in a class definition. Step 1: use the array of Student references we went over in lecture to help. Write an invoice class. The field for the Invoice class for this lab are: String invoice ID String description Double amount Boolean isPaid Write two constructor methods, a toStoring() method, a compareTo(), method and an equals() method, in addition to the set() methods for ispaid and amount. The equals() method should use the invoiceID field and the compareTo() methods should use the amount field. Be sure this invoice class has all of the above methods. Create 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.txt . Use the loop to create the ten objects and store their addresses 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 fith 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, 2,3 K) and a value. The Jack, Queen and King have a value of 10, the Ace has a value of 11. Write an equal() method based on the suit and face, a compareTo() method based on the value field and 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 format of the entire deck of cards. Use the 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago