I would like you to employ the Decorator patterns when developing your solution.
Create an interface IShip. It will contain • shipDescription function, which will return the ship and its armour • weight property, which will return weight of the ship
Create a base ship class which implement the interface • weight property will return 10 • shipDescription will return the “ship”
Create shipDecorator as a class which implements the interface • has a private field of armouredShip • has a constructor which will take in a parameter of type of IShip and sets the armoured ship • the shipDescription will return the armouredShips ship description Create a class withNano • extends the ship decorator • the constructor will o call the base class constructor o set a private weight value to 1 • the weight property will return base’s weight plus its own private weight • the shipDescription will return the base’s description with “nano armour” added to it create a class withSteel • same as with nano • weight = 75 • description is “steel armour” create a class called withHoneycomb • same as nano • weight = 0.8 * weight of previous armours • description is “honeycombed super structure” Create a function in the main class that will print out how much the ship weighs and what the ship description is to the console. Create a form that will allow a user to “build” their ship On the form will be a checkbox for each of the armour types and a button that will say display ship details. When display ship details is clicked, it will build the ship using the decorations that were selected It will print out the weight to one label (saying that it is the weight and what the weight is). It will also print out the description of the ship to another label. Process: - build the base, get it to work - add one decorator, apply it and get it to work - rinse repeat More patterns For the following create a word document and submit it the word document. The word document will contain the UML diagram (1), an explanation, IN YOUR WORDS, of why you would use the pattern (2), what problems it resolves(1) and how it resolves the problem(1). - Object pool - Prototype Bonus - Apply one of the above patterns in a simple code solution - Not copied from the internet - The pattern needs to be applied and shown to work
Aucun commentaire:
Enregistrer un commentaire