Assignment Document

Software Engineering: Analysis & Design - Design Patterns, Static Attributes, Singleton

Pages:

Preview:


  • "ITECH 7201 Software Engineering:Analysis & Design Week 8 – Design Patterns, Static Attributes, Singleton Commonwealth of Australia Copyright Act 1968 Notice for paragraph 135ZXA (a) of the Copyright Act 1968Warning This Material has been reprodu..

Preview Container:


  • "ITECH 7201 Software Engineering:Analysis & Design Week 8 – Design Patterns, Static Attributes, Singleton Commonwealth of Australia Copyright Act 1968 Notice for paragraph 135ZXA (a) of the Copyright Act 1968Warning This Material has been reproduced and communicated to you by or on behalf of Federation University Australia underPart VB of the Copyright Act 1968 (the Act). The Material in this communication may be subject to copyright under the Act. Any further reproduction orcommunication of this material by you may be the subject of copyright protection under the Act. Do not remove this notice.FOST This week’s tasks • After completing this week’s tasks you should be able to: • Describe the purpose of a design pattern • Explain the principle of “programming to an interface” • Explain how static variables belong to a class instead of toan instance of a class • Explain the singleton design pattern • Describe lazy instantiation (initialisation) • Write small code fragments involving static attributes• Write Singleton classesFOST Lab 7 • Lab 7 provides the basis of our mazegame • You won’t be able to proceed with the assignment until thislab is complete so if you haven’t finished it yet get onto it ? In this lab you were provided with some base code and youadded some more • At the end of the lab you should have finished with a smallmaze game that allows you to move from one location toanother or to quit the game ? We will spend the first part of the lecture looking more deeplyat the labFOST Mazegame • The maze game itself is text based • input and output will appear in the console at the bottom ofEclipse • If you can’t see your console window let your tutor know ? Based loosely on “Dungeons and Dragons” • Player moves between locations solving problems andperforming tasks ? A location is a room or a space in which a player can remainbetween turns • Locations are connected by ExitsFOST Turns • The game progresses in cycles which we will call “turns” • Each turn consists of• A player typing a command into the console window • The game responding to that command in an appropriateway ? For example, a player might give the command “move west”.The system will respond by updating the player’s location tothe location that can be reached by the Exit on the west. • If such an Exit doesn’t exist, a message to that effect isdisplayedFOST Commands • The game waits for a player to enter a command • A command consists of 1 or 2 (or more) words• The first word is the command itself • The second (and subsequent) words are arguments ? For example, move west • “move” is the command • “west” is the argumentFOST Fetching Commands • The first thing we needed to do was to fetch the command from theconsole and make it available to the application • We added the classes Parser and ParsedInput • Parser provided methods which • Fetched the command from the console window (as a wholeString) – eg “move west” • Broke this string up into its constituent words “move”, “west” • Created a ParsedInput object which contains a command and alist of arguments • The ParsedInput object is the one which the game uses to “understand”the commandFOST runGame method • We then turned our attention to the DungeonMaster class • The “engine room” of our game functionality • It starts the game, sets up the various objects and processturns until the “quit” command is given ? The method runGame is called to process turns. It consists ofa loop that keeps iterating until the player enters “quit” ? The loop consists of a method called processTurn which looksafter a single turnFOST processTurn method ? Works as follows (write to find the code that does these things) • It fetches the command and creates a ParsedInput object • It checks the command against a list of acceptable commands • There are currently two – “quit” and “move” although “move” currentlydoesn’t have any real functionality • If the command exists the appropriate response is generated • Otherwise a message saying that the command can’t be found isdisplayedFOST Move command ? The rest of the lab involved implementing the Move command ? A new private (why private?) method called processMove wasadded to the DungeonMaster class • This method was called from processMove • Look at this method and see how it implements thefunctionality for moving a player from one location toanother • What happens if an exit doesn’t exist in the directionspecified?"

Why US?

Because we aim to spread high-quality education or digital products, thus our services are used worldwide.
Few Reasons to Build Trust with Students.

128+

Countries

24x7

Hours of Working

89.2 %

Customer Retention

9521+

Experts Team

7+

Years of Business

9,67,789 +

Solved Problems

Search Solved Classroom Assignments & Textbook Solutions

A huge collection of quality study resources. More than 18,98,789 solved problems, classroom assignments, textbooks solutions.

Scroll to Top