-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomer_Invoice.java
More file actions
47 lines (45 loc) · 1.18 KB
/
Customer_Invoice.java
File metadata and controls
47 lines (45 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
class Customer{
int id;
String name;
int discount;
Customer(int id,String name,int discount){
this.name=name;
this.id=id;
this.discount=discount;
}
int getId(){ return id; }
String getName(){ return name; }
int getDiscount(){ return discount ; }
void setDiscount(int d){ discount=d; }
public String toString(){
return "Name: "+name+" Id: "+id+" Discount: "+discount;
}
}
class Invoice{
Customer customer;
int id;
double amount;
Invoice(Customer c,int id,double amt){
this.amount=amt;
this.id=id;
this.customer=c;
}
int getId(){ return id ;}
Customer getCustomer(){ return customer; }
void setCustomer(Customer c){ customer=c; }
String getAmount(){ return Double.toString(amount); }
void setAmount(Double amt){ amount=amt; }
String getCustomerName(){ return customer.getName() ; }
double afterDiscount(){
double f=amount-customer.getDiscount()*0.01*amount;
return f;
}
}
class Customer_Invoice{
public static void main(String args[]){
Customer c1=new Customer(1111,"Kakashi",5);
Invoice i1=new Invoice(c1,9009,200);
System.out.println("details of c1\n"+c1);
System.out.println("amount to be paid by c1: "+i1.afterDiscount());
}
}