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

Bellow is the course test if needed: package university.debug; import static org

ID: 3744181 • Letter: B

Question

Bellow is the course test if needed:
package university.debug;

import static org.junit.Assert.*; import org.junit.*;
import university.*; import java.util.ArrayList;

public class CourseTest {    @Test public void testStudent() { Student s1 = new Student(); s1.setName("Tom");
assertEquals("Tom", s1.getName()); Department d = new Department(); s1.setDepartment(d); assertEquals(d, s1.getDepartment()); Course course1 = new Course(); course1.setName("Java"); course1.setSchedule(201); course1.setSchedule(401); course1.setCourseNumber(373); s1.addCourse(course1); assertEquals("Tom", course1.getStudentRoster().get(0).getName()); } @Test public void testDepartment() { Department d1 = new Department(); d1.setDepartmentName("ECE"); assertEquals("ECE", d1.getDepartmentName()); Course course1 = new Course(); course1.setName("OO Programming"); course1.setSchedule(201); course1.setSchedule(401); course1.setCourseNumber(373); d1.addCourse(course1); assertEquals("ECE", course1.getDepartment().getDepartmentName()); Student s1 = new Student(); s1.setName("Pattie"); d1.addStudent(s1); assertTrue(s1.getDepartment().equals(d1)); assertEquals("Pattie", d1.getStudents().get(0).getName()); }
@Test public void testStudentRoster() { Student s1 = new Student(); s1.setName("Hagen"); Student s2 = new Student(); s2.setName("Daz");
Department d1 = new Department(); d1.setDepartmentName("ECE");
Course course1 = new Course(); course1.setName("OO Programming"); course1.setSchedule(201); course1.setSchedule(401); course1.setCourseNumber(373);
s1.addCourse(course1); s2.addCourse(course1); d1.addCourse(course1);
ArrayList<Student> sr = course1.getStudentRoster(); System.out.println(" Here is the Roster for " + course1.getName() + " course");
for (Student st : sr) { System.out.println(st.getName() + " "); }
System.out.println(" Here is the schedule for " + course1.getName() + " course"); ArrayList<Integer> schedule = course1.getSchedule(); for (Integer time : schedule) { System.out.println(time + " "); }
System.out.println(" The department for " + course1.getName() +" course is " + course1.getDepartment().getDepartmentName());
} @Test public void testUniversity() { University univ = new University(); Student s1 = new Student(); s1.setName("Hagen"); Student s2 = new Student(); s2.setName("Daz");
Department d1 = new Department(); d1.setDepartmentName("ECE");
Course course1 = new Course(); course1.setName("OO Programming"); course1.setSchedule(201); course1.setSchedule(401); course1.setCourseNumber(373);
s1.addCourse(course1); s2.addCourse(course1); d1.addCourse(course1); d1.addStudent(s1); d1.addStudent(s2); univ.departmentList.add(d1); /* Print department list from university */ System.out.println(" The list of departments in the university:"); univ.printDepartmentList(); /* Print student list from university */ System.out.println(" The list of students in the university:"); univ.printStudentList(); /* Print course list from university */ System.out.println(" The list of courses in the university:"); univ.printCourseList(); }
}
package university.debug;

import static org.junit.Assert.*; import org.junit.*;
import university.*; import java.util.ArrayList;

