Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write all the contents of a Java file named ‘ Restaurant.java ’. This file conta

ID: 3770011 • Letter: W

Question

Write all the contents of a Java file named ‘Restaurant.java’. This file contains the class Restaurant that represents some data about a Restaurant.

Every Restaurant is identified by its 3 attributes: a category (like “Chinese” or “Mediterranean”), a rating in stars (between 0 to 5 stars), and the indication that it has vegetarian food or not (true or false).

Write syntactically correct Java code for all these 3 attributes, its 3 accessor methods(get methods), its 3 mutator methods (set methods), and two appropriate constructor methods (one default and one with all attributes as parameters) that initialize all its instance variables. You must also write an equals method that compares all attributes of the Restaurant for equality. There is no need to add comments to the program. If you add comments you are wasting your time. Write only the required sentences.

Explanation / Answer

import java.util.Objects;



public class Resturant {

  
    private String category;
    private int rating;
    private boolean vegetarian;
    public Resturant()
    {
       
    }
    public Resturant(String category, int rating, boolean vegetarian) {
        this.category = category;
        this.rating = rating;
        this.vegetarian = vegetarian;
    }
  

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public int getRating() {
        return rating;
    }

    public void setRating(int rating) {
        this.rating = rating;
    }

    public boolean isVegetarian() {
        return vegetarian;
    }

    public void setVegetarian(boolean vegetarian) {
        this.vegetarian = vegetarian;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Resturant other = (Resturant) obj;
        if (!Objects.equals(this.category, other.category)) {
            return false;
        }
        if (this.rating != other.rating) {
            return false;
        }
        if (this.vegetarian != other.vegetarian) {
            return false;
        }
        return true;
    }

  

   
   
   
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote