From 748ec0ba2124aa8564ea12f8b2db9b484791f82c Mon Sep 17 00:00:00 2001
From: mahboobe <mahboobe.shakerinadr@ucalgary.ca>
Date: Fri, 25 Oct 2024 13:28:32 -0600
Subject: [PATCH] EXTENDED class example added

---
 src/Main.java     | 65 ++++++++++++++++++++++++++---------------------
 src/SportCar.java | 30 ++++++++++++++++++++++
 2 files changed, 66 insertions(+), 29 deletions(-)
 create mode 100644 src/SportCar.java

diff --git a/src/Main.java b/src/Main.java
index 50acee4..e76e987 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -18,35 +18,42 @@ public class Main {
 //        mahboobeCar.printDetails();
         mahboobeCar.setPrice(40000);
 //        mahboobeCar.printDetails();
-        try {
-            mahboobeCar.setPrice(-10);
-        }catch (Exception e) {
-            System.out.println(e.getMessage());
-        }
-        mahboobeCar.printDetails();
-        try {
-            Car testCar = new Car("Toyota", "LR4", 2024, -50000);
-            testCar.printDetails();
-        } catch (Exception e) {
-            System.out.println(e.getMessage());
-        }
-
-        Car carWithoutYear = new Car("Toyota", "LR4",  50000.0);
-        carWithoutYear.printDetails();
-        Car test1 = new Car("Toyota", "LR4", 2024);
-        test1.printDetails();
-        Car test2 = new Car("Tesla", "LR4");
-        test2.printDetails();
-
-        ArrayList<Car> carList = new ArrayList<>();
-        carList.add(mahboobeCar);
-        carList.add(test1);
-        carList.add(test2);
-        carList.add(new Car("Toyota", "list", 2024));
-
-        for (Car car : carList) {
-            car.printDetails();
-        }
+//        try {
+//            mahboobeCar.setPrice(-10);
+//        }catch (Exception e) {
+//            System.out.println(e.getMessage());
+//        }
+//        mahboobeCar.printDetails();
+//        try {
+//            Car testCar = new Car("Toyota", "LR4", 2024, -50000);
+//            testCar.printDetails();
+//        } catch (Exception e) {
+//            System.out.println(e.getMessage());
+//        }
+
+//        Car carWithoutYear = new Car("Toyota", "LR4",  50000.0);
+//        carWithoutYear.printDetails();
+//        Car test1 = new Car("Toyota", "LR4", 2024);
+//        test1.printDetails();
+//        Car test2 = new Car("Tesla", "LR4");
+//        test2.printDetails();
+//
+//        ArrayList<Car> carList = new ArrayList<>();
+//        carList.add(mahboobeCar);
+//        carList.add(test1);
+//        carList.add(test2);
+//        carList.add(new Car("Toyota", "list", 2024));
+//
+//        for (Car car : carList) {
+//            car.printDetails();
+//        }
+
+        SportCar sport_car1 = new SportCar("ferarri", "rx4", 2018, 100000, 50000, false);
+        sport_car1.printDetails();
+        sport_car1.setPrice(400000);
+        sport_car1.printDetails();
+        sport_car1.setHorsePower(6000);
+        sport_car1.printDetails();
 
 
 //         Exception Examples
diff --git a/src/SportCar.java b/src/SportCar.java
new file mode 100644
index 0000000..3924049
--- /dev/null
+++ b/src/SportCar.java
@@ -0,0 +1,30 @@
+public class SportCar extends Car {
+    private int horsePower;
+    private boolean turbo;
+
+    public SportCar(String brand, String model, int year, double price, int horsePower, boolean turbo) {
+        super(brand,model, year, price);
+        this.horsePower = horsePower;
+        this.turbo = turbo;
+    }
+
+    public int getHoursPower() {
+        return horsePower;
+    }
+    public void setHorsePower(int horsePower) {
+        this.horsePower = horsePower;
+    }
+    public boolean isTurbo() {
+        return turbo;
+    }
+    public void setTurbo(boolean turbo) {
+        this.turbo = turbo;
+    }
+
+    @Override
+    public void printDetails() {
+        super.printDetails();
+        System.out.println("Horsepower: " + horsePower + " Turbo mode: " + turbo);
+    }
+
+}
-- 
GitLab