- Joined
- Nov 13, 2004
- Location
- Brookline, MA
The current project we have is essentially developing an AI; it uses a random number generator to give stats about a car (does it start, how is it turning/accelerating, etc). A large portion is severely flawed as given to us, but the instructor says it is correct (basically a fairly important function that is based on data that we do not have, were not given and cannot get from any other methods).
I've written the bit of code for starting the engine, but the compiler is throwing a fit with the boolean return statements, and no matter what I do to fix it I get the same or worse errors.
The errors it's giving me are at the boolean return statements: "return outside method". That seems to be the only thing preventing this from working, except I can't figure out what it wants me to do (maybe I need to go to bed; been working on this all day).
Any ideas?
*grumbles: my school is too cheap to hire tutors for this stuff*
I've written the bit of code for starting the engine, but the compiler is throwing a fit with the boolean return statements, and no matter what I do to fix it I get the same or worse errors.
Code:
package carapp;
import java.util.Random;
import java.lang.Object;
public class CarApp
{
double num;
boolean StartEngine;
{
num = (double)(Math.random());
if (num > 0.75)
return True;
System.out.println("Engine successfully started!");
if (num < 0.25)
return False;
System.out.println("Engine start failed.");
}
Any ideas?
*grumbles: my school is too cheap to hire tutors for this stuff*