134 lines
No EOL
3.4 KiB
Text
134 lines
No EOL
3.4 KiB
Text
[](https://classroom.github.com/a/HcxcWfxH)
|
|
:sectnums:
|
|
:nofooter:
|
|
:toc: left
|
|
:icons: font
|
|
:data-uri:
|
|
:source-highlighter: highlightjs
|
|
:stem: latexmath
|
|
|
|
= Col.04 -- Training
|
|
|
|
It is paramount that you are totally comfortable implementing collections based on linked nodes -- with different requirements, on your own and quickly.
|
|
This assignment consists of two more exercises for training exactly that.
|
|
|
|
NOTE: Generics are not required for these exercises, we'll come back to that topic soon
|
|
|
|
== Exam Calendar Management
|
|
|
|
You are going to implement an application which manages the exam of a school class.
|
|
|
|
* Exam information can be read from a CSV file
|
|
* Exams are stored in a list
|
|
** This list stores them _sorted_ by date
|
|
** It allows for:
|
|
*** Adding exams
|
|
*** Removing exams
|
|
*** Finding exams in a specific date range
|
|
*** Being converted into an array
|
|
* Exams have a subject, a date and a teacher
|
|
* At each day there can only be a single exam
|
|
|
|
[plantuml]
|
|
----
|
|
@startuml
|
|
hide empty methods
|
|
|
|
class Exam {
|
|
+string? Subject [readonly]
|
|
+DateTime Date [readonly]
|
|
+string Teacher [readonly]
|
|
}
|
|
class Node {
|
|
+Exam Data [readonly]
|
|
+Node? Next
|
|
|
|
+Node(Exam)
|
|
}
|
|
class ExamList {
|
|
-Node? _head
|
|
+int Count [private set]
|
|
|
|
+bool Insert(Exam?)
|
|
+Exam? GetAt(int)
|
|
+Exam[] ToArray()
|
|
+Exam[] GetExamsInInterval(DateTime, DateTime)
|
|
+bool Remove(DateTime, out Exam?)
|
|
}
|
|
|
|
Exam "1" -u- "0..1" Node: contains
|
|
ExamList "1" -r- "0..1" Node: contains
|
|
Node -- "0..1" Node: next
|
|
|
|
@enduml
|
|
----
|
|
|
|
TIP: Extensive unit tests have been provided -- those together with the XMLDoc should guide you to the correct implementation
|
|
|
|
=== Sample Run
|
|
|
|
You have been provided with the real exam schedule from a past year.
|
|
Processing it with your application should yield the following result.
|
|
|
|
image::pics/exam_cal_sample_run.png[Exam List Sample Run,width=300]
|
|
|
|
== Doctor's Waiting Room
|
|
|
|
In this exercise you are going to implement the waiting room of a doctor's office.
|
|
|
|
* Patients arrive at different times
|
|
* They are treated in order of their arrival
|
|
* However, some patients are emergency cases, these are treated first
|
|
** Arrival order _within_ the group of emergency patients still applies
|
|
* A patient can be declared an emergency while already waiting as a 'normal' patient
|
|
|
|
[plantuml]
|
|
----
|
|
@startuml
|
|
hide empty methods
|
|
|
|
class Node {
|
|
+Patient Data [readonly]
|
|
+Node? Next
|
|
|
|
+Node(Patient)
|
|
}
|
|
class Patient {
|
|
+string Name [readonly]
|
|
+DateTime Arrival [readonly]
|
|
+bool IsEmergency
|
|
|
|
+Patient(string, DateTime)
|
|
+Patient(string, DateTime, bool)
|
|
}
|
|
class PatientQueue {
|
|
-Node? _head
|
|
+int Size [readonly]
|
|
|
|
+void Enqueue(Patient)
|
|
+Patient? Dequeue()
|
|
+bool Remove(Patient)
|
|
}
|
|
class WaitingRoom {
|
|
-PatientQueue _emergencyQueue [readonly]
|
|
-PatientQueue _normalQueue [readonly]
|
|
+int CountEmergency [readonly]
|
|
+int CountNormal [readonly]
|
|
+int CountAll [readonly]
|
|
|
|
+string ToString() [override]
|
|
+void AddPatient(Patient)
|
|
+Patient? Next()
|
|
+void SetPatientToEmergency(Patient)
|
|
}
|
|
|
|
Node "0..1" -u- "1" Patient: contains
|
|
Node "0..1" -l- "1" PatientQueue: contains
|
|
WaitingRoom "1" -- "2" PatientQueue: has
|
|
Node -- "0..1" Node: next
|
|
|
|
@enduml
|
|
----
|
|
|
|
* The starter code initially does not compile -- add the missing pieces in `Node` and `Patient` first
|
|
* Some unit tests have been provided |