Essays.club - Получите бесплатные рефераты, курсовые работы и научные статьи
Поиск

Классы языка C#

Автор:   •  Июнь 19, 2023  •  Лабораторная работа  •  2,661 Слов (11 Страниц)  •  112 Просмотры

Страница 1 из 11

МИНИСТЕРСТВО ОБРАЗОВАНИЯ И НАУКИ РОССИЙСКОЙ ФЕДЕРАЦИИ

«Сибирский государственный университет науки и технологий

имени академика М.Ф. Решетнева»

Отчет по лабораторной работе №3

«КЛАССЫ ЯЗЫКА C#»

Вариант: 5

Красноярск 2022

[pic 1]

Текст программы:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace лаба_3_шарп

{

    class Tbook

    {

        int age;

        string name, author, agecons;

        public Tbook()

        {

            this.age = 0;

            this.author = "";

            this.name = "";

        }

        public Tbook(int age, string name, string author)

        {

            this.age = age;

            this.author = author;

            this.name = name;

        }

        ~Tbook()

        {

        }

        public Tbook(Tbook other)

        {

            this.age = other.age;

            this.author = other.author;

            this.name = other.name;

        }

        public void findBookAgeAuthor(string str1, int kk)

        {

            if (this.author == str1 && this.age > kk)

                Console.WriteLine(name + " " + age + " " + author);

        }

        public void ReadBook()

        {

        link:

            Console.WriteLine("Введите год издания книги");

            agecons = Console.ReadLine();

            try

            {

                this.age = int.Parse(this.agecons);

                if (this.age < 0 || this.age > 2022)

                {

                    Console.WriteLine("введен некорректный год!");

                    goto link;

                }

            }

            catch

            {

                Console.WriteLine("неправильно введен год издания");

                goto link;

            }

            Console.WriteLine("Введите автора книги");

            author = Console.ReadLine();

            Console.WriteLine("Введите название книги");

            name = Console.ReadLine();

        }

        public void WriteBook()

        {

            Console.WriteLine("год издания " + age);

            Console.WriteLine("название книги " + name);

            Console.WriteLine("автор книги " + author);

        }

        public void findBookAge(int kk, string str)

        {

            if (str == "=")

                if (this.age == kk)

                    Console.WriteLine(name + " " + age);

            if (str == ">=")

                if (this.age >= kk)

                    Console.WriteLine(name + " " + age);

            if (str == "<=")

                if (this.age <= kk)

                    Console.WriteLine(name + " " + age);

        }

        public void findBookAuthor(string str)

        {

            if (this.author == str)

                Console.WriteLine(this.name + " " + this.age);

        }

    };

    class Program

    {

        static void Main(string[] args)

        {

            string str, sim, comma, sim1;

            int n, age;

            int comm = 0;

            try

            {

                while (true)

                {

                    try

                    {

                        Console.WriteLine("Сколько будет введено книг");

                        n = int.Parse(Console.ReadLine());

...

Скачать:   txt (6.9 Kb)   pdf (182 Kb)   docx (136.6 Kb)  
Продолжить читать еще 10 страниц(ы) »
Доступно только на Essays.club