Cab201 programming principles - you will now implement the


Project - Space Race

Part A: Console Implementation

INTRODUCTION

This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a partially implemented prototype for a project that has not been fully specified at this stage. There is supporting documentation to the project in addition to this document. You are required to deliver a working prototype by the required date.

THE TASK

For this assignment your task is to develop a program for an on-line board game with the working title, Space Race. In Part A you will develop a Console application and in Part B a Windows Form GUI (Graphical User Interface).

The reason for implementing the Console application is so that you can develop the logic of the game correctly and test your program thoroughly without the task being complicated by trying to develop the GUI. You will see how to create Window Forms programs in Lectures 7 & 9 and the associated weekly worksheets.

If you work on this assignment with a partner, you should work together on each version, rather than one doing the Console version and the other doing the GUI version. This is because the assignment is designed so that the GUI version builds on top of the game play logic of the Console version, i.e. you can't develop each version independently.

The requirements for the GUI version will be released as Part B of this assignment specification, once Lecture 9 has taken place. Do not try to work on the GUI version until you see Part B of the specification, i.e. you can't just make up a GUI of your own design.

Read up to the end of the first paragraph in the section with the Heading "WHERE TO START" before attempting to write any code.

THE SPACE RACE GAME

This is entirely fictitious board game and bears no resemblance to any actual on-line game of the same name. It is similar to the popular ancient Indian board game, Snakes and Ladders. If you are unfamiliar with Snakes and Ladders, refer to the entry in Wikipedia.

The game is a simple race contest based on sheer luck. It is played between 2 or more players (limited to 6 for this assignment) on a board consisting of 56 squares and a pair of six-sided dice. The object of the game is for each player to move their token according to the roll of the dice from the Start square to the Finish square, helped or hindered by landing on certain select squares. Players take turns rolling the pair of dice once and moving their token the required number of squares. When all players have had a turn, that round is completed.

The squares are numbered 0 to 55, with square 0 the "Start" square and square 55 the "Finish" square. Each square from 1 to 54 is either an "ordinary", "wormhole", or "blackhole" square. Landing on a "wormhole" or "blackhole" square will result in the player being transported to another square as part of their turn. Landing on a "wormhole" square moves the player closer to the "Finish" square whilst landing on a "blackhole" square moves the player further away from the "Finish" square.

- Squares 2, 3, 5, 12, 16, 29, 40 and 45 are "wormhole" squares

- Squares 10, 26, 30, 35, 36, 49, 52, 53 are "blackhole" squares

Each player starts the game with a limited amount of fuel and landing on any square, at the end of their turn, results in the consumption of a specified amount of fuel. Should a player run out of fuel that player will take no further part in the game. It is a possibility, though very unlikely, that all players may run out of fuel before reaching the Finish square in which case no one would win the game.

Unlike most board games where the first player to reach the finish, wins and the game is over, in this game all players still in the game will complete their turn in that round. This gives the possibility that more than one player may reach the "Finish" square in a round and so there would be multiple winners. See document titled Screenshots of Console Play which shows various aspects of the game play. Your console interactions should be identical to these screenshots, though the actual output values will differ.

PROTOTYPE IMPLEMENTATION NOTES

The supplied prototype consists of four (4) projects within the Solution file, Space Race.sln

- The Console Class will contain the high-level code for running the Console version of the game in Main. This class currently has two trivial methods which output various messages to the Console, other methods will need to be added. Main contains a suggested high-level algorithm for playing the game once.

- The Game Logic Class will contain code that will be used by both the Console application and the GUI. Extra private instance variables, public properties and methods will need to be added to this class. It currently contains two empty methods PlayOneRound and SetUpPlayers.

- The GUI Class contains incomplete code for creating the GUI version of the game. No code in this class will be used by Console application and should be ignored until Part A is completed. Do not edit the current contents of this class until starting Part B.

- The Object Classes contains the low-level objects used by both versions of the game.

o The Board Class - Board.cs
This class models the board used in this game. I.e. this class contain all the squares that make up the board in the array named squares.
This class is incomplete. While no other instance variables or properties are required to implement the board, code must be added for initializing the 54 squares in the method SetUpBoard. Also, the method FindDestinationSquare needs to be completed. No additional pubic methods or properties are required in this class. You can define additional constants or variables if you require them.

o The Die class - Die.cs
This class represents a many-sided die (commonly called a "dice") with each face having a distinct and unique value between 1 and the number of faces. This class is complete, i.e. no other variables, properties or methods need to be added to this class.
Note that the Class variable random is initialised using the constructor which takes a parameter (seed). This is so that when testing your code, the same sequence of "random" values will be generated. You can change the seed when testing your code.

