Results 1 to 6 of 6
- 06-10-2011, 08:37 PM #1
Member
- Join Date
- May 2011
- Posts
- 39
- Rep Power
- 0
Unaware as to how the code did not compile??? confused?
This is my only class that didn't compile w/o bugs. I can't figure out why.
Java Code:public class Bus extends MotorVehicles { private int nbrPassSeats; private int range; private int stowCapacity; public Bus(int wheels, String trans, String brakes, String steering, int passSeats, int distance, int stowage) { super(wheels, trans, brakes, steering); setNbrPassSeats(passSeats); setRange(distance); setStowCapacity(stowage); } public void setNbrPassSeats(int passSeats) { nbrPassSeats = passSeats; } public int NbrPassSeats() { return nbrPassSeats; } public void setRange(int distance) { range = distance; } public int getRange() { return range; } public void setStowCapacity(int stowage) { stowCapacity = stowage; } public int getStowCapacity() { return stowCapacity; } @Override public String toString() { return String.format( "\nThis vehicle has %d wheels, %s transmission, %s brakes, %s steering, %d seats, a range of %d miles, and a cargo capacity of %d pounds\n", getNbrWheels(), getTranType(), getBrakeSystem(), getSteeringSystem(), getNbrPassSeats(), getRange(), getStowCapacity() ); } }Here is my application and my other classes.Java Code:symbol: class MotorVehicles public class Bus extends MotorVehicles ^ C:\Users\Timzareli\Documents\JCreator LE\MyProjects\TestMyVehicles\src\Bus.java:57: cannot find symbol symbol : method getNbrWheels() location: class Bus getNbrWheels(), getTranType(), getBrakeSystem(), getSteeringSystem(), getNbrPassSeats(), ^ C:\Users\Timzareli\Documents\JCreator LE\MyProjects\TestMyVehicles\src\Bus.java:57: cannot find symbol symbol : method getTranType() location: class Bus getNbrWheels(), getTranType(), getBrakeSystem(), getSteeringSystem(), getNbrPassSeats(), ^ C:\Users\Timzareli\Documents\JCreator LE\MyProjects\TestMyVehicles\src\Bus.java:57: cannot find symbol symbol : method getBrakeSystem() location: class Bus getNbrWheels(), getTranType(), getBrakeSystem(), getSteeringSystem(), getNbrPassSeats(), ^ C:\Users\Timzareli\Documents\JCreator LE\MyProjects\TestMyVehicles\src\Bus.java:57: cannot find symbol symbol : method getSteeringSystem() location: class Bus getNbrWheels(), getTranType(), getBrakeSystem(), getSteeringSystem(), getNbrPassSeats(), ^ C:\Users\Timzareli\Documents\JCreator LE\MyProjects\TestMyVehicles\src\Bus.java:57: cannot find symbol symbol : method getNbrPassSeats() location: class Bus getNbrWheels(), getTranType(), getBrakeSystem(), getSteeringSystem(), getNbrPassSeats(), ^ C:\Users\Timzareli\Documents\JCreator LE\MyProjects\TestMyVehicles\src\Bus.java:53: method does not override or implement a method from a supertype @Override ^ 7 errors Process completed.
Java Code:public class TestMyVehicles { public static void main(String [] args) { // MotorVehicle[] myVehicles = new MotorVehicle[4]; // comment this line to test your code MotorVehicle[] myVehicles = new MotorVehicle[6]; // uncomment this line to test your code myVehicles[0] = new MotorVehicle( 4, "auto","anti-lock", "power" ); myVehicles[1] = new MotorVehicle( 6, "automatic", "disc", "power assist"); myVehicles[2] = new Automobile(4, "automatic", "anti-lock", "power assist", 4, 4); myVehicles[3] = new Automobile(4, "automatic", "anti-lock", "power assist", 5, 5); myVehicles[4] = new Bus( 14, "automatic", "disc", "power assist", 40, 300, 2200); myVehicles[5] = new Bus( 18, "automatic", "disc", "power assist", 60, 450, 4200); for (MotorVehicle currVehicle : myVehicles) System.out.printf( currVehicle.toString()); } } // end class TestMyVehiclesJava Code:symbol : class Bus location: class TestMyVehicles myVehicles[5] = new Bus( 18, "automatic", "disc", "power assist", 60, 450, 4200); ^ 2 errors Process completed.
Java Code:public class Automobile extends MotorVehicle { private int nbrDoors; private int nbrWindows; // Four-argument constructor public Automobile( int wheels, String trans, String brakes, String steering, int doors, int windows) { super (wheels, trans, brakes, steering); setNbrDoors( doors ); setNbrWindows( windows ); } // end Automobile constructor // set number of doors public void setNbrDoors( int doors ) { nbrDoors = doors; } // end method setFirstName // return nubmer of doors public int getNbrDoors() { return nbrDoors; } // end method getNbrDoors // set number of windows public void setNbrWindows( int windows ) { nbrWindows = windows; } // end method setNbrWindows // return nubmer of windows public int getNbrWindows() { return nbrWindows; } // end method getNbrWindows // return String representation of MotorVehicle object @Override public String toString() { return String.format( "\nThis vehicle has %d wheels, %s transmission, %s brakes, %s steering, %d doors and %d windows", getNbrWheels(), getTranType(), getBrakeSystem(), getSteeringSystem(), getNbrDoors(), getNbrWindows() ); } // end method toString } // end class AutomobileI apologize for the amount of code, any help given will be greatly appreciated.Java Code://public abstract class MotorVehicle public class MotorVehicle { private int nbrWheels; private String tranType; private String brakeSystem; private String steeringSystem; // Four-argument constructor public MotorVehicle( int wheels, String trans, String brakes, String steering) { setNbrWheels( wheels); setTranType( trans ); setBrakeSystem( brakes ); setSteeringSystem( steering); } // end four-argument Employee constructor // set number of wheels public void setNbrWheels( int wheels ) { nbrWheels = wheels; // should validate } // end method setFirstName // return nubmer of wheels public int getNbrWheels() { return nbrWheels; } // end method getNbrWheels // set transmission type public void setTranType( String trans ) { if ((trans == "automatic") || (trans == "standard")) tranType = trans; else tranType = "standard"; } // end method setTranType // return TranType public String getTranType() { return tranType; } // end method getLastName // set type of brake system public void setBrakeSystem( String brakes ) { brakeSystem = brakes; } // end method setBrakeSystem // return type of brake system public String getBrakeSystem() { return brakeSystem; } // end method // set type of steering system public void setSteeringSystem( String steering ) { steeringSystem = steering; } // end method setSteeringSystem // return type of steering system public String getSteeringSystem() { return steeringSystem; } // end method // return String representation of MotorVehicle object @Override public String toString() { return String.format( "\nThis vehicle has %d wheels, %s transmission, %s brakes, and %s steering", getNbrWheels(), getTranType(), getBrakeSystem(), getSteeringSystem() ); } // end method toString } // end abstract class MotorVehicle
Thank you
- 06-10-2011, 08:43 PM #2
Member
- Join Date
- Jun 2011
- Location
- San Diego, CA
- Posts
- 24
- Rep Power
- 0
It looks to me in your Bus class, the getNbrPassSeats() method is missing the "get" part. you call getNbrPassSeats() at the bottom but the actual method name you have right now is NbrPassSeats() w/o the "get".
- 06-10-2011, 08:52 PM #3
Member
- Join Date
- May 2011
- Posts
- 39
- Rep Power
- 0
I have done that, thank you, now I only have 6 errors, do you know why my class is not inheriting the methods while my other classes successfully did so?
- 06-10-2011, 08:53 PM #4
Member
- Join Date
- May 2011
- Posts
- 39
- Rep Power
- 0
I also am wondering why I have an override error, I don't see anything wrong with how I declared it.
- 06-10-2011, 08:53 PM #5
The first part of the error message that you posted appears to be missing some text. I think that missing part is the key to the rest of the problems.
- 06-10-2011, 09:17 PM #6
Member
- Join Date
- May 2011
- Posts
- 39
- Rep Power
- 0
Similar Threads
-
Do not understand how to fix error I keeping getting in my code. Totally Confused.
By Raven9 in forum New To JavaReplies: 3Last Post: 04-18-2011, 11:33 PM -
Code does not Compile
By ustar in forum New To JavaReplies: 13Last Post: 03-06-2010, 04:54 PM -
The code isnt working unless I add print statements at diffrent points!:confused:
By Addez in forum New To JavaReplies: 6Last Post: 11-12-2009, 10:50 AM -
Code will not compile
By ShotGunRockets in forum New To JavaReplies: 17Last Post: 05-10-2009, 03:31 AM -
confused code
By creativehacker in forum New To JavaReplies: 6Last Post: 07-02-2007, 08:10 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks