Skip to content

Instantly share code, notes, and snippets.

@StevenMeiklejohn
Created September 4, 2017 14:15
Show Gist options
  • Save StevenMeiklejohn/534aa830c408edd7bbd0c44d8a2f59ed to your computer and use it in GitHub Desktop.
Save StevenMeiklejohn/534aa830c408edd7bbd0c44d8a2f59ed to your computer and use it in GitHub Desktop.

Homework

Create your own class with an internal collection of a different class. It should have methods for count, add, isFull etc. Remember to write tests for your classes!

Some examples:

  • A Bus class with an array, passengers of Persons.
  • A Classroom class with an array, students of Persons.
  • A Library class with an array, stock, of Books.

Extensions:

Add a third class which interacts with the other two. E.g. you could add a BusStop with a method that takes a Bus and moves Persons from the BusStop to the Bus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment