-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnewtest.cpp
48 lines (40 loc) · 981 Bytes
/
newtest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <string>
using namespace std;
class Restaurant
{ // Info about a restaurant
public:
void SetName(string restaurantName)
{ // Sets the restaurant's name
name = restaurantName;
}
void SetRating(int userRating)
{ // Sets the rating (1-5, with 5 best)
rating = userRating;
}
void Print() // Prints name and rating on one line
{
cout << name << " -- " << rating << endl;
}
private:
string name;
int rating;
};
// Prints name and rating on one line
// void Restaurant::Print()
// {
// cout << name << " -- " << rating << endl;
// }
int main()
{
Restaurant favLunchPlace;
Restaurant favDinnerPlace;
favLunchPlace.SetName("Central Deli");
favLunchPlace.SetRating(4);
favDinnerPlace.SetName("Friends Cafe");
favDinnerPlace.SetRating(5);
cout << "My favorite restaurants: " << endl;
favLunchPlace.Print();
favDinnerPlace.Print();
return 0;
}