o The Player Class - Player.cs
This class represents a player of the game. A player has a name, an amount of fuel, knows which square they are currently on (location) as well as the number of that square (position). (Although not important for the Console game, a player has two other properties that will be used in the GUI game: a token-colour and a token-image.)

Note the constructor only initialises the name of the player, other instance variables are set by the Game Logic Class using the various public properties, Position, Location, and FuelLeft that are available in this class.

This class is incomplete. The bodies of the following two methods need to be completed: Play and ReachedFinalSquare. You may need additional private instance variables and/or private methods in this class to play the game according to the assignment specifications . However, make a note of these additions as you will need to mention these additions in your final project report.
o The Square Class - Square.cs
This class represents an ordinary square on the board, including the Start and Finish squares. It is also the base class for the Wormhole Square class and the Blackhole Square class.
Each square has a number which is the position (0 ... 55) of the square on the board, with the Start square's number is 0 and the Finish square's number is 55. Each square also has a name which is simply the string version of its position on the board except the Start square's name is "Start", and Finish square's name is "Finish".
The NextSquare property is only used by Wormhole and Blackhole squares to "jump" to their respective destination square.

The method LandOn for an Ordinary square uses a constant amount of fuel regardless of the number of squares traversed to arrive at that square. For Wormhole and Blackhole squares this method consumes a specified amount of fuel as well transporting the player to another square on the board.
This class is complete, i.e. no other variables, properties or methods need to be added to this class.
o The Blackhole Square Class - BlackholeSquare.cs
A subclass of Square which represents a Blackhole square on the board. This class is complete, , i.e. no other variables, properties or methods need to be added to this class.
o The Wormhole Square Class - WormholeSquare.cs
A subclass of Square which represents a Wormhole square on the board. This class is complete, i.e. no other variables, properties or methods need to be added to this class.

WHERE TO START
Tackling a large project such as this assignment may initially seem daunting, however breaking it down into smaller tasks that can be implemented and tested will make the task much more manageable and is an important skill for professional practice. You will develop this assignment as a bottom-up implementation exercise. This means that you will work with the supplied code in Space Race.sln that has already been written and implement methods, one by one, starting with various low-level functionality and incrementally implementing the body of Main in the Console Class to test the low-level functionality.

Become familiar with the six classes in the Object Classes project and, the Constructor methods for Square, WormholeSquare and BlackholeSquare. Starting with the Board Class implement the two incomplete methods, SetUpBoard and FindDestinationSquare. When compiling (building) the Board Class, select Build Object Classes from the Build menu. This will restrict any compiler errors to just this class.
To test if these methods are correct, call SetUpBoard from Main in the Console Class. A Breakpoint has been inserted on the last line of SetUpBoard so that you can examine the contents of the array squares. Do not proceed any further until you can initialise each element of squares correctly.

In the completed version of the Console implementation, the program will ask the user the number of players in a particular game and will check that the number of players is between 2 and 6 inclusive. Start with two players only for testing purposes as per the declaration in

SpaceRaceGame.cs before
In Game Logic Class implement the method SetUpPlayers. The players are stored in a special List type, called a BindingList, which is just like an array except the List can grow as elements are added to it. For the Console version use the default names defined in the string array names. When compiling (building) the Game Logic Class, select Game Logic Class from the Build menu.

To test this method, place a Breakpoint on the line containing the closing brace (curly bracket) of whatever loop construct you are using to initialise the player's instance variables. Run the program and examine the contents of the list Players. Do not proceed any further until you can initialise each element of Players correctly.

You are now ready to implement the loop to play a round of the game in Main. In this game, a player does not need to roll the exact number to reach the Finish square. For example, a player may be on Square 50 and roll a total of 7, this player will finish on Square 55, the Finish square. However, be carefully that you code does not attempt to place the player on the non-existent Square 57.
When you believe your program is working correctly for any number of players, add to your code so that the user can choose to play another game or exit the program.

There are to be no explicit Write or WriteLine calls within the body of Main, you should use trivial methods similar to DisplayIntroductionMessage method in the Console Class to output any messages to the screen.
Any numeric input will need to be checked that it is the correct type and that it is within the range of allowable values for that input.
When asking the user to play another game, your code will accept either "Y" or "y" as yes and all other inputs will mean they wish to exit the program. If the user decides to play another game, they will have the option of changing the number of players in the new game.

To test the possibility of one or more players running out of fuel you will need to change the INITIAL_FUEL_AMOUNT in the Player Class to a much smaller value. However, be sure to change the constant back to the original value of 60 before submitting the assignment.Part B: GUI Implementation

PART B

Do not start on the GUI implementation if your Console implementation cannot play at least 1 game of Space Race correctly or at least appears to play the game correctly.

