Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace BookstoreLibrary
- {
- public class Book : Product
- {
- private short _numberOfPages;
- private short _year;
- private double _rating;
- public short NumberOfPages
- {
- get => _numberOfPages;
- set
- {
- if (value > 0)
- _numberOfPages = value;
- else
- throw new ArgumentException("Количество страниц должно быть положительным!");
- }
- }
- public short Year
- {
- get => _year;
- set
- {
- if (value >= 1990 && value <= 2020)
- _year = value;
- else
- throw new ArgumentException("Год издания книги должен принимать значение в диапазоне [1990, 2020]");
- }
- }
- public double Rating
- {
- get => _rating;
- set
- {
- if (value >= 0 && value < 5)
- _rating = value;
- else
- throw new ArgumentException("Рейтинг книги должен принимать значение в диапазоне [0, 5)");
- }
- }
- public string GetShortInfo()
- {
- return "";
- }
- public override string ToString()
- {
- return base.ToString() + GetShortInfo();
- }
- }
- }
Add Comment
Please, Sign In to add comment