A-level Computing 2009/AQA/Problem Solving, Programming, Data Representation and Practical Exercise/Skeleton code/2014 Exam/Section D

At the end of the game the player is asked to enter their name. Currently the player can just enter nothing by pressing Return. Modify the program to disallow empty inputs.
VB.Net solution

Modify the function GetPlayerName as follows:

Python Solution

Java solution

Pascal solution

Save/Load Recent scores from a file
VB.Net solution

Python Solution

Java solution

Pascal solution

Ranked/Top/High Scores
VB.Net solution

Python Solution

Java solution

Pascal solution

Add a new suit to the deck
VB.Net solution

Function GetSuit(ByVal SuitNo As Integer) As String Dim Suit As String = "" Select Case SuitNo Case 1 : Suit = "Clubs" Case 2 : Suit = "Diamonds" Case 3 : Suit = "Hearts" Case 4 : Suit = "Spades" Case 5 : Suit = "Swords" End Select Return Suit End Function // Also in every instance of 52 or 51 add 13 to increase the deck size to accommodate another suit and add this to the text file: 5 1 5 2 5 3 5 4 5 5 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13

Python Solution

Java solution

Pascal solution

Change the objective of the game to higher or lower rather than just higher or not
VB.Net solution

Python Solution

Java solution

Pascal solution

Use the suit of the card to determine if the same value card is higher or not - suits are ranked 1 to 4 as they are in Bridge - Clubs, Diamonds, Hearts, Spades
VB.Net solution

Enter this as IsNextCardHigher 'Mr Patel 'Highdown

'More efficient version which uses ELSE —Geoguy180--

Python Solution

Please note this solution amends the existing PlayGame function rather than creates a complete new function. It does need a need function called IsNextCardLower(LastCard, NextCard)
 * 1) Python Solution

Java solution

Pascal solution

Getting the Users choice to choose if the next card will be higher will not accept capital letters. Modify the code to allow this.
VB.Net solution

Python Solution

Java solution

Pascal solution

Currently there is no way to quit during the game. Allow the user to quit during the game.
VB.Net solution

Python Solution

Java solution

Pascal solution

Limit the user's "username" to X characters
VB.Net Solution

NOTE: This piece of code has also disallowed an input of 0 characters for the 'username'. Therefore the username must be between 1 and 10 characters long. Jack.Wall

Python Solution

Note: This also has the fix for Question 1

Java solution

Pascal solution

Using the previously shown cards show a percentage of the next card being higher.
Second Python solution is a less compute intensive solution than most, and works all way from 1st to last card. Easy to port to other languages

'Note: none of these solutions take into account the fact that the total cards in each rank decreases

VB.Net solution

Python Solution

Less Compute intensive solution every GetCard does ONE subtract, and MAX of 12 numbers to SUM to get percentage

Java solution

Pascal solution

Allow the user a certain number of card swaps if they don't like the card dealt to them (Based on Bruce's "Play Your Cards Right" for those of a certain age!)
VB.Net solution

Python Solution

Java solution

Pascal solution

Record the number of games played and an average score
VB.Net solution

Python Solution

Java solution

Pascal solution

Give a player 2 lives. If they get it wrong they lose a life
VB.Net solution

Python Solution

Java solution

Pascal solution

Replay a shuffled deck. Add a menu option to replay the last "shuffled" game.
As each card is thrown away and moved up the deck this requires changing the deck handling to include a pointer. Is this Likely?

This does not appear to be needed. You can just replay with Deck as the contents of that are not lost. There is no need for a copy of the Deck to play again. No it doesn't. As the person who produced the Pascal solution has shown - just take a copy of the shuffled deck before you start playing. You can play this copy again and again.

GetCard effectively pops card from deck and fills in a blank on bottom so destroys the deck while playing Python version available as well

VB.Net solution

Python Solution

Java solution

Pascal solution

Create a gambling element where reaching a certain score earns you more money, based on a user bet.
VB.Net solution

Python Solution

Java solution

Pascal solution

The Ace could be considered as a high card or a low card. Change the value of the aces to make them the highest card.
VB.Net solution

Python Solution

Java solution

Pascal solution

Allow user to save the whole game, including the current player pack and the recent scores, quit the program, then restart program and continue to play saved game/scores
VB.Net solution

Python Solution

Java solution

Pascal solution

When the card number is the same you draw and go onto the next card instead of losing.
Basically change IsNextCardHigher to become IsNextCardHigherOrEqual

VB.Net solution

Python Solution

Java solution

Pascal solution

=== Make a two player game. Instead of 'Game over' play passes to the other player. Last man standing when the deck is exhausted wins. Or they get 5 guesses each, top score wins./*Surely the scores will be the same if no-one's got it wrong after 5?*/ /*If so, continue*/ ===

VB.Net solution

Python Solution

Java solution

Pascal solution

When displaying the scores sort the player names into alphabetical order regardless of score
VB.Net solution

Python Solution

Java solution

Pascal solution

Code provided by AQA is linked here
VB.NET

Java

Python

Pascal