Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > IT форум > Помощь студентам
Регистрация

Восстановить пароль

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 14.10.2014, 19:53   #1
Skipper Ok
Пользователь
 
Аватар для Skipper Ok
 
Регистрация: 08.11.2013
Сообщений: 23
По умолчанию C# ООП Выводит результаты не так, как нужно!

Начинающий! В программе мне нужно, чтобы он выводил результаты в нужном порядке, а выводится верх тормашками образно говоря...код не очень хорошо выглядит...
Стрелочкой указал, мне нужно,чтобы они выводились...
Код:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication6
{
    abstract class Zoo
    {
        public Int16 Number;
        public Int32 iN;
        public string TypeOfZoo;
        public byte Time, iAdults_iChildrens;
        public int ipriceforadults, ipriceforchildrens;
        public abstract void Animals();
        public abstract void Entry_Price();
        public abstract void Print();
    }
    class ExoticZoo : Zoo
    {
        public override void Animals()
        {
            Console.WriteLine("Type of  animals: exotic");
            Console.WriteLine("Exotic animals: Жирафы, Кенгуру, Тигры, Льыы, Леопарды, Носухи, Кинкажу, Генетты ");
        }
        public override void Entry_Price()
        {
            Console.WriteLine("Enter the max value of price for a adults: ");
            ipriceforadults = Int32.Parse(Console.ReadLine());
            if (ipriceforadults > 40)
                throw new ArgumentOutOfRangeException("price for adults");
            Console.WriteLine("Enter the max value of price for childrens: ");
            ipriceforchildrens = Int32.Parse(Console.ReadLine());
            if (ipriceforchildrens > 25)
                throw new ArgumentOutOfRangeException("price for childrens");
        }
        public override void Print()
        {
            Console.WriteLine("Value of price for adults is: {0}", ipriceforadults);
            Console.WriteLine("Value of price for childrens: {0}", ipriceforchildrens);
            Console.WriteLine("With respect, Zoo administration");
        }
    }
 
 
 
    class NorthZoo : Zoo
    {
        public override void Animals()
        {
            Console.WriteLine("Type animals: north animals");
            Console.WriteLine("Type of north animals: Койот, Гризли, Калан, Белый медведь, Лоси, Олени, Кабарга");
        }
        public override void Entry_Price()
        {
            Console.WriteLine("Enter the max price for adults: ");
            ipriceforadults = Int32.Parse(Console.ReadLine());
            if (ipriceforadults > 30)
                throw new ArgumentOutOfRangeException("price for adults");
            Console.WriteLine("Enter the price for childrens: ");
            ipriceforchildrens = Int32.Parse(Console.ReadLine());
            if (ipriceforchildrens > 20)
                throw new ArgumentOutOfRangeException("price for childrens");
        }
        public override void Print()
        {
            Console.WriteLine("The max value of price  for adults: {0}", ipriceforadults);
            Console.WriteLine("The max value of price  for childrens: {0}", ipriceforchildrens);
            Console.WriteLine("With respect, Zoo administration");
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            ExoticZoo ExoticAnimals = new ExoticZoo();
            NorthZoo NorthAnimals = new NorthZoo();
            Zoo zoo;
            Console.WriteLine("Which class of zoo do you want to visit: 1 - exotic; 2 -  animals");
            int i = Int32.Parse(Console.ReadLine());
            if (i == 1)
            {
                zoo = ExoticAnimals;
            }
            else
            {
                zoo = NorthAnimals;
            }
            Console.WriteLine("Vvedite detskih posetiteley: ");
            zoo.iN = Int16.Parse(Console.ReadLine());
            Console.WriteLine("Vvedite kolichestvo vzroslih posetitelei: ");
            zoo.iN = Int32.Parse(Console.ReadLine());
            Console.WriteLine("Enter the time which do you want to be in: {0} hours ");
            zoo.Time = Byte.Parse(Console.ReadLine()); 
            Console.WriteLine("Enter the the value of childrens and adults: ");
            zoo.iAdults_iChildrens = Byte.Parse(Console.ReadLine());
           
            Console.WriteLine("Enter the value of age childrens: {0}", zoo.Number);
            zoo.Animals();
            zoo.Entry_Price();
            zoo.Print();
        }
    }
}
Изображения
Тип файла: jpg Zoo.jpg (66.5 Кб, 61 просмотров)
Skipper Ok вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Прошу откорректировать данную программу так, чтобы на печать выводились результаты в виде обычного (курсивного) шрифта Windows или IZOPGRAM Паскаль, Turbo Pascal, PascalABC.NET 3 09.06.2012 18:35
WinInet работает не так как нужно! 1234567852 Win Api 7 26.02.2012 19:45
Написал программу,работает,но не так как нужно( С++ ) Diwolf Помощь студентам 0 21.12.2011 19:47
Программа на цикле неверно выводит результаты nox7 Паскаль, Turbo Pascal, PascalABC.NET 4 26.09.2010 19:28
ООП как лучше, и почему так. optimist32 Общие вопросы C/C++ 6 15.11.2009 04:43