Write A JAVA Program
Write a JAVA program to solve the following problem. Your program should properly
compile and run. Your code MUST follow the documentation style used in your textbook.
You need to upload into Moodle the following:
The electronic version of your SINGLE source code file after you successfully
compiled and ran it. Please label your file appropriately.
lab1/.classpath
lab1/.project
lab1 org.eclipse.jdt.core.javabuilder org.eclipse.jdt.core.javanature
lab1/.settings/org.eclipse.jdt.core.prefs
eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.source=1.8
lab1/bin/lab1/Car.class
package lab1;
public synchronized class Car {
private static final Object egn;
Engine eng;
Wheel whe;
Wheel[] Window;
public void Car();
public boolean equals(Object);
}
lab1/bin/lab1/Engine.class
package lab1;
public synchronized class Engine {
public void Engine();
}
lab1/bin/lab1/Vehicle.class
package lab1;
public abstract synchronized class Vehicle {
private String vehicleName;
public void Vehicle();
public void AbstrtactVehicle(String);
public String getVehicleName();
public String toString();
}
lab1/bin/lab1/Wheel.class
package lab1;
public synchronized class Wheel {
public void Wheel();
}
lab1/src/lab1/Car.java
lab1/src/lab1/Car.java
package lab1 ;
public class Car {
private static final Object egn = null ;
/*
Data fields
*/
Engine eng ;
Wheel whe ,
Window [] windows = new Window [ 4 ];
public boolean equals ( Object obj ) {
if ( obj == this ) return true ;
if ( obj == null ) return false ;
if ( this . getClass () == obj . getClass ()) {
Car other = ( Car ) obj ;
return egn . equals ( other . eng ) && whe . equals ( other . whe );
} else {
return false ;
}
}
}
lab1/src/lab1/Engine.java
lab1/src/lab1/Engine.java
package lab1 ;
public class Engine {
}
lab1/src/lab1/Vehicle.java
lab1/src/lab1/Vehicle.java
package lab1 ;
public abstract class Vehicle {
/** The name of the vehicle */
private String vehicleName ;
/**
* Initializes the vehicleName.
* @param vehicleName the kind of vehicle
* @return
*/
public void AbstrtactVehicle ( String vehicleName ) {
this . vehicleName = vehicleName ;
}
/**
* Get the kind of vehicle.
* @return the vehicleName
*/
public String getVehicleName () {
return vehicleName ;
}
@ Override
public String toString () {
return "Vehicle is a " + vehicleName ;
}
}
lab1/src/lab1/Wheel.java
lab1/src/lab1/Wheel.java
package lab1 ;
public class Wheel {
}
lab.png
lab1.png
lab2.png