Event Driven Bird Feeder

application using good object orientated principles to simulate a suga

Page 1 of 1

1 Replies - 1116 Views - Last Post: 03 September 2008 - 07:17 AM Rate Topic: -----

#1 bravo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 08-May 08

Event Driven Bird Feeder

Posted 03 September 2008 - 07:11 AM

Please I need help on this assignment

Write an application using good object orientated principles to simulate a sugarbird feeding on nectar of flowers during daytime.

1. The observer pattern must be used to open and close the flowers and tell the sugarbird it is time to feed.

2. The sugarbird and the flowers will be observers of the sun's on and off state.

3. The sun will stay on for 12 counts and off for 12 counts, ie. the flowers will be OPEN for 12 counts and the sugarbird can feed for 12 counts, the other 12 counts the sugarbird will sleep and the flowers will be closed. The sun should keep a global counter, so that we can measure the counts.

4. There should be 3 events : onDayStart, onDayEnd, onHourChange (change the flower that the bird feeds on). The sugarbird will feed on a different flower every hour, so the sugarbird can feed on 12 flowers in a day. The flowers do not need to do anything on the onHourChange event, the implemenation can be left blank.

5. There are 10 flowers and they can only be fed on 10 times by the sugarbird.
Once a flower cannot be fed on, the sugarbird will immediately try another flower.

6. The sugarbird will always randomly pick which flower to feed on.

7. The flowers will remember their state from day to day. So it will keep their feeding counts until the next day, so the flower will be empty after a few days of feeding.

8. The application will exit when there is no more nectar in any flower.

9. No timer needs to be used, the application can simply run and complete as fast as possible.

10. Print the results, as the application runs to file or console in the following fashion (count in parenthesis :
------------------------------------------------
DAY START (0)

HOUR CHANGE (0)
FLOWER-4 (9)

HOUR CHANGE (1)
FLOWER-8 (9)

HOUR CHANGE (2)
FLOWER-3 (9)

HOUR CHANGE (3)
FLOWER-4 (8) <-- note, it randomly changed to the flower already visited.

...
...
...

DAY END (11)

HOUR CHANGE (11)
SLEEP
HOUR CHANGE (12)
SLEEP
HOUR CHANGE (13)

...
...
...

DAY START (0)

HOUR CHANGE (0)
FLOWER-3 (0) <-- flower is empty, immediately choose a new flower
FLOWER-4 (3)

HOUR CHANGE (1)
FLOWER-5 (6)

HOUR CHANGE (2)
FLOWER-2 (1)


...
...
...

DAY END (23)

...
...
...

EXIT (1233) <-- the total count that the application ran for.

Is This A Good Question/Topic? 0
  • +

Replies To: Event Driven Bird Feeder

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Event Driven Bird Feeder

Posted 03 September 2008 - 07:17 AM

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: :code:

Thanks.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1