Welcome to EduCorp, The nation's leading purveyor of educational support software! You will be joining the team tasked with developing EduCorp's latest classroom support product, SitRite3K.
For this assignment, you must implement three classes, a class
named Student that encapsulates information about
individual students, a class named Posse class that
manages an individual Student object's friends, and a
utility class named Social that contains methods for
performing calculations involving social networks.
At a high level of abstraction, the relationships between these classes can be modeled using the following UML class diagram.
The details of each class in this diagram are provided below.
Social ClassSocial class must conform to the following detailed
class diagram.
distance()distance() method must calculate the Euclidean
distance between two seats, \( s \) and \( t \), as follows:
\[ d(s, t) = \sqrt{(s_0 - t_0)^2 + (s_1 - t_1)^2}\]
where element 0 contains the row and element 1 contains the column.
For simplicity, it assumes that the seats are arranged in a uniform
grid with one meter of separation between adjacent seats.
Student Class Student class must conform to the following detailed class diagram.
You are free to add additional private helper methods, but the public methods must match the UML specification exactly.
name attribute and Posse
attributes should be apparent from the UML
diagrams. The seat attribute must have a length of 2 and
must contain the row and column (in that order) of
the Student object's seat.
setRow()
and setColumn()).
getUnhappiness() method, which
is discussed below, the getters and setters must perform the obvious
operations (accounting for parameter validation as discussed above).
addFriend()Student object to the
Posse named friends. However, it must not
add a Student object to her/his own Posse.
equals()true if and only if
the name of the owning Student object is the
same as the name of the given Student object. (Note that,
this product assumes that names are unique.)
getUnhappiness()If the student has no friends then this method must return 0.0.
Posse ClassPosse class must conform to the following UML
diagram:
You are free to add additional private helper methods, but the public methods must match the UML specification exactly.
Posse to have a maxSize of
DEFAULT_SIZE. (Note: As always, you must avoid code duplication.)
get() Methodsget() methods must return either (a reference to)
a Student that is in the owning
object's Posse or null.
The version that is passed an int must return
the Student at the given index of
the members array if the index is valid and
must return null otherwise.
The version that is passed a String must return
the Student with the given name if
that Student is in the
members array and must return null otherwise
(including when the parameter is null). You may assume
that the parameter name is unique.
The get() methods must not contain duplicate code and must
not duplicate code in any other methods.
contains()contains() method must return true if
the given Student is in the owning Posse and
must return false otherwise (including when the parameter
is null). It must not duplicate code that is in
the get() methods (i.e., it should call one of
the get() methods and/or call a private helper method.)
add()add() method must add the given Student
to the end of the owning Posse if and only if it is not
already in the Posse and the Posse is not
full.
It must return false if the Posse was full
and true if either the Student was added or
if it was already in the Posse.
getSize()getSize() method must return the number of
Student objects that are currently in the Posse
(not the maximum size of the Posse).
You should consider implementing the classes/methods in the following order:
distance() method in ths Social() class.Student
class.equals() method in the Student class.Posse class.add() method in the Posse class.getSize() method in the Posse class.get() methods in the Posse class.contains() methods in the Posse class.add() method in the Student class.getUnhappiness() method in the Student
class.Don't delete the tests when you finish a method! You may be able to reuse them if you need to modify the method later. They also provide a useful reference if you need to get help.
You should start by carefully reading the project specifications. (In general it is a good idea to print a paper copy so that you can take notes and perform calculations as you read.) After you are sure that you understand the specifications, you should log into Canvas and complete the "quiz" for Part A.
Since you must completely understand the project specifications, YOU MUST ANSWER ALL QUESTIONS CORRECTLY TO GET ANY CREDIT FOR THIS PART. Since you probably have not yet acquired the skills you need to do so, you may take the "quiz" as many times as necessary.
You are not required to submit tests for these classes.
| Part A | 10% |
| Part B Style | 10% |
| Part B Correctness | 60% |
| Part B Code Quality | 20% |
The code quality grade will be based on such things as:
Code that fails any of the Web-CAT submission tests will receive at most 50% of the possible points allocated to part B. This includes both the correctness tests and the style checks.