// Car.java
public class Car {
private String model;
private int year;
private double price;
public Car(String model, int year, double price) {
this.model = model;
this.year = year;
this.price = price;
}
public String getModel() {
return model;
}
public int getYear() {
return year;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public String toString() {
return model + " (" + year + ") - $" + price;
}
}
// CarInventory.java
import java.util.ArrayList;
public class CarInventory {
private ArrayList<Car> inventory;
public CarInventory() {
inventory = new ArrayList<Car>();
}
public void addCar(Car car) {
inventory.add(car);
}
public void displayInventory() {
if (inventory.size() == 0) {
System.out.println("Inventory is empty.");
} else {
for (Car car : inventory) {
System.out.println(car);
}
}
}
public void updateCarPrice(String model, int year, double price) {
for (Car car : inventory) {
if (car.getModel().equalsIgnoreCase(model) && car.getYear() == year) {
car.setPrice(price);
break;
}
}
}
public void deleteCar(String model, int year) {
for (int i = 0; i < inventory.size(); i++) {
Car car = inventory.get(i);
if (car.getModel().equalsIgnoreCase(model) && car.getYear() == year) {
inventory.remove(i);
break;
}
}
}
}
// Main.java
public class Main {
public static void main(String[] args) {
Car car1 = new Car("Honda Civic", 2021, 20000.0);
Car car2 = new Car("Toyota Corolla", 2020, 18000.0);
Car car3 = new Car("Ford Mustang", 2019, 30000.0);
CarInventory inventory = new CarInventory();
inventory.addCar(car1);
inventory.addCar(car2);
inventory.addCar(car3);
inventory.displayInventory();
inventory.updateCarPrice("Honda Civic", 2021, 22000.0);
inventory.deleteCar("Toyota Corolla", 2020);
inventory.displayInventory();
}
}
Car class represents a car object with its attributes (model, year, and price) and methods (getters, setters, and toString()). CarInventory class represents the inventory of cars stored in the inventory ArrayList. It has methods to add a car, display the inventory, update the price of a car, and delete a car from the inventory.Main class creates Car objects, adds them to the inventory, displays the inventory, updates the price of one car, deletes another car from the inventory, and displays the updated inventory.Car and CarInventory classes are abstractions that encapsulate the data and methods related to cars and car inventories, respectively.Car class encapsulates the car's attributes and methods, and the CarInventory class encapsulates the inventory of cars and its methods.hehe may mga teacher kasi ako paps na naandito kaya dapat uto remove yung questionParang nalito po ako, hmh
Haha ok lodshehe may mga teacher kasi ako paps na naandito kaya dapat uto remove yung question
Create 10 moreSure, here are 10 unique arguments using the rules of inference:
1. If the weather is sunny, then I will go for a walk. The weather is sunny. Therefore, I will go for a walk. (Modus Ponens)
Symbolically: p → q, p ⊢ q
2. If John studies hard, he will pass his exams. John passed his exams. Therefore, John studied hard. (Modus Tollens)
Symbolically: p → q, ¬q ⊢ ¬p
3. If it is raining, then the streets will be wet. The streets are wet. Therefore, it is raining. (Modus Ponens)
Symbolically: p → q, q ⊢ p
4. All cats are animals. Fluffy is a cat. Therefore, Fluffy is an animal. (Categorical Syllogism)
Symbolically: All A are B, X is A ⊢ X is B
5. If the train is on time, I will catch it. I did not catch the train. Therefore, the train was not on time. (Modus Tollens)
Symbolically: p → q, ¬q ⊢ ¬p
6. If it is summer, then the days are longer. Today, the days are longer. Therefore, it is summer. (Modus Ponens)
Symbolically: p → q, q ⊢ p
7. If the cake is chocolate, then I will eat it. I am not eating the cake. Therefore, the cake is not chocolate. (Modus Tollens)
Symbolically: p → q, ¬q ⊢ ¬p
8. If the car is out of gas, then it will not start. The car did not start. Therefore, it must have been out of gas. (Modus Tollens)
Symbolically: p → q, ¬q ⊢ ¬p
9. All fruits are healthy. Apples are fruits. Therefore, apples are healthy. (Categorical Syllogism)
Symbolically: All A are B, X is A ⊢ X is B
10. If it is cold outside, then I will wear a jacket. I am wearing a jacket. Therefore, it must be cold outside. (Modus Ponens)
Symbolically: p → q, p ⊢ q
Sure, here are 10 more unique arguments using the rules of inference:Create 10 more