?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Difficult

Program Design Using Related Classes

Free
APCSA-Y6ELJM

Consider the following requirement.

A company owns a chain of restaurants at different locations in the state. It has two different types of restaurants (fast food and family-style), each with distinct business practices. The company wants to enforce similar functions across both restaurant types, but it allows differences in how these functions are defined for each type.

Each individual restaurant within a specific restaurant type will implement the functions exactly the same.

What would be the BEST design for the company in programming terms?

A
public interface Restaurant 
{
    // data and methods not shown
}

public class FastFoodRestaurant implements Restaurant 
{
    // data and methods not shown
}

public class FamilyStyleRestaurant implements Restaurant
{
    // data and methods not shown
}

// all fast food restaurants extend FastFoodRestaurant in this fashion    
public class Restaurant100 extends FastFoodRestaurant 
{
    // data and methods not shown
}

// all family-style restaurants extend FamilyStyleRestaurant in this fashion    
public class Restaurant300 extends FamilyStyleRestaurant
{
    // data and methods not shown
}
B
public class Restaurant 
{
    // data and methods not shown
}

public class FastFoodRestaurant extends Restaurant 
{
    private int restaurantID;  // restaurant id number
    private String restaurantName;
    // other data and methods not shown
}

public class FamilyStyleRestaurant extends Restaurant
{
    private int restaurantID;  // restaurant id number
    private String restaurantName;
    // other data and methods not shown
}
C
public class Restaurant 
{
    // data and methods not shown
}

public class FastFoodRestaurant extends Restaurant 
{
    // data and methods not shown
}

public class FamilyStyleRestaurant extends Restaurant
{
    // data and methods not shown
}

// all fast food restaurants extend FastFoodRestaurant in this fashion    
public class Restaurant100 extends FastFoodRestaurant 
{
    // data and methods not shown
}

// all family-style restaurants extend FamilyStyleRestaurant in this fashion    
public class Restaurant300 extends FamilyStyleRestaurant
{
    // data and methods not shown
}
D
public abstract class Restaurant 
{
    // data and methods not shown
}

public class FastFoodRestaurant implements Restaurant 
{
    // data and methods not shown
}

public class FamilyStyleRestaurant implements Restaurant
{
    // data and methods not shown
}

// all fast food restaurants extend FastFoodRestaurant in this fashion    
public class Restaurant100 extends FastFoodRestaurant 
{
    // data and methods not shown
}

// all family-style restaurants extend FamilyStyleRestaurant in this fashion    
public class Restaurant300 extends FamilyStyleRestaurant
{
    // data and methods not shown
}
E
public interface Restaurant 
{
    // data and methods not shown
}

public class FastFoodRestaurant implements Restaurant 
{
    private int restaurantID;  // restaurant id number
    private String restaurantName;
    // other data and methods not shown
}

public class FamilyStyleRestaurant implements Restaurant
{
    private int restaurantID;  // restaurant id number
    private String restaurantName;
    // other data and methods not shown
}