Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace hotel
- {
- class Hotel
- {
- private float length = 1;
- private float width = 1;
- public Hotel(float length, float width)
- {
- Length = length;
- Width = width;
- }
- public float Length
- {
- get { return this.length; }
- set
- {
- if (value <= 0.0f)
- this.length = 1.0f;
- else
- this.length = value;
- }
- }
- public float Width
- {
- get { return this.width; }
- set
- {
- if (value <= 0.0f)
- this.width = 1.0f;
- else
- this.width = value;
- }
- }
- public float Perimeter
- {
- get
- {
- return (Length + Width) * 2;
- }
- }
- public float Area
- {
- get
- {
- return (Length * Width);
- }
- }
- public override string ToString()
- {
- return string.Format("A szoba területe: " + Area);
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- while (true)
- {
- float length, width;
- Console.WriteLine("Írd be a szoba szélességét: ");
- width = float.Parse(Console.ReadLine());
- Console.WriteLine("Írd be a szoba hosszát: ");
- length = float.Parse(Console.ReadLine());
- if (length < 0.0f || width < 0.0f)
- break;
- Hotel sz1 = new Hotel(length, width);
- Console.WriteLine(sz1);
- Console.WriteLine("Nyomj entert az új szoba kiszámolásához!");
- Console.ReadKey();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement