Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Pr1
- {
- class Avto
- {
- public string numb;
- public string model;
- public string color;
- public string fullName;
- public void PrintInfo(string numb, string model, string color, string fullName)
- {
- Console.WriteLine("Auto Numb: {0} \nCar Model: {1} \nCar Color: {2}, \nOwner Full Name: {3} \n", numb, model, color, fullName);
- }
- }
- class Book
- {
- private string autor = "[NULL]";
- private string name = "[NULL]";
- private string pubH = "[NULL]";
- private int pagesN = -1;
- private int pubY = -1;
- private static double price = 30;
- public void Print()
- {
- Console.WriteLine("Autor: {0} \nBook Name: {1} \nPublishing House: {2} \nPages Numb: {3} \nPublishing Year: {4} \n", this.autor, this.name, this.pubH, this.pagesN, this.pubY);
- }
- public void Default()
- {
- this.autor = "L.N. Tolstoy";
- this.name = "War and Peace";
- this.pubH = "Ecsmo";
- this.pagesN = 1225;
- this.pubY = 1867;
- }
- public void SetPrice(double price)
- {
- Book.price = price;
- }
- public double RentPrice(int s)
- {
- double cust = price * s;
- return cust;
- }
- }
- class Person
- {
- public string name;
- public int age;
- public Person(string n)
- {
- Random rand = new Random();
- name = n;
- age = rand.Next(1, 100);
- }
- public void Say()
- {
- Random rand = new Random();
- int rand_talk = rand.Next(2, 3);
- if (rand_talk == 1)
- Console.WriteLine("Привет, меня зовут {0}", name);
- else
- Console.WriteLine("Мне {0} лет, а тебе?", age);
- }
- }
- class MainClass
- {
- public static void Main(string[] args)
- {
- // Задание 1
- Avto myCar1 = new Avto();
- Avto myCar2 = new Avto();
- myCar1.numb = "RCU 891";
- myCar1.model = "Volkswagen “polo“";
- myCar1.color = "Blue";
- myCar1.fullName = "Jane Olivier Andrey";
- myCar2.numb = "ABA D12";
- myCar2.model = "Kia “Cerato“";
- myCar2.color = "Black";
- myCar2.fullName = "Jane Olivier Andrey";
- myCar1.PrintInfo(myCar1.numb, myCar1.model, myCar1.color, myCar1.fullName);
- myCar2.PrintInfo(myCar2.numb, myCar2.model, myCar2.color, myCar2.fullName);
- // Задание 2
- Book myBook = new Book();
- myBook.Default();
- myBook.Print();
- myBook.SetPrice(20);
- Console.WriteLine("Rent Cost: {0} \n", myBook.RentPrice(3));
- // Задание 3
- Person ti = new Person("Pasha");
- ti.Say();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement