Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Laba3
- {
- class Human
- {
- private string _name;
- private int _age;
- public string Name
- {
- set
- {
- if (value == "")
- {
- Console.WriteLine("Enter your name, please.");
- }
- else
- {
- _name = value;
- }
- }
- }
- public int Age
- {
- set
- {
- if (value <= 0)
- {
- Console.WriteLine("Should be positive !");
- }
- else
- {
- _age = value;
- }
- }
- get { return _age; }
- }
- public void out_info()
- {
- Console.WriteLine($"Name: {_name} Age: {Age}");
- }
- }
- class Student:Human
- {
- public float average_grade;
- private int _class;
- public bool scholarship;
- public int Class {
- set
- {
- if (value <= 0)
- {
- Console.WriteLine("Check your info about your studying year!");
- }
- else
- {
- _class = value;
- }
- }
- get { return _class; }
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Human ellia = new Human();
- Student feda = new Student();
- feda.Age = 19;
- feda.out_info();
- ellia.out_info();
- ellia.Age = -9;
- ellia.Name = "Ellia";
- ellia.out_info();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement