473,785 Members | 2,299 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"cannot be applied to ()" error?

15 New Member
I'm trying to make an object to represent a single playing card. Like if it's an EIGHT of HEARTS, the object should be "8 H". Here is what I came up with, but I keep getting the error message,
"DisplayDeck.ja va:12: switchRank(int) in DisplayCards cannot be applied to ()
sRank = dispCards.switc hRank();" .
The error points out the dot in "dispCards.switchRank()".

Can someone help me out?

Thank you.


public class DisplayCards {
String sRank = "";
String sSuit = "";
int rank = 1;
int suit = 1;

public String switchSuit(int suit) {
switch(suit) {
case 1:
sSuit = "D";
//break;
case 2:
sSuit = "H";
//break;
case 3:
sSuit = "S";
//break;
case 4:
sSuit = "C";
//break;
default:
break;
}
return sSuit;
}

public String switchRank(int rank) {
switch(rank) {
case 1:
sRank = "A";
case 2:
sRank = "2";
break;
case 3:
sRank = "3";
break;
case 4:
sRank = "4";
break;
case 5:
sRank = "5";
break;
case 6:
sRank = "6";
break;
case 7:
sRank = "7";
break;
case 8:
sRank = "8";
break;
case 9:
sRank = "9";
break;
case 10:
sRank = "10";
break;
case 11:
sRank = "J";
break;
case 12:
sRank = "Q";
break;
case 13:
sRank = "K";
break;
default:
break;
}
return sRank;
}

}



this is the main class.

public class DisplayDeck {
public static void main(String[] args) {

int rank = 0;
String sRank="";
DisplayCards dispCards = new DisplayCards ();


rank = 2;
sRank = dispCards.switc hRank();
}
}
Jan 1 '08 #1
2 1494
JosAH
11,448 Recognized Expert MVP
Your switchRank method needs a single parameter of type int; you defined it that
way. You are trying to call it without using a parameter (see your main method).
That's what your compiler is complaining about. You should pass a single int
value to that method.

kind regards,

Jos
Jan 1 '08 #2
cerise
15 New Member
Your switchRank method needs a single parameter of type int; you defined it that
way. You are trying to call it without using a parameter (see your main method).
That's what your compiler is complaining about. You should pass a single int
value to that method.

kind regards,

Jos
Thank you SO MUCH. It's compiling fine now.
Jan 1 '08 #3

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

Similar topics

5
5048
by: BJ | last post by:
The application I have been developing is great except one flaw. When Windows NT shuts down, it doesn't send the Event to my application (if it did, it would close all of the open forms and kill an activity flag I create on launch) and an error comes up that says "Cannot Quit". I have no idea where this error is coming from as I did put it in there. I am unsure if this is because of the hidden form which has a bunch of timers on it (I...
1
3639
by: Chris | last post by:
I built small C# Web and Web Service applications in a training class last week. The applications worked in the class, but when I tried to run them again over the weekend, they both bombed. Instead of getting my Web page, or the Web Service page, I get a page full of error text (below). I am hoping the anwser will be obvious to someone. I've tried a few things to address the problem, including
1
3128
by: Thomas Barnet-Lamb | last post by:
I was wondering if anyone could give me some help with the following. Consider the code snippet: struct qqq{typedef qqq* pointer;}; template<class al> struct foo : public al { template <class T> struct rebind { typedef foo<qqq> other;
1
1858
by: Dgates | last post by:
This request might belong in a "SQL"-related newsgroup, but it's such a pain using Agent to subscribe to a new group (and download its 50,000 messages!) just to ask one question. So, since it deals with an ASP.NET app, I thought I'd ask here. ============================================== I am using Web Data Adminstrator, which I downloaded recently from the Microsoft site. I get an error when I create tables or columns:
3
16519
by: David T. Ashley | last post by:
Hi, Red Hat Enterprise Linux 4.X. I'm writing command-line PHP scripts for the first time. I get the messages below. What do they mean? Are these operating system library modules, or something in PHP that I don't have? Do I need to install more Linux packages? Or adjust PHP in some way?
15
28824
by: Bjorn Jensen | last post by:
Hi! An beginner question: Pleas help me with this (-: Error (the arrow points on the s in sqrt) ===== tal.java:6: cannot find symbol symbol : method sqrt(int) location: class tal System.out.println(i + ": " + sqrt(4));
0
2455
by: jonny | last post by:
The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. -------------------------------------------------------------------------------- A name was started with an invalid character. Error processing resource 'http://localhost/Downtime/JohnsSite/Default.aspx'....
6
12004
by: Dave | last post by:
I really don't like the users getting an unhandled expception page, and I'm still to new with ASP.Net and C#. So please accept my appology for the 2 part question. SqlException (0x80131904) 1.) Is an "Cannot insert duplicate key row" exception from a FormView returned as part of the ItemInserting or ItemInserted event? 2.) What is the recommended way to catch and deal with an "Cannot
4
4761
by: GHUM | last post by:
The compile works, BUT linking fails: 2.5\Release\psycopg\_psycopg.def -Lc:\python25\libs -Lc: \python25\PCBuild -Lc:/p ostgres/83RC2/lib -lpython25 -lpq -lws2_32 -ladvapi32 -o build \lib.win32-2.5\psy copg2\_psycopg.pyd c:\mingw\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot find -lpq collect2: ld returned 1 exit status
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10147
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9947
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.