Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: help me to solve my problem

  1. #1
    Junior Member
    Join Date
    Feb 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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


  2. #2
    Member samfin's Avatar
    Join Date
    Dec 2010
    Location
    Manchester UK
    Posts
    37
    Thanks
    1
    Thanked 5 Times in 4 Posts

    Default 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

  3. #3
    Junior Member
    Join Date
    Feb 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: help me to solve my problem

    for Cards.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
    Last edited by KevinWorkman; February 14th, 2011 at 09:40 AM.

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default 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.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. solve it plz
    By tillu in forum Java Theory & Questions
    Replies: 4
    Last Post: December 17th, 2010, 01:45 PM
  2. Plz solve the problem
    By rasheedmgs in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: October 14th, 2010, 11:59 AM
  3. Questions about a Problem I'm trying to solve
    By DarkEssence in forum Java Theory & Questions
    Replies: 4
    Last Post: March 17th, 2010, 06:29 AM
  4. Replies: 3
    Last Post: June 14th, 2009, 09:31 PM
  5. Replies: 4
    Last Post: June 10th, 2009, 01:04 AM