Write a program in which you declare a class HotelRoom. The class has the fol- lowing private instance variables: the room number (a string), the room capacity (an integer representing the maximum number of people the room can accom- modate), the occupancy status (an integer, 0 if the room is not occupied, other- wise the number of occupants in the room), and the daily rate (a double). Include a three-argument constructor that sets the room number to its first argument, the room capacity to the second argument, the room rate to the third argument, and that sets the room occupancy status to 0. Compile and test the program. Note: We will continue this exercise in the next section.
1
Expert's answer
2016-04-27T10:51:05-0400
using System;
namespace HotelRoom { class HotelRoom { string room_number; int room_capacity; int occupancy_status; double daily_rate;
public HotelRoom(string room_num, int room_cap, double daily_ra, int occup_stat = 0) { room_number = room_num; room_capacity = room_cap; daily_rate = daily_ra; occupancy_status = occup_stat; } } }
using System;
namespace HotelRoom { class Program { static void Main(string[] args) { HotelRoom hr101 = new HotelRoom("101", 4, 200); HotelRoom hr102 = new HotelRoom("102", 2, 100.75, 2); } } }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment