Question: Course.Java The following UML describes mostly the public interface of the Course class. The public interface (the API) includes not only methods and constructors, but
Course.Java
The following UML describes mostly the public interface of the Course class. The public interface (the API) includes not only methods and constructors, but also constants that should or could be of interest to the user of the class. You may implement this class using any additional private members as you require, but should not add to the public interface.
Course
+ COURSE_NUMBER_LENGTH:int + MAXIMUM_CREDITS:int + MINIMUM_CREDITS:int + MISSING_CREDITS_VALUE:int - counter: ObjectCounter - courseName: String - courseNum: String - credits: int +
[It is not usual to specify private fields, but in the interests of making the test program more capable of helping with the evaluation of the assignment, it is requested that these private fields be present and be used as specified.]
Here are specific requirements for the Course class:
Each Course object represents one course, such as CSC-2040 (where the three letters are a prefix, and the four remaining characters (after the -) are a course number).
The Course class will keep track of how many total Course objects are currently created (possibly zero) by use of the ObjectCounter class. Nothing further beyond declaring and initializing the counter variable is requiredsee Counting Objects below.
Each Course has properties for prefix, course number, course name and credits.
The prefix must be a value of type Prefix. (No error checking is required here.)
The course number is a four-character text String, not necessarily an actual number. It is possible for some course numbers to contain alphabetic values. Assume that any String that is not null and of the correct length (4 characters) is valid. If no valid String is supplied, the value for the course number should be set to an empty String, and no error message is produced.
The course name is a String that is not null, and not blank. If a null String or a String that is otherwise invalid is supplied, the value for the course name should be set to an empty String, and no error message is produced.
The number of credits, when valid, are whole number ( int) values from 0 to 5. These values are exported (made public) so that the user of the class may see them via the API by defining the ( static) constants MINIMUM_CREDITS and MAXIMUM_CREDITS.
The ( static) constant value MISSING_CREDITS_VALUE (which should be some int value that is a value not permitted as a valid credits value) is used initially to indicate that the credits value has not been set yet. When invalid values for credits are seen, the invalid value should be replaced by the (static) constant value MISSING_CREDITS_VALUE (to indicate the absence of a valid value), and no error message is produced.
The ( static) constant value COURSE_NUMBER_LENGTH is also an int exported (made public) so that the user of the class may see via the API the value of the number of characters in a course number.
The getDetails method will return a String properly displaying all four attributes.
The toString method should return just the prefix, a hyphen, and the course number as in CSC-2040. This method is not required to give a correctly formatted String if any of the attributes used are invalidly set.
UML Specifications
Additional private methods and other private members may be added to the class and used as you find them advisable or necessary. However, no additional public methods should be added in your implementation.
The minus sign (-;) implies private internal values, the plus sign (+) indicates public members, and the tilde (~) indicates default access (i.e., the access indicated in Java that has no modifer keywordthe access called package-private) . Underlined names indicate static members. Remember that in an implementation, additional private members (fields or methods) may and should be defined as needed; however, no additional public members should be added to the defined application programming interface (API).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
