首页 > > 详细

辅导R编程、R设计辅导留学生、解析R编程、R讲解、讲解R

This document describes the programming assignment for Programming for Engineers.
The assignment is intended to provide you with the opportunity to put into practice what you have learnt in the course
by applying your knowledge and skills to implement a program that will allow players to play Blackjack against the
computer and will maintain information on players (using an array of structures). You are to write a program (using
multiple C source files) that will keep a record of the players who play Blackjack. Player information will be stored in a
text file that will be read in when the program commences. Once the application has read the initial player data, it should
allow the user to interactively query and manipulate the player information as well as play Blackjack against the
computer. Blackjack game play and rules are provided at the end of the document (for your information only).
This assignment is an individual task that will require an individual submission. If you are an internal student, you
will be required to submit your work via learnonline before Tuesday 12 June (swot-vac week), 10am (internal
students). You will also be required to present your work to your supervisor during your allocated session held
in the swot-vac week of the study period. Important: You must attend your allocated session in order to have your
assignment marked. If you are an external student, you are only required to submit an electronic copy of your program
via learnonline before Tuesday 12 June (swot-vac week), 10am (external students). External students are not
required to demonstrate in person.
This document is a kind of specification of the required end product that will be generated by implementing the
assignment. Like many specifications, it is written in English and hence will contain some imperfectly specified parts.
Please make sure you seek clarification if you are not clear on any aspect of this assignment.

GRADUATE QUALITIES
By undertaking this assessment, you will progress in developing the qualities of a University of South Australia graduate.
The Graduate qualities being assessed by this assignment are:
 The ability to demonstrate and apply a body of knowledge (GQ1) gained from the lectures and text book
readings. This is demonstrated in your ability to apply programming theory to a practical situation.
 The development of skills required for lifelong learning (GQ2), by searching for information and learning to use
and understand the resources provided (supplied assignment files, C standard library, lecture notes, text book,
practical exercises, etc), in order to complete a programming exercise.
 The ability to effectively problem solve (GQ3) using the C programming language to complete the programming
problem. Effective problem solving is demonstrated by the ability to understand what is required, utilise the
relevant information from lectures, the text book and practical work, write C code, and evaluate the effectiveness
of the code by testing it.
 The ability to work autonomously (GQ4) in order to complete the task.
 The ability to behave ethically (GQ5) by ensuring that you abide by the University’s policies and procedures
relating to academic integrity as they apply to assessment. Your solutions must be your own work.
 The use of communication skills (GQ6) by producing source code that has been properly formatted; and by
writing adequate, concise and clear comments.
 The application of international standards (GQ7) by making sure your solution conforms to the standards
presented in the programming practices lecture slides (available on the course website).

PRACTICAL REQUIREMENTS
It is recommended that you develop this assignment in the suggested stages.
It is expected that your solution WILL include the use of the following:
Your program must be developed using multiple C source files, with the number and names of all the files strictly
adhering to the specifications below.
Your program must be developed with three C source files and two header files. These files must be:
 assign.c - This file contains the main() function and contains code to implement the interactive
mode, which uses the functions contained in playerRecord.h. It allows the user to
interactively query and manipulate the player information and play Blackjack. The array
of structures for the player information and the array of structures for the deck of cards
must be defined within the main() function in file assign.c.
 playerRecord.h - Provided for you on the web. This file contains the function prototypes for functions to
load, query, and manipulate the player information (stored in the array of structures). It
also allows the player to play Blackjack against the computer (using the functions in
blackJack.h). This file must not be altered with the exception of completing the data
structure declaration.
 playerRecord.c - This file contains the implementations of the function prototypes listed in
playerRecord.h. It may also contain additional functions (to assist in your
implementation of the functions listed in playerRecord.h). It will also call functions
provided for you in blackJack.h which will allow the player to play Blackjack against
the computer.
 blackJack.h - Provided for you on the web. This file contains function prototypes for functions which
shuffle, deal, and play one game of Blackjack against the computer. This file must not
be altered.
 blackJack.c - Provided for you on the web. This file contains the implementations of the function
prototypes listed in blackJack.h. This file must not be altered.

Please note: You do not have to write the code that plays one game of Blackjack against the computer, this
has been provided for you. The blackJack.h and blackJack.c files contain a function called play_one_game()
that plays one game of Blackjack adhering to the rules provided in the assignment handout. The function takes the
deck of cards, chip balance and bet amount as parameters and returns the result of the player’s game against the dealer
(computer), and the bet amount as a call-by-reference parameter. The function returns 3 if the player wins, 1 if the
player draws with the dealer and 0 if the player loses. You are required to use this (i.e. call the function) as part of this
assignment, however, please do not modify the blackjack.h or blackjack.c files. There are other functions
within the blackjack library that create the playing deck, and shuffle it, but you do not have to worry about those functions,
you only have to make use of the play_one_game() function in your solution, the other functions will take care of the
rest for you!


