Welcome to Dream.In.Code
Getting Java Help is Easy!

Join 132,641 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,090 people online right now. Registration is fast and FREE... Join Now!




assingment

 
Reply to this topicStart new topic

assingment, convert into java code

rajkumar123
post 4 Sep, 2008 - 11:09 AM
Post #1


New D.I.C Head

*
Joined: 4 Sep, 2008
Posts: 1

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.
User is offlineProfile CardPM

Go to the top of the page

Nykc
post 4 Sep, 2008 - 11:11 AM
Post #2


sudo rm -R /

Group Icon
Joined: 14 Sep, 2007
Posts: 4,023



Thanked 12 times

Dream Kudos: 275
My Contributions


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.

Please post like this:

Thank you for helping us helping you.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 04:36AM

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month