Question

Create a class called Restaurant that is the base class for all restaurants. It should have attributes for the restaurants nFastFood.java FastFoodDemo.Java Restaurant.Java New Full Screen 1

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE:

Restaurant class:

class Restaurant
{
    private int seats;
    protected String name;
    Restaurant(int seats,String name)
    {
        this.seats = seats;
        this.name = name;
    }
    public int getSeats()
    {
        return seats;
    }
    public void setSeats(int seats)
    {
        this.seats = seats;
    }
    public String toString()
    {
        return name+"\n"+seats;
    }
}

FastFood class:

class FastFood extends Restaurant
{
    private String slogan;
    FastFood(int s,String n,String sl)
    {
        super(s,n);
        slogan = sl;
    }
    public String getSlogan()
    {
        return slogan;
    }
    public void setSlogan(String s)
    {
        slogan = s;
    }
    public void increaseSeats(int s)
    {
        int x = super.getSeats();
        x = x + s;
        super.setSeats(x);
    }
    public String toString()
    {
        return super.name+" - "+slogan+"\n"+super.getSeats()+"\n";
    }
}

FastFoodDemo class:

import java.util.*;
class FastFoodDemo
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int s = sc.nextInt();
sc.nextLine();
String n = sc.nextLine();
String sl = sc.nextLine();
int inc = sc.nextInt();
FastFood ob = new FastFood(s,n,sl);
ob.increaseSeats(inc);
System.out.println(ob);
}
}

OUTPUT:

In the right image, blue text is input and black text is output.

Class Edit Tools Options Options 25 Restaurant X FastFood X FastFood Demo X Compile Undo Cut Copy Paste Find... Close Source

Add a comment
Know the answer?
Add Answer to:
Create a class called Restaurant that is the base class for all restaurants. It should have...
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
  • Design a restaurant class to help manage multiple restaurants and their menus equiremen The class...

    program is C# Design a restaurant class to help manage multiple restaurants and their menus equiremen The class contains: 1) A static int variable named storeCounter that starts at 1 and increments for each new restaurant item that is created 2) A string array called Menu 3) An int variable called StoreID 4) A Boolean variable called isOpen 5) A no-argument constructor that performs the following a. Sets storelD to storeCounter, then increments storeCounter b. Sets isOpen to true c....

  • Generics Objectives: OOWorking with a Generic Class 1. Create a class called Node that is Generic...

    java Generics Objectives: OOWorking with a Generic Class 1. Create a class called Node that is Generic. The class has one class attribute that is an element. It will need 2 Constructors, a setter and getter for the class attribute, and a toString method. 2. Write a Lab10Driver that will: Instantiate a Node Integer object with no value. I. Il. Ill. IV. a. Then call the set method to set the value to 5. Instantiate a Node String object with...

  • Use inheritance to create a new class AudioRecording based on Recording class that: it will retain...

    Use inheritance to create a new class AudioRecording based on Recording class that: it will retain all the members of the Recording class, it will have an additional field bitrate (non-integer numerical; it cannot be modified once set), its constructors (non-parametrized and parametrized) will set all the attributes / fields of this class (reuse code by utilizing superclass / parent class constructors): Non-parametrized constructor should set bitrate to zero, If arguments for the parametrized constructor are illegal or null, it...

  • CS1180 Lab 9 Students will learn how to create a user-defined class. Part 1. Create a...

    CS1180 Lab 9 Students will learn how to create a user-defined class. Part 1. Create a user-defined class. 1. Follow the UML diagram below to create a user-defined class, Automobile When implementing the constructors, use the default value of 0 for numeric types and "unknown" for VehicleMake and VehicleModel when not given as a parameter Implement the toString method in a format ofyour choosing, as long as it clearly includes information for all four member variables Make sure to include...

  • Problem 5: Monster Factory (10 points) (Game Dev) Create a Monster class that maintains a count...

    Problem 5: Monster Factory (10 points) (Game Dev) Create a Monster class that maintains a count of all monsters instantiated and includes a static method that generates a new random monster object. In software engineering, a method that generates new instances of classes based on configuration information is called the Factory pattern. UML Class Diagram: Monster - name: String - health: int - strength: int - xp: int + spawn(type:String): Monster + constructor (name: String, health: int, strength: int, xp:...

  • Create a NetBeans project called "Question 1". Then create a public class inside question1 package called Author according to the following information (Make sure to check the UML diagram)

    Create a NetBeans project called "Question 1". Then create a public class inside question1 package called Author according to the following information (Make sure to check the UML diagram) Author -name:String -email:String -gender:char +Author(name:String, email:String, gender:char) +getName():String +getEmail):String +setEmail (email:String):void +getGender():char +tostring ):String . Three private instance variables: name (String), email (String), and gender (char of either 'm' or 'f'): One constructor to initialize the name, email and gender with the given values . Getters and setters: get Name (), getEmail() and getGender (). There are no setters for name and...

  • All question base on Java Se 8 Consider the Top class i public abstract class Topí...

    All question base on Java Se 8 Consider the Top class i public abstract class Topí 2 private 3 protected String name; 4 public intx - 12; int age; e public Top(String name)[ this.namename age0; System.out.println(x); 10 12 public abstract void foo(String f); 13 Create a Middle class that extends the Top class. The class should have a single constructor that takes two input parameters: a String (for name) and int (for age). Your constructor should not have any redundant...

  • Assignment Requirements I have also attached a Class Diagram that describes the hierarchy of the inheritance...

    Assignment Requirements I have also attached a Class Diagram that describes the hierarchy of the inheritance and interface behaviors . The link to the PDF of the diagram is below MotorVehical.pdf Minimize File Preview User Define Object Assignment: Create a Intellij Project. The Intellij project will contain three user defined classes. The project will test two of the User Define Classes by using the invoking each of their methods and printing the results. You are required to create three UML...

  • The current code I have is the following: package uml; public class uml {        public...

    The current code I have is the following: package uml; public class uml {        public static void main(String[] args) {              // TODO Auto-generated method stub        } } class Account { private String accountID; public Account(String accountID) { this.accountID = accountID; } public String getAccountID() { return accountID; } public void setAccountID(String accountID) { this.accountID = accountID; } @Override public String toString() { return "Account [accountID=" + accountID + "]"; } } class SuppliesAccount extends Account { private...

  • You will have to write one method in the GradeHistogram class The method should be called...

    You will have to write one method in the GradeHistogram class The method should be called printDataRow It has two formal parameters A string for the row label An int for how many asterisks are in the row The method will print The string that was passed in followed by a colon and a space The asterisks (*) After the last asterisk it will print a newline Example: the statement: printDataRow("Number of As", 7); would output the following Number of...

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
ADVERTISEMENT