Both implementations of the game must work correctly for you to gain full marks. The GUI implementation will not involve making any changes to either the Game Logic Class or the Object Classes.

This specification and its associated documents are fairly detail and do not expect to understand or remember all that is contained in them in a single read .

THE TASK FOR PART B
Having implemented the Console version of the game, you will now implement the GUI version of the same game. It is required that you use Windows Form, rather than any other GUI technologies such as WPF, XNA, or web pages. This means that Visual Studio for Mac and MonoDevelop will likely be insufficient - you will need to ensure that you have access to Visual Studio for Windows to do this assignment.
You must test your program in one of the CAB201 labs prior to submission. Markers will attempt to compile and run your code in that environment only. It is your responsibility to ensure that your code compiles and runs on PCs in the QUT computer labs of CAB201 as the target platform.

You will implement the GUI version as part of the GUI Class within the same VS2017 solution as the Console version. Remember you are not to develop a GUI of your own design. Though you are not expected to position the various controls in the location and size correct to the last pixel, your layout should look like the layout in the Fig 3 in the document Screenshots of GUI.

Building GUI Implementation
Open the Solution Explorer, and right-click on the GUI Class project and select Set as StartUp Project. If you want to run the Console version again, then do the same to the Console Class project.

The GUI Class contains the form, SpaceRaceForm.cs, which is to be used to display GUI version of the game. The form is at an early stage, you can Start (run) the form to see a blank form apart from one button is the lower right-hand corner which can be clicked to close the form.

Details of the form: The form size is set to 900 x 700 pixels. This is a good size for using Design View to layout the form and shouldn't be changed. The form's precise size will be altered by program code that I've already written, so that each of the board's squares is displayed with the same size.

The form contains two controls so far, see Fig 1 in Screenshots of GUI. Both controls are essential.

- A SplitContainer which divides the form into two panels: one on the left, for the board; and one on the right, for all the other controls. You can't really see the SplitContainer, just its two panels. The SplitContainer is docked in its parent container, the form, so that its panels occupy the whole of the form, i.e. its Dock property = Fill. (This is the default behaviour when you add a SplitContainer to a form, so you shouldn't have to do anything. But if you accidentally change this property, your form will look a mess.) This control is complete. Its position on the form is correct. Do not move it.
- The Exit button. It has an event-handler that terminates the game. This control is complete.

Now add a TableLayoutPanel to the left-hand panel. Refer to the document Creating a TableLayoutPanel. When completed, your form should look like Fig 2 in Screenshots of GUI. Do not proceed further until you have placed the TableLayoutPanel correctly on your form.
Look at Fig 3, where there are now three Labels, a ComboBox, a DataGridView , three Buttons, a
GroupBox containing two RadioButtons in the right-hand panel
- The two larger Labels, Space Race and Players, are 16pt. All three labels are bold.

- The additional two Buttons, Game Reset and Roll Dice, need to be given reasonable names, so that you can easily refer to them in your code later, rather than default names likes button1, etc. Suggest looking at the (Name) property of the Exit button.

- The ComboBox, beside the Number of Players Label, needs the following properties set:

o Size: 35, 21 is recommended
o Items: left click the value (Collection), left click the greyed box to the right which will open the String Editor. Enter the values 2, through to 6, one per line and click OK.
o Text: 6 (This will ensure that the ComboBox will initially display this value, otherwise it will be blank.)
o Now run your Form, only the controls that you have added in the right-hand panel will be visible and you should be able to select anyone of the five values from your ComboBox.

- From the Data group in the Toolbox, select DataGridView and place it roughly below the Players label, do not be concern if the control extends beyond the right-hand edge of the Form, that will be fixed later.

- Now refer to the document, Setting up a DataGridView, noting that the first two screenshots are from an older assignment so there will be some small difference from what you will see initially. When finished run your form and it will look like the last screenshot in the Setting up a DataGridView document.

- From the Container group, place a GroupBox below the DataGridView. Change its Text property to Single Step? and set its Enabled property to False and its BackColor to ControlDark.

- From the Toolbox now add two RadioButtons to the GroupBox, side-by-side with the text
Yes and No respectively, as well as renaming each radio button.

- Now drag the GroupBox borders to fit inside the panel and change its Size to approximately 140 by 55. You may have to move the radio buttons around within the GroupBox so that the control looks reasonable.

- This GroupBox will be disabled until advised later in this specification. When completed, your form, in Design View, should look like Fig 3 in Screenshots of GUI.

Attachment:- Major Assignment.rar

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Cab201 programming principles - you will now implement the
Reference No:- TGS02943314

Expected delivery within 24 Hoursrs

2015 ┬ęTutorsGlobe All rights reserved. TutorsGlobe Rated 4.8/5 based on 34139 reviews.