April 2019
Intermediate to advanced
360 pages
9h 17m
English
Our program begins with a KitchenStaff interface that contains an empty getDetails() method:
public interface KitchenStaff { public String getDetails();}
The Chef class, shown here, implements the KitchenStaff class. It contains three class variables and a constructor:
import java.util.ArrayList;import java.util.List;public class Chef implements KitchenStaff { private String name; private String role; private List<KitchenStaff> staffList; Chef(String name, String role) { this.name = name; this.role = role; staffList = new ArrayList<KitchenStaff>(); }
The next section of the Chef class contains three methods—add(), fire(), and getStaffList():
public void add(Chef chef) { staffList.add(chef);}public void fire(Chef ...
Read now
Unlock full access