I have been studying explicit and implicit casting in Java.
I created a Customer class that has two subclasses like RetailCustomer and CorporateCustomer. Also, I created a Bill class that has Customer property.
I want to create a Bill object according to user selection. If the user selects "1", the Bill object will be created for the retail customer, or if the user selects "2", the Bill object will be created for the corporate customer.
I'm very confused. How can I use explicit and implicit casting?
public class Customer {
private int CustomerID;
private String CustomerName;
private String CustomerLastName;
}
public class RetailCostumer extends Customer {
private int CitizenShipID;
private int CustomerNo
}
public class CorporateCustomer extends Customer {
private int TaxNumber;
private int CustomerNo
}
public class Bill {
private int BillID;
private Customer customer;
}
public class BillManagement {
public static void main(String[] args) {
}
}