d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > What Am I Doing Wrong?
Prev12345Next
Add Reply New Topic New Poll
Member
Posts: 34,575
Joined: Mar 25 2009
Gold: 12,633.00
Apr 23 2016 10:29pm
Quote (carteblanche @ Apr 24 2016 12:25am)
sounds like a good start.



did you try calling it from System.out.println when you used it before? if not, then it's a totally different scenario.
Code
System.out.println(range());




another good idea. don't return a boolean.


hmm ok ty

also... this was the code i used void with method:

Code
void range() {
System.out.println("Range is: " + fuelcap * mpg);
}



calling it:

Code
System.out.println("Sportscar can carry " + sportscar.passengers + ". ");
sportscar.range();





EDIT: So the only problem is that i wasn't using string? I'm still not sure how to use string, cuz i haven't covered that in my book yet
EDIT: btw thank you for helpnig :)

This post was edited by ferf on Apr 23 2016 10:31pm
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Apr 23 2016 10:31pm
Quote (ferf @ Apr 24 2016 12:29am)
hmm ok ty

also... this was the code i used void with method:

Code
void range() {
System.out.println("Range is: " + fuelcap * mpg);
}



calling it:

Code
System.out.println("Sportscar can carry " + sportscar.passengers + ". ");
sportscar.range();


this is completely different from how you're using check. here, you call range outside of the print statement, so its return value is irrelevant. whereas you call check() inside of the print statement, so its return statement is very relevant.
Member
Posts: 34,575
Joined: Mar 25 2009
Gold: 12,633.00
Apr 23 2016 10:33pm
Quote (carteblanche @ Apr 24 2016 12:31am)
this is completely different from how you're using check. here, you call range outside of the print statement, so its return value is irrelevant. whereas you call check() inside of the print statement, so its return statement is very relevant.


hmmm ok gotchya
Member
Posts: 34,575
Joined: Mar 25 2009
Gold: 12,633.00
Apr 23 2016 10:35pm
how would i use string to replace

void check() {


I typed: string check() {

didn't work











EDIT: i also changed:

Code
void check() {
if(omnivore == true) System.out.print("omnivore");
if(carnivore == true) System.out.print("carnivore");
if(herbavore == true) System.out.print("herbavore");
}


from println to print.... i think with this way it'd be better formated?

This post was edited by ferf on Apr 23 2016 10:36pm
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Apr 23 2016 10:42pm
Quote (ferf @ Apr 24 2016 12:35am)
how would i use string to replace

void check() {


I typed: string check() {

didn't work











EDIT: i also changed:

Code
void check() {
if(omnivore == true) System.out.print("omnivore");
if(carnivore == true) System.out.print("carnivore");
if(herbavore == true) System.out.print("herbavore");
}


from println to print.... i think with this way it'd be better formated?


look around 2:16. i think you'll see a familiar error message and the solution


This post was edited by carteblanche on Apr 23 2016 10:42pm
Member
Posts: 34,575
Joined: Mar 25 2009
Gold: 12,633.00
Apr 23 2016 10:47pm
Quote (carteblanche @ Apr 24 2016 12:42am)
look around 2:16. i think you'll see a familiar error message and the solution
http://www.youtube.com/watch?v=_TvRFUnRxoo


bleh, i tried kind of what the video said, but like i said i haven't covered strings yet, bleh long story i just got another error after doing it

I'ma just say screw this code till i cover string etc.... thanks for your help , sorry
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Apr 23 2016 11:30pm
you doing this alone or following a college course/class? just curious
Member
Posts: 34,575
Joined: Mar 25 2009
Gold: 12,633.00
Apr 23 2016 11:49pm
Quote (Eep @ Apr 24 2016 01:30am)
you doing this alone or following a college course/class? just curious


ummm stuff i learned from a book, but it's written by me. alone...
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Apr 23 2016 11:51pm
Quote (Eep @ Apr 24 2016 01:30am)
you doing this alone or following a college course/class? just curious


In guessing it's self learning.

Considering he's been asking random java questions for at least 6 months; he asked for a Java buddy a month or two ago; and it's the end of April (almost final exam time) and he's doing this of all things
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Apr 24 2016 12:30am
Quote (carteblanche @ Apr 24 2016 12:51am)
In guessing it's self learning.

Considering he's been asking random java questions for at least 6 months; he asked for a Java buddy a month or two ago; and it's the end of April (almost final exam time) and he's doing this of all things


true. I lose track of time pretty easily these days......april eh.

All I can think about is a big release we are doing in August....
Go Back To Programming & Development Topic List
Prev12345Next
Add Reply New Topic New Poll