Skip to content

Instantly share code, notes, and snippets.

@avermeulen
Last active March 27, 2019 15:05
Show Gist options
  • Save avermeulen/25532e2046c8dd6d429fd3dff34753fb to your computer and use it in GitHub Desktop.
Save avermeulen/25532e2046c8dd6d429fd3dff34753fb to your computer and use it in GitHub Desktop.

Teachers, Learners & Lessons

Learn more about Java Objects using Teachers, Learners, Lessons & Tokens.

A short programming exercise to practice using Classes

A person has a firstName, lastName & email address.

Teachers & Students

A teacher teach 1-more subjects. They can only teach subjects they are qualified for.

A Learner needs to be registered for 3 subjects before that can attend any lesson.

Lessons & Subjects

Lessons are for a given Subject. Learners can only attend Lessons for Subjects they are registered for.

A Lesson is taught by a teacher - attended by learners. If there are less than 5 learners attending a Lesson is cancelled. A teacher earn 5 tokens for each lesson teached. A Lesson has a teacher, time and subject. A student can only attend one lesson at a time.

Notes & Tokens

Each time a student attend a Lesson they are given notes. If a student didn't attended a Lesson the can ask other students who attended a Lesson for the notes.

Attending a Lesson earn a student 3 tokens. Asking for notes costs 2 tokens. You can only ask for notes if you have enough tokens.

Asking for notes of Subjects you are not registered for costs 5 tokens.

Students should keep track of Notes they have and if they earned it via lesson attendance or bought it.

At the end of each day a Students should be able to see what notes and how much tokens they have.

Cafeteria

Tokens can be used at the Cafeteria to Buy Breakfast (4 tokens), Lunch (6 tokens) or an afternoon snack (3 tokens). A drink costs 2 tokens. The Cafeteria manager wants a total of daily tokens received. And also which Person bought what. Teacher gets a 25% discount in the cafeteria once they taught 5 lessons.

The Principal needs to know how many Lessons for each subject is taught on a day and how many Lessons have been cancelled for the day.

Instructions

Create all the Classes needed for this scenario.

  • Use the the Java Collection Framework where needed.
  • Focus on 1 school day only.
  • Write JUnit tests.
  • No persistence is required.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment