Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class First
- {
- public static void Main(string[] args)
- {
- Human oleg = new Human();
- Animal dog = new Animal();
- Phone iphoneX = new Phone();
- Computer macbookWindows = new Computer();
- }
- }
- class Human
- {
- string sex = null;
- public Human()
- {
- Console.WriteLine("Олег родился");
- intro();
- }
- void intro()
- {
- Console.WriteLine("Привет! Я - человек. Выбери мне имя, пол, возраст и научите ездить");
- }
- public void maleOrfemale()
- {
- Console.WriteLine("1 - male, 2 - female");
- }
- public string chooseSex (int decision)
- {
- if (decision == 1) this.sex = "Male"; //this присваивает значение глобальной переменной класса
- if (decision == 2) this.sex = "Female";
- return sex;
- }
- public void writeSex()
- {
- Console.WriteLine(sex + "from object");
- }
- }
- class Animal
- {
- public Animal()
- {
- Console.WriteLine("СОБАКА " + 12 + "лет!");
- }
- }
- class Phone
- {
- public Phone()
- {
- Console.WriteLine("Apple Iphone");
- }
- }
- class Text
- {
- }
- class Computer
- {
- public Computer()
- {
- Console.WriteLine("Minecraft запустись");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement