Hi, I need to simulate a drag race between 4 cars ( a total of 3 races) to determine a winner based on the ratio between weigh/horsepower and I'm having trouble creating a determineWinner method. Here's my code so far:
Track class:
import java.util.*;
import java.text.*;
/*
Author: Joey Turner
Date: April 23rd, 2010
Purpose: For this lab we will simulate a race using 3 seperate classes. A total of
3 races will take place between cars of different make/model.
*/
public class Track
{
//Attributes
//Constructors
public Track()
{
}//end default constructor
//Methods
public static void main(String[] args)
{
Car myCar = new Car();
Race myRace = new Race();
//settings for 1st car
myCar.setMake("Pontiac");
myCar.setModel("Firebird");
myCar.setWeight(3700);
myCar.setHorsePower(345);
//settings for 2nd car
Car newCar = new Car("Ford", "Mustang",3600, 335);
//settings for 3rd car
Car newCar3 = new Car("Dodge", "Charger", 3670, 335);
//settings for final car
Car finalCar = new Car("Chevy", "Camaro", 3300, 325);
//method call --> determineWinner
Race.determineWinner();
}//end main
}//end Track Class
Car class:
public class Car
{
//Attributes
private String make;
private String model;
private int weight;
private int horsepower;
//Constructors
public Car()
{
}//end default constructor
public Car(String ma, String mo, int w, int horse)
{
make = ma;
model = mo;
weight = w;
horsepower = horse;
}//end 4-arg constructor
public Car(Car ca)
{
make = ca.make;
model = ca.model;
weight = ca.weight;
horsepower = ca.horsepower;
}//end copy constructor
//Methods
//Getters
public String getMake()
{
return make;
}//end getMake
public String getModel()
{
return model;
}//end getModel
public int getWeight()
{
return weight;
}//end getWeight
public int getHorsePower()
{
return horsepower;
}//end getHorsePower
//Setters
public void setMake(String ma)
{
make = ma;
}//end setMake
public void setModel(String mo)
{
model = mo;
}//end setModel
public void setWeight(int w)
{
weight = w;
}//end setWeight
public void setHorsePower(int horse)
{
horsepower = horse;
}//end setHorsePower
}//end car Class
Race class:
public class Race
{
//attributes
raceCarOne = x;
raceCarTwo = y;
//constructors
//methods
public String determineWinner(int x, int y, double w)
{
x
}//end determineWinner
}//end class
I only need 2 attributes and a determineWinner method in the race class. Any suggestions on what i should do?