| Assignment |
A2: Implementing Classes and Fundamental Data Types |
|---|---|
| Due Date | Wednesday, July 6, 2005 at 4:00 pm (CSL Time) |
| Last Mod Date |
|
| Links |
Objectives | Description | Specification | Testing | Front End | Javadocs | Requirements | Output | Questions | Hints | Handin |
| Announcements |
|
| 06/28/2005 | Released |
A small media store founded in 1920 is having a sale. In the past they used a calculator to compute the total price for a customers purchase. The unbelievably low prices at the sale have caused a lot of customers to flock to the store. Fortunately/unfortunately they will need to replace the calculator with a sophisticated Java program if they want to tend to all their customers. The customers are usually undecided and keep adding and removing items even after they have reached the checkout counter. You are now employed to work on the back end of the application.
The store only carries DVDs, books, and VHS tapes.
You are required to write a MediaStoreBiller class that contains all the backend code. You will also be required to write a test class, MediaStoreBillerTester, that contains a main method and tests the methods of your MediaStoreBiller class to verify that they work correctly. To demonstrate your understanding of this step, you must submit a text file expected.out that contains the expected results of your tests. Finally, you must answer some questions relating to the assignment.
You will need three instance fields to store the number of DVDs, number of books, and number of VHS tapes. Each will store the number of media of the given type on the current bill.
Each DVD costs $25.00, each book costs $18.00, and each VHS tape costs $15.00. Declare these as double variables. In addition, recall that class constants are always declared as public static final.
The MediaStoreBiller class must have the following two constructors. The first constructor takes no parameters and sets the number of DVDs, books, and VHS tapes to 0. The second constructor sets the number of DVDs, books, and VHS tapes to values that are passed in via parameters.
The MediaStoreBiller class must have the following four public accessor methods. the first three methods return the number of DVDs, books, and VHS tapes, respectively, in the customers cart. The computePrice() method computes the price and returns it as a double.
The MediaStoreBiller class must have the following public mutator methods. The methods addDVDs(), addBooks(), and addTapes()should add the value specified by the value of the parameter passed to the method to the instance field storing the number of DVDs, books, and VHS tapes, respectively, The methods removeDVDs(), removeBooks() and removeTapes() should subtract the value specified by the value of the parameter passed to the method from the instance field storing the number of DVDs, books, and VHS tapes, respectively.
Your MediaStoreBillerTester class should test each method of the MediaStoreBiller class to ensure that each method functions correctly. To be useful, your MediaStoreBillerTester class should print something that you can use to verify the functionality of each method. It's a good idea to figure out what it should print out and record it in your expected.out file before you run the test. The following is a code fragment that you might include in the main method of your MediaStoreBillerTester class next to the corresponding entry for your expected.out file. Assume that msb is a MediaStoreBiller object that is already instantiated and that each media component has the value 0.
|
|
There should be a line in your expected.out file for every line printed out by your MediaStoreBillerTester class.
We have provided a small GUI application that you can use to see your object in action. The GUI application contains its own main() method, but it requires the MediaStoreBiller class that you have written in order to function. You must implement every method in the MediaStoreBiller class before you can use the GUI. Follow these instructions to download and execute a GUI app that uses your class.
If you are working from home, you will have to download and add the BillerViewer.jar file to your Eclipse project. This step is only necessary, if you wish to run the user interface for the MediaStoreBiller Application.
To run the GUI application, right-click on the BillerViewer.jar entry in the Package Explorer pane, and select the "Run" and then "Java Application" options. You should see an application and several buttons that you can click on. Click a few and see what happens!
Note that viewing the behavior of your class using the GUI is not the same as testing your class. The testing that you are required to do is a way of verifying that your code performs exactly according to the specifications. The GUI is simply provided so that you have a convenient way of seeing how the values your MediaStoreBiller class calculates relate to the actual colors that you see.
Documentation for Java source code is almost always provided in a special javadoc format. This documentation is automatically generated from the source code comments, which must follow a special format.
We will be using classes from the Java API in every assignment. The documentation for every class in the Java API can be found at http://java.sun.com/j2se/1.5.0/docs/api.
This section outlines the major requirements of the assignment. Your solution to the assignment must meet each of these requirements. Be sure to read the announcements frequently and ask questions if you need clarification.
Some of the questions in this assignment require that you copy and paste into questions.txt the output of your program. See Assignment 0 for the definition of output.
The answers to questions that require program output must be answered with output that is generated by your program.
It is academic misconduct to submit as your output anything other than the output that your program generates. If your program does not produce output (ie. it doesn't work), you may still answer these questions. However, you must clearly state for each question how the answer was obtained.
This section lists several questions that should deepen your understanding of the assignment. Create a text-only file named questions.txt and answer these questions.
Be sure to include the descriptive information listed below as well as the answers to each question.
Assignment Number:
Assignment Name:
Date Completed:
Partner 1 Name:
Partner 1 Login:
Partner 1 TA:
Partner 2 Name:
Partner 2 Login:
Partner 2 TA:
Use the Handin instructions from the Eclipse Tutorial to hand in your work. Students working in pairs will only submit one copy of all program files, except the README file described below.
Do not hand in .doc, .metadata, *.class, *.jar, or *.html files.All students working in pairs must read the Pair Programming Document and submit a README file. Each student working in a pair, must handin this file to their own handin directory. Copy, complete and handin the file that is linked here.
Feedback, questions or accessibility issues.
Copyright: Akanksha Baid, Suresh Sridharan ©2005 (Original version by Michelle Moravan, Mulhern, and Randy Smith
Latest update: