Hi all, i am newbie in ood, recently i have been asked this question in amazon lld round, please add your feedback.
class Billing{
User user,
List<Items> items,
Payment payment
public void createUser(user){
// check if user is already there or not, if user is already created then we will use existing userId
}
public float createBill(userId,items){
float total=0
for(int i=0;i<items.length;i++){
total+=items[i].price*items[i]*quantity
}
return total
}
}
class User {
int id,
String Name,
int phoneNo
}
class Items{
int id,
Category category
float price,
int quantity
}
enum Category{
KIDS,SPORTS,PANTRY
}
class Payment{
PaymentType type,
PaymentStatus status
public bool doPayment(typeOfPayment){
}
}
enum PaymentStatus{
DONE,PENDING
}
enum PaymentType{
CASH,UPI,DEBIT_CARD,CREDIT_CARD
}