It is expected that your solution WILL also include the use of the following:
 An array of structs which will store player information (defined in the main() function).
 An array of structs which will store a deck of cards (defined in the main() function).
 A variable which records the number of player records stored in the array (defined in the main() function).
 No global variables.
 The supplied playerRecord.h file which must not be altered with the exception of completing the data
structure declaration.
 The supplied blackJack.h file which must not be altered.
 The supplied blackJack.c file which must not be altered.
 Appropriate functions – 1 idea per function.
 Pass-by-reference parameters.
 Use of #define for symbolic constants (i.e. #define MAX_PLAYERS 5). No magic numbers.
 Well constructed loops. Marks will be lost if you use break, quit(), exit() or return statements or
the like in order to exit from loops.
 Output that strictly adheres to the assignment specifications. If you are not sure about these details, you should
check with the ‘Sample Output’ provided at the end of this document.
 Good programming practice:
o Consistent commenting, layout and indentation. You are to provide comments to describe: your details,
program description, ALL variable definitions, all function prototypes and all function definitions, and
every significant section of code.
o Meaningful variable names. No single letter variable names.

Your solutions MUST NOT use:
 break, or continue statements in your solution. Do not use the quit() or exit() functions or the break
or return statements (or any other techniques) as a way to break out of loops. Doing so will result in a
significant mark deduction.
 The sort function(s) that are a part of the C Standard Library.

A portion of the marks will be allocated according to your use of the above. Refer to the C programming practice
slides (available on the course website) and ensure your code adheres to the standards/conventions described
in these slides.
PLEASE NOTE: You are reminded that you should ensure that all input and output conform. to the specifications
listed here; if you are not sure about these details you should check with the sample output provided at the end
of this document or post a message to the discussion forum.
Please ensure that you use Microsoft Visual Studio in order to complete your assignments. Your programs MUST run
on the version of Microsoft Visual Studio on your personal device and/or on the campus computer pools.

INPUT
When your program begins, it will read in player information from a file called players.txt. This is a text file that
stores information relating to players. The table below details the information provided for each player.

Field No. Field Name Description
1 Name up to 25 characters
2 Games played an integer
3 Number won an integer
4 Number lost an integer
5 Number drawn an integer
6 Chip balance an integer
7 Total score an integer
Figure 1: PlayerRecord Structure.

The name of the player is stored on a separate line. The very next line contains the number of games played, games
won, games lost, games drawn, chip balance and the total score, are stored on one line and are separated by the space
character as seen below:

Jake Peralta
5 5 0 0 100 15
Johnny Rose
6 2 0 4 20 10
Amy Santiago
7 4 0 3 300 15
Jessica Jones
12 0 6 6 50 6
Figure 2: Player information file format (players.txt).


An example input file called players.txt can be found on the course website (you are not required to create it
yourself).
You may assume that all data is in the correct format. When storing the player's name, you should use only the minimum
amount of space required. Hint: use malloc() for this.

After the program has stored the data (using an array of structs), it will enter interactive mode as described in the
following section.

INTERACTIVE MODE
Your program should enter an interactive mode after the player information has been read in from the file. The program
will allow the user to enter commands and process these commands until the quit command is entered. The following
commands must be allowed:

Command Description
players
Displays for all players, the player’s name, games played, won, lost,
drawn, number of chips and their total score. Outputs the contents of
the array of players as described in the section ‘Screen Format’ below.

buy
Prompts for and reads the player’s name and searches for the player
in the array of players. If the player is found in the array of players, the
number of chips the player would like to buy is prompted for and read.
The player’s chip balance is updated accordingly and a message
indicating that this has been done is displayed to the screen.
If the player is not found in the player array, an error message is
displayed.

chips
Displays the player with the highest chip balance in the player array.
Where two players have the same chip balance, the player with the
lower games played value should be displayed. If no players are stored
in the array or a player with a highest chip balance cannot be found
(i.e. players have a chip balance of zero), display an error message
accordingly. See section ‘Screen Format’ below.

clear
Prompts for and reads the player’s name and searches for the player
in the array of players. If the player is found, the player’s game
statistics (games played, number won, number lost, number drawn and
player’s total score) and chip balance are set to zero and a message is
displayed to the screen indicating that this has been done.
If the player is not found in the player array, an error message is
displayed.

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!