Untitled
unknown
plain_text
a year ago
1.8 kB
9
Indexable
// Order.java
public class Order {
private String orderId;
private String customerId;
private double amount;
public Order(String orderId, String customerId, double amount) {
this.orderId = orderId;
this.customerId = customerId;
this.amount = amount;
}
public void printOrderDetails() {
System.out.println("Order ID: " + orderId);
System.out.println("Customer ID: " + customerId);
System.out.println("Amount: $" + amount);
}
public void applyDiscount(double discountPercentage) {
if (discountPercentage > 0 && discountPercentage <= 100) {
amount = amount - (amount * discountPercentage / 100);
}
}
public String getOrderId() {
return orderId;
}
public String getCustomerId() {
return customerId;
}
public double getAmount() {
return amount;
}
}
// Customer.java
public class Customer {
private String customerId;
private String name;
private String email;
private String phoneNumber;
public Customer(String customerId, String name, String email, String phoneNumber) {
this.customerId = customerId;
this.name = name;
this.email = email;
this.phoneNumber = phoneNumber;
}
public void printCustomerDetails() {
System.out.println("Customer ID: " + customerId);
System.out.println("Name: " + name);
System.out.println("Email: " + email);
System.out.println("Phone Number: " + phoneNumber);
}
public String getCustomerId() {
return customerId;
}
public String getName() {
return name;
}
public String getEmail() {
return email;
}
public String getPhoneNumber() {
return phoneNumber;
}
}
Editor is loading...
Leave a Comment