-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhospital.java
More file actions
69 lines (59 loc) · 1.21 KB
/
Copy pathhospital.java
File metadata and controls
69 lines (59 loc) · 1.21 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
abstract class Plan
{
private String patientName;
private double baseFee;
Plan(String pn, double bf)
{
patientName = pn;
baseFee = bf;
}
abstract void calculateBill();
double giveBaseFee()
{
return baseFee;
}
}
class SilverPlan extends Plan
{
double base;
void getBaseFee()
{
base = giveBaseFee();
}
SilverPlan(String pn, double bf)
{
super(pn, bf);
}
void calculateBill()
{
double bill = base + 15;
System.out.println("Silver Plan Bill: " + bill);
}
}
class GoldPlan extends Plan
{
double base;
void getBaseFee()
{
base = giveBaseFee();
}
GoldPlan(String pn, double bf)
{
super(pn, bf);
}
void calculateBill()
{
double bill = base + (0.1 * base) - 20;
System.out.println("Gold Plan Bill: " + bill);
}
}
public class hospital
{
public static void main(String[] args)
{
Plan obj1 = new SilverPlan("Rohan", 2000);
Plan obj2 = new GoldPlan("Rohit", 3000);
obj1.calculateBill();
obj2.calculateBill();
}
}