diff --git a/newnew/List_of_Cars_manufactured_in_2000_price_higher_than_5000.txt b/newnew/List_of_Cars_manufactured_in_2000_price_higher_than_5000.txt new file mode 100644 index 0000000..cc67dcb --- /dev/null +++ b/newnew/List_of_Cars_manufactured_in_2000_price_higher_than_5000.txt @@ -0,0 +1,18 @@ +List of Cars manufactured in 2000 with price higher than 5000 +------------------------------- +ID: 12 +Make: Toyota +Model: SUV +Manufacture Year: 2000 +Color: Blue +Price: 20008 +Registration Number: BH0C0411 +------------------------------- +ID: 14 +Make: AUDI +Model: Hatchback +Manufacture Year: 2000 +Color: White +Price: 20010 +Registration Number: BH0C0003 +------------------------------- diff --git a/newnew/List_of_Cars_of_BMW.txt b/newnew/List_of_Cars_of_BMW.txt new file mode 100644 index 0000000..5d0a4bc --- /dev/null +++ b/newnew/List_of_Cars_of_BMW.txt @@ -0,0 +1,18 @@ +List of Cars of a given brand: BMW +------------------------------- +ID: 2 +Make: BMW +Model: Sedan +Manufacture Year: 2005 +Color: White +Price: 5500 +Registration Number: DL2C9898 +------------------------------- +ID: 10 +Make: BMW +Model: Sedan +Manufacture Year: 1996 +Color: Pink +Price: 2000 +Registration Number: BH0C2052 +------------------------------- diff --git a/newnew/List_of_Cars_of_Sedan_more_than_10_years.txt b/newnew/List_of_Cars_of_Sedan_more_than_10_years.txt new file mode 100644 index 0000000..a5dd89b --- /dev/null +++ b/newnew/List_of_Cars_of_Sedan_more_than_10_years.txt @@ -0,0 +1,34 @@ +List of Cars of a given model used for more than 10 years: Sedan +------------------------------- +ID: 1 +Make: Mercedes +Model: Sedan +Manufacture Year: 1995 +Color: Grey +Price: 2500 +Registration Number: DL3C2001 +------------------------------- +ID: 2 +Make: BMW +Model: Sedan +Manufacture Year: 2005 +Color: White +Price: 5500 +Registration Number: DL2C9898 +------------------------------- +ID: 8 +Make: AUDI +Model: Sedan +Manufacture Year: 2001 +Color: Black +Price: 12500 +Registration Number: DL3C8501 +------------------------------- +ID: 10 +Make: BMW +Model: Sedan +Manufacture Year: 1996 +Color: Pink +Price: 2000 +Registration Number: BH0C2052 +------------------------------- diff --git a/newnew/Main.java b/newnew/Main.java new file mode 100644 index 0000000..83fd4c8 --- /dev/null +++ b/newnew/Main.java @@ -0,0 +1,69 @@ +import java.io.*; + +class Car { + int id; + String make; + String model; + int manufacture_year; + String color; + int price; + String registration_number; + + public Car(int id, String make, String model, int manufacture_year, String color, int price, String registration_number) { + this.id = id; + this.make = make; + this.model = model; + this.manufacture_year = manufacture_year; + this.color = color; + this.price = price; + this.registration_number = registration_number; + } +} + +public class Main { + public static void main(String[] args) { + Car[] obj = { + new Car(1,"Mercedes","Sedan",1995,"Grey",2500,"DL3C2001"), + new Car(2,"BMW","Sedan",2005,"White",5500,"DL2C9898"), + new Car(3,"Mercedes","SUV",2010,"White",7000,"DL2C2000"), + new Car(4,"Bugatti","Coupe",2016,"Red",592500,"DL4C2041"), + new Car(5,"AUDI","Coupe",2022,"Black",72500,"DL6C8451"), + new Car(6,"Mercedes","Convertible",2015,"Grey",152500,"DL3C6666"), + new Car(7,"Porsche","Coupe",2015,"White",102500,"DL3C6333"), + new Car(8,"AUDI","Sedan",2001,"Black",12500,"DL3C8501"), + new Car(9,"AUDI","Hatchback",2005,"White",4000,"DLAC2581"), + new Car(10,"BMW","Sedan",1996,"Pink",2000,"BH0C2052"), + new Car(11,"BMW","SUV",2016,"Blue",20010,"BH0C0001"), + }; + + String brandToFilter = "BMW"; + String listFilePath = "List_of_Cars_of_" + brandToFilter + ".txt"; + + try { + System.out.println("Creating a list of cars of the given brand: " + brandToFilter); + FileWriter fileWriter = new FileWriter(listFilePath); + fileWriter.write("List of Cars of a given brand: " + brandToFilter); + fileWriter.write("\n-------------------------------\n"); + + for (Car car : obj) { + String carBrand = car.make.toLowerCase(); + if (carBrand.equals(brandToFilter.toLowerCase())) { + + fileWriter.write("ID: " + car.id + "\n"); + fileWriter.write("Make: " + car.make + "\n"); + fileWriter.write("Model: " + car.model + "\n"); + fileWriter.write("Manufacture Year: " + car.manufacture_year + "\n"); + fileWriter.write("Color: " + car.color + "\n"); + fileWriter.write("Price: " + car.price + "\n"); + fileWriter.write("Registration Number: " + car.registration_number + "\n"); + fileWriter.write("-------------------------------\n"); + } + } + + fileWriter.close(); + System.out.println("List of cars saved to: " + listFilePath); + } catch (IOException e) { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/newnew/Main2.java b/newnew/Main2.java new file mode 100644 index 0000000..4a562ea --- /dev/null +++ b/newnew/Main2.java @@ -0,0 +1,68 @@ +import java.io.*; + +class Car { + int id; + String make; + String model; + int manufacture_year; + String color; + int price; + String registration_number; + + public Car(int id, String make, String model, int manufacture_year, String color, int price, String registration_number) { + this.id = id; + this.make = make; + this.model = model; + this.manufacture_year = manufacture_year; + this.color = color; + this.price = price; + this.registration_number = registration_number; + } +} + +public class Main2 { + public static void main(String[] args) { + Car[] obj = { + new Car(1,"Mercedes","Sedan",1995,"Grey",2500,"DL3C2001"), + new Car(2,"BMW","Sedan",2005,"White",5500,"DL2C9898"), + new Car(3,"Mercedes","SUV",2010,"White",7000,"DL2C2000"), + new Car(4,"Bugatti","Coupe",2016,"Red",592500,"DL4C2041"), + new Car(5,"AUDI","Coupe",2022,"Black",72500,"DL6C8451"), + new Car(6,"Mercedes","Convertible",2015,"Grey",152500,"DL3C6666"), + new Car(7,"Porsche","Coupe",2015,"White",102500,"DL3C6333"), + new Car(8,"AUDI","Sedan",2001,"Black",12500,"DL3C8501"), + new Car(9,"AUDI","Hatchback",2005,"White",4000,"DLAC2581"), + new Car(10,"BMW","Sedan",1996,"Pink",2000,"BH0C2052"), + new Car(11,"BMW","SUV",2016,"Blue",20010,"BH0C0001"), + }; + + String modelToFilter = "Sedan"; + int yearsThreshold = 10; // Cars used for more than 10 years + String listFilePath = "List_of_Cars_of_" + modelToFilter + "_more_than_" + yearsThreshold + "_years.txt"; + + try { + System.out.println("Creating a list of cars of the given model used for more than " + yearsThreshold + " years: " + modelToFilter); + FileWriter fileWriter = new FileWriter(listFilePath); + fileWriter.write("List of Cars of a given model used for more than " + yearsThreshold + " years: " + modelToFilter); + fileWriter.write("\n-------------------------------\n"); + + for (Car car : obj) { + if (car.model.equalsIgnoreCase(modelToFilter) && (2023 - car.manufacture_year > yearsThreshold)) { + fileWriter.write("ID: " + car.id + "\n"); + fileWriter.write("Make: " + car.make + "\n"); + fileWriter.write("Model: " + car.model + "\n"); + fileWriter.write("Manufacture Year: " + car.manufacture_year + "\n"); + fileWriter.write("Color: " + car.color + "\n"); + fileWriter.write("Price: " + car.price + "\n"); + fileWriter.write("Registration Number: " + car.registration_number + "\n"); + fileWriter.write("-------------------------------\n"); + } + } + + fileWriter.close(); + System.out.println("List of cars saved to: " + listFilePath); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/newnew/Main3.java b/newnew/Main3.java new file mode 100644 index 0000000..7c089a2 --- /dev/null +++ b/newnew/Main3.java @@ -0,0 +1,73 @@ +import java.io.*; + +class Car { + int id; + String make; + String model; + int manufacture_year; + String color; + int price; + String registration_number; + + public Car(int id, String make, String model, int manufacture_year, String color, int price, String registration_number) { + this.id = id; + this.make = make; + this.model = model; + this.manufacture_year = manufacture_year; + this.color = color; + this.price = price; + this.registration_number = registration_number; + } +} + +public class Main3 { + public static void main(String[] args) { + Car[] obj = { + new Car(1, "Mercedes", "Sedan", 1995, "Grey", 2500, "DL3C2001"), + new Car(2, "BMW", "Sedan", 2005, "White", 5500, "DL2C9898"), + new Car(3, "Mercedes", "SUV", 2010, "White", 7000, "DL2C2000"), + new Car(4, "Bugatti", "Coupe", 2016, "Red", 592500, "DL4C2041"), + new Car(5, "AUDI", "Coupe", 2022, "Black", 72500, "DL6C8451"), + new Car(6, "Mercedes", "Convertible", 2015, "Grey", 152500, "DL3C6666"), + new Car(7, "Porsche", "Coupe", 2015, "White", 102500, "DL3C6333"), + new Car(8, "AUDI", "Sedan", 2001, "Black", 12500, "DL3C8501"), + new Car(9, "AUDI", "Hatchback", 2005, "White", 4000, "DLAC2581"), + new Car(10, "BMW", "Sedan", 1996, "Pink", 2000, "BH0C2052"), + new Car(11, "BMW", "SUV", 2016, "Blue", 20710, "BH0C0001"), + new Car(12, "Toyota", "SUV", 2000, "Blue", 20008, "BH0C0411"), + new Car(13, "Toyota", "SUV", 2016, "Black", 40010, "BH0C0002"), + new Car(14, "AUDI", "Hatchback", 2000, "White", 20010, "BH0C0003"), + }; + + int yearToFilter = 2000; + int priceThreshold = 5000; // Cars with price higher than 5000 + String listFilePath = "List_of_Cars_manufactured_in_" + yearToFilter + "_price_higher_than_" + priceThreshold + ".txt"; + + try { + System.out.println("Creating a list of cars manufactured in " + yearToFilter + + " with price higher than " + priceThreshold); + FileWriter fileWriter = new FileWriter(listFilePath); + fileWriter.write("List of Cars manufactured in " + yearToFilter + + " with price higher than " + priceThreshold); + fileWriter.write("\n-------------------------------\n"); + + for (Car car : obj) { + if (car.manufacture_year == yearToFilter && car.price > priceThreshold) { + fileWriter.write("ID: " + car.id + "\n"); + fileWriter.write("Make: " + car.make + "\n"); + fileWriter.write("Model: " + car.model + "\n"); + fileWriter.write("Manufacture Year: " + car.manufacture_year + "\n"); + fileWriter.write("Color: " + car.color + "\n"); + fileWriter.write("Price: " + car.price + "\n"); + fileWriter.write("Registration Number: " + car.registration_number + "\n"); + fileWriter.write("-------------------------------\n"); + } + } + + fileWriter.close(); + System.out.println("List of cars saved to: " + listFilePath); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/task2/prechec/Engine2.java b/task2/prechec/Engine2.java new file mode 100644 index 0000000..9b6a703 --- /dev/null +++ b/task2/prechec/Engine2.java @@ -0,0 +1,162 @@ +package prechec; + +class Engine { + String Enginematerial; + double Uniqueid; + int cost; + + public Engine(String Enginematerial, double Uniqueid, int cost) { + this.Enginematerial = Enginematerial; + this.Uniqueid = Uniqueid; + this.cost = cost; + } + + public String getEnginematerial() { + return Enginematerial; + } + + public double getUniqueid() { + return Uniqueid; + } + + public int getcost() { + return cost; + } +} + +class CombustionEngine extends Engine { + public CombustionEngine(String Enginematerial, double Uniqueid, int cost) { + super(Enginematerial, Uniqueid, cost); + } +} + +class ElectricEngine extends Engine { + public ElectricEngine(String Enginematerial, double Uniqueid, int cost) { + super(Enginematerial, Uniqueid, cost); + } +} + +class HybridEngine extends Engine { + public HybridEngine(String Enginematerial, double Uniqueid, int cost) { + super(Enginematerial, Uniqueid, cost); + } +} + +class Manufacture { + private String Manufacturename; + private int yearOfManufacture; + + public Manufacture(String Manufacturename, int yearOfManufacture) { + this.Manufacturename = Manufacturename; + this.yearOfManufacture = yearOfManufacture; + } + + public String getManufacturename() { + return Manufacturename; + } + + public int getyearOfManufacture() { + return yearOfManufacture; + } +} + +abstract class Vehicle { + private Manufacture manufacture; + private Engine engine; + + public Vehicle(Manufacture manufacture, Engine engine) { + this.manufacture = manufacture; + this.engine = engine; + } + + public Manufacture getManufacture() { + return manufacture; + } + + public Engine getEngine() { + return engine; + } + + public abstract void ShowCharacteristics(); +} + +class ICEV extends Vehicle { + public ICEV(Manufacture manufacture, Engine engine) { + super(manufacture, engine); + } + + public void ShowCharacteristics() { + System.out.println("Internal Combustion Engine Vehicle (ICEV)"); + System.out.println("Manufacture Name: " + getManufacture().getManufacturename()); + System.out.println("Year Of Manufacture: " + getManufacture().getyearOfManufacture()); + System.out.println("Engine Material: " + getEngine().getEnginematerial()); + System.out.println("Engine Unique ID : " + getEngine().getUniqueid()); + System.out.println("Engine Cost: " + getEngine().getcost()); + } +} + +class BEV extends Vehicle { + public BEV(Manufacture manufacture, Engine engine) { + super(manufacture, engine); + } + + public void ShowCharacteristics() { + System.out.println("Battery Electric Vehicle (BEV)"); + System.out.println("Manufacture Name: " + getManufacture().getManufacturename()); + System.out.println("Year Of Manufacture: " + getManufacture().getyearOfManufacture()); + System.out.println("Engine Material: " + getEngine().getEnginematerial()); + System.out.println("Engine Unique ID : " + getEngine().getUniqueid()); + System.out.println("Engine Cost: " + getEngine().getcost()); + } +} + +class HybridV extends Vehicle { + public HybridV(Manufacture manufacture, Engine engine) { + super(manufacture, engine); + } + + public void ShowCharacteristics() { + System.out.println("Hybrid Vehicle (HybridV)"); + System.out.println("Manufacture Name: " + getManufacture().getManufacturename()); + System.out.println("Year Of Manufacture: " + getManufacture().getyearOfManufacture()); + System.out.println("Engine Material: " + getEngine().getEnginematerial()); + System.out.println("Engine Unique ID : " + getEngine().getUniqueid()); + System.out.println("Engine Cost: " + getEngine().getcost()); + } +} + +public class Engine2 { + public static void main(String[] args) { + Manufacture porsche = new Manufacture("Porsche", 2015); + Manufacture audi = new Manufacture("Audi", 2023); + Manufacture suzuki = new Manufacture("Suzuki", 2022); + Manufacture kia = new Manufacture("KIA", 2016); + + Engine iceEngine = new Engine("Steel", 134.0, 23400); + Engine electricEngine = new Engine("Copper", 321, 12005); + Engine manualEngine = new Engine("Zinc", 2321.0, 123059); + + ICEV icev = new ICEV(porsche, iceEngine); + BEV bev = new BEV(porsche, electricEngine); + HybridV hybridv = new HybridV(porsche, manualEngine); + + ICEV icev1 = new ICEV(audi, iceEngine); + BEV bev1 = new BEV(audi, electricEngine); + HybridV hybridv1 = new HybridV(audi, manualEngine); + + ICEV icev2 = new ICEV(suzuki, iceEngine); + BEV bev2 = new BEV(suzuki, electricEngine); + HybridV hybridv2 = new HybridV(suzuki, manualEngine); + + ICEV icev3 = new ICEV(kia, iceEngine); + BEV bev3 = new BEV(kia, electricEngine); + HybridV hybridv3 = new HybridV(kia, manualEngine); + + Vehicle[] vehicles = {icev, bev, hybridv, icev1, bev1, hybridv1, icev2, bev2, hybridv2, icev3, bev3, hybridv3}; + + for (Vehicle vehicle : vehicles) { + vehicle.ShowCharacteristics(); + System.out.println(); + } + } +} \ No newline at end of file diff --git a/task2/prechec/output.txt b/task2/prechec/output.txt new file mode 100644 index 0000000..c1cb2bb --- /dev/null +++ b/task2/prechec/output.txt @@ -0,0 +1,83 @@ +Internal Combustion Engine Vehicle (ICEV) +Manufacture Name: Porsche +Year Of Manufacture: 2015 +Engine Material: Steel +Engine Unique ID : 134.0 +Engine Cost: 23400 + +Battery Electric Vehicle (BEV) +Manufacture Name: Porsche +Year Of Manufacture: 2015 +Engine Material: Copper +Engine Unique ID : 321.0 +Engine Cost: 12005 + +Hybrid Vehicle (HybridV) +Manufacture Name: Porsche +Year Of Manufacture: 2015 +Engine Material: Zinc +Engine Unique ID : 2321.0 +Engine Cost: 123059 + +Internal Combustion Engine Vehicle (ICEV) +Manufacture Name: Audi +Year Of Manufacture: 2023 +Engine Material: Steel +Engine Unique ID : 134.0 +Engine Cost: 23400 + +Battery Electric Vehicle (BEV) +Manufacture Name: Audi +Year Of Manufacture: 2023 +Engine Material: Copper +Engine Unique ID : 321.0 +Engine Cost: 12005 + +Hybrid Vehicle (HybridV) +Manufacture Name: Audi +Year Of Manufacture: 2023 +Engine Material: Zinc +Engine Unique ID : 2321.0 +Engine Cost: 123059 + +Internal Combustion Engine Vehicle (ICEV) +Manufacture Name: Suzuki +Year Of Manufacture: 2022 +Engine Material: Steel +Engine Unique ID : 134.0 +Engine Cost: 23400 + +Battery Electric Vehicle (BEV) +Manufacture Name: Suzuki +Year Of Manufacture: 2022 +Engine Material: Copper +Engine Unique ID : 321.0 +Engine Cost: 12005 + +Hybrid Vehicle (HybridV) +Manufacture Name: Suzuki +Year Of Manufacture: 2022 +Engine Material: Zinc +Engine Unique ID : 2321.0 +Engine Cost: 123059 + +Internal Combustion Engine Vehicle (ICEV) +Manufacture Name: KIA +Year Of Manufacture: 2016 +Engine Material: Steel +Engine Unique ID : 134.0 +Engine Cost: 23400 + +Battery Electric Vehicle (BEV) +Manufacture Name: KIA +Year Of Manufacture: 2016 +Engine Material: Copper +Engine Unique ID : 321.0 +Engine Cost: 12005 + +Hybrid Vehicle (HybridV) +Manufacture Name: KIA +Year Of Manufacture: 2016 +Engine Material: Zinc +Engine Unique ID : 2321.0 +Engine Cost: 123059 \ No newline at end of file