Assessment Overview
This assessment aims at testing some concepts of C programming. in particular the ability to use files and structures, as well as the routine of code development using the software development process (SDP) presented in Lecture 1, namely the five main steps of the software development process:
- Problem statement: formulate the problem.
- Analysis: determine the inputs, outputs, variables, etc
- Design: define the list of steps (the algorithm) needed to solve the problem.
- Implementation: the C code has to be submitted as a separate file. Just indicate here the name of the file.
- Testing: explain how you have tested and verified your C program.
EXERCISE 1
Roulette is a common game found in casinos throughout the world. A picture of a roulette wheel and take is show in Figure 1. Players are asked to bet on a number (as many as they like) and then a ball is placed into the spinning wheel. The ball lands on a number and players who have chosen that number win. Since there are 37 numbers, the probability of guessing correctly is 37:1 and therefore the player wins 37 times the amount they bet. Other bets are often possible, such as choosing red or black, or between even and odd numbers (winning at a rate of 2:1).
An entertainment company would like a new piece of software designed to allow users to play a roulette based game on a computer. The company would like you to create your own game and rules to allow users to bet on randomly generated numbers and then determine if they have won or lost. There are a small number of requirements as described in the following section. The game is played by 1 player at a time.
Program Requirements
- You program should provide users with the ability to create an account. An account should be a structure type variable containing: a username, a password and their available money.
- Users should be able to credit their account with more money.
- All of the accounts should be stored in a data file and accessed by the program.
- Once a user is logged on to the game they should be able to bet with the money they have in their account on a randomly generated number From Figure 1 that would be a value between 0 and 36 (you can decide what values to use in your game). Then determine if they have won or lost and adjust their account balance accordingly.
Ideas
With all of the player accounts stored in a file, use a single structure variable to read the accounts into the program one by one, checking till you find the right players account.
Perform the gaming with the structure variable, then when the player finishes write the data back to the file to save.
You can create a board like that in Figure 1 using a 2D matrix.
You can use the random number generator to simulate the ball in the roulette wheel. You do not need to draw the roulette wheel on the screen, just generate the random number!
Try to create your own functions to simplify the programming task. Try to use local variables where possible. You might consider making the structure global.
Keep the gaming rules simple. At least start by only playing to bet on one number.
What should be submitted?
You should submit the following:
- 1) A short report (up to a few pages of text plus C source codes) detailing for each question:
- a) SDP steps 1 to 3 in the report (Report + Specification + Analysis + Algorithm Design) (40%)
- b) SDP step 4 (Implementation(35%) + Robustness(10%)): your C source code including the comments. (45%)
- c) SDP step 5 in the report (testing): you will explain your testing methodology including: what you wanted to test, how you have tested it and the outcome of your tests. (15%). Note: you do not need to include screenshots of results
Please refer to the file “EEE101 Marking Guidelines Assignments 4-5” on ICE for a detailed marking scheme.
- 2) The report in Microsoft Word or pdf format and C source code of your implementation for each question should be zipped into a single file, i.e. the zip file will contain 2 files, one document and one source code. (It is a good practice to include comments in your code stating the aim of the program, what are the inputs, what are the outputs, which algorithm is used, who is the author and so on.)
The naming of Report (.doc or .pdf), Source Code (.c) and Compressed file (.zip, or .rar)
How the work should be submitted?
Should be submitted electronically through ICE so that the marker can run your programs during marking. Feedback and your grade will also be given through ICE.