Question Details Problem #1: Ms P’s Course Creator Issue: Ms. P. would like a pr
ID: 3622282 • Letter: Q
Question
Question DetailsProblem #1: Ms P’s Course Creator
Issue:
Ms. P. would like a program that helps her create courses for her next semester. She will provide for you the test file that will run your classes. Review the test file carefully before programming. Look to the specifications for which classes you will need.
Setup:
Create a new Eclipse project called A8_lastName. Then import the test file given into your new project. To do this, right click on your project and select import. Now select File System and click Next. Browse for the folder that contains the file you wish to import. Then place a checkmark next to the file you want to import and click Finish.
Make sure the files you want to run in your program are under the src folder of your project.
There will be errors all throughout the tester file because you have not created the classes it needs. Comment out all of the main method code until you have created each class. I have a tester file to test just the Instructor and Student class and then the other tester file will test all three. I recommend creating the Student and Instructor class first and make sure they work before creating the Course class.
Specifications:
Student.java
1. Your class will have the following private class variables
a. name – default “ “
b. major – default “unknown”
c. age – default 0
d. classification – default “ “
2. Your class will have a getter and setter for each class variable
3. Your class will have a no-arg constructor that makes all class variables their default value.
4. Your class will have a one parameter constructor that makes the student’s name equal to the one provided.
5. Your class will have a four parameter constructor that makes all the class variables equal to the ones provided.
Instructor.java
1. Your class will have the following private class variables
a. name – default “ “
b. officeLocation – default “ “
c. department – default “ “
d. phoneNumber – default “ “
e. emailAddress – default “ “
2. Your class will have a getter and setter for each class variable.
3. Your class will have a no-arg constructor that makes all the class variables their default values.
4. Your Your class will have a one parameter constructor that makes the instructor’s name equal to the one provided.
5. Your class will have a five parameter constructor that makes all the class variables equal to the ones provided.
Course.java
1. Your class will have the following private class variables
a. courseName
b. an array of Student objects of size 20
c. an Instructor object instructor
d. numberOfStudents
e. meetingTime
f. meetingLocation
g. static variable for numberOfCourses
2. Your class will have a two parameter constructor with the courseName and instructor.
3. Your class will have a four parameter constructor with the courseName, instructor, meetingTime and meetingLocation.
4. Your class will have a method that will add a student to the course and keep track of the number of students for the course. It will also check to see if the course is full.
5. Your class will have a method that will print a student roster listing all the names of the students in the course. This will use the Student.java getter for the class variable name to print the Student’s names.
6. Your class will have a method that will print a student roster listing the name, major, age and classification of the students in the course. This will use the Student.java getters for the class variables to print the Student’s information.
7. Your class will have a method that prints the course information including the instructor’s name, numberOfStudents, meetingTime, meetingLocation and courseName. This should use the Course.java class’s getters to print the information.
Program Help:
• Use the test file to see what the methods should be called. If you don’t name the methods the same way as the test file I use then your program won’t work.
• If you want to create your own test file then you can, but make sure when you are finished that your files will run with the test file provided.
• To compile and run your program with the test file provided do the following:
o Import the test file into your project.
o Start out the program by commenting out most everything in the main method. As you create portions of the instructions uncomment that portion of the main method.
Explanation / Answer
The following is an example of the Student class as you have described it. Read and try to understand how it works, and try to apply what you have learned to the Instructor class. Part of the Course class is also provided to help you get started. Good luck! public class Student { public String name; public String major; public int age; public String classification; public Student() { this.name = ""; this.major = "unknown"; this.age = 0; this.classification = ""; } public Student(String name) { this.name = name; this.major = "unknown"; this.age = 0; this.classification = ""; } public Student(String name, String major, int age, String classification) { this.name = name; this.major = major; this.age = age; this.classification = classification; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public String getClassification() { return classification; } public void setClassification(String classification) { this.classification = classification; } public String getMajor() { return major; } public void setMajor(String major) { this.major = major; } public String getName() { return name; } public void setName(String name) { this.name = name; } } public class Course { public String courseName; public Student[] students; public Instructor instructor; public int numberOfStudents; public static int numberOfCourses = 0; /* need to declare meetingTime and meetingLocation */ public Course(String courseName, Instructor instructor) { this.courseName = courseName; this.instructor = instructor; this.students = new Student[20]; /* all students are initialied to null */ } /* need to write the other constructor */ public void addStudent(Student stu) { if (numberOfStudents == this.students.length) { throw new IllegalStateException("Class is full."); } students[numberOfStudents] = stu; numberOfStudents = numberOfStudents + 1; } /* need to write the other methods */ /* hint: use System.out.println to print out text */ }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.