Create a new Java file, and name it Course.java. (You do not need to prefix it w
ID: 3663849 • Letter: C
Question
Create a new Java file, and name it Course.java. (You do not need to prefix it with your name this time.) Name the class appropriately to match. You have been provided with a main program file, called TestAlQl.java. Create five instance variables: a String for the course title, a String for the department offering the course, an integer for the program year of the course (1 ,, year course, 2^d year course, etc.), an integer for the term (1, 2 or 3, indicating Winter, Spring and Fall terms) and a String course registration number (CRN) that uniquely identifies the course. All variables should be private. Additionally, create a class variable called numCou rs es, an integer, which will keep track of the number of Course objects that have been created. Initialize it to zero. Create only a single constructor that accepts four parameters: the course title, the department, the term and the program year of the course. This constructor should also assign a unique CRN to the Course. All CRNs start with "2016", followed by the term (a single digit), and finally a sequence number (3 digits, starting at "001", and incrementing by 1 each time a course is added. Use the numCourses variable to do this.). Write accessor ("get" or "getter") methods for all five instance variables. Do not define any mutators ("set" or "setter" methods). Define a toSt r ing() method that returns the CRN, term, title, department, and year, in the format shown in the lines of output in the example below (not including the leading blanks). Note that the term is printed as names, not the numeric value. Declare a constant array of Strings for printing the term names (i.e. don't use if -statements).Explanation / Answer
class Course
{
private String Course_Title;
private String Course_Dept;
private int Course_Year; //use 1st year.2nd year etc..
private int Course_Term; //use 1,2 or # indicating Winter,Spring and Fall terms
private String CRN;
public static numCourse=0;
public Course(String ct,String cd,int cy,int cterm)
{
Course_Title=ct;
Course_Dept=cd;
Course_Yea=cy; //use 1st year.2nd year etc..
Course_Term=cterm;
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.