public class CourseTest {    @Test public void testStudent() { Student s1 = new Student(); s1.setName("Tom");
assertEquals("Tom", s1.getName()); Department d = new Department(); s1.setDepartment(d); assertEquals(d, s1.getDepartment()); Course course1 = new Course(); course1.setName("Java"); course1.setSchedule(201); course1.setSchedule(401); course1.setCourseNumber(373); s1.addCourse(course1); assertEquals("Tom", course1.getStudentRoster().get(0).getName()); } @Test public void testDepartment() { Department d1 = new Department(); d1.setDepartmentName("ECE"); assertEquals("ECE", d1.getDepartmentName()); Course course1 = new Course(); course1.setName("OO Programming"); course1.setSchedule(201); course1.setSchedule(401); course1.setCourseNumber(373); d1.addCourse(course1); assertEquals("ECE", course1.getDepartment().getDepartmentName()); Student s1 = new Student(); s1.setName("Pattie"); d1.addStudent(s1); assertTrue(s1.getDepartment().equals(d1)); assertEquals("Pattie", d1.getStudents().get(0).getName()); }
@Test public void testStudentRoster() { Student s1 = new Student(); s1.setName("Hagen"); Student s2 = new Student(); s2.setName("Daz");
Department d1 = new Department(); d1.setDepartmentName("ECE");
Course course1 = new Course(); course1.setName("OO Programming"); course1.setSchedule(201); course1.setSchedule(401); course1.setCourseNumber(373);
s1.addCourse(course1); s2.addCourse(course1); d1.addCourse(course1);
ArrayList<Student> sr = course1.getStudentRoster(); System.out.println(" Here is the Roster for " + course1.getName() + " course");
for (Student st : sr) { System.out.println(st.getName() + " "); }
System.out.println(" Here is the schedule for " + course1.getName() + " course"); ArrayList<Integer> schedule = course1.getSchedule(); for (Integer time : schedule) { System.out.println(time + " "); }
System.out.println(" The department for " + course1.getName() +" course is " + course1.getDepartment().getDepartmentName());
} @Test public void testUniversity() { University univ = new University(); Student s1 = new Student(); s1.setName("Hagen"); Student s2 = new Student(); s2.setName("Daz");
Department d1 = new Department(); d1.setDepartmentName("ECE");
Course course1 = new Course(); course1.setName("OO Programming"); course1.setSchedule(201); course1.setSchedule(401); course1.setCourseNumber(373);
s1.addCourse(course1); s2.addCourse(course1); d1.addCourse(course1); d1.addStudent(s1); d1.addStudent(s2); univ.departmentList.add(d1); /* Print department list from university */ System.out.println(" The list of departments in the university:"); univ.printDepartmentList(); /* Print student list from university */ System.out.println(" The list of students in the university:"); univ.printStudentList(); /* Print course list from university */ System.out.println(" The list of courses in the university:"); univ.printCourseList(); }
}
Assignment 1 Classes in an Object-Oriented Model of a University 1. Objective In this assignment you will familiarize yourself with implementing a simplified object oriented model of a particular University's course offering/s. Learning objectives include developing UML class diagrams to describe OO classes familiarizing with Eclipse IDE translate UML class diagrams to Java code JUnit testing concepts and procedures Once the model is implemented in Java, JUnit testing needs to be done to verify your model is behaving as it should. Make sure you go through the JUnit tests/code given at the end of this document BEFORE you design and implement your classes. 2. The Model The model must observe the following rules: Each Student will have a name, and is enrolled in a university department, and has a course list. Students can sign up for courses. -When a student signs up for a course, the course should appear in his list of courses, and reciprocally he/she should appear on the course roster - Students can sign up for multiple courses - no detection of course schedule conflicts is necessary Each Department has a department name, a list of courses it offers, and a list of students enrolled in (majoring in) that department Departments add new students: the Student is added to the department's list of Students, and also the student's department should be set to that specific department. Departments add Courses: the Course will be added to the Department's list of Courses, and also the Course's department should be set to that specific department. -

Explanation / Answer

1. UML diagrams are very much necessary to complete this problem. However based on the JUnit test case given, I've reverse engineered the field names and types.

2. Schedule in the JUnit test case is using an integer number when setting it whereas expecting an ArrayList<Integer> when getting it. Need more clarification on this to give correct code.

Please feel free to comment or provide additional information if you need any changes.

Course.java

package universitycourses;

import java.util.ArrayList;

class Course {

// course number

int courseNumber;

// course name

String name;

// department to which this course belongs.

Department department;

// list of registered students for this course.

ArrayList<Student> studentRoster;

// Need UMLs to figure out what exactly schedule type is.

ArrayList<Integer> schedule;

public int getCourseNumber() {

return courseNumber;

}

public void setCourseNumber(int courseNumber) {

this.courseNumber = courseNumber;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public Department getDepartment() {

return department;

}

public void setDepartment(Department department) {

this.department = department;

}

public ArrayList<Student> getStudentRoster() {

return studentRoster;

}

public void setStudentRoster(ArrayList<Student> studentRoster) {

this.studentRoster = studentRoster;

}

public ArrayList<Integer> getSchedule() {

return schedule;

}

public void setSchedule(ArrayList<Integer> schedule) {

this.schedule = schedule;

}

}

Department.java

package universitycourses;

import java.util.List;

class Department {

// department name

String departmentName;

// list of courses offered by the department

List<Course> offeredCourses;

// list of enrolled students for this department

List<Student> enrolledStudents;

public String getDepartmentName() {

return departmentName;

}

public void setDepartmentName(String departmentName) {

this.departmentName = departmentName;

}

public List<Course> getOfferedCourses() {

return offeredCourses;

}

public void addCourse(Course course) {

this.offeredCourses.add(course);

}

public List<Student> getStudents() {

return enrolledStudents;

}

public void addStudent(Student student) {

this.enrolledStudents.add(student);

}

}

Student.java

package universitycourses;

import java.util.List;

public class Student {

// student name

String name;

// department to which the student belongs

Department department;

// list of courses the student is enrolled.

List<Course> courseList;

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public Department getDepartment() {

return department;

}

public void setDepartment(Department department) {

this.department = department;

}

public List<Course> getCourseList() {

return courseList;

}

public void addCourse(Course course) {

this.courseList.add(course);

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote