Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
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 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 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems X Special Issue On Database And Expert Systems Applications Lncs 8220

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Stephen W. Liddle ,Klaus-Dieter Schewe ,Xiaofang Zhou

2013th Edition

3642412203, 978-3642412202

More Books

Students also viewed these Databases questions