Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace ConsoleApp1
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- //Tarolo[] tarolok = { new Tarolo("Lekvár", 80, Tarolo.Besorolas.KurvaNehez), new Tarolo("Uborka", 40, Tarolo.Besorolas.EbbeMegLehetPakolni), new Tarolo("Kolbász", 150, Tarolo.Besorolas.KurvaNehez) };
- //foreach (Tarolo item in tarolok)
- //{
- // Console.WriteLine(item.Cimke);
- //}
- //Array.Sort(tarolok);
- //foreach (Tarolo item in tarolok)
- //{
- // Console.WriteLine(item.Cimke);
- //}
- Lodgings lodgings = new Lodgings(3, 25000, 3, 5, 30000);
- Console.WriteLine(lodgings.Book(3));
- Console.WriteLine(lodgings.IsBooked());
- Console.WriteLine(lodgings.MoveIn(1));
- }
- }
- }
- ----------------------------------------------------------------------
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp1
- {
- internal interface IRealEstate
- {
- int TotalValue();
- }
- }
- ----------------------------------------------------------------------
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp1
- {
- internal interface IRent
- {
- int GetCost(int months);
- bool IsBooked();
- bool Book(int months);
- }
- }
- ----------------------------------------------------------------------
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp1
- {
- internal abstract class Flat : IRealEstate
- {
- protected double area;
- protected int roomsCount;
- protected int inhabitantsCount;
- protected int unitPrice;
- double Area { get; set; }
- int RoomsCount { get; set; }
- int InhabitantsCount { get; set; }
- int UnitPrice { get; set; }
- protected Flat(double area, int roomsCount, int inhabitantsCount, int unitPrice)
- {
- this.area = area;
- this.roomsCount = roomsCount;
- this.inhabitantsCount = inhabitantsCount;
- this.unitPrice = unitPrice;
- }
- public abstract bool MoveIn(int newInhabitants);
- public int GetInhabitamtsCount()
- {
- return this.inhabitantsCount;
- }
- public int TotalValue()
- {
- return (int)(this.UnitPrice * this.area);
- }
- public override string ToString()
- {
- return $"{this.roomsCount} {this.inhabitantsCount} {this.area} {this.unitPrice}";
- }
- }
- }
- ----------------------------------------------------------------------
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp1
- {
- internal class Lodgings : Flat, IRent
- {
- protected int bookedMonths;
- public Lodgings(int bookedMonths, double area, int roomsCount, int inhabitantsCount, int unitPrice) : base(area, roomsCount, inhabitantsCount, unitPrice)
- {
- this.bookedMonths = 0;
- this.inhabitantsCount = 0;
- }
- public bool Book(int months)
- {
- return IsBooked();
- }
- public int GetCost(int months)
- {
- return (TotalValue() / 240) / inhabitantsCount;
- }
- public bool IsBooked()
- {
- if (bookedMonths == 0) return false;
- return true;
- }
- public override bool MoveIn(int newInhabitants)
- {
- if (IsBooked() == true && (inhabitantsCount + newInhabitants) < 9 && ((inhabitantsCount + newInhabitants) / area) > 2)
- {
- inhabitantsCount += newInhabitants;
- return true;
- }
- return false;
- }
- public override string ToString()
- {
- return $"{base.ToString()} + {bookedMonths}";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement