Kerja6_2
-
Upload
shafiq-mujahid -
Category
Documents
-
view
217 -
download
0
Transcript of Kerja6_2
![Page 1: Kerja6_2](https://reader030.fdocuments.us/reader030/viewer/2022021121/563db953550346aa9a9c3f4b/html5/thumbnails/1.jpg)
7/23/2019 Kerja6_2
http://slidepdf.com/reader/full/kerja62 1/2
/** * @(#)Vehicle.java * * * @MUHAMAD SHAFIQ AMINI BIN MOHD ZANI * @1139015 * @version 1.00 2012/8/30 */
public class Vehicle {int noOfTyres; // no of tyresprivate boolean accessories; // check if accessorees present or notprotected String brand; // Brand of the carprivate static int counter; // No of Vehicle objects createdVehicle() {
System.out.println("Constructor of the Super class called");noOfTyres = 5;accessories = true;brand = "X";counter++;
}public void switchOn() {
accessories = true;
}public void switchOff() {accessories = false;
}public boolean isPresent() {
return accessories;}private void getBrand() {
System.out.println("Vehicle Brand: " + brand);}public static void getNoOfVehicles() {
System.out.println("Number of Vehicles: " + counter);}
}
class Car extends Vehicle { private int carNo = 10;
public void printCarInfo() {System.out.println("Car number: " + carNo);System.out.println("No of Tyres: " + noOfTyres); // Inherited.System.out.println("accessories: " + isPresent()); // Inherited.
System.out.println("Brand: " + brand); // Inherited. getNoOfVehicles(); // Inherited.
}}class VehicleDetails { // (3)
public static void main(String[] args) {new Car().printCarInfo();
}}--------------------Configuration: <Default>--------------------Constructor of the Super class calledCar number: 10No of Tyres: 5accessories: true
![Page 2: Kerja6_2](https://reader030.fdocuments.us/reader030/viewer/2022021121/563db953550346aa9a9c3f4b/html5/thumbnails/2.jpg)
7/23/2019 Kerja6_2
http://slidepdf.com/reader/full/kerja62 2/2
Brand: XNumber of Vehicles: 1
Process completed.