Question: public class Course { private String department; private int courseNumber; private char special; private String section; public Course (String department, int courseNumber, char special, String

public class Course {

private String department;

private int courseNumber;

private char special;

private String section;

public Course (String department, int courseNumber, char special, String section) {

throw new UnsupportedOperationException("Remove this line and replace with your implementation.");

}

public String getDepartment() {

throw new UnsupportedOperationException("Remove this line and replace with your implementation.");

}

public String getCourse () {

throw new UnsupportedOperationException("Remove this line and replace with your implementation.");

}

public String getSection() {

throw new UnsupportedOperationException("Remove this line and replace with your implementation.");

}

public boolean equals (Object o) {

throw new UnsupportedOperationException("Remove this line and replace with your implementation.");

}

}

import java.util.HashMap;

import java.util.Map;

public class CourseGrade implements Comparable {

private Professor professor;

private Course course;

private Map grades;

public CourseGrade (Professor professor, Course course) {

throw new UnsupportedOperationException("Remove this line and replace with your implementation.");

}

public Professor getProfessor() {

throw new UnsupportedOperationException("Remove this line and replace with your implementation.");

}

public Course getCourse() {

throw new UnsupportedOperationException("Remove this line and replace with your implementation.");

}

public Map getGrades() {

throw new UnsupportedOperationException("Remove this line and replace with your implementation.");

}

public void updateGrade (String grade, int numStudents) {

throw new UnsupportedOperationException("Remove this line and replace with your implementation.");

}

public float getAverage () {

throw new UnsupportedOperationException("Remove this line and replace with your implementation.");

}

public int getNumGrade (String grade) {

throw new UnsupportedOperationException("Remove this line and replace with your implementation.");

}

public int getNumStudents() {

throw new UnsupportedOperationException("Remove this line and replace with your implementation.");

}

@Override

public int compareTo(CourseGrade o) {

throw new UnsupportedOperationException("Remove this line and replace with your implementation.");

}

}

public class Professor {

private String name;

public Professor (String name) {

throw new UnsupportedOperationException("Remove this line and replace with your implementation.");

}

public String getName () {

throw new UnsupportedOperationException("Remove this line and replace with your implementation.");

}

public boolean equals (Object o) {

throw new UnsupportedOperationException("Remove this line and replace with your implementation.");

}

}

________________________________________________________________________________Tests

import static org.junit.Assert.assertEquals;

import static org.junit.Assert.assertFalse;

import static org.junit.Assert.assertTrue;

import java.io.FileNotFoundException;

import java.util.ArrayList;

import java.util.List;

import org.junit.Before;

import org.junit.Test;

public class PublicTests {

Analyze analyzer;

@Before

public void prepare () throws FileNotFoundException {

analyzer = new Analyze();

analyzer.readData("201708_edited.csv");

}

@Test

public void testProfessor() {

Professor pOne = new Professor("Momo Brown");

Professor pTwo = new Professor("Momo Brown");

Professor pThree = new Professor("Brice Taylor");

assertEquals("Momo Brown", pOne.getName());

assertTrue(pOne.equals(pTwo));

assertFalse(pOne.equals(pThree));

}

@Test

public void testCourse() {

Course cOne = new Course("CS", 100, '\0', "-1");

Course cTwo = new Course("CS", 100, '\0', "-1");

Course cThree = new Course("CS", 100, 'A', "-1");

Course cFour = new Course("CS", 100, 'A', "101");

assertEquals("CS100\0", cOne.getCourse());

assertEquals("CS", cOne.getDepartment());

assertEquals("-1", cOne.getSection());

assertEquals("0101", cFour.getSection());

assertTrue(cOne.equals(cTwo));

assertFalse(cOne.equals(cThree));

}

@Test

public void testCourseGrade() {

CourseGrade cOne = new CourseGrade(new Professor("A A"), new Course("AAAA", 000, '\0', "-1"));

cOne.updateGrade("A+", 4);

cOne.updateGrade("A", 4);

cOne.updateGrade("A-", 4);

cOne.updateGrade("B+", 4);

cOne.updateGrade("B", 4);

cOne.updateGrade("B-", 4);

cOne.updateGrade("C+", 4);

cOne.updateGrade("C", 4);

cOne.updateGrade("C-", 4);

cOne.updateGrade("D+", 4);

cOne.updateGrade("D", 4);

cOne.updateGrade("D-", 4);

cOne.updateGrade("F", 4);

cOne.updateGrade("W", 4);

cOne.updateGrade("Other", 2);

CourseGrade cTwo = new CourseGrade(new Professor("A A"), new Course("AAAA", 000, '\0', "-1"));

cTwo.updateGrade("A+", 5);

cTwo.updateGrade("A", 4);

cTwo.updateGrade("A-", 4);

cTwo.updateGrade("B+", 4);

cTwo.updateGrade("B", 4);

cTwo.updateGrade("B-", 4);

cTwo.updateGrade("C+", 4);

cTwo.updateGrade("C", 4);

cTwo.updateGrade("C-", 4);

cTwo.updateGrade("D+", 4);

cTwo.updateGrade("D", 4);

cTwo.updateGrade("D-", 4);

cTwo.updateGrade("F", 4);

cTwo.updateGrade("W", 4);

cTwo.updateGrade("Other", 2);

assertEquals("2.12", String.format("%.2f", cOne.getAverage()));

assertEquals(2, cOne.getNumGrade("Other"));

assertEquals(58, cOne.getNumStudents());

assertEquals(0, cOne.compareTo(cOne));

assertEquals(-1, cOne.compareTo(cTwo));

assertEquals(1, cTwo.compareTo(cOne));

}

@Test

public void testCourseData() {

assertEquals("2.63", String.format("%.2f", analyzer.getCourseAverage(new Course("CS", 100, '\0', "-1"), false)));

assertEquals("2.46", String.format("%.2f", analyzer.getCourseAverage(new Course("CS", 100, '\0', "-1"), false)));

assertEquals("2.31", String.format("%.2f", analyzer.getCourseAverage(new Course("MATH", 140, '\0', "-1"), false)));

assertEquals("2.63", String.format("%.2f", analyzer.getCourseAverage(new Course("CS", 100, '\0', "0101"), true)));

assertEquals("2.53", String.format("%.2f", analyzer.getCourseAverage(new Course("CS", 100, '\0', "0401"), true)));

assertEquals("-1.00", String.format("%.2f", analyzer.getCourseAverage(new Course("AAAA", 000, '\0', "-1"), false)));

}

@Test

public void testProfessorData() {

assertEquals("2.67", String.format("%.2f", analyzer.getProfessorAverage(new Professor("Brice Taylor"))));

assertEquals("2.15", String.format("%.2f", analyzer.getProfessorAverage(new Professor("Momo Brown"))));

assertEquals("-1.00", String.format("%.2f", analyzer.getProfessorAverage(new Professor("A A"))));

}

@Test

public void testDepartmentData() {

assertEquals("2.74", String.format("%.2f", analyzer.getDepartmentAverage("CS")));

assertEquals("2.50", String.format("%.2f", analyzer.getDepartmentAverage("MATH")));

}

@Test

public void testGetProfessors() {

List professorsOne = analyzer.getProfessorsTeachingCourse(new Course("CS", 100, '\0', "-1"));

assertTrue(professorsOne.contains(new Professor("Momo Brown")));

assertFalse(professorsOne.contains(new Professor("Brice Taylor")));

assertFalse(hasDuplicateProfessors(professorsOne));

List professorsTwo = analyzer.getProfessorsTeachingDepartment("CS");

assertTrue(professorsTwo.contains(new Professor("Momo Brown")));

assertTrue(professorsTwo.contains(new Professor("Brice Taylor")));

assertFalse(professorsTwo.contains(new Professor("A A")));

assertFalse(hasDuplicateProfessors(professorsTwo));

List professorsThree = analyzer.getProfessorsTeachingDepartment("AAAA");

assertEquals(0, professorsThree.size());

}

public boolean hasDuplicateProfessors(List l) {

ArrayList professors = new ArrayList();

for (Professor o : l) {

if (professors.contains(o)) {

return true;

}

professors.add(o);

}

return false;

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!