Ok, one more time i need help...

ok, i've got my class program running properly... just need some help with the test program... i need this to print out the name of a card when the user is prompted to type one in... for example the user types in "8H" and it would print out "8 of hearts"... here's my class program and test program... i just need help with the test program...(i know i'm missing some lines on it, but i'm not sure what to put in)... so here it is:
public class Card
public Card(String x, String y)
facevalue = x;
suit = y;
public String getDescription()
String x;
if (facevalue.equalsIgnoreCase("A"))
x = "Ace of";
else if (facevalue.equalsIgnoreCase("K"))
x = "King of";
else if (facevalue.equalsIgnoreCase("Q"))
x = "Queen of";
else if (facevalue.equalsIgnoreCase("J"))
x = "Jack of";
else if (facevalue.equalsIgnoreCase("10"))
x = "10 of";
else if (facevalue.equalsIgnoreCase("9"))
x = "9 of";
else if (facevalue.equalsIgnoreCase("8"))
x = "8 of";
else if (facevalue.equalsIgnoreCase("7"))
x = "7 of";
else if (facevalue.equalsIgnoreCase("6"))
x = "6 of";
else if (facevalue.equalsIgnoreCase("5"))
x = "5 of";
else if (facevalue.equalsIgnoreCase("4"))
x = "4 of";
else if (facevalue.equalsIgnoreCase("3"))
x = "3 of";
else if (facevalue.equalsIgnoreCase("2"))
x = "2 of";
else
x = "Please enter a valid face value";
String y;
if (suit.equalsIgnoreCase("H"))
y = x + "Hearts";
else if (suit.equalsIgnoreCase("D"))
y = x + "Diamonds";
else if (suit.equalsIgnoreCase("C"))
y = x + "Clubs";
else if (suit.equalsIgnoreCase("S"))
y = x + "Spades";
else
y = x + "Please enter a valid suit";
return y;
private String facevalue;
private String suit;
and the test program...
import javax.swing.JOptionPane;
A class to test the Card class.
public class CardTest
public static void main(String[] args)
String input = JOptionPane.showInputDialog(
"Enter a face value in the form of a letter (for face cards) or a number and a letter for the suit of a card:");
Card c1 = Card();
System.out.println(c1.getDescription());
System.exit(0);
}

ok, i've got my class program running properly...
just need some help with the test program... i need
this to print out the name of a card when the user is
prompted to type one in... for example the user types
in "8H" and it would print out "8 of hearts"...
here's my class program and test program... i just
need help with the test program...(i know i'm missing
some lines on it, but i'm not sure what to put in)...
so here it is:
public class Card
public Card(String x, String y)
facevalue = x;
suit = y;
public String getDescription()
String x;
if (facevalue.equalsIgnoreCase("A"))
x = "Ace of";
else if (facevalue.equalsIgnoreCase("K"))
x = "King of";
else if (facevalue.equalsIgnoreCase("Q"))
x = "Queen of";
else if (facevalue.equalsIgnoreCase("J"))
x = "Jack of";
else if (facevalue.equalsIgnoreCase("10"))
x = "10 of";
else if (facevalue.equalsIgnoreCase("9"))
x = "9 of";
else if (facevalue.equalsIgnoreCase("8"))
x = "8 of";
else if (facevalue.equalsIgnoreCase("7"))
x = "7 of";
else if (facevalue.equalsIgnoreCase("6"))
x = "6 of";
else if (facevalue.equalsIgnoreCase("5"))
x = "5 of";
else if (facevalue.equalsIgnoreCase("4"))
x = "4 of";
else if (facevalue.equalsIgnoreCase("3"))
x = "3 of";
else if (facevalue.equalsIgnoreCase("2"))
x = "2 of";
else
x = "Please enter a valid face value";
String y;
if (suit.equalsIgnoreCase("H"))
y = x + "Hearts";
else if (suit.equalsIgnoreCase("D"))
y = x + "Diamonds";
else if (suit.equalsIgnoreCase("C"))
y = x + "Clubs";
else if (suit.equalsIgnoreCase("S"))
y = x + "Spades";
else
y = x + "Please enter a valid suit";
return y;
private String facevalue;
private String suit;
and the test program...
import javax.swing.JOptionPane;
A class to test the Card class.
public class CardTest
public static void main(String[] args)
String input = JOptionPane.showInputDialog(
"Enter a face value in the form of a letter (for
r face cards) or a number and a letter for the suit
of a card:");
Card c1 = Card();
System.out.println(c1.getDescription());
System.exit(0);
}Instead of
Card c1 = Card();try
Card c1 = Card("a", "h");You have to pass something for the class to knwo what you are trying to do. In short you need to initialize the object. Now where you get these values from is your call.

Similar Messages

  • ONe more time - Java program Help -

    HI. I need to know what the code would be to print the Nodes. I simply can't figure it out.I'm not allowed to change anything or add anything. I just have to fill in the methods and make the ListSort work as it is. I can't figure out how to print each node so the out put looks like this:
    *12 2 10 5*
    *12 2 10 5*
    Eventually I have to have to program sort them but I can probably figure it out if I can just print them. ANy help? I have posted before but with no luck. GOod advice its just i can't find out the code to write in the printLIst and insertNodeAtBeginning that will get the nodes to print.
    * implements various methods related to manipulating a singly-linked list
    public class LinkedList
    private Node firstNode = null;
    * prints all the elements of the list in order on one line, separated by s
    paces
    * puts a line of dashes above and below the printed list
    public void printList()
    System.out.println("----------");
    Node currentNode = firstNode;
    System.out.println("----------");
    * inserts a new node into the list at the beginning of the list
    public void insertNodeAtBeginning(Node newNode)
    // quick error checking
    if (newNode == null)
    return;
    // TODO: insert newNode into the beginning of the list
    * inserts the newNode into the list just before the first node that
    * has a larger value than newNode; if the list is empty or if newNode
    * has the smallest value, then newNode will be inserted at the beginning
    * of the list; if newNode has the largest value in the list, then it
    * should be inserted at the end of the list
    public void insertNodeInAscendingOrder(Node newNode)
    // quick error checking
    if (newNode == null)
    return;
    // TODO: insert newNode in the right place in the list
    * remove the first node in the list and return it. if there are no
    * elements in the list, then return null
    public Node removeFirstNode()
    return firstNode;// TODO: remove the first element in the list and return
    it, or
    // return null if the list is empty
    * use recursion to sort the given list in ascending order
    public static void recursiveListSort(LinkedList list)
    // quick error checking
    if (list == null)
    return;
    // TODO: use recursion to sort the list
    Next file:
    public class ListSort {
    * @param args
    public static void main(String[] args) {
    LinkedList list = new LinkedList();
    list.insertNodeAtBeginning(new Node(5));
    list.insertNodeAtBeginning(new Node(10));
    list.insertNodeAtBeginning(new Node(2));
    list.insertNodeAtBeginning(new Node(12));
    list.printList();
    LinkedList.recursiveListSort(list);
    list.printList();
    Next File:
    public class Node
    private int value;
    public Node next = null;
    public Node(int newValue)
    value = newValue;
    public int getValue()
    return value;
    }

    You did receive good advice previously and would do well to study it and search the forum as well. One other thing to help you get advice is to post your code so it is readable without hurting the eyes. So please use code tags so that your code will be well-formatted and readable. To do this, place the tag [code] at the top of your block of code and the tag [/code] at the bottom, like so:
    [code]
    // your code block goes here.
    [/code]

  • I know this sounds repetative, but one more time.. HELP?

    i know there have been dozens of posts about the loss of ones input device to import video after the upgrades of OSX and the the upgrades of FCP... i also rmember a site tha has all these questions answered... where is the sight.. or who do i chat with about getting my DV deck to get recognized by FCP at startup..
    thank you

    ASSUMING that you have FCP 5...
    you HAVE to have this:
    http://www.apple.com/downloads/macosx/video/fcprescue.html
    It's a sweet little app for deleting, saving and restoring your preferences.
    I am guessing that in the upgrade your prefs got tweaked or QT did some finkydinky, there was an old post that referenced FCE, but that may help you...
    The workaround is to download Quicktime manually, after removing the "receipts" which indicate that it is loaded. Specifically, I was told to do the following:
    1. Navigate to Library -> Receipts on your main drive (not from your personal folder).
    2. Remove all files of the form QuickTime*.pkg, where "*" is a version number. E.g. QuickTime600.pkg, QuickTime650.pkg, Quicktime700.pkg and QuickTime701.pkg. This simply tells your system that those packages are not installed.
    3. Go to http://www.apple.com/quicktime/downloads and click on the "download Quicktime" link. DO NOT USE THE AUTOMATIC UPDATE UTILITY. Download QuickTimeInstallerX.dmg. Double click this file (probably on your desktop) and then invoke the installer by double clicking QuickTime701.pkg.
    4. After your computer reboots, you should be able to restart FCE and see your camera.
    let me know...
    N

  • I have to pay one more time!

    Hi!
    I have bought the album called "Disc-Overy" from Tinie Tempah. I did reset my iPhone and set it up as a new iPhone. I also synced with another iTunes library. Now iTunes ask me to pay for the album again! I aldo bought the ringtone called "Levels" of Avicii and I have to pay for that one more time too!
    And when it comes to app. I downloaded iCopter from appstore. I bought the pro version in-app and when i try to do the same again with this newly setup iPhone I also have to pay for this one more time! Please help me!

    I've had the same problem with the albums when switching iPhones.
    Usually when you click purchase in the app- or itunes store it will start the download but will then give you the message: "You've already bought this item, do you want to download it again?". In that case you won't be charged twice, but in my expirience that won't show up untill you're willing to make the purchase.
    Best thing would be to just sync the new iPhone with iTunes if that already contains your purchased apps, books and music.

  • How to download one more time the purchased content?

    I purchased yesterday the OST of Fast Five, and unexpectedly I deleted it from my Mac. How to access it one more time?

    If you are in a country where you can re-download music, and if it is still in the store, then it should show under the Purchased link under Quicklinks on the right-hand side of the iTunes store home page on your computer's iTunes for re-downloading. If you aren't in a country where music can currently be re-downloaded then you will need to try contacting iTunes Support and see if they will grant you a re-download : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption

  • HT5552 Apple decline payment method for apple ID (credit card VISA) after 2 weeks of active using it. And did it one more time

    Few mothes ago I registered my Apple ID.Payment method chose credit card VISA. It allowed me to make purchases and download apps. But after 2 weeks it said that my payment method was declined and I have to register and pay 1$ once again. So I registered one more time with the same credit card, made several downloads and purchases and after 2-3 weeks the situation was the same. My payment method was declined. What is the reason?

    Kateryna Malykhina wrote:
    ... My payment method was declined. What is the reason?
    As this is a User to User forum no one here would know...
    You need to Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact

  • How can i Delete all foto from my iphone and after some time get them one more time on it but not as a new album :)?

    How can i Delete all foto from my iphone and after some time get them one more time on it but not as a new album, i want them in the camera roll ?

    How can I delete EVERY THING off my Mac and have it like new?
    Boot from the software install DVD and do an "erase and install" when prompted.

  • [svn] 1594: Update the warning message when outbound throttle policy of REPLACE is used one more time .

    Revision: 1594
    Author: [email protected]
    Date: 2008-05-07 11:10:27 -0700 (Wed, 07 May 2008)
    Log Message:
    Update the warning message when outbound throttle policy of REPLACE is used one more time. Now the warning says this. . .
    Throttle outbound policy 'REPLACE' found on message destination 'MESSAGE_DESTINATION'. The 'REPLACE' throttle outbound policy has been deprecated. Please remove it from your configuration file.
    Modified Paths:
    blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/MessageDestination.java

    hamish72 wrote:
    You can still download as much as you can only a lot slower during peak times off peak will not be restricted.
    Thanks for this explanation. I had taken it that it was at all times.
    As I said in the first place it will be great if they throttle me to 1Mb at peak times as it will be better half the time than I am getting anyway!!!!!!!!!
    hamish72 wrote:
    Have you chased up why your line is so bad, long way from exchange and so on
    Posting your router stats may get advice from someone
    enter for homehub for other routers will differ
    192.168.1.254 in browser click A to Z top right
    then ADSL enter pas and click MORE DETAIL
    POST RESULTS
    Also post results of test at ( best done from master test socket)
    http://speedtester.bt.com/
    Connection Information
    Line state
    Connected
    Connection time
    6 days, 11:57:55
    Downstream
    5,760 Kbps
    Upstream
    448 Kbps
    ADSL Settings
    VPI/VCI
    0/38
    Type
    PPPoA
    Modulation
    G.992.1 Annex A
    Latency type
    Interleaved
    Noise margin (Down/Up)
    5.7 dB / 21.0 dB
    Line attenuation (Down/Up)
    44.6 dB / 24.0 dB
    Output power (Down/Up)
    8.9 dBm / 1.6 dBm
    Loss of Framing (Local/Remote)
    0 / 0
    Loss of Signal (Local/Remote)
    0 / 0
    Loss of Power (Local/Remote)
    0 / 0
    FEC Errors (Down/Up)
    25279 / 134
    CRC Errors (Down/Up)
    700 / 196
    HEC Errors (Down/Up)
    5427 / 142
    Error Seconds (Local/Remote)
    477 / 102

  • How do you overlap PDF's and finish with one PDF file? Need help ASAP

    how do you overlap PDF's and finish with one PDF file?
    Need help ASAP

    I'm not sure if you can do that with CreatePDF.  Try it; you got one free use when you sign up with Acrobat.com
    If not, you will have to use Adobe Acrobat; there is a full-use 30 days trial.

  • My iphone has broken and I had songs that I had purchased on there that I had not yet backed up on my computer. apparently you can download the tracks one more time free of charge does anybody know how??

    how do you re download tracks that are on a broken iphone???

    apparently you can download the tracks one more time free of charge does anybody know how??"
    Not true.  You get one and only one download.
    In some instances, itunes has allowed another download to a few.  This is not the norm.
    You can try contacting itunes support and asking for an exception, but they are under no obligation to allow.
    Hope all goes well.
    http://www.apple.com/support/itunes

  • HT201272 I bought PDF expert $9.99 for my ipad. When I tried to download to my iphone 5 , they tried to charge me one more time. Any solution?

    I bought PDF expert $9.99 for my ipad. When I tried to download to my iphone 5 , they tried to charge me one more time. Any solution?

    There are two separate PDF Expert versions on App Store: PDF Expert for iPad and PDF Expert for iPhone. PDF Expert for iPad differs from iPhone version and both versions are not free.

  • Big problem with my macbook pro 2009 - 3 motherboard changed at applestore Velisy and one more time it is for nothing.... ! Apple says you're not lucky?????

    3 motherboard i have changed at applestore Velisy and one more time it is for nothing.... !
    Apple says you're not lucky????? What can i do

    A sorry it 's macbook pro unibody from 2011

  • Date/time-operations - need help

    Hi there,
    I have a simple question but i don't have really good ideas to solve the problem with ABAP.
    This is the situation in which I need help:
    I have many date/time-pairs (every in a single variable of type d and t). Now I want to compare one date/time-pair with a given date (also as pair). This will give a time difference between the two dates.
    After that I want that all other date/time-pairs are shifted by this time difference (can be + and -).
    So now my solution yet:
    * FORM for calculation the time difference between 2 dates
    FORM idoc_compare_dates  USING    iv_date_orig
                                      iv_time_orig
                                      iv_date_new
                                      iv_time_new
                             CHANGING cv_diff       TYPE p.
      DATA: lv_timestamp_orig    TYPE timestamp,
            lv_timestamp_new     TYPE timestamp.
    * Creating timestamps for comparison
      CONVERT DATE iv_date_orig TIME iv_time_orig
        INTO TIME STAMP lv_timestamp_orig TIME ZONE sy-zonlo.
      CONVERT DATE iv_date_new TIME iv_time_new
        INTO TIME STAMP lv_timestamp_new TIME ZONE sy-zonlo.
    * Calculation the time difference
      cv_diff = lv_timestamp_new - lv_timestamp_orig.
    ENDFORM.                    " IDOC_COMPARE_DATES
    * FORM for shifting a date by the time period calculated in the first FORM
    FORM idoc_calc_single_date  USING    iv_diff      TYPE p
                                         iv_date_orig
                                         iv_time_orig
                                CHANGING cv_date_new
                                         cv_time_new.
      DATA: lv_timestamp_orig   TYPE timestamp,
            lv_timestamp_new    TYPE timestamp.
    * Creating a timestamp for the original date
      CONVERT DATE iv_date_orig TIME iv_time_orig
        INTO TIME STAMP lv_timestamp_orig TIME ZONE sy-zonlo.
    * Shifting the date
      lv_timestamp_new = lv_timestamp_orig + iv_diff.
    * Creating the new date into the output-variables
      CONVERT TIME STAMP lv_timestamp_new TIME ZONE sy-zonlo
        INTO DATE cv_date_new TIME cv_time_new.
    ENDFORM.                    " IDOC_CALC_SINGLE_DATE
    I am not sure if this coding above is really correct. Can you please check it? Perhaps you have also other ideas to solve this problem?
    Thank you!!
    Kind regards

    Thank you for your answers. Now I've created a small dummy-report, that tests the logic. And I think it seems to be okay.
    You can also check it if you want to with this small report:
    REPORT  zjz_test_timediff.
    PARAMETERS: p_dat1  TYPE sydatum DEFAULT sy-datum,
                p_zei1  TYPE syuzeit DEFAULT sy-uzeit,
                p_dat2  TYPE sydatum DEFAULT sy-datum,
                p_zei2  TYPE syuzeit DEFAULT sy-uzeit.
    SELECTION-SCREEN: SKIP 2.
    PARAMETERS: p_diff type p.
    SELECTION-SCREEN: SKIP 2.
    PARAMETERS: p_dat3  TYPE sydatum,
                p_zei3  TYPE syuzeit.
    DATA: lv_timestamp_orig   TYPE timestamp,
          lv_timestamp_new    TYPE timestamp,
          lv_diff             TYPE p.
    AT SELECTION-SCREEN.
      PERFORM idoc_compare_dates USING p_dat1
                                       p_zei1
                                       p_dat2
                                       p_zei2
                              CHANGING p_diff.
      PERFORM idoc_calc_single_date USING p_diff
                                          p_dat1
                                          p_zei1
                                 CHANGING p_dat3
                                          p_zei3.
    *&      Form  IDOC_COMPARE_DATES
    FORM idoc_compare_dates  USING    iv_date_orig
                                      iv_time_orig
                                      iv_date_new
                                      iv_time_new
                             CHANGING cv_diff       TYPE p.
      DATA: lv_timestamp_orig    TYPE timestamp,
            lv_timestamp_new     TYPE timestamp.
      CONVERT DATE iv_date_orig TIME iv_time_orig
        INTO TIME STAMP lv_timestamp_orig TIME ZONE sy-zonlo.
      CONVERT DATE iv_date_new TIME iv_time_new
        INTO TIME STAMP lv_timestamp_new TIME ZONE sy-zonlo.
      cv_diff = lv_timestamp_new - lv_timestamp_orig.
    ENDFORM.                    " IDOC_COMPARE_DATES
    *&      Form  IDOC_CALC_SINGLE_DATE
    FORM idoc_calc_single_date  USING    iv_diff      TYPE p
                                         iv_date_orig
                                         iv_time_orig
                                CHANGING cv_date_new
                                         cv_time_new.
      DATA: lv_timestamp_orig   TYPE timestamp,
            lv_timestamp_new    TYPE timestamp.
      CONVERT DATE iv_date_orig TIME iv_time_orig
        INTO TIME STAMP lv_timestamp_orig TIME ZONE sy-zonlo.
      lv_timestamp_new = lv_timestamp_orig + iv_diff.
      CONVERT TIME STAMP lv_timestamp_new TIME ZONE sy-zonlo
        INTO DATE cv_date_new TIME cv_time_new.
    ENDFORM.                    " IDOC_CALC_SINGLE_DATE

  • NO one answered me! Need help: Iphone 5 doesn't search for  a signal!

    Everytime I am in library, my cellphone doesn't have a signal. So my phone only gets wifi.
    When I leave the library, my iPhone 5 doesn't search for a signal. It shows me "no service" until I turn on/off the airplane mode.
    Then the phone starts to search for signal.
    Is this my phone problem or the carrier?
    Should I get a replacement?
    Thank you

    i have similar problem with my new iPhone and my old iPhone 4 as I thought if I get the new handset and new sim. this problem would go away, BUT still have a big problem with connection as if i move slightly in one room like as if i move my head to side to grab a pen the signals goes and thats endes my phone call and this is near anoth everytime i call. just been away to spain and the phone was perfect not a singal fault even my 3g was fast and didnt loose signal. so wen i come off the plane in england same again.no signal takes ages to connect to a new call after. i need help fast as this is my work phone and i am telling customers to ring landline. needs sort asa. apple can you help as this isn't the 02 connection as this is new phone and sim, and even if i get another sim still the same. regards matt 

  • Some more 'not writable and cannot be opened" . . . one more time . . .

    OK, I give up and need help.  I have all LR 2.6 files and folders on an EHD (F:).  I downloaded the LR 2.6 update to C: drive on my laptop (Vista) and upon the initial opening of the updated LR was able to open one of my two catalogs (.lrcats).  However, upon closing that I am no longer able to access either THAT catalog again OR  the other .lrcat because they are " not writable and cannot be opened".
    I've read a multitude of threads on this problem and either the answers don't apply or I just don't understand what I need to do in order to open the F: lrcats on the laptop C: LR.   Double clicking on the catalogs just brings up the above message. Properties indicates the catalogs are readable and have permissions . . .   (It works perfectly on LR 2.6 on C: on my win xp sp3 desktop.)
    I've tried everything I can think of (which AIN'T much - have always admitted to being computer-challenged).  Any idea what I'm missing?

    Well, is the catalogue (and the folder it is in) writable? Have you actually checked the permissions? Lightroom won't be spitting out the error just to tick you off, and - computer wizard or not - this sounds very much like something you'll have to fix at the OS level: it's probably nothing to do with Lightroom or those funny lads at Adobe.
    Some light reading for you, courtesy of the site search: https://forums.adobe.com/search.jspa?q=%22+not+writable+and+cannot+be+opened%22&place=%2Fp laces%2F1383621&depth=ALL
    It would help to know your OS.

Maybe you are looking for

  • Enter key instead of TAB key

    Hi folks, I'd like to make the ENTER key behave the same way as the TAB key in the system I'm developing. I thought I would be able to do it by setting the ENTER as a function key (using Window.SetAsFunctionKey), and then after detecting an ENTER key

  • Error 37- a bad filename or volume name was encountered

    I'm getting this message when trying to few a video clip taken by my camera. The video clip is in My Pictures. The pictures are showing up correctly, and the video clip shows up as "Quick Time Movie". When I click on it to view I get this message. I

  • I can call out but I can't recieve them

    I got my iPod fr Christmas well my FaceTime was working and I could receive calls but lately I can't. I looked it up and it said that there could be something wrong with my Internet so I went to my boyfriends house and still couldn't do it. He also c

  • After updating to version 2.4 I am unable to enter the develop module

    I have a pc with windows xp and 2gb ram, lightroom was working fine all this time and when I updated to version 2.4 I am unable to enter the develop module and it just hangs. I tired repairing the install via the adobe installer with no success. Any

  • Common Distribution Channel and Divisions

    <b>How to configure Common Distribution Channel and Divisions and what is the advantage of the same?</b>