Question

Using the following code: store.py from abc import ABC,abstractmethod class Store(ABC): #creating a abstract class name=''...

Using the following code:

store.py

from abc import ABC,abstractmethod
class Store(ABC): #creating a abstract class
name='' #declaring attributes in class
address=''
status=''
sales_tax_percentage=0.0

def __init__(self,name,address,status,sales_tax_percentage): #init method to initialize the class attributes
self.name=name
self.address=address
self.status=status
self.sales_tax_percentage=sales_tax_percentage

def get_name(self): #Getter and setter methods for variables
return self.name

def set_name(self,name):
self.name=name

def get_address(self):
return self.address

def set_address(self,address):
self.address=address

def set_status(self,status):
self.status=status

def get_status(self):
return self.status

def set_sales_tax_percentage(self,sales_tax_percentage):
self.sales_tax_percentage=sales_tax_percentage

def get_sales_tax_percentage(self):
return self.sales_tax_percentage

def is_store_open(self): #check store status or availability
if self.status=="open": #Return true if store is open
return True
elif self.status=="closed": #Return false if store is closed
return False

def calculate_total_sales_tax(self): #abstract method
pass

def calculate_total_sales(self): #abstract method
pass

  1. Create a file called restaurant.py which contains a class called Restaurant which is type of Store. It should possess all the attributes and functions present in the Store class without having to re-implement those in the Restaurant class. The Restaurant class is made up of the following:
    • Attributes/Properties o Total number of people served
      • Max occupancy o Current occupancy o Price per person
    • Functions/Functionality o Constructor which provides the ability to pass and set the values for the various attributes
      • seat_patrons should do the following:
        • Take the number of people to be seated as input
        • Update the values of the appropriate attributes
        • If number of people to be seated does not exceed or equals the max occupancy
          • Print “Welcome to [replace with name of restaurant]” • Return True
        • If number of people to be seated exceeds the max occupancy
          • Print “We are at capacity, we appreciate your patience”
          • Return False
      • serve_patrons which should do the following:
        • Take the number of people to serve as input
        • Update the values of the appropriate attributes
        • Return the number of people being served currently o checkout_patrons (this is when the patrons are ready to leave the restaurant) which should do the following:
        • Take the number of people leaving as input
        • Update the values of the appropriate attributes
        • Return the current occupancy of the restaurant o Create a getter and setter for the attribute: Price per person
0 0
Add a comment Improve this question Transcribed image text
Answer #1

This is Restaurant class which extending the store class defined in the question. As the ques states, without implementing the store class... I just extend it to fetch the name of restaurant.

class Restaurant extends store{
   int total_people_served, max_occupancy, current_occupancy;
   double price_per_person;
  
   public Restaurant(int total_people_served, int max_occupancy, int current_occupancy, double price_per_person){
       this.total_people_served= total_people_served;
       this.max_occupancy= max_occupancy;
       this.current_occupancy= current_occupancy;
       this.price_per_person= price_per_person;
          
   }
  
  
   public int seat_patrons(int numOfPeopleSeated){
         
       int check= this.current_occupancy+numOfPeopleSeated;
       if(check <= this.max_occupancy){
           serve_patrons(numOfPeopleSeated);
           this.total_people_served+=numOfPeopleSeated;
           this.current_occupancy+=numOfPeopleSeated;
           return 1 ;
       }
       else
           return 0;
       }
     
      public void serve_patrons(int num){
         
       System.out.println("number of people being served: "+ num);
         
         
   }
     
      public void checkOut(int checkout_total){
         
       this.current_occupancy-=checkout_total;
       System.out.println("current occupancy: "+ this.current_occupancy);
         
       }
public static void main(String[] args){
      
       int ch, ch_in;
       Scanner sc= new Scanner(System.in);
       store s1= new store();
       s1.setName("KFC");
       Restaurant r1= new Restaurant(100, 15, 10, 500);
       System.out.println("Enter number of people arrive: ");
       ch_in= sc.nextInt();
       int res= r1.seat_patrons(ch_in);
       if(res == 1){
           System.out.println("Welcome to "+ s1.getName());
       }else
           System.out.println("We are at capacity, we appreciate your patience");
       System.out.println("Enter number of people for checkout: ");
       ch= sc.nextInt();
       r1.checkOut(ch);
      
   }
}

The Store class:

public store(){
  
}

public store(String name,String address, int status, double sales_tax_percentage){
  
   this.name= name;
   this.address=address;
   this.status=status;
   this.sales_tax_percentage= sales_tax_percentage;
  
}

public String getName(){
   return this.name;
}
public void setName(String name){
   this.name= name;
}

public String getAddress(){
   return this.address;
}

public void setAddress(String address){
   this.address= address;
}

public int getStatus(){
   return this.status;
}
public void setStatus(int status){
   this.status= status;
}
public double getsales_tax_percentage(){
   return this.sales_tax_percentage;
}

public void settsales_tax_percentage(double sales_tax_percentage){
   this.sales_tax_percentage= sales_tax_percentage;
}
}

Now run the program and outputs are follows:

in here max capacity= 15, So when I gave input 4 as number of people arrived

current occupancy was 10, 10+4 = 14,

14< 15, that's why it prints welcome message.

Then check out people input is given as 3, so,

current occupancy= 14,, 14- 3= 11,

and it shows current occupancy as 11 in output.

On 2nd time running of code:

I gave input as 7,

So, current occupancy= 10, i.e. 10+7= 17,

Max occupancy = 15, Which is smaller then current arrival of people

Thus shows "the patience" message.

Images showing the code implementation on Notepad++


Add a comment
Know the answer?
Add Answer to:
Using the following code: store.py from abc import ABC,abstractmethod class Store(ABC): #creating a abstract class name=''...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Here is a sample run of the tester program: Make sure your program follows the Java...

    Here is a sample run of the tester program: Make sure your program follows the Java Coding Guidelines. Consider the following class: /** * A store superclass with a Name and Sales Tax Rate */ public class Store {      public final double SALES_TAX_RATE = 0.06;      private String name;           /**      * Constructor to create a new store      * @param newName      */      public Store(String newName)      {           name = newName;      }     ...

  • PYTHON 3.6 Overview In this assignment we implement a class called TripleString. It consists of a...

    PYTHON 3.6 Overview In this assignment we implement a class called TripleString. It consists of a few instance attribute and a few instance methods to support those attributes. In the next assignment, the TripleString class will help us create a more involved application. Before we do that though, we have to thoroughly test our TripleString implementation. Specifications The class TripleString will contain symbolic constants, instance attributes, and instance methods. ▶ Class symbolic constants This class has 3 symbolic constants, which...

  • In Java, Write a class encapsulating a restaurant,which inherits from Store. A restaurant has the following...

    In Java, Write a class encapsulating a restaurant,which inherits from Store. A restaurant has the following additional attributes: how many people are served every year and the average price per person. code the constructor, accessors, mutators, toString and equals method of the new subclass; also code a method returning the average taxes per year. You also need to include a client class to test your code for both the parent class and the subclass. Code for Store below(Super class aka...

  • USING JAVA, Class Design: Person The Person class is intended to be an abstract and simplified representation of a pers...

    USING JAVA, Class Design: Person The Person class is intended to be an abstract and simplified representation of a person. Each person will have an array of "friends" - which are other "Person" instances. Data to Store (2 Points) Name private instance variable with only private setter (2 Points) Friends private instance array with neither getter nor setter Actions Constructor o 1 Point) Take in as argument the name of the person (enforce invariants) o (1 Point) Initialize the array...

  • Use your Food class, utilities code, and sample data from Lab 1 to complete the following...

    Use your Food class, utilities code, and sample data from Lab 1 to complete the following Tasks. def average_calories(foods):     """     -------------------------------------------------------     Determines the average calories in a list of foods.     foods is unchanged.     Use: avg = average_calories(foods)     -------------------------------------------------------     Parameters:         foods - a list of Food objects (list of Food)     Returns:         avg - average calories in all Food objects of foods (int)     -------------------------------------------------------     """ your code here is the...

  • ***IN PYTHON 2.7****Augment the following code with a new class named 'Coin'. Coin should inherit from...

    ***IN PYTHON 2.7****Augment the following code with a new class named 'Coin'. Coin should inherit from Die, with the following modifications; The constructor should not take any arguments; a coin always has two sides add a flip() method that uses the roll() method from the parent class. If roll returns 1; flip should return "HEADS". If roll returns a 2, flip should return "TAILS" Do not override the roll or rollMultiple methods from the parent class #!/usr/bin/python # your class...

  • class Livestock: def __init__(self,name,price_in,utilizations): self.name,self.price_in,self.utilizations = name,float(price_in),utilizations def __lt__(self,other): if self.utilizations is None: return True elif...

    class Livestock: def __init__(self,name,price_in,utilizations): self.name,self.price_in,self.utilizations = name,float(price_in),utilizations def __lt__(self,other): if self.utilizations is None: return True elif other.utilizations is None: return False else: return self.utilizations.count(';') < other.utilizations.count(';') def __eq__(self,other): return self.name == other.name def __repr__(self): return ("{}, {}".format(self.name,self.price_in)) raw_livestock_data = [ # name, price_in, utilizations ['Dog', '200.0', 'Draught,Hunting,Herding,Searching,Guarding.'], ['Goat', '1000.0', 'Dairy,Meat,Wool,Leather.'], ['Python', '10000.3', ''], ['Cattle', '2000.75', 'Meat,Dairy,Leather,Draught.'], ['Donkey', '3400.01', 'Draught,Meat,Dairy.'], ['Pig', '900.5', 'Meat,Leather.'], ['Llama', '5000.66', 'Draught,Meat,Wool.'], ['Deer', '920.32', 'Meat,Leather.'], ['Sheep', '1300.12', 'Wool,Dairy,Leather,Meat.'], ['Rabbit', '100.0', 'Meat,Fur.'], ['Camel', '1800.9', 'Meat,Dairy,Mount.'], ['Reindeer', '4000.55', 'Meat,Leather,Dairy,Draught.'],...

  • Type up the GeometricObject class (code given on the back of the paper). Name this file Geometric...

    Python only please, thanks in advance. Type up the GeometricObject class (code given on the back of the paper). Name this file GeometricObjectClass and store it in the folder you made (xxlab14) 1. Design a class named Rectangle as a subclass of the GeometricObject class. Name the file RectangleClass and place it in the folder. 2. The Rectangle class contains Two float data fields named length and width A constructor that creates a rectangle with the specified fields with default...

  • Task 2: SecretWord class: Download and save a copy of LinkedLists.py (found at the bottom of...

    Task 2: SecretWord class: Download and save a copy of LinkedLists.py (found at the bottom of this assignment page on eClass). In this file, you have been given the complete code for a LinkedList class. Familiarize yourself with this class, noticing that it uses the Node class from Task 1 and is almost identical to the SLinkedList class given in the lectures. However, it also has a complete insert(pos, item) method (which should be similar to the insert method you...

  • JAVA The following is about creating a class Ruler and testing it. ​​(i) Create a class...

    JAVA The following is about creating a class Ruler and testing it. ​​(i) Create a class Ruler with the attributes brand (which is a string) and length (an integer) which are used to store the brand and length of the ruler respectively. Write a constructor Ruler(String brand, int length) which assigns the brand and length appropriately. Write also the getter/setter methods of the two attributes. Save the content under an appropriate file name. Copy the content of the file as...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT