All pastes #884586 Raw Edit

Something

public text v1 · immutable
#884586 ·published 2008-01-30 13:46 UTC
rendered paste body
class Cons {

	double mpg, fuel_cap, boot_space, fuel_result, distence;
	String vehicle_name;

	Cons(double mpg, double fuel_cap, String vehicle_name) {
		this.distence = distence;
		this.mpg = mpg;
		this.fuel_cap = fuel_cap;
		this.vehicle_name = vehicle_name;

		distence = this.fuel_cap * this.mpg;
	}
}

	class MainTest2 {
		public static void main(String args[]) {

			Cons mpgcalc1 = new Cons(30, 60, "Avensis");
			Cons mpgcalc2 = new Cons(23, 23, "Rav 4");
			Cons mpgcalc3 = new Cons(12, 54, "Beasty Bastard");

			System.out.println("The " + mpgcalc1.vehicle_name + " has a fuel capacity of "
			+ mpgcalc1.fuel_cap + "mpg, on a full tank it can go " + mpgcalc1.distence + "miles");

			System.out.println();

			System.out.println("The " + mpgcalc2.vehicle_name + " has a fuel capacity of "
			+ mpgcalc2.fuel_cap + "mpg, on a full tank it can go " + mpgcalc2.distence + "miles");

			System.out.println();

			System.out.println("The " + mpgcalc3.vehicle_name + " has a fuel capacity of "
			+ mpgcalc3.fuel_cap + "mpg, on a full tank it can go " + mpgcalc3.distence + "miles");

			System.out.println();
		}
	}