Skip to content

Chapter15AbstractClassPractice #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
abstract class Restaurant {

//insert abstract method

}

public class AbstractClassesTutorial {

//Create 4 classes that extend the abstract class

public static void main(String[] args) {

//print out the 4 abstract classes

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,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();

}
}