Step 1
Develop the following class:
Class
Name: CollegeDegree
Access Modifier: public
Instance variables
Name: major
Access modifier: private
Data type: String
Name: numberOfCourses
Access modifier: private
Data type: int
Name: courseNameArray
Access modifier: private
Data type: String [ ]
Name: courseCreditArray
Access modifier: private
Data type: int [ ]
Static variables
Name: maximumNumberOfCourses
Access modifier: private
Data type: int
Initial Value: 40
Constructor
Name: CollegeDegree
Access modifier: public
Parameters: none (default constructor)
Task: sets major to the empty string
Sets numberOfCourses to 0
Sets courseNameArray to refer to an array of Strings with the number of elements equal to the value of the static variable maximumNumberOfCourses
Sets courseCreditArray to refer to an array of ints with the number of elements equal to the value of the static variable maximumNumberOfCourses
Non-static Methods
Name: setMajor
Access modifier: public
Parameters: newMajor
Return type: void
Task: sets the value of the instance variable major to the value of newMajor
Name: getMajor
Access modifier: public
Parameters: none
Return type: String
Task: returns the value of the instance variable major
Name: addCourse
Access modifier: public
Parameters: courseName (data type String), numberOfCredits (data type int)
Return type: void
Task: if numberOfCredits is greater than or equal to 1 and less than or equal to 5 and numberOfCourses is less than the length of the courseNameArray then place the value of courseName into the courseNameArray in the element whose index is equal to the instance variable numberOfCourses and place the value of numberOfCredits into the courseCreditArray in the element whose index is equal to the instance variable numberOfCourses and then increase the value of the instance variable numberOfCourses by 1
Name: getCourses
Access modifier: public
Parameters: none
Return type: String
Task: returns the concatenation of the name of each course located in the courseNameArray (Note: This can be accomplished by looping through the part of the courseNameArray that is filled with course names and concatenating each of these values into a single string)
Name: getNumberOfCourses
Access modifier: public
Parameters: none
Return type: int
Task: returns the value of the instance variable numberOfCourses
Name: getTotalNumberOfCredits
Access modifier: public
Parameters: none
Return type: int
Task: returns sum of the all the credits in the courseCreditArray (Note: This can be accomplished by looping through the part of the courseCreditArray that is filled with course credits and summing these into a single int)
Static Methods
Name: increaseMaximumNumberOfCourses
Access modifier: public
Parameters: nexMaximumNumberOfCourses
Return type: void
Task: if the value of is greater than the value of the static variable maximumNumberOfCourses then change the value of maximumNumberOfCourses to the value of newMaximumNumberOfCourses
Name: getMaximumNumberOfCourses
Access modifier: public
Parameters: none
Return type: int
Task: returns the value of the static variable maximumNumberOfCourses
public class CollegeDegree { private String major; private int numberOfCourses; private String[] courseNameArray; private int[] courseCreditArray; private static int maximumNumberOfCourses = 40; public CollegeDegree() { this.major = ""; this.numberOfCourses = 0; this.courseNameArray = new String[maximumNumberOfCourses]; this.courseCreditArray = new int[maximumNumberOfCourses]; } public void setMajor(String major) { this.major = major; } public String getMajor() { return major; } public void addCourse(String courseName, int numberOfCredits) { if(numberOfCourses >= 1 && numberOfCourses <= 5 && numberOfCourses < courseNameArray.length) { courseNameArray[numberOfCourses] = courseName; courseCreditArray[numberOfCourses] = numberOfCredits; numberOfCourses++; } } public String getCourses() { String courses = ""; for (int i = 0; i < numberOfCourses; i++) { courses += courseNameArray[i]; if (i < numberOfCourses - 1) courses += " "; } return courses; } public int getNumberOfCourses() { return numberOfCourses; } public int geTotalNumberOfCredits() { int credits = 0; for (int i = 0; i < numberOfCourses; i++) { credits += courseCreditArray[i]; } return credits; } public static void increaseMaximumNumberOfCourses(int nexMaximumNumberOfCourses) { if (nexMaximumNumberOfCourses > maximumNumberOfCourses) maximumNumberOfCourses = nexMaximumNumberOfCourses; } public static int getMaximumNumberOfCourses() { return maximumNumberOfCourses; } }
Step 1 Develop the following class: Class Name: CollegeDegree Access Modifier: public Instance variables Name: major...
Step 1Develop the following class:ClassName: CollegeDegreeAccess Modifier: publicInstance variablesName: majorAccess modifier: privateData type: StringName: numberOfCoursesAccess modifier: privateData type: intName: courseNameArrayAccess modifier: privateData type: String [ ]Name: courseCreditArrayAccess modifier: privateData type: int [ ]Static variablesName: maximumNumberOfCoursesAccess modifier: privateData type: intInitial Value: 40ConstructorName: CollegeDegreeAccess modifier: publicParameters: none (default constructor)Task: sets major to the empty stringSets numberOfCourses to 0Sets courseNameArray to refer to an array of Strings with the number of elements equal to the value of the static variable maximumNumberOfCoursesSets courseCreditArray to...
You may not add any instance variables to any class, though you may create local variables inside of a method to accomplish its task. No other methods should be created other than the ones listed here. Step 1 Develop the following class: Class Name: CollegeDegree Access Modifier: public Instance variables Name: major Access modifier: private Data type: String Name: numberOfCourses Access modifier: private Data type: int Name: courseNameArray Access modifier: private Data type: String [ ] Name: courseCreditArray Access...
You may not add any instance variables to any class, though you may create local variables inside of a method to accomplish its task. No other methods should be created other than the ones listed here. (I need step 2 please.) Step 1 Develop the following class: Class Name: CollegeDegree Access Modifier: public Instance variables Name: major Access modifier: private Data type: String Name: numberOfCourses Access modifier: private Data type: int Name: courseNameArray Access modifier: private Data type: String [...
Programming assignment for Java:
Do not add any other instance variables to any class, but you
can create local variables in a method to accomplish tasks. Do not
create any methods other than the ones listed below.
Step 1 Develop the following class: Class Name: College Degree Access Modifier: public Instance variables Name: major Access modifier: private Data type: String Name: numberOfCourses Access modifier: private Data type: int Name: courseNameArray Access modifier: private Data type: String Name: courseCreditArray Access modifier:...
You may not add any instance variables to any class, though you may create local variables inside of a method to accomplish its task. No other methods should be created other than the ones listed here. Step 1Develop the following class:ClassName: CollegeDegreeAccess Modifier: publicInstance variablesName: majorAccess modifier: privateData type: StringName: numberOfCoursesAccess modifier: privateData type: intName: courseNameArrayAccess modifier: privateData type: String [ ]Name: courseCreditArrayAccess modifier: privateData type: int [ ]Static variablesName: maximumNumberOfCoursesAccess modifier: privateData type: intInitial Value: 40ConstructorName: CollegeDegreeAccess modifier: publicParameters: none...
Step 1 Develop the following class: Class Name: Bag Access Modifier: public Instance variables Name: name Access modifier: private Data Type: String Name: currentWeight Access modifier: private Data Type: double Name: maximumWeight Access modifier: private Data Type: double Constructors Name: Bag Access modifier: public Parameters: none (default constructor) Task: sets the value of the instance variable name to the empty string sets the value of the instance variable currentWeight to 0.0 sets the value of the instance variable maximumWeight to...
Step 2 Develop the following class: Class Name: QueueNode<T> Access Modifier: public Instance variables Name: info Access modifier: private Data type: T (parameterized type) Name: link Access modifier: private Data type: QueueNode<T> Constructors: Name: QueueNode Access modifier: public Parameters: info (data type T) Task: sets the value of this.info to the value of the info parameter sets the value of link to null Methods Name: setInfo Access modifier: public Parameters: info (data type T) Return type: void Task: sets the...
Step 3 Develop the following class: Class Name: ImprovedQueue<T> Access Modifier: public Implements: QueueInterface<T> Instance variables Name: front Access modifier: private Data type: QueueNode<T> Constructors: Name: ImprovedQueue Access modifier: public Parameters: none (default constructor) Task: sets the value of front to null Methods Name: isEmpty Access modifier: public Parameters: none Return type: boolean Task: returns true if the front is equal to null; otherwise return false Name: dequeue Access modifier: public Parameters: none Return type: T (parameterized type) Task: makes...
Step 1 Develop the following interface: Interface Name: QueueInterface<T> Access Modifier: public Methods Name: isEmpty Access modifier: public Parameters: none Return type: boolean Name: dequeue Access modifier: public Parameters: none Return type: T (parameterized type) Name: enqueue Access modifier: public Parameters: element (data type T, parameterized type) Return type: void Step 2 Develop the following class: Class Name: QueueNode<T> Access Modifier: public Instance variables Name: info Access modifier: private Data type: T (parameterized type) Name: link Access modifier: private Data...
Step 1 Develop the following interface: Interface Name: QueueInterface<T> Access Modifier: public Methods Name: isEmpty Access modifier: public Parameters: none Return type: boolean Name: dequeue Access modifier: public Parameters: none Return type: T (parameterized type) Name: enqueue Access modifier: public Parameters: element (data type T, parameterized type) Return type: void Step 2 Develop the following class: Class Name: QueueNode<T> Access Modifier: public Instance variables Name: info Access modifier: private Data type: T (parameterized type) Name: link Access modifier: private Data...