” SIT232程序 写作、 辅导Java,PythonSIT232 Object‐Oriented Development Trimester 1, 20211Practical Task 5.3(Distinction Task)Submission deadline: 10:00am Monday, May 17Discussion deadline: 10:00pm Friday, May 28General InstructionsIn object‐oriented design, a pattern is a General repeatable solution to a commonly occurring problem. It isnot a finished design that can be transformed directly into code, but rather a description or template for howto solve a problem that can be used in many different situations. Effective software design requiresconsidering issuesthat may not become Visible until later in the implementation. Design patterns can handlesuch issues and speed up development process by providing tested, proven development paradigms.This practical task introduces you to the State Design Pattern and make you familiar with problems posedby event‐driven systems. The state pattern is close to the concept of finite‐state machines and allows anobject to alter its behaviour as its internal state changes. It can be interpreted as a strategy pattern, which isable to switch a strategy through invocations of methods defined in the patterns interface. This patternhelps to achieve the following. It makes a class independent of how state‐specific behaviour is implemented. It enables to add new states by defining new state classes. It allows to change the classs behaviour at run‐time by changing its current state object.Indeed, implementing state‐specific behaviour directly within a classisinflexible because it commitsthe classto a particular behaviour and makes it impossible to add a new state or change the behaviour of an existingstate later independently from (Without changing) the class. The state pattern overcomes this challenge.First, it defines separate (state) objects that encapsulate state‐specific behaviour for each state. This impliesan interface (state) for performing State‐specific behaviour. It then defines classes that implement theinterface for each state. Second, it Ensures that a class delegates state‐specific behaviour to its current stateobject instead of implementing state‐specific behaviour directly.Now, letsfocus on the task description. Imagine that you have been hired by an electronics company to builda software for a simple Reaction‐Timer game. The Reaction‐Timer machine has two inputs: a coin‐slot that starts the game and a Go/Stop button that controls it.There is also a display that indicates to the player what he/she should do next. The machine must behave asfollows. Initially, the display shows Insert coin, and the machine waits for the player to do so. When the player inserts a coin, the machine displays Press GO! and waits for the player to do so. When the player presses the Go/Stop button, the machine displays Wait… for a random time between1.0 and 2.5 seconds. After the random delay expires, the machine displays a time‐value that incrementsevery 10 milliseconds,starting atzero. The player must now pressthe Go/Stop button assoon as possible the goal of the game is to show fast reactions! If the player presses the Go/Stop button during therandom delay period, i.e. the player tries to guess when the delay will expire, the machine aborts thegame and immediately demands another coin. To put it simply, there is no reward for trying to cheat! Ifthe user has not pressed stop after two seconds, the machine will stop automatically no living personcould be that slow!SIT232 Object‐Oriented Development Trimester 1, 20212 Whether the player has pressed the Go/Stop button within the two seconds waiting time period or not,the machine displays the final timer value for three seconds, then the game is over until another coin isinserted. If the player presses the Go/Stop button while the measured reaction time is being displayed,the machine immediately displays Insert coin.1. Start with exploring the two provided templates for the program that you will need to write. You are freeto select any of these two. The first option is a Windows Forms application, which issuitable for MS VisualStudio on Windows platform. The second option is a Console Application, which is cross‐platform andappropriate for both MS Visual Studio and Visual Studio Code. Regardless the template you will select,your program must consist of the following parts. A main program module, Which is ready for you and provided in the SimpleReactionMachine.cs file.This module emulates the Reaction‐Timer machine itself and serves as a base to test and use thecontroller that is a part of your particular task. The controller will drive the machine. A GUI component for the Reaction‐Timer machine, which is also ready and provided. Its configurationdepends on the template you will select. In both cases, it includes a button labelled Coin inserted anda button labelled Go/Stop. It also has a display region to show the messages of the machine. The GUIconforms to the IGui interface. Simple Reaction Controller is the module that you will need to implement. This is the main part of theexercise. You are free to write this component in any way you choose if it implements the requiredIController interface. Specifically, yourtask isto add a SimpleReactionController.cs source codefile and complete a new SimpleReactionController class that functions as prescribed for theReaction‐Timer machine above. The IController interface is included in the templates.2. Spend some time to elaborate on how the Reaction‐Timer machine as an event‐driven system should act.Explore the notes on the implementation of finite‐state machines (FSM), of which the Reaction‐Timermachine is an example. Here, we refer to the book chapter attached to the project.To proceed to the next step, you should first complete the design of the system by building what is calledas a state‐transition diagram. The attached document has a number of very similar examples and willguide you in decision making on the number of required states and their properties as well as possibletransitions. This step is crucial as the translation from the diagram to a program code is quitestraightforward, sure if your diagram is correct. Certainly, many programmers are tempted to say I canget this right without a FSM. Unfortunately, this statement is rarely true. Most often, the program thatresults will be hard to understand, hard to modify, and will not be correct. The document will try toconvince you of the Advantage of FSMs. It explains how to convert the correct design into errorless code.3. If you trust your design and it meets the machines specification, it is time to think about the code youwill need to write. Again, we refer to the attached document and examples that it describes. Some videomaterials referred at the bottom of this task sheet will also help you with the structure of the correctimplementation. You should know what you are going to write before you start. Focus on the use of thegiven IController interface and exploit the dynamic‐dispatch mechanism that eliminates the need forthe switch statement. In addition, search and read about implementation of so‐called nested (also calledinner) classes in C# that allow to define a class within another class. This will allow you to strengthenencapsulation in your program and manipulate the states.4. It is finally the time for coding. If you prefer to build a console application, import the files from theSimpleReactionMachine Console directory. If your choice is a Windows Forms application, then openthe existing project from SimpleReactionMachine WinForms, which will ask you to add the missingSimpleReactionController.cs file to the prepared project. In both cases, you will face compilation errorsdue to the lack of the required source code file. Therefore, add the SimpleReactionController classand make sure that it implements the IController interface and contains the following methods. SIT232 Object‐Oriented Development Trimester 1, 20213 void Connect( IGui gui, IRandom rng );Connectsthe controller to the specified GUI component, which implementsthe IGui interface, and the specifiedrandom number generator. void Init();Initialises the controller. void CoinInserted();Reacts on the insertion of a coin into the machine. void GoStopPressed();Reacts on the pressing of the Go/Stop button of the machine. void Tick();Reacts on the Tick event addressed to the controller.Obviously, your controller needs a source of timing information. You must obtain this information byimplementing the Tick method in your controller. The main SimpleReactionMachine class guaranteesto call this method every 10 milliseconds. Do not use any other timer. Furthermore, your controller alsoneeds a source of random numbers. You must obtain your random numbers by calling the GetRandom()method of the provided generator. Do not use the Random class. Note that time must be displayed withtwo decimal places. For Example, a value of 1.5 seconds must be shown as 1.50.5. As you progress with the implementation of the SimpleReactionController class, you should startusing the Tester class from the SimpleReactionMachine Tester directory of the project. It will allowyou to thoroughly test the class you are developing aiming on the coverage of all potential logical issuesand runtime errors. This(testing) part of the task is asimportant as writing the controller itself. To activatetesting, make a separate Console Application project using the files in the SimpleReactionMachineTester and import your current version of the SimpleReactionMachine class. Explore the Tester classto get details of the tests we prepared for you and the sequence that they are applied. If you fail a test,then the logic (behaviour) of your controller is incorrect.The following displays the expected printout produced by the attached Tester, specifically by its Mainmethod.test A: passed successfullytest B: passed successfullytest C: passed successfullytest D: passed successfullytest E: passed successfullytest F: passed successfullytest G: passed successfullytest H: passed successfullytest I: passed successfullytest J: passed successfullytest K: passed successfullytest L: passed successfullytest M: passed successfullytest N: passed successfullytest O: passed successfullytest P: passed successfullytest Q: passed successfullytest R: passed successfullytest S: passed successfullytest T: passed successfullytest U: passed successfullytest V: passed successfullytest W: passed successfullytest X: passed successfullytest Y:Passed successfullySIT232 Object‐Oriented Development Trimester 1, 20214test Z: passed successfullytest a: passed successfullytest b: passed successfullytest c: passed successfullytest d: passed successfullytest e: passed successfullytest f: passed successfullytest g: passed successfullytest h: passed successfullytest i: passed successfullytest j: passed successfullytest k: passed successfullytest l: passed successfully=====================================Summary: 38 tests passed out of 386. Finally, remember that this task is primarily about object‐oriented design rather than pure coding. If youfollow the instructions, your code should not be longer than (approximately) 200 lines. This is how longour solution is. Our past experience says that students coding without design will likely end up withseveral times longer Code, which is usually messy and inefficient because of many plugs and conditionalstatements.Further Notes Explore the attached book chapter entitled Notes on Finite State Machines to learn about the conceptsyou will need to complete this project correctly. Especially, focus on the examples of the state‐transitiondiagrams as they will help you sketch your FSM. The following video materials will give you more insights on the finite state machines, their relevance tothe state design pattern, and how to implement the pattern in code.Submission Instructions and Marking ProcessTo get your task completed, you must finish the following steps strictly on time. Make sure that your programsimplement the required functionality. They must compile and have no runtime errors.Programs causing compilation or runtime errors will not be accepted as a solution. You need to test your programsthoroughly before submission. Think about potential errors where your programs might fail. Submit the expected code files as a solution to the task via OnTrack submission system. Once your code solution is accepted by the tutor, you will be invited to continue its discussion and answer relevanttheoretical questions through a face‐to‐face interview with your marking tutor. Specifically, you will need to meetwith the tutor to demonstrate and discuss the accepted solution in one of the dedicated practical sessions (runonline via MS Teams for cloud students and organised as an on‐campus practical for students who selected to joinSIT232 Object‐Oriented Development Trimester 1, 20215classes at Burwood or Geelong). Be on time with respect to the specified discussion deadline. Please, come preparedso that the class time is used efficiently and fairly for all students in it.You will also need to answer all additional questions that your tutor may ask you. Questions will cover the lecturenotes;so attending (or watching) the lecturesshould help you with this compulsory discussion part. You should startthe discussion as soon as possible as if your answers are wrong, you may have to pass another round, still before thedeadline. Use available attempts properly.Note that we will not accept your solution after the submission deadline and will not discuss it after the discussiondeadline. If you fail one of the deadlines, you fail the task and this reduces the chance to pass the unit. Unless extendedfor all students, the deadlines Are strict to guarantee smooth and on‐time work throughout the unit.Remember that this is your responsibility to keep track of your progress in the unit that includes checking which taskshave been marked as completed in the OnTrack system by your marking tutor, and which are still to be finalised. Whenmarking you at the end of the unit, we will solely rely on the records of the OnTrack system and feedback provided byyour tutor about your overall progress and the quality of your solutions.请加QQ:99515681 或邮箱:99515681@qq.com WX:codehelp
“
添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导。