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 3 of 3

Thread: my programs- Card and CardTest

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Location
    norcross, ga
    Posts
    24
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Exclamation my programs- Card and CardTest

    hi,

    i'm writing a program called Card and its tester, CardTest. i find it very difficult to handle the input from the user in between these two programs.

    CardTest reads in a card value in such a format: 4S (meaning 4 of spades)

    in my Card class, there is a method called getDescription() that returns a String variable with the value of the card.

    so, in my Card class, there are a number of important things, notably:

    the constructor
    public Card()
    {
      String value, suit;
    }
    and the method
    public String getDescription()
    {
    sdkfa;dsjf i can figure out most of the logic
    }
    in CardTest,
    i can say
    String cardName = in.nextString(); //the variable to hold the user inputed card
    Card card = new Card(System.in);
    card.getDescription(cardName) <-------
    ^^^^^^^^^^^^^^^^^^^
    is this the right way to send the user input into the method??? i'm very confused. if not, how can i send user input into the method getDescription?

    by the way, this does have to be done in separate classes..
    Last edited by helloworld922; January 27th, 2010 at 01:46 AM. Reason: Please use [code] tags!


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: my programs- Card and CardTest- i don't know how to handle the user input in-betw

    You need to declare the method signature to take in parameters before passing them.

    public Card(String cardName)
    {
         // constructor code
    }

  3. The Following User Says Thank You to helloworld922 For This Useful Post:

    etidd (January 27th, 2010)

  4. #3
    Junior Member
    Join Date
    Jan 2010
    Location
    norcross, ga
    Posts
    24
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default Re: my programs- Card and CardTest

    okay, i got it. the last thing is a logic error with the program. i don't know what to put inside the constructor... does it just allow me to make an object in the CardTest class?

Similar Threads

  1. Replies: 1
    Last Post: November 2nd, 2012, 02:21 PM
  2. Reading user input from the console with the Scanner class
    By JavaPF in forum Java SE API Tutorials
    Replies: 3
    Last Post: September 7th, 2011, 03:09 AM
  3. Method for Cedit card check, help!!!!1
    By raidcomputer in forum What's Wrong With My Code?
    Replies: 6
    Last Post: October 31st, 2009, 09:16 AM
  4. How to handle quadratic roots that don't exist?
    By kairojya in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 28th, 2009, 12:21 PM
  5. User Input Loop
    By cfmonster in forum Loops & Control Statements
    Replies: 7
    Last Post: August 24th, 2009, 01:52 PM