If anyone can help me figure out the what the missing return statements are, I think it might be the fact that I need to add a return false in the getValue()? 6 2410
@ getValue().....
JVM says: "what if value is not equal to ace, jack, queen or king?" what should i return if none of them are satisfied?".... .. null? your name? the System's specification? an object? a cloned class?
You must be aware of having "no else statement".... when returning a data....
And also @ getSuit().....
regards,
sukatoa....
@ getValue().....
JVM says: "what if value is not equal to ace, jack, queen or king?" what should i return if none of them are satisfied?".... .. null? your name? the System's specification? an object? a cloned class?
You must be aware of having "no else statement".... when returning a data....
And also @ getSuit().....
regards,
sukatoa....
Would that also apply to getSuit, that is what I was thinking.
Would that also apply to getSuit, that is what I was thinking.
...........Yep. ...........
Update us,
sukatoa
...........Yep. ...........
Update us,
sukatoa
Ok got that fixed, everything compiled correctly, but now I am getting output:
Card 1 value is - Invalid Value
Card 2 suit is - Invalid Value
Card 1 is the 2 of Diamonds.
Card 2 is the ?? of Diamonds. The CardTester file I am using is here: -
/**
-
* Short program that uses the Card class.
-
* NOTE: Not a comprehensive test!
-
* @version (10/1/04)
-
*/
-
public class CardTester
-
{
-
public static void main (String [] args) {
-
Card c1 = new Card(); //creates a random card
-
Card c2 = new Card(1,12); //creates the Queen of Diamonds
-
-
System.out.println("Card 1 value is - " + c1.getValue()); //note: this will print the numeric value
-
System.out.println("Card 2 suit is - " + c2.getSuit()); //note: this will print the numeric value
-
-
System.out.println ("Card 1 is the " + c1.toString() + "." );
-
System.out.println ("Card 2 is the " + c2.toString() + "." );
-
}
-
-
}
-
Here is the fixed file:
Could you post your expected correct output?
I like to test your code.....
sukatoa
Could you post your expected correct output?
I like to test your code.....
sukatoa
Try to put an else statement instead of directly return a value after the last ( else if ).. try to observe what happens,
Update us,
sukatoa
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: sureshjayaram |
last post by:
In some functions where i need to return multiple error codes at
multiple places, I use multiple return statements. Say for ex.
if (Found == 1)
{
if (val == -1)
return error1;
}
else
{
if (val2 == -1)
|
by: Skybuck Flying |
last post by:
Sometime ago on the comp.lang.c, I saw a teacher's post asking why C
compilers produce so many error messages as soon as a closing bracket is
missing. The response was simply because the compiler can't tell where a
bracket is missing.... a few weeks have past, I requested a feature for the
delphi ide/editor "automatic identation of code in begin/end statements etc"
and today when I woke up I suddenly released a very simple solution for this...
|
by: Nerox |
last post by:
Hi, If i write:
#include <stdio.h>
int foo(int);
int main(void){
int a = 3;
foo(a);
}
|
by: tshad |
last post by:
I am trying to set up a reusable library (business component) that I can use
in a bunch of my pages.
I built the file and it almost compiles, but I am not sure what I am
missing.
The vbc command and results are:
************************************************************************
C:\Inetpub\wwwroot\Development>vbc /t:library emailClass.vb
|
by: John Sidney-Woollett |
last post by:
<rant>
Please can someone explain why Postgres cannot recognize that objects
(referenced by pl/pgsql functions) whose OID no longer exists could in
fact be found (as new objects) if the function was reparsed and compiled
again.
Here's an example:
Create table t1 (f1 integer);
| |
by: fritz-bayer |
last post by:
Hi,
in a shell script of mine I'm executing a mysql SELECT in batch mode. I
want to use the return value for other sql statements.
The problem I'm facing is that the tabs, which seperate the columns
from each other, are missing in the output.
What am I doing wrong?
|
by: DavidB |
last post by:
Hi all
I have a script that works perfectly in IE but not in FF. I am sure
that the problem is easy to resolve, but I seem to be too dumb to
figure it out.
<html>
<head>
<script language="javascript">
|
by: Fred Chateau |
last post by:
Still working on my XML DataSet...
Having moved on past difficult and complex problems, resolved with the
assistance of everyone here, I find myself facing yet another problem. My
XML document breaks the schema. There are missing tags everywhere, on
purpose I'm told, because we don't need them.
I'm getting a "System.Data: There is no row at position <row number>" error.
Hopefully I can workaround this issue. I need to find a way to...
|
by: macracan |
last post by:
I'm wondering what was the rationale that caused gcc to only have a
warning (disabled by default!!) to signal the following:
int a()
{}; // intentionally no statements
int main()
{
printf("%d", a());
return 0;
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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...
|
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...
|
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...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |