Skip to content

Commit

Permalink
Merge pull request #12 from Spindler-ICS4UC-1-1819/angela
Browse files Browse the repository at this point in the history
Angela
  • Loading branch information
angela-zhou authored Jan 27, 2019
2 parents efef13f + 20ce448 commit 3b64c36
Show file tree
Hide file tree
Showing 48 changed files with 1,773 additions and 683 deletions.
1 change: 1 addition & 0 deletions ICS4UC_RST/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
<classpathentry kind="lib" path="lib/SimpleIO.jar"/>
<classpathentry kind="lib" path="lib/xom-1.2.11.jar"/>
<classpathentry kind="lib" path="res/PacManImagesMusic.jar"/>
<classpathentry kind="lib" path="res/CARDS.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Binary file added ICS4UC_RST/res/CARDS.jar
Binary file not shown.
Binary file added ICS4UC_RST/res/MenuImages/Invaders Graphic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ICS4UC_RST/res/MenuImages/Pong Graphic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ICS4UC_RST/res/MenuImages/Tetris Graphic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
87 changes: 87 additions & 0 deletions ICS4UC_RST/src/egyptianWar/Card.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package egyptianWar;

/**
* @author Angela Zhou
* Date: Jan 2019
* Course: ICS4U
* Teacher: Mrs. Spindler
* Card.java
*/
import javafx.scene.image.Image;

public class Card {

private final char value;
private final char suit;

public Card(String name) {
value = name.charAt(0); // first char gives the name
suit = name.charAt(1); // second char gives the suit
}

public Card() { // default constructor shows back of card
this("XX");
}

public Image getCardImage() {
return new Image(getClass().getResource("/CARDS/" + value + suit + ".jpg").toString());
}

public String toString() {

String returnValue = "";

// get the name of the card for display purposes
if (Character.isDigit(value)) returnValue = Character.toString(value); // card value 2 - 9
else if (value == 'T') returnValue = "10"; // card value 10
else if (value == 'J') returnValue = "Jack";
else if (value == 'Q') returnValue = "Queen";
else if (value == 'K') returnValue = "King";
else if (value == 'A') returnValue = "Ace";

switch (suit) {
case 'S': returnValue += " of Spades"; break;
case 'H': returnValue += " of Hearts"; break;
case 'D': returnValue += " of Diamonds"; break;
case 'C': returnValue += " of Clubs"; break;
}

return returnValue;
}

public int getIntValue() {

int intValue = 0;

// get the value of the card for comparison
if (Character.isDigit(value)) { // card value 2 - 9
intValue = Character.getNumericValue(value);
} else if (value == 'T') { // card value 10
intValue = 10;
} else if (value == 'J') {
intValue = 11;
} else if (value == 'Q') {
intValue = 12;
} else if (value == 'K') {
intValue = 13;
} else if (value == 'A') {
intValue = 14;
}
return intValue;
}

@Override
public boolean equals(Object obj) {
// check if object is a card
if (!(obj instanceof Card)) {
return false;
}

// return the boolean value
// of the comparison b/w card strings
Card temp = (Card)obj;
return temp.toString().equals(this.toString());

}

}
80 changes: 80 additions & 0 deletions ICS4UC_RST/src/egyptianWar/Deck.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package egyptianWar;

/**
* @author Angela Zhou
* Date: Jan 2019
* Course: ICS4U
* Teacher: Mrs. Spindler
* Deck.java
*/
import java.util.ArrayList;
import java.util.Arrays;

public class Deck {

// 1st char is the name (T = 10, J = 11, Q = 12, K = 13, A = 14)
// 2nd char is the suit
final static private String[] CARDS = {
"2C", "3C", "4C", "5C", "6C", "7C", "8C", "9C", "TC", "JC", "QC", "KC", "AC",
"2D", "3D", "4D", "5D", "6D", "7D", "8D", "9D", "TD", "JD", "QD", "KD", "AD",
"2H", "3H", "4H", "5H", "6H", "7H", "8H", "9H", "TH", "JH", "QH", "KH", "AH",
"2S", "3S", "4S", "5S", "6S", "7S", "8S", "9S", "TS", "JS", "QS", "KS", "AS" };

private ArrayList<String> deck;

private ArrayList<String> discardDeck;

public Deck() {
// create ArrayList from the deck
deck = new ArrayList<String>(Arrays.asList(CARDS));
}

/**
* gets the next card from the deck
* returns null if the deck is empty
**/
public Card dealNextCard() {
Card dealtCard;

int cardsLeft = deck.size();

// select a random card from the remaining cards
int newCardIndex = (int) (cardsLeft * Math.random());

// get the name of the card and make a new card from it
dealtCard = new Card(deck.get(newCardIndex));

// remove it from the deck
deck.remove(newCardIndex);

return dealtCard;
}

/**
* discards a card into a separate array
**/
public void discardCard(String card, ArrayList<String> hand) {
// remove card from hand
hand.remove(card);

// add the card to the discard pile
discardDeck.add(card);
}

/**
* combines all the cards to later be dealt
* dealing is random; true "shuffling" is done as the cards are dealt
*/
public void shuffle() {
// add all the cards in the discard pile
deck.addAll(discardDeck);
}

/**
* clears the deck then adds all the cards back in
*/
public void reset() {
deck.clear();
deck.addAll(Arrays.asList(CARDS));
}
}
Loading

0 comments on commit 3b64c36

Please sign in to comment.