Retired

Bird Breeding with Lights (retired)

Description:

You are an exotic bird breeder and are thinking of applying your newly acquired coding skills to remotely manage your ornithological duties. You have exactly 1 bird of each of the following species:

Hummingbirds, Orioles, Goldfinches, Warblers, Bluebirds, Jays.

Every 2 days, your birds need to get out of their cage and spread their wings for a full day.

Once you've let your birds out, it could be troublesome to get them back inside! Luckily you use the birds' attraction to colours to your advantage, and have equipped each bird's cage with a lighting device that can shine light of whichever color or color combination you command it to.

The following list shows which colours attract the different bird species.

=> Red: Hummingbirds

=> Pink: Orioles

=> Yellow: Goldfinches, Warblers

=> Blue: Bluebirds, Jays

Shining the birds' favourite lights will provide them comfort while inside, and signal to come back when they've been out for a full day. White light will tell the birds to leave the cage when they've been inside for 2 days.

The lighting mechanism shall connect to a database (an object providing a data structure), which provides the following information about each bird (in this order):

=> the day when each bird last flew;

=> their favourite colour;

=> the current light colour shining.

The mechanism should shine white light if the birds need to go out, or their favourite colour if they need to come back or stay in.

You are required to:

=> Define the method "controlCages" (takes no arguments), which creates the database and updates it according to the above logic.

=> When creating the database, initialize dates at random as past days of last week (do not include today), and assume all birds are initially inside their cage.

=> Define the method "dateCheck" (takes no arguments), which checks if, after having run your system at least once, each bird is either out or has flown yesterday (Hint: take a look at the test cases). This will be a useful function to debug your system.

Fundamentals

More By Author:

Check out these other kata created by franzmoro88

Stats:

CreatedOct 31, 2015
Warriors Trained41
Total Skips10
Total Code Submissions37
Total Times Completed8
Ruby Completions8
Total Stars2
% of votes with a positive feedback rating0% of 4
Total "Very Satisfied" Votes0
Total "Somewhat Satisfied" Votes0
Total "Not Satisfied" Votes4
Total Rank Assessments2
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • franzmoro88 Avatar
Ad