The Census

Task 1

A town official has organised a taskforce of workers to go out into the community and count the number of people living at each street address.

Each task force worker has a name, an ID, a numberOfHousesVisited count and a vacation indicator.

Design the Worker class. Here are the methods definitions that you will design:

Method Description
Constructor Takes a name, and an ID as parameters and sets the number of houses visited to 0 and vacation indicator to False
getName() returns STRING returns the name attribute
getID() returns STRING returns the ID attribute
getHousesVisited() returns INTEGER returns the count of houses visited
getVacationIndicator() returns BOOLEAN returns the vacation indicator
visitHouse() increments the number of houses visited by one and sets the vacation indicator to True if the number of houses visited is greater than 50.

Write a main program that will construct a Worker. Test that all of the methods work.

suggested solution

 

Task 2 - the Team class

A Team of Workers is stored in a Team object. The Workers are stored in an array of up to 10 people.

Each Team also has an ID.

Design the Team class. Here are the methods definitions that you will design:

Method Description
Constructor Takes an ID as a parameter and also creates an empty array that Workers will be appended to.
getID() returns STRING returns the ID attribute
getWorkers() returns ARRAY[] OF Worker returns a reference to the array of Worker objects
getWorker(id) returns Worker takes an id as a parameter and returns a Worker from the array with the same id or None if no Worker with that id is found.
addWorker(worker) takes a Worker as a parameter and adds it to the array, as long as the array is not already full.
getVacationNumber() returns int returns a count of how many Workers in the array are on vacation.

Write a main program that will construct a Team, add Workers to it, get a specific worker, make him/her visit 51 houses and finally confirm that the worker was given a vacation!

suggested solution

 

Task 3 - screencasting

Create a screencast for your portfolio. Describe how your code works and run the program to show your audience.

Recommended software is screencastomatic.

Testing

Make sure you are thoughtful when testing your solution.

If your code has a validation check, test your code with acceptable/valid data and unacceptable/invalid data.