473,410 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

String to int??? I've seen this done like this before. Mine just doesn't want to agre

Expand|Select|Wrap|Line Numbers
  1. import java.util.Scanner;
  2. public class Card
  3. {
  4.  
  5.    private int num;   // 2...10, 11=J, 12=Q, 13=K, 14=A
  6.    private int suit;  // 0=club, 1=diamond, 2=heart, 3=spade
  7.  
  8.    //**********************************************************
  9.  
  10.    public Card(int num, int suit)
  11.    {
  12.       this.num = num;
  13.       this.suit = suit;
  14.    } // end constructor
  15.  
  16.    //**********************************************************
  17.  
  18.    public int getNum()
  19.    {
  20.  
  21.         if (num == 2)
  22.         return "2";
  23.        if (num == 3)
  24.         return "3";
  25.        if (num == 4)
  26.         return "4";
  27.        if (num == 5)
  28.         return "5";
  29.        if (num == 6)
  30.         return "6";
  31.        if (num == 7)
  32.         return "7";
  33.        if (num == 8)
  34.         return "8";
  35.        if (num == 9)
  36.         return "9";
  37.        if (num == 10)
  38.         return "10";
  39.        if (num == 11)
  40.         return "Jack";
  41.        if (num == 12)
  42.         return "Queen";
  43.        if (num == 13)
  44.         return "King";
  45.        if (num == 14)
  46.         return "Ace";
  47.    } // end constructor
  48.  
  49.    //**********************************************************
  50.  
  51.    public int getSuit()
  52.    {
  53.     if (suit == 0)
  54.      return "Clubs";
  55.  
  56.     if (suit == 1)
  57.      return "Diamonds";
  58.  
  59.     if (suit == 2)
  60.      return "Hearts";
  61.  
  62.     if (suit == 3)
  63.      return "Spades";
  64.  
  65.    } // end constructor
  66.  
  67.    //**********************************************************
  68.  
  69.    public void display()
  70.    {
  71.       System.out.print(num, "of", suit);
  72.  
  73.    } // end display
  74. } // end Card class
Card.java:27: error: incompatible types: String cannot be converted to int

I don't want to convert a string to an int. I just want to return a string from the specified int. Any help??
Dec 8 '14 #1
1 1186
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code or formatted data.

The problem is that on line 18, you tell the program that you are returning an into.
Dec 9 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
6
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: ...
3
by: lindsay.manning | last post by:
I understand it is a beta and I am just wondering if this is a bug that will be fixed or if anyone might be able to shed some light on what is happenning? I am using VWD on WinXP Pro and SQL...
4
by: MadCrazyNewbie | last post by:
Hey Group, Hows ya all doing? Sorry i know i`ve asked this before but my HDD failed at the weekend and i`ve lot some of my notes:( I have a ComboBox bound to a database. How do I get it...
8
by: Wayne Gillespie | last post by:
I have an application in service (A97) which is a booking system for a modelling agency. When they add / edit a job I display a subform which lists all models, filtered according to criteria set by...
1
by: MPutt | last post by:
I apologize if I am posting this to the wrong area, but I am stuck. Here is my problem. I am running a .NET 2003 Windows service against Oracle 9i. This service is attempting to run a stored...
3
by: Arun Nair | last post by:
''' Can anyone help me with this program it just takes probability of the first team and runs the program doesnt takes the probability of the second team even though specified''' from random...
4
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i've never seen "using" in the following context before, could someone please explain: static void Main() { string queryString = "SELECT CategoryID, CategoryName FROM...
4
by: setiarakesh | last post by:
I have designed a socket Server and developed asynchronous server . It is working fine with 60 Clients which are connecting to ths Server running at Machine (2 GB RAM and OS is Windows 2003...
6
by: babaidebnath | last post by:
Hello all, I am presently having a problem with printing in C#. The problem is my customer provided me a pre printed paper and I need to print value into some specific positions. But problem is C#...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.