Untitled
unknown
plain_text
a year ago
3.1 kB
1
Indexable
Never
namespace ConsoleApp3 { internal class Program { static void Main(string[] args) { Console.Write("Введите свойства книги 1 через запятую (название, автор, год, кол-во страниц, издатель)"); string[] book = Console.ReadLine().Split(','); FeaturesBooks Book1 = new FeaturesBooks(book[0], book[1], Convert.ToInt32(book[2]), Convert.ToInt32(book[3]), book[4]); Book1.Name = "Портрет Дориана Грея"; Console.WriteLine(Book1.Info); Console.Write("Введите свойства книги 2 через запятую (название, автор, год, кол-во страниц, издатель)"); book = Console.ReadLine().Split(','); MethodBooks Book2 = new MethodBooks(book[0], book[1], Convert.ToInt32(book[2]), Convert.ToInt32(book[3]), book[4]); Book2.setName("Портрет Дориана Грея"); Console.WriteLine(Book2.getInfo()); } } public class FeaturesBooks { string name; string author; int year; int pagesCount; public string Publisher { get { return Publisher; } set { Publisher = "пицца"; } } public FeaturesBooks(string name, string author, int year, int pagesCount, string publisher) { this.name = name; this.author = author; this.year = year; this.pagesCount = pagesCount; this.Publisher = publisher; } public string Name { get { return name; } set { name = value; } } public string Author { get { return author; } } public string Info { get { return $"{name} - {author} {year} г., {pagesCount} стр., издательство {Publisher}"; } } } public class MethodBooks { string name; string author; int year; int pagesCount; string publisher; public MethodBooks(string name, string author, int year, int pagesCount, string publisher) { this.name = name; this.author = author; this.year = year; this.pagesCount = pagesCount; this.publisher = publisher; } public string getName() { return name; } public void setName(string name) { this.name = name; } public string getAuthor() { return author; } public string getInfo() { return $"{name} - {author} {year} г., {pagesCount} стр., издательство {publisher}"; } } }