r/programminghomework • u/AlohaSexJuice • Mar 26 '16
Need help with HiLo Card game in Java!
I'm fairly new to programming and I have no idea why the Card object is coming up as an error. Help!
Heres my code
class HiLoGame {
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
Card myCard = new Card();
String guess = null, response = null;
double bankroll = 0.0, bet = 0.0;
System.out.print("How much money is in your bankroll? ");
bankroll = keyboard.nextDouble();
do
{
System.out.print("\nHow much are you betting? ");
bet = keyboard.nextDouble();
keyboard.nextLine();
myCard.drawCard();
System.out.println("I drew a " + myCard);
} while (bankroll > 0.0);
System.out.println("\nYou have $" + bankroll + " left.");
}}
And heres the error message:
PlayingCard.java:120: error: cannot find symbol Card myCard = new Card(); ^ symbol: class Card location: class HiLoGame PlayingCard.java:120: error: cannot find symbol Card myCard = new Card(); ^ symbol: class Card location: class HiLoGame 2 errors
3
Upvotes
2
u/thediabloman Mar 27 '16
Hi friend,
Could it be because your card class is named PlayingCard and you are trying to instantiate a class named Card?
1
u/AlohaSexJuice Mar 26 '16
Sorry, forgot to include the playingcard class:
import java.util.Scanner; import java.util.Random;
public class PlayingCard { private int face; private int suit;
public PlayingCard () { drawCard(); }
public void drawCard () { face = (int) (Math.random() * 13) + 2; suit = (int) (Math.random() * 4); }
public boolean isEquals (PlayingCard c) { return (face == c.face && suit == c.suit); }
public int getFace() {
return face; }
public int getSuit() {
return suit; }
public String toString() { String cardName = null;
} }