Question: public class Course { //attributes private int courseReferenceNumber; private int creditHours; private String courseName; private String instructor; // PLEASE START YOUR CODE HERE // ===========================



public class Course { //attributes private int courseReferenceNumber; private int creditHours; private String courseName; private String instructor;
// PLEASE START YOUR CODE HERE // ===========================
//constructor
// =========================== // PLEASE END YOUR CODE HERE
public String toString() { return "Course: "+courseName + " Instructor: " + instructor + " CRN: " + courseReferenceNumber + " Credit hours: " + creditHours; }
}
Instructions Is it time to register for classes again? Today you are going to create a constructor for the Course class which will define the details of a course to be offered. You will then instantiate a course with information read in as input. For this task, you will make use of both Course.java' and 'PoD.java. POD.java' makes use of the Course class. You are going to write the constructor in the Course class in Course.java : (Note: You chan choose tabs for either the 'PoD.java' or 'Course.java files and toggle between the two.) You've been given all the fields of the Course class: courseReferenceNumber, creditHours, courseName and Instructor. You will build a constructor which takes in the course reference number, credit hours, course name and instructor name and assigns them to those fields. We have also created a toString method to output the course details. The main method in PoD.java' has been written for you. It reads in course details. You must use these details to instantiate the Course class with a new object to be named newCourse. The main method then prints out the result using the toString() method of the Course class. Course.java Course -courseReferenceNumber: int -creditHours: int -courseName: String -instructor: String +Course (courseReferenceNumber: int, creditHours: int, courseName: String, instructor: String) +toString(): String Input Parameters The following input parameters are expected: an integer: the course reference number an integer: the number of credit hours associated with the class a string: the name of the course a string: the instructor's name Processing The constructor should takes in the above input parameters and assign them to the appropriate fields associated with the class. Sample Input/output: Sample Input Sample Output Rubik's cube for beginners Dr. Angela A. Siegel 17892 Course: Rubik's cube for beginners Instructor: Dr. Angela A. Siegel CRN: 17892 Credit hours: 3 6 public class Course //attributes private int courseReferenceNumber; private int creditHours; private String courseName; private String instructor; // PLEASE START YOUR CODE HERE / EE=== == // constructor // =========================== // PLEASE END YOUR CODE HERE public String toString() return "Course: "+courseName + " Instructor: " + instructor + " CRN: " + courseReferenceNumber + " Credit hours: " + creditHours; 44 }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
