Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

i need a Course Java class, which includes information for a course (CSE231 for

ID: 671041 • Letter: I

Question

i need a Course Java class, which includes information for a course (CSE231 for example) and a list of students enrolled in this course. The information for a course includes course name, instructor, class meeting time, etc. A list of student enrolled in the course should be implemented using Linked List of student object references. The class should provide methods: enroll(int stuID) and enroll(Student stu), numStudents() (number of students enrolled in this course), contains (int stuID) and contains(Student stu) (check whether a student is enrolled or not), and other methods for retrieving information about the course. Your enroll(int stuID) and contains(int stuID) methods need to retrieve student object reference from OU people using the stuID. You can only enroll a student that is already in the OUPeople database and you can only enroll a student in a course once. Please make sure your enroll methods also check those condition and report necessary errors (or exceptions) to users. Feel free to reuse code segments of LinkedStringLog and LLStringNode classes from Chapter 02 of the textbook source code for your implementation. (30 points)

here is what i have so far.

public abstract class Person {

// all information that will be used for both the instrucor and the student.

protected String FirstName;

protected String LastName;

protected int IDnumber;

  

public Person(String FirstName , String LastName, int IDnumber){

setFirstName(FirstName);

setLastName(LastName);

setIDnumber(IDnumber);

  

}

private void setFirstName(String FirstName){

this.FirstName = FirstName;

}

public String getFirstName(){

return this.FirstName;

}

  

private void setLastName(String LastName){

this.LastName = LastName;

}

public String getLastName(){

return this.LastName;

}

private void setIDnumber(int IDnumber){

this.IDnumber = IDnumber;

}

public int getIDnumber(){

return this.IDnumber;

}

  

  

@Override

public String toString(){

return " " + "First Name: " + FirstName + " " + "Last Name: " + LastName + " " + "id number: " + IDnumber + " ";

}

}

-------------------------------------------------------------------------------------

public class Student extends Person {

// adds more details to the person class.

private int YearsInCollege;

public Student(String fn, String ln, int idn, int YearsInCollege)

{

// adds in the details from the person class

super(fn, ln, idn);

setYearsInCollege(YearsInCollege);

}

private void setYearsInCollege(int YearsInCollege){

this.YearsInCollege = YearsInCollege;

}

public int getYearsInCollege(){

return this.YearsInCollege;

}

  

  

  

@Override

public String toString(){

  

return super.toString() + "Years in college: " + YearsInCollege + "";

  

}

}

-------------------------------------------------------------------------------------

public class Instructor extends Person {

// adds details to the person class from the instructor.

private int roomnumber;

public Instructor(String fn, String ln, int idn, int roomnumber) {

super(fn, ln, idn);

setroomnumber(roomnumber);

  

}

private void setroomnumber(int roomnumber){

this.roomnumber = roomnumber;

}

public int getroomnumber(){

return this.roomnumber;

}

@Override

public String toString(){

return super.toString() + "room number: " + this.roomnumber + "";

}

}

-------------------------------------------------------------------------------------

public class Course {

private String courseName;

private String[] students = new String[100];

private int numberOfStudents;

  

public Course(String courseName) {

this.courseName = courseName;

}

  

public void addStudent(String student) {

students[numberOfStudents] = student;

numberOfStudents++;

}

  

public String[] getStudents() {

return students;

}

public int getNumberOfStudents() {

return numberOfStudents;

}

public String getCourseName() {

return courseName;

}

}

------------------------------------------------------------

public class OUpeople {

Scanner scan = new Scanner(System.in);

ArrayList<Student> StudentArray = new ArrayList<>();

ArrayList<Instructor> InstructorArray = new ArrayList<>();

public void populateStudents(){

//adds details about the students and adds them to the array.

Student s1 = new Student("Eli", "hunt", 123, 4);

Student s2 = new Student("Leo", "Masharin", 321, 4);

Student s3 = new Student("Brittney","Sauerwein", 456, 3);

Student s4 = new Student("Kyle", "Kohls", 666, 4);

StudentArray.add(s1);

StudentArray.add(s2);

StudentArray.add(s3);

StudentArray.add(s4);

}

public void populateInstructor(){

//adds details about the instructors and adds them to the array.

Instructor i1 = new Instructor("y", "yan", 415, 313);

Instructor i2 = new Instructor("Eddy", "Chang", 508, 263);

InstructorArray.add(i1);

InstructorArray.add(i2);

  

}

public void FindStudent(){

// searches for student by id number by compairing the id number that the user types in to the student id numbers in the array

int id =0;

Scanner scan = new Scanner(System.in);

  

System.out.println("Please enter student ID: " + id);

id = scan.nextInt();

if(id == StudentArray.get(0).IDnumber)

System.out.println(StudentArray.get(0));

else

if(id == StudentArray.get(1).IDnumber)

System.out.println(StudentArray.get(1));

else

if(id == StudentArray.get(2).IDnumber)

System.out.println(StudentArray.get(2));

else

if(id == StudentArray.get(3).IDnumber)

System.out.println(StudentArray.get(3));

else

System.out.println("Does not match any ID number in the data base");

  

}

public void FindInstructor(){

// searches for instructors by id number by compairing the id number the user typs in to the id numbers in the array

  

Scanner scan = new Scanner(System.in);

int id = scan.nextInt();

System.out.println("Enter instructor ID: " + id);

if(id == InstructorArray.get(0).IDnumber)

System.out.println(InstructorArray.get(0));

else

if(id == InstructorArray.get(1).IDnumber)

System.out.println(InstructorArray.get(1));

else

System.out.println("Does not match an ID number in this data base");

}

public void PrintInstructors(){

//loops through and prints all of the instructors in the array

for (Instructor InstructorArray1 : InstructorArray) {

System.out.println(InstructorArray1);

}

}

public void PrintStudents(){

// loops through and prints all students in the array

for(Student StudentArray1 : StudentArray){

System.out.println(StudentArray1);

  

}

}

public void RemoveStudent(){

// finds student by typing in an id number and removes them from the array.

Scanner scan = new Scanner(System.in);

int id = scan.nextInt();

System.out.println("Please enter id number of the student you would like to remove: " + id);

if(id == StudentArray.get(0).IDnumber)

StudentArray.remove(0);

else

if(id == StudentArray.get(1).IDnumber)

StudentArray.remove(1);

else

if(id == StudentArray.get(2).IDnumber)

StudentArray.remove(2);

else

if(id == StudentArray.get(3).IDnumber)

StudentArray.remove(3);

else

System.out.println("id does not match a student in the data base.");

  

System.out.println("the Student has been removed.");

  

  

}

public void RemoveInstructor(){

// finds instrucor by id number and removes the from the array.

  

Scanner scan = new Scanner(System.in);

int id = scan.nextInt();

System.out.println("Please enter id number of the instructor you would like to remove: " + id);

if(id == InstructorArray.get(0).IDnumber)

InstructorArray.remove(0);

else

if(id == InstructorArray.get(1).IDnumber)

InstructorArray.remove(1);

else

System.out.println("id does not match a instructor in the data base.");

  

System.out.println("the instrucor has been removed.");

}

public void createCourses(){

Course c1 = new Course("CSE231");

Course c2 = new Course("APM263");

}

  

}

------------------------------------------------------------

basically i just don't know how to add a student to the course.

thanks.

Explanation / Answer

The following method is in your Course class. c1.addStudent(student);

public void addStudent(String student) {

students[numberOfStudents] = student;

numberOfStudents++;

}

In OUpeople you can define new method

void addStudentToCourse(Course c, Student st) {

          c.addStudent(st.getFirstName()+" "+st.getLastName());

}