Skip to content

Commit 2785bfd

Browse files
committed
Re-take Project OOP
1 parent 6367a52 commit 2785bfd

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

retake-project-oop.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Re-take Project OOP
2+
3+
All of the code you develop must be in package `roads` and/or subpackages.
4+
5+
## 1. Road Network
6+
7+
Define and implement an entity-relationship abstraction, consisting of classes `City` and `Road`, for representing a network of roads connecting cities. A city has a name. A road connects exactly two cities, and has a length in kilometers, expressed as an `int`, greater than zero. Allow clients to create a city with a given name, create a road with a given length connecting two given cities, retrieve the name of a city and the set of roads that connect that city to other cities, and the length of a road and the set of cities that this road connects. You need not support the removal of roads or cities from the network.
8+
9+
The constructors shall deal with illegal arguments defensively. Provide complete public and internal formal documentation. (You need not provide informal documentation.)
10+
11+
To fully document the `Road` constructor, it may be useful to introduce a static method `getRoadsMap` that takes a set of cities and returns a map that maps each city from the set to its set of roads. Furthermore, you may use the [`logicalcollections`](https://github.com/btj/logicalcollections) project.
12+
13+
## 2. Routes
14+
15+
Define and implement an immutable abstraction, consisting of classes `Route`, `EmptyRoute`, and `NonemptyRoute`, for representing *routes*. A route is either an empty route or a nonempty route. Each route has a start city. A nonempty route also has a first leg, which is a road, and a continuation, which is again a route. It is illegal if the client attempts to construct a nonempty route whose first leg does not connect its start city and the start city of its continuation. Allow the client to obtain the length (in kilometers) and the end city of any `Route` object. The end city of an empty route equals its start city; the end city of a nonempty route equals its continuation's end city.
16+
17+
Ensure that two `Route` objects `r1` and `r2` are considered equal by the Java Collections library, by JUnit, etc., (for example, `new HashSet<>(List.of(r1)).contains(r2)` returns `true`) if and only if they represent the same route. Write a test case to check this.
18+
19+
Your implementation shall deal with illegal cases defensively; however, you need not write any documentation.
20+
21+
## 3. getRoutesTo
22+
23+
Add a method `getRoutesTo` to class `City` that returns a `Set<Route>` containing all routes from the receiver city to the given city that have no loops, i.e. that do not pass through the same city more than once. You need not write any documentation for this method.
24+
25+
**Implementation Hints:** It may be useful to define a helper method that additionally takes a set of cities to avoid. Also, note that if A and C are not the same city, then there is a route from A to C for every combination of a road from A to B and a route from B to C.
26+
27+
## Grading
28+
29+
### Teams of 2 studenten
30+
31+
To obtain a passing grade (>= 10/20) for this project, you must execute
32+
Section 1 above. You must provide complete `@throws`
33+
clauses and postconditions, complete abstract state invariants and complete
34+
representation invariants.
35+
36+
To obtain a score of 15/20 or more, you must additionally execute Section 2.
37+
38+
To obtain a score of 17/20 or more, you must execute Section 3 as well; furthermore, for Section 1 you must provide all necessary `@inspects`, `@mutates`, `@mutates_properties`, `@representationObject`, `@peerObject`, and `@peerObjects` clauses.
39+
40+
To obtain a score of 20/20, additionally, for Section 1 you must apply nested abstractions.
41+
42+
In each case, for each Section that you execute, you must provide a test suite that tests each statement of your implementation, except for statements that run only in illegal cases.
43+
44+
### Teams of 1 student
45+
46+
To obtain a passing grade (>= 10/20) for this project, you must execute
47+
Section 1 above. You must provide complete `@throws`
48+
clauses and postconditions, complete abstract state invariants and complete
49+
representation invariants.
50+
51+
To obtain a score of 13/20 or more, you must additionally execute Section 2.
52+
53+
To obtain a score of 15/20 or more, you must execute Section 3 as well; furthermore, for Section 1 you must provide all necessary `@inspects`, `@mutates`, `@mutates_properties`, `@representationObject`, `@peerObject`, and `@peerObjects` clauses.
54+
55+
To obtain a score of 20/20, additionally, for Section 1 you must apply nested abstractions.
56+
57+
In each case, for each Section that you execute, you must provide a test suite that tests each statement of your implementation, except for statements that run only in illegal cases.

0 commit comments

Comments
 (0)