Question: Help Please -- Write a Java Programming :- There are two main parts to this assignment. Write a project and package that contains definitions for
Help Please -- Write a Java Programming :- There are two main parts to this assignment.
Write a project and package that contains definitions for the MyDate class and the BoxOffice class (see below for specifications).
Write a project and package that unit tests the MyDate and BoxOffice classes. You will have to import the package that has the definitions of the MyDate and BoxOffice classes.
Part 1 - Class Specifications
Class MyDate
Store in project/package: .bcs345.hwk.movies.business
Member Variables (all private)
| Data Type | ||
| Contains the month portion of the date. | ||
| Contains the day portion of the date. | ||
| Contains the year portion of the date. |
Member Method Signatures and Descirptions (all public)
| Default constructor. Sets the values of each member variable to a default value. | |
| MyDate(int month, int day, int year) | Constructor. Sets the values of each member variable to the corresponding parameter values. |
| Get/Set methods | Write get/set methods for all member variables. |
| void Read(Scanner s) | Read the contents of all member variables from the given instance of Scanner. Assume the following: Scanner is already open. Member variable values are on separate lines. |
| void Write(PrintStream ps) | Write the contents of all member variables to the given instance of PrintStream. Assume the PrintStream is already open and ready to use. Data should be written on to separate lines. DO NOT ADD ANY DESCRIPTIVE TEXT IN THE OUTPUT. JUST PRINT THE VALUES. IMPORTANT - Whatever data is written out should be readable by the Read method of this class. If descriptive text is added then Read will not work. |
| String GetJSON() | This method should return a string using JSON formatting (www.json.org). Here is the format: { variable name : value, } Each variable name should be surrounded by quotes. If the variable data type is String then the value should be surrounded by double quotes. There should be a comma between each pair (no comma after the last pair). Example (5/25/2017): {"month" : 5, "day" : 25, "year" : 2017} Example (6/14/2013): {"month" : 6, "day" : 14, "year" : 2013} |
| String toString() | This method should return a String instance (not print on the screen) that contains a formatted date. Here is an example of a string that gets returned from the method. Example date string: |
Class BoxOffice
Store in project/package: .bcs345.hwk.movies.business
Member Variables (all private)
| Data Type | ||
| Contains the gross amount of money made. | ||
| Contains the number of theaters the movie showed in. |
Member Method Signatures and Descirptions (all public)
| Default Constructor | Default constructor. Sets the values of each member variable to a default value. |
| Constructor Two Parameters | Constructor that sets the values of the member variables. There should be a corresponding parameter for each member variable. |
| Get/set methods for all member variables | |
| void Write(PrintStream ps) | Write the contents of all member variables to the given instance of PrintStream. Assume the PrintStream is already open and ready to use. Data should be written on to separate lines. DO NOT ADD ANY DESCRIPTIVE TEXT IN THE OUTPUT. JUST PRINT THE VALUES. IMPORTANT - Whatever data is written out should be readable by the Read method of this class. If descriptive text is added then Read will not work. |
| void Read(Scanner s) | Read the contents of all member variables from the given instance of Scanner. Assume the following: Scanner is already open. Member variable values are on separate lines. |
| String GetJSON() | This method should return a string using JSON formatting (www.json.org). Here is the format: { variable name : value, } Each variable name should be surrounded by quotes. If the variable data type is String then the value should be surrounded by double quotes. There should be a comma between each pair (no comma after the last pair). Example : { Gross: 797.1, TheaterCount: 4165 } |
| String toString() | This method should show descriptive text and data. It will be used to display a date to the user. For example: Gross: 797.1 Number of Theaters: 4165 |
Class Main
Store in project/package: .bcs345.hwk.movies.presentation
Member Variables (all private)
| Data Type | ||
| No member variables |
Member Method Signatures and Descirptions (all public)
| public static void main(String args[]) | Write unit testing code in main. See below for details. |
Automated Test
Use the Automated Testing slides on Blackboard as a guide when coding this section.
Create an automated test in main.
There should be unit tests of ALL get/set methods of both classes. GetJSON is NOT included here.
You need to write code that runs the other methods that are not being unit tested on each class (this includes GetJSON, constructors, Read, Write, toString etc).
The automated test should contain code that demonstrates that ALL methods work on both classes. DO NOT TAKE THE TESTING CODE LIGHTLY. IT IS VERY IMPORTANT TO SHOW THAT EVERYTHING ON EACH CLASS WORKS.
Hint: To truly test if the output produced by the Write method of either class works you need to try and read in the file that it class generates with its Read method. For example, assume you write data to a file named abc.txt using the write method. You should now use abc.txt file as input to the read method. If the program fails on this read there is an error.
Thank you so much for helping !!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
