This first project simulates something that might happen in a company that has existing Java applications. You are being asked to integrate some of your previous homework into this project and to write some new code. Be sure to read the Grading Approach at the end of this document. You may want to print this document.
Step 1. Write a new test driver called Class Project100. See Project100 specifications
Step 2. Take Class Date from Assignment 2 and verify that it works with Project100. See method dateTest().
Step 3. Take Parking from Assignment 3, modify it and integrate it into Project100. See method parkingTest().
Step 4. Take your Roll Dice from Assignment 4 and integrate it into Project 100. See method diceTest()
Step 5. Write new classes for the Shape Hierarchy. See Shape Hierarchy specifications
Step 6. Replace your dummy shapeTest() method with a real shapeTest method. See shapeTest specifications.
Step 7. Test everything together.(Project100,Dice,Parking,Date,TwoDimensionalShape,Circle,Square,ThreeDimensionalShape,Cube ,Sphere)
Step 8. Write a bat file named test100.bat that the instructor can run to compile ALL your classes and the run your Project100 driver. This bat file will consist of one javac statement for every .java file that should be compiled and one java statement (java Project100).
Step 9. Zip all you java files and your bat file into a single zip archive named Project100.zip. When the instructor runs your bat file it should successfully compile all your programs and run the test. If you are working on a non-Windows machine and cannot develop a bat file, send an email to your instructor during the first two weeks of this project.
Step 10. Unzip your archive into a clean (empty) folder. Run your bat file to verify that it works.
Step 11. Submit your zip archive to Blackboard.
You are to write a new Class called Project100. All input and output in this class is to be done using javax.swing.JoptionPane (See 14.3 in your textbook). Figure 14.2 has an example that will help. This is the class that contains your one and only main method.
Loop through the program multiple times until the user types Exit.
Display a dialog box asking the use to enter a test command. The user can enter Date or Parking or Dice or Shape or Exit.
If the user enters Exit, you should display a message and terminate the program.
If the user enters Date, you should call the method dateTest() in Class Project100
If the user enters Parking, you should call the method parkingTest() in ClassProject100
If the user enters Dice, you should call the method diceTest() in Class Project100
If the user enters Shape, you should call the method shapeTest() in Class Project100
Make sure your program handles multiple inputs. Do not quit after you process the first user input unless that input was Exit.
Write dummy methods for dateTest(), parkingTest(), diceTest() and shapeTest() that do nothing except Return. This will allow you to test your Project100 Class
Method dateTest()
Use your Class Date from Assignment 2. Feed it at least four dates -- two valid and two invalid. Display the results.
Method parkingTest()
Use your logic from Assignment 3. If you implemented Assignment 3 as a separate class, use that class and call it for testing. If you implemented Assignment 3 as method main, you should turn your Parking logic into a separate class (Class Parking) and then instantiate and call that class from Method parkingTest().. You are required to have at least four customers in your test. One customer that parks for 23 hours, one customer that parks for 4.5 hours, one customer that parks for 3.5 hours and one customer that parks for 1 hour. You must show for each customer at least the parking charge and the accumulated charges to date. For the first customer, the parking charge and the accumulated charges will be equal. Since you will be using a separate class, it is OK to use System.out to display results in Class Parking.
Method diceTest()
Use the logic that you wrote for Assignment 4 to show the results of your 36000 rolls. You output should look something like:
Sum Frequency Percentage
2 1006 2.79
3 2083 5.79
4 2935 8.15
5 3907 10.85
6 5128 14.24
7 5910 16.42
8 5044 14.01
9 3927 10.91
10 2989 8.30
11 2052 5.70
12 1019 2.83
You should turn your Assignment 4 code into a class (Class Dice) and then instantiate and call that class from this method. Remember that you Class Dice should not have a method main(String[] args)
Method shapeTest() - See shapeTest specifications
Create 7 classes. TwoDimensionShape and ThreeDimensionalShape inherit from Shape. Circle and Square Inherit from TwoDimensionalShape. Sphere and Cube Inherit from ThreeDimensionalShape.
| Class | Class | Class | Methods |
|---|---|---|---|
| Shape | getArea() abstract | ||
| toString() abstract | |||
| getVolume() abstract | |||
| TwoDimensionalShape | getArea() abstract | ||
| toString abstract | |||
| getVolume() - provide a default value - return (float)0; | |||
| Circle | constructor Circle(float radius) | ||
| getArea() - return float (calculate area of circle) | |||
| toString() - return String "I am a circle" | |||
| Square | constructor Square(float side) | ||
| getArea() - return float (calculate area of square) | |||
| toString() - return String "I am a square" | |||
| ThreeDimensionalShape | getVolume() abstract | ||
| getArea() abstract | |||
| toString() abstract | |||
| Cube | constructor Cube(float side) | ||
| getArea() return float side*side*6 | |||
| getVolume() return float side*side*side | |||
| toString() return String "I am a cube" | |||
| Sphere | constructor Sphere(float radius) | ||
| getArea() return float 4*PI*r*r | |||
| getVolume() return float (4/3)*PI*r*r*r | |||
| toString return String "I am a Sphere" |
Method shapeTest()
Create an array that will hold 8 object references. This array should be of type Shape.
Create 8 objects and store the reference for each of the 8 objects in your array. (Create two circles, two squares, two spheres, and two cubes. Use different values for each object that you create).
Loop through the array:
If the object is an instanceof a ThreeDimensionalShape, call the getArea, getVolume and toString methods on that object and display the results.
If the object is an instance of a TwoDimensionalShape, call the getArea and toString methods on that object and display the results.