News:

Keep our threads alive by bumping them often here and here

Main Menu

Trouble with javascript homework

Started by nate, September 12, 2013, 03:22:49 AM

Previous topic - Next topic

nate




It compiles, and the first dialog box pops up.



I enter "Air" into it (minus the "), and it gives me this error.


This is / isn't a serious post



James

Dats some ugly code you got their Nate :)




nate

Quote from: James on September 12, 2013, 08:43:16 AM
Dats some ugly code you got their Nate :)

sorry, im currently in my 3rd week of ever using java in my life haha

This is / isn't a serious post



Kryptonite

Ummm you don't have anything defined as "value"... You make a case for something being "air" if you haven't defined it.

Quote from: Recoil on April 18, 2012, 06:21:22 PM
Quote from: X on April 18, 2012, 06:20:22 PM
Quote from: Recoil on April 18, 2012, 05:59:45 PM
Da fuq are you doing in a graffiti painted hobo dungeon for?

weed
Just lost all the respect I once had for you.



nate

Quote from: Kryptonite on September 12, 2013, 04:14:13 PM
Ummm you don't have anything defined as "value"... You make a case for something being "air" if you haven't defined it.

I dont really know how to define it :p. Could you just show me what I need to add to it?

This is / isn't a serious post



Kryptonite

Quote from: nate on September 12, 2013, 08:00:51 PM
Quote from: Kryptonite on September 12, 2013, 04:14:13 PM
Ummm you don't have anything defined as "value"... You make a case for something being "air" if you haven't defined it.

I dont really know how to define it :p. Could you just show me what I need to add to it?

Um okay, so you have "double air = 1100;" that's defining a double named "air" and setting the value as 1100. You need to do something similar for "value", so wherever that "value" is supposed to be coming from (I don't know where you want this), do something like you did with the air and stuff except name it value.

Quote from: Recoil on April 18, 2012, 06:21:22 PM
Quote from: X on April 18, 2012, 06:20:22 PM
Quote from: Recoil on April 18, 2012, 05:59:45 PM
Da fuq are you doing in a graffiti painted hobo dungeon for?

weed
Just lost all the respect I once had for you.



nate


This is / isn't a serious post



James





Kryptonite


Quote from: Recoil on April 18, 2012, 06:21:22 PM
Quote from: X on April 18, 2012, 06:20:22 PM
Quote from: Recoil on April 18, 2012, 05:59:45 PM
Da fuq are you doing in a graffiti painted hobo dungeon for?

weed
Just lost all the respect I once had for you.



nate

shhhhhhhh!  ;)

ok so now that I changed that, I get this error. havent changed anything else but interger to integer.

Still a little confused because I have initialized distance and time as a int. I tried also doing

String time;
String distance;

but that don't work :p


This is / isn't a serious post



Kryptonite

Can you update your first post again?

Quote from: Recoil on April 18, 2012, 06:21:22 PM
Quote from: X on April 18, 2012, 06:20:22 PM
Quote from: Recoil on April 18, 2012, 05:59:45 PM
Da fuq are you doing in a graffiti painted hobo dungeon for?

weed
Just lost all the respect I once had for you.



nate


This is / isn't a serious post



Predator

Quote from: James on September 12, 2013, 08:43:16 AM
Dats some ugly code you got their Nate :)

James! you code so he gets A++++ ON TEST!
[COMPLETE] 1. Get 135 in every skill
[COMPLETE] 2. Pass 10 billion total experience (10/10)
[COMPLETE] 3. Pass 20 billion total experience (20/20)
[COMPLETE] 4. Pass 30 billion total experience (30/30)
[COMPLETE] 5. complete zombies all by myself (840 kills)
[PROGRESSING] 6. hit 2b Exp in all skills (15/21)
[PROGRESSING] 7. Collect 1000 exp lamps (676/1000)


Kryptonite

Ok nate, for the error you posted in your first post, you're trying to convert the string "Air" into an integer, but "air" is all letters.

I wrote one possible solution for you. After the end of your void "main", (right before the last bracket), add this int (i hope you know how to do this for gods sake):



private static int GetNumericalType(String input) {
if (input.equalsIgnoreCase("Air"))
return Air;
if (input.equalsIgnoreCase("Water"))
return Water;
if (input.equalsIgnoreCase("Steel"))
return Steel;
}


This transforms your string input into the numbers that you defined. Now, switch this in your class (line 20 in your picture, where you're having troubles):


type = Integer.parseInt(input);


replace that with this:


type = GetNumericalType(input);



Then you should be good to go. I may have made a slight mistake because I wrote this stuff down in a crappy editing program. If you get any errors after this let me know.

Also, if you're still getting "Variable distance might not have been initialized" error, instead of defining distance as


int distance;


write it as


int distance = 69; //yolo


I think I covered everything......

Quote from: Recoil on April 18, 2012, 06:21:22 PM
Quote from: X on April 18, 2012, 06:20:22 PM
Quote from: Recoil on April 18, 2012, 05:59:45 PM
Da fuq are you doing in a graffiti painted hobo dungeon for?

weed
Just lost all the respect I once had for you.



nate

THANKS SO MUCH IT FINALLY WORKED ;D ;D

This is / isn't a serious post