This project requires the use of the following Java program files:
|
Download them to your PC before doing this project.
Abide to the Emory Honor code when doing assignments.
|
that are subclasses of the GameCard class.
The super class GameCard object represents a "playing card in some card game" and contains 2 variables: rank and suit which are integers:
/* ----------------------------------------------------------
The suit of the card is represented as follows:
0 = Diamond 1 = Clubs 2 = Hearts 3 = Spades
---------------------------------------------------------- */
private int suit;
/* ----------------------------------------------------------
The rank of the card is represented as follows:
0 = Ace 4 = 5 8 = 9 12 = King
1 = 2 5 = 6 9 = 10
2 = 3 6 = 7 10 = Jack
3 = 4 7 = 8 11 = Queen
---------------------------------------------------------- */
private int rank;
|
You will only use the rank variable in this assignment.
The GameCard class provides a getRank() method to retrieve the rank of a GameCard object:
// getSuit(): return the rank of the card
public int getRank()
{
return rank;
}
|
The rank of a GameCard is always represented as follows:
0 = Ace 4 = 5 8 = 9 12 = King
1 = 2 5 = 6 9 = 10
2 = 3 6 = 7 10 = Jack
3 = 4 7 = 8 11 = Queen
|
The ranking of a GameCard
The ranking of a GameCard is the position of the Gamecard in a specific scenario
You will need to handle 3 different scenarios:
|
The GameCard class contains a non-functional getRanking() method:
/* -----------------------------------------------------------------
The card ranking impose a ranking on each card
Different type of card games will use different card ranking
------------------------------------------------------------------ */
public int getCardRanking()
{
return 0;
}
|
You must override this method and return the desired card ranking for each type of scenario.
public class Sort
{
// Sort an array of GameCard objects
public static void selectionSort(GameCard[] list)
{
.. selection sort algorithm ...
}
}
|
You are given the TestA.java program that creates 5 PlayingCard objects and uses the selectionSort() method in the Sort class to sort them:
public class TestA
{
public static void main(String[] args)
{
int err = 0;
GameCard[] myList = new GameCard[5]; // Array of GameCards objs
// Make 5 PlayingCards
myList[0] = new PlayingCard("Spades", "2");
myList[1] = new PlayingCard("Clubs", "King");
myList[2] = new PlayingCard("Diamonds", "Ace");
myList[3] = new PlayingCard("Hearts", "Jack");
myList[4] = new PlayingCard("Clubs", "4");
Sort.selectionSort(myList);
...
}
|
Part A of the assignment requires you to implement the PlayingCard class as a subclass of GameCard so that TestA program can sort them.
|
Use the Java program TestA.java to test your PlayingCard class.
You are given the TestB.java program that creates 5 PokerCard objects and uses the selectionSort() method in the Sort class to sort them:
public class TestB
{
public static void main(String[] args)
{
int err = 0;
GameCard[] myList = new GameCard[5]; // Array of GameCards objs
// Make 5 PokerCards
myList[0] = new PokerCard("Spades", "2");
myList[1] = new PokerCard("Clubs", "King");
myList[2] = new PokerCard("Diamonds", "Ace");
myList[3] = new PokerCard("Hearts", "Jack");
myList[4] = new PokerCard("Clubs", "4");
Sort.selectionSort(myList);
...
}
|
Part B of the assignment requires you to implement the PokerCard class as a subclass of GameCard so that TestB program can sort them.
|
Use the Java program TestB.java to test your PokerCard class.
You are given the TestC.java program that creates 5 Big2Card objects and uses the selectionSort() method in the Sort class to sort them:
public class TestC
{
public static void main(String[] args)
{
int err = 0;
GameCard[] myList = new GameCard[5]; // Array of GameCards objs
// Make 5 Big2Cards
myList[0] = new Big2Card("Spades", "2");
myList[1] = new Big2Card("Clubs", "King");
myList[2] = new Big2Card("Diamonds", "Ace");
myList[3] = new Big2Card("Hearts", "Jack");
myList[4] = new Big2Card("Clubs", "4");
Sort.selectionSort(myList);
...
}
|
Part C of the assignment requires you to implement the Big2Card class as a subclass of GameCard so that TestC program can sort them.
|
Use the Java program TestC.java to test your Big2Card class.
You must be on Emory campus (e.g.: Emory unplugged) in order to turn in an assignment
Use your web browser and visit the cs171 turnin website: click here
|
Follow the instructions given in homework 1 to turn in.
You must be on Emory campus (e.g.: Emory unplugged) in order to make extension requests
Use your web browser and visit the cs171 turnin website: click here
Use assignment code hw4 to request extension for this homework.
Follow the instructions given in homework 1 to request extension.