help me to solve my problem
given a class that name player..contains under that class is
+getCards(): Cards[]
the description for this contains is -> getCards() – a method that gets card from the player
then my coding for this class is
public class Player
{
public Cards[] getCards ()
{
return cards;
}//getCards
}//class
then when i compile...it has an error on that..
cannot find symbol class Cards
How it happen?what is an error actually?
TQ
Re: help me to solve my problem
If it can't find Cards it means that you don't have a Cards class in the same folder or the same package when you're trying to compile. Have you written the Cards class? If so, can you post it along with a copy of any error messages you're getting.
Can you put you're main method in as well so we can see what you're trying to call.
Can you stick your code in [ highlight=Java] [/highlight] tags please, makes it easier to read, cheers
Re: help me to solve my problem
for Cards.java
Code java:
public class Card
{
private char faceValue ;
private char symbol ;
public Card (char value, char logo)
{
faceValue = value;
symbol = logo;
}//Constructor
public void setFaceValue (char value)
{
faceValue = value;
}//setFacevalue
public char getFaceValue()
{
return faceValue;
}//getFaceValue
public void setSymbol (char logo)
{
symbol = logo ;
}//getSymbol
public char getSymbol()
{
return symbol;
}//getSymbol
}//Card
for Player.java
public class Player
{
private String name;
private Card cards[] = new Card[3];
public Player(String initName)
{
name = initName;
}//Constructor
public void setName (String newName)
{
name = newName;
}//setName
public String getName ()
{
return name;
}//getName
public void setCards (Card[] theCard)
{
cards = theCard;
}//setCards
public Cards[] getCards ()
{
return cards;
}//getCards
/*
public int calculateTotalCardValue()
{
//to implement details here...
getRealValue;
return totalValue;
}//calculateTotalCardValue
*/
public void printPlayerDetails()
{
System.out.println("Player's name is " + getName());
//details here how to display player's info
}//printPlayerDetails
public int getRealValue(char fv)
{
int realValue = 0;
switch (fv)
{
case '1':
realValue = 1;
break;
case '2':
realValue = 2;
break;
case '3':
realValue = 3;
break;
case '4':
realValue = 4;
break;
case '5':
realValue = 5;
break;
case '6':
realValue = 6;
break;
case '7':
realValue = 7;
break;
case '8':
realValue = 8;
break;
case '9':
realValue = 9;
break;
case 'A':
realValue = 10;
break;
case 'K':
realValue = 10;
break;
case 'Q':
realValue = 10;
break;
case 'J':
realValue = 10;
break;
}//Switch
return realValue;
}//getRealValue
}//Player
for DemoBlackJack.java
public class DemoBlackJack
{
public static void main(String[] main)
{
//this is to create cards. cards are put in draws
Card card1 = new Card('1', 'H');
Card card2 = new Card('9', 'S');
Card card3 = new Card('3', 'S');
Card draw1[] = new Card[3];
draw1[0] = card1;
draw1[1] = card2;
draw1[2] = card3;
//this is to create players
Player player1 = new Player("Madhu Taneja");
Player player2 = new Player("Prasun Kumar");
Player player3 = new Player("Sunny Gogia");
player1.printPlayerDetails();
player2.printPlayerDetails();
player3.printPlayerDetails();
}//main
}//DemoBlackJack
Re: help me to solve my problem
You were asked to use the highlight tags. I edited your post to include them, but please be more mindful in the future.
You were also asked to provide the actual error message.
Please don't simply dump your code here. If you want help, boil your problem down to an SSCCE (that's a link), and be as specific as possible.
But for starters- Your class name is Card, but your file name is Cards.