Ch 3 Lab: The Invoice Class

Authors: Ralph Morelli & Bronzell Dinkins
Trinity College, Hartford, CT
For use with Chapter 3

Brief description

This lab goes with Chapter 3. It requires coding an Invoice class, given a fairly detailed specification of its attributes and methods. The Invoice class uses String variables and get() and set() methods with String parameters and return types. In the optional part, students are asked to introduce a double variable with its corresponding mutator and access methods.

Objectives

The objectives of this lab are:

Before Lab

Read Chapter 3 of Java, Java, Java, 3E. Read through this document and bring your textbook to lab.

Problem Statement

An Invoice object maintains information about the purchase of some software and is capable of printing an invoice of a customer's purchases from the Acme Software Company. Design and implement an Invoice class. Here are some additional specifications:

Problem Decomposition

This problem can be divided into one class, the Invoice class, which will contain the instance variables and methods described above. Include a main() method in the class so that you can create Invoice objects that can be used to test your set() and get() methods.

Design

Implementation (Stepwise Refinement)

Optional

This section is required if you complete all other lab activites before 3:30 PM.

The Acme Software Company's product line has expanded to the point where it is no longer feasible to charge $99 for every software title. Modify the Invoice class to keep track of the price of the software title. This will require an additional instance variable and additional mutator and accessor methods. Modify the print() method to reflect this change. For example, after this modification, the following invoice should be possible:

-----------------------------------
Acme Software Invoice
Customer Name: Trinity College
Software Title: Chess for Experts
Aount due: $198.00
-----------------------------------

Lab Checkout

Have your work checked by the lab instructor before you leave the lab. Make sure to include your name and the lab section in  files.

Hand in your file: Invoice.java.

You're done. Great work!