-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCarDemo.java
More file actions
40 lines (35 loc) · 1.56 KB
/
Copy pathCarDemo.java
File metadata and controls
40 lines (35 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Programmer: Edgar Colin
// Student ID: EDG2140344
// Class: CIS263AA JAVA II Class # 12303
// Instructor: Michael Parmeley
// Chapter: 10
// Problem: 3
// Part: d)
// Filename: CarDemo.java
import java.util.*;
public class CarDemo
{
public static void main(String[] args)
{
// Grand Parent Class
Car Ford = new Car("Ford","Focus");
// Parent Class
Camaro ChevyCamaro = new Camaro("Chevy", "Camaro", 155.3);
// Grand Child Class
SmartCar SmartElectric = new SmartCar("Smart", "Electric", 100, "Car Charging");
System.out.println("Car 1 Grand Parent Class:");
System.out.println("Make: " +Ford.getModel()); // Original Method
System.out.println("Model: " + Ford.getMake()); // Original Method
System.out.println("");
System.out.println("Car 2 Parent Class:");
System.out.println("Make: " + ChevyCamaro.getMake()); // Inhereted from Grand Parent
System.out.println("Model: " + ChevyCamaro.getModel()); // Inhereted from Grand Parent
System.out.println("Top Speed (mph): " + ChevyCamaro.getSpeed()); // New Method
System.out.println("");
System.out.println("Car 3 Grandchild Class");
System.out.println("Make: " +SmartElectric.getMake()); // Inhereted from Grand Parent
System.out.println("Model: " + SmartElectric.getModel()); // Inhereted from Grand Parent
System.out.println("Top Speed (mph): " + SmartElectric.getSpeed()); // Inhereted from Parent
System.out.println("Status: " + SmartElectric.getCharging()); // New Method
}
}