Assignment 6: Cyclic data; Graphs
Goals: Constructing and using cyclic data of various complexities.
Instructions
As always, be very careful with your naming conventions.
The submissions will be organized as follows:
Submission Homework 6 Problem 1: The Registrar.java file.
Submission Homework 6 Problem 2: The Buddies.zip file containing: ILoBuddy.java, MtLoBuddy.java, ConsLoBuddy.java, Person.java, and ExamplesBuddies.java.
Problem 1 – Tuesday, November 21st at 10:00pm
Problem 2 – Tuesday, November 21st at 10:00pm
1 Problem 1 – The Registrar’s Office
The registrar’s office maintains a great deal of information about classes, instructors, and students. Your task in this problem is to model that data, and implement a few methods on it. We deliberately do not give you the class diagram for this problem: from the description below, you should properly design whatever classes you think are relevant. Please use generic lists (i.e. IList<T>) for this problem.
1.1 Data constraints
A Course consists of a name (a String), an Instructor named prof, and a list of Students named students. No Course can be constructed without an Instructor available to teach it. Hint: Do you think that you should provide a list when constructing a Course? Why or why not?
An Instructor has a name and a list of Courses named courses he or she teaches. Instructors are initially constructed without any Courses to teach.
A Student has a name, an id number (an int), and a list of Courses they are taking. Students are initially constructed without taking any Courses.
It should always be the case that any Student who is enrolled in a Course should appear in the list of Students for that Course, and the Course should likewise appear in the Student’s list of Courses.
It should always be the case that the Instructor for any Course should have that Course appear in the Instructor’s list of Courses.
1.2 Methods and examples to design
Design a method void enroll(Course c) that enrolls a Student in the given Course. Design any helper methods as appropriate.
Design a method boolean classmates(Student c) that determines whether the given Student is in any of the same classes as this Student.
Design a method boolean dejavu(Student c) that determines whether the given Student is in more than one of this Instructor’s Courses.
Construct example data consisting of at least five Students, at least four Courses and at least two Instructors. Test all your methods thoroughly.
2 Problem 2 – If A Buddy Catch A Buddy
Finish all work in the Recitation 9: Working with Cyclic Data and hand it in.
Specifically:
In your ExamplesBuddies class, be sure to have all of the examples we describe. When you initialize your data, your method should be called initBuddies, and take in no arguments.
Design the method addBuddy and then make example of the circle of buddies as given in the lab.
Design the method hasDirectBuddy
Design the method countCommonBuddies
Design the method hasExtendedBuddy
Design the method partyCount that counts the number of people who will attend a party given by this person if all buddies and all buddies of all buddies (including the distant ones) come to the party. The party organizer attends their own party.
Design the method maxLikelihood on Person that takes in some other person that and returns the maximum likelihood that this person can correctly convey a message to that person. Add an additional constructor to the Person class that takes in the person’s diction score and hearing score. The constructor that takes in just the person’s name can set their diction and hearing scores to 0.0 as default values.