-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathRestaurants.java
More file actions
44 lines (35 loc) · 804 Bytes
/
Restaurants.java
File metadata and controls
44 lines (35 loc) · 804 Bytes
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
abstract class Restaurant {
public abstract void food();
}
class Tacobell extends Restaurant {
public void food() {
System.out.println("Tacos!");
}
}
class Pizzahut extends Restaurant {
public void food() {
System.out.println("Pizza!");
}
}
class McDonalds extends Restaurant {
public void food() {
System.out.println("Burgers!");
}
}
class KFC extends Restaurant {
public void food() {
System.out.println("Chicken!");
}
}
public class AbstractClassesTutorial {
public static void main(String[] args) {
Tacobell t = new Tacobell();
t.food();
Pizzahut p = new Pizzahut();
p.food();
McDonalds m = new McDonalds();
m.food();
KFC k = new KFC();
k.food();
}
}