RBE104TC C/C++ Programming Language Resit


Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due


RBE104TC C/C++ Programming Language Resit

Contribution to the Overall Marks
100%
Issue Date

Submission Deadline

Assignment Overview:

This assignment is geared towards assessing fundamental coding concepts in C/C++ and initiating the process of code development using the software development process (SDP) discussed in relevant lectures.
In composing the SDP report [in English], we request you to fulfil the following criteria:


  • Design: Clearly explain your understanding of the given problem and specify a sequence of steps necessary to accomplish the task (illustrated through flowcharts).
  • Coding Progress: Attach 3-5 screenshots that show the code and running results as evidence, particularly highlighting any errors or situations you believe are valuable to document. The corresponding 3-5 versions of the C code should also be saved. All files must clearly demonstrate the progression of your programming task from the initial stage to the final version.
  • Analysis: Describe the files submitted in the Coding Progress section. Discuss the expected results, any encountered or unexpected errors, and your solutions to those issues.
  • Implementation: The C code must be submitted in a separate file. Please specify the file name and provide instructions for user operation.
  • Testing: Describe how you tested and validated your code for required functionalities, as well as its robustness.


Exercise 1 (35%):

Write a modular C program that will allow two players to play the game of tic-tac-toe (also known as noughts and crosses), see the game example output in the following figure.

To start the game the two players should agree who will go first.

Players take turns to place their token (an ‘O’ or an ‘X’) on the board by choosing a number from 1-9. The game is won if one player can place three of their tokens in a row, horizontally, vertically or diagonally. The game is drawn if all of the squares are filled and neither player has been able to make a row of three tokens.

* If illegal user input is detected in each input scenario, the software should be capable of informing the user and enabling re-input to meet the software robustness requirement;
Advice:
  • display the game board;
  • player 1 enters the number of the square they wish to choose;
  • the game board is updated;
  • the winning status of the game is tested and the game finishes if the player won;
  • player 2 enters the number of the square they wish to choose;
  • the game board is updated;
  • the winning status of the game is tested and the game finishes if the player won;
  • and so on…
Consider that for everything you want to repeat for example each iteration of the two players you will need a loop.

Produce the program one step at a time. e.g. if you can produce the input and test for player 1 then player 2 will be similar. Work out how to display your board (note it does not have to look exactly the same as in Figure 1). Each square choice can be a variable (i.e. 9 variables), that you can change the value of when it is chosen. Then the whole board can be printed with one printf statement that uses the values stored in the 9 variables.

The assignment tests your understanding of creating a basic modular program. Therefore, repetitive actions such as printing the board or testing for a win should be performed in separate functions and called when required. In this assignment use of global variables is acceptable.

Exercise 2 (25%):

Design a new class to represent a date like follows:
JAN - 25

The class Date contains two data members, denoting the 3-letter abbreviation of the month and the date (all capitalised).

Part 1: Fundamental requirements:

1. Write the constructors, destructor, and output function members of this class;
Part 2: Using “operator overloading” to realise the following tasks:
2. Define the assignment operator “=” to assign the value of one Date object to the other;
3. Define the comparator “>” “<” and “==” to compare two dates;
4. Define the unary sign “++” to add one day to a date object:
Eg: Date dToday(MAR, 20); // value of dToday is Mar-20
++dToday; // value of dToday changed to Mar-21
* Illegal user input should be detected and processed properly.

Exercise 3 (40%)

You are asked to program a card game called Blackjack, also known as Twenty-one. Blackjack is a comparing card game between a player and dealer (In a real game, multiple players are allowed.

However, only one player is considered in this assignment). One may win a game in one of the following 3 ways:

  • Get 21 points on the player's first two cards (called a "blackjack"), without a dealer get a "blackjack"
  • Reach a final score higher than the dealer without exceeding 21.
  • Let the dealer draw additional cards until his or her hand exceeds 21.

A game starts with both the dealer and the player are dealt an initial two-card hand. An ace can be counted as 1 point or 11 points. Face cards (kings, queens, and jacks) are counted as ten points. All other cards are counted as the numeric value shown on the card. After receiving their initial two cards, the player can place his initial bet. In any given round, the player has the following options:

  • Hit: Take another card from the dealer
  • Stand: Take no more cards.

The player’s decision also includes whether or not the player wants to increase the bet and how much he wants to increase if yes. The dealer must hit until the cards total 17 or more points. Scoring higher than 21 (called "busting" or "going bust") results in a loss. You may write an algorithm for the dealer to make a decision or simply make the decision for the dealer when it is the dealer’s turn to make the decision.

To play this game, every player must set up an account first with positive balance say the starting deposit is 100. The player’s account balance will be increased by twice of the size of the bet if he wins. Otherwise, the player losses his bet and he is not allowed to continue his game if the balance becomes zero. You should design and implement at least 3 classes (objects).

* Illegal user input should be detected and processed properly.
Hint:
  • The cards are from a standard deck of playing cards, as shown in the following figures. It contains a total of 4 suits with 13 cards each, amounting to 52 cards in total that are distributed during the game.


  • Initially, the card 'Ace' is counted as 11 points. However, if the total sum of the cards in your hand exceeds 21, then the 'Ace' is revalued to 1 point..
  • A player may choose to stop taking more cards in a given round. The dealer, on the other hand, must take more cards (hit) if the total value of his hand is less than 17. Once the dealer's hand reaches a value of 17 or more, he must stop taking more cards (stand).
What should be submitted?
  • You should submit the followings two:


1. A concise report (with text spanning a few pages) accompanied by C source codes. This report should delve into the specifics for each question:

Detail SDP steps 1 to 3 within the report (Design + Coding Progress + Analysis), accounting for 30% of the evaluation.

Encompass SDP step 4 (Implementation + Robustness) with your source code. Your code should correspond with the final screenshot provided in the Coding Progress section and include appropriate comments. Implementation contributes 35% while Robustness adds

5%.

Elaborate on SDP step 5 (Testing), elucidating how you validated the correctness,robustness, and thoroughness of your codes. Employ screenshots and ample explanations as verification, encompassing 20% of the evaluation.

The overall quality of the report accounts for 10% of the evaluation.

2. All C/C++ source code files, including files from different stages corresponding to the screenshots.
  • For a comprehensive grading scheme, please consult the Marking Guidelines available on the Learning Mall system.
  • The report must be saved in PDF format. Place the report in the same folder with source code files and compress the folder into a single zipped file. Your final submission should include:
- Zipped file containing:
- The report
- The source codes
  • The naming convention for the submitted Report and source code files should adhere to the subsequent format:
- StudentID_LastName_FirstName_AssignmentID.pdf
- StudentID_AssignmentNumber_ExerciseID_SSScreenShotNumber.c/cpp
- StudentID_LastName_FirstName_AssignmentID.zip

As an illustration:

The report and C source files would be placed in the same folder as follows:

The folder would be compressed to the ultimate zipped submission file, and it would be named: 

• 1234567_Albert_Einstein_1.zip

How the work should be submitted?

Submission should take place electronically through the Learning Mall system, enabling us to execute your software during the assessment. Additionally, feedback will be provided via the same Learning Mall system.

发表评论

电子邮件地址不会被公开。 必填项已用*标注