Introduction to Programming (JAVA) Solved

$ 24.99
Category:

Description

Question1: Card Guessing Game
In this question, your task is implementing a card guessing game. There are four card type such as “spade”, “heart”, “diamond” and “club”. Each card can have value 1 to 13. The program chooses a card from deck and asks player card type and value. The program informs player about whether his/her guess is correct or wrong. Program runs until player guess is correct.
Card.java
Constructor [5 Points]
public Card(String cardType, int value):

Constructor initializes the new card instance with given card type and value.

Getters [5 x 2 Points]

public String getCardType():

This method returns the card type.

public int getCardValue():

This method returns the card value.

Equality [10 Points]
public boolean equals(Card other):

In this method, you must check the given card equals current card. If both cards are same type and have same value then they are equal. Otherwise, they are not equal.

Question1.java

Program Structure [25 Points]

public void run(){
ArrayList<Card> cardDeck = generateCardDeck();
Card randomCard = cardDeck.get(rgen.nextInt(52));
Card testCard = cardDeck.get(0);//spade 1

println(“Welcome to the card guessing game! “);

//Your code starts here

//Your code ends here

}

Sample output:

Reviews

There are no reviews yet.

Be the first to review “Introduction to Programming (JAVA) Solved”

Your email address will not be published. Required fields are marked *