java - design patterns assignments -
is there place find multiple assignments implementing design patterns( along solutions ?)
my idea hands on in proper way. implement in java. @ moment need basic design patterns , not j2ee patterns.
i'm looking complete application developed uses of design patterns. (all design patterns in single assignment)
build me antfarm!!
you want assignment? i'll give one. it's due tuesday, february 22 @ 9:00pm pacific time. going build me antfarm, , you're going use common design patterns it.
this not have every design pattern, because that's silly. does, however, have enough interactions complex while being simple enough implement quickly. once done, can @ adding in more features our ant farm!
i add requirements (with revision added) needs arise.
here's requirements:
functional requirements:
- a meadow can have many ant farms in them. assignment, ever allow 1 meadow take place.
- a meadow should capable of spawning logically unlimited number of antfarms.
- an antfarm should comprised of network of antfarm rooms.
- an antfarm should have rooms spawning more ants.
- ants should able battle other ants. when do, loser of battle should die (it's antfarm can no longer command it), , winner of battle should attributes of ant.
- an antfarm should have 1 species of ant. each species should have kind of bonus them. perhaps harvest food faster. perhaps have higher chance kill other ants.
- if member of ant colony kills queen of colony, killer's queen should assume control of dead queen's population of ants. ants should have attributes of both species of ant. (so if 1 species strong, , other species efficient, both populations merged single population both strong , efficient.)
- ants should have rest every often. when do, should consume food. antfarm should limited in capacity of how many ants can rest @ time based on number of rooms (x amount per resting room).
- the simulation should end when, @ end of tick, there 1 or less active colonies/queens. means should spawn @ least 2 colonies before first tick.
- rooms in antfarm should require (probably large) number of worker-ticks build. so, if take 1 worker 100 ticks dig room, take 50 workers 2 ticks, etc. there should significant cost building room, since rooms determine how can rest. (this requirement added in spec revision 1.)
technical requirements: (design patterns bolded)
- the meadow class must singleton.
- an antfarm should built building rooms antfarm. (builder pattern)
- drones , warriors should created factory pattern antrooms, , queens factory pattern meadows purposes of new colony.
- use decorator pattern keep track of ant's attributes.
- antfarms should templated (using java generics) hold type of ant, , antfarm should specify @ runtime type of ant holds.
- the simulation should tick-based. (mediator pattern) each tick, every ant (in random order) should perform action based on surroundings. drones should food, warriors should hunt enemies (or go food if hungry) , queens should spawn egg.
interface requirements:
the interface ant farm should command line interface following commands:
spawn x y t
- should create new colony @ position x,y of species t. output should give identifier colony can controlled later.- example
spawn 14 -32 killer
creates colony of "killer" ants @ position x14 y-32. give r a
- should give colony identified (at creation) resource r of amount a.- example
give 1 food 50
gives colony 1 50 food. example
give 3 warrior 10
gives colony 3 10 warriors spawn @ colony 3's base.tick [t]
- should perform t tick operations. convience, allow t not specified, , tick once.- example
tick 10
example
tick
summary i
- should give summary of colony i. summary gives information colony.- example
summary 1
might give following output:
output:
species: killer workers: 14 warriors: 10 ant kills: 18 colony kills: 2 (2:pansy 4:gatherer) ticks alive: 143 status: alive
- example
summary 2
might give following output:
output:
species: pansy workers: 4 warriors: 0 ant kills: 2 colony kills: 0 ticks alive: 25 status: killed 1:killer
if run difficulty, post comment it. i'll try give hints blank classes, method headers, or general ideas how make these design patterns interact eachother.
good luck, , have fun!!
Comments
Post a Comment