MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / main

Function main

Hackerrank_problems/Hotel Price/solution.cpp:30–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28};
29
30int main() {
31 int n;
32 cin >> n;
33//loop for inputing room quantities
34 vector<HotelRoom*> rooms;
35 for (int i = 0; i < n; ++i) {
36 string room_type;
37 int bedrooms;
38 int bathrooms;
39 cin >> room_type >> bedrooms >> bathrooms;
40 if (room_type == "standard") {
41 rooms.push_back(new HotelRoom(bedrooms, bathrooms));
42 } else {
43 rooms.push_back(new HotelApartment(bedrooms, bathrooms));
44 }
45 }
46
47 int total_profit = 0;
48//loop to sum the total profit
49 for (auto room : rooms) {
50 total_profit += room->get_price();
51 }
52 cout << total_profit << endl;
53//loop for deleting room
54 for (auto room : rooms) {
55 delete room;
56 }
57 rooms.clear();
58
59 return 0;
60}

Callers

nothing calls this directly

Calls 1

get_priceMethod · 0.45

Tested by

no test coverage detected