Question: Write a program that contains a custom class called Restaurant . The Restaurant class will have the following private member variables: name : string, address
Write a program that contains a custom class called Restaurant.
The Restaurant class will have the following private member variables: name: string, address: string, genre: string, numOfRatings: int, rating: double
You will need to implement public getters and setters (accessors and mutators) for the first three fields: name, address, and genre. In addition you will need to implement the following public member functions. rate(score: int): void, getRating( ): double
display( ): void
The rate(int) member function should take a rating between 1 and 10 and alter the rating member variable of that instance by an appropriate amount given the current rating and number of ratings. It should also increment the numOfRatings by one to reflect the new rating.
The getRating( ) member function should just return the value of the rating member variable. (Basic getter.) I only listed it separately so that you would know I don't want you to create a setter for that field. It's read only. You set the rating of a Restaurant by rating the Restaurant.
The display( ) member function is just a convenience function to print all of the information about an instance of Restaurant to the screen.
C++
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
