Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Zadacha_1
- {
- class QuestionaryForNewAdeptsItem
- {
- private string _question;
- private string[] _answerVariation;
- public string Question
- {
- get { return _question; }
- set { _question = value; }
- }
- public string[] AnswerVariation
- {
- get { return _answerVariation; }
- set { _answerVariation = value; }
- }
- public QuestionaryForNewAdeptsItem(string quest, string[] answers)
- {
- Question = quest;
- AnswerVariation = answers;
- }
- }
- class Candidate
- {
- private string _whoIam;
- private string _whatIwant;
- private string _myOccupation;
- public string WhoIam
- {
- get { return _whoIam; }
- set { _whoIam = value; }
- }
- public string WhatIwant
- {
- get { return _whatIwant; }
- set { _whatIwant = value; }
- }
- public string MyOccupation
- {
- get { return _myOccupation; }
- set { _myOccupation = value; }
- }
- public Candidate()
- {
- }
- }
- class Door
- {
- private bool _isOpen;
- public bool IsOpen
- {
- get { return _isOpen; }
- set { _isOpen = value; }
- }
- public Door()
- {
- IsOpen = false;
- }
- }
- class Interview
- {
- public Interview()
- {
- }
- public void GenerateDialog(QuestionaryForNewAdeptsItem[] Items, Door[] doors)
- {
- Candidate adept = new Candidate();
- for (int i = 0; i < Items.Length; i++)
- {
- int selectionIndex = 0;
- var q = Items[i];
- Console.WriteLine(q.Question);
- PrintVariants(q);
- selectionIndex = CheckingValue();
- if (i == 0)
- {
- adept.WhoIam = q.AnswerVariation[selectionIndex];
- }
- if (i == 1)
- {
- adept.WhatIwant = q.AnswerVariation[selectionIndex];
- }
- if (i == 2)
- {
- adept.MyOccupation = q.AnswerVariation[selectionIndex];
- if (CheckingNewCandidate(adept))
- {
- Console.WriteLine("Отлично! Ты-то нам и нужен! Эй, Джонни, открой дверь - добро пожаловать в Орден, брат!");
- doors[i].IsOpen = true;
- Console.ReadKey();
- }
- else
- {
- Console.WriteLine("Ты не подходишь Ордену!");
- Console.ReadKey();
- }
- }
- }
- }
- public bool CheckingNewCandidate(Candidate newCandidate)
- {
- bool isNeo = false;
- if(newCandidate.MyOccupation.Equals("Я отличный воин") && newCandidate.WhatIwant.Equals("Найти боевых товарищей"))
- {
- isNeo = true;
- }
- return isNeo;
- }
- public int CheckingValue()
- {
- int Index = 0;
- try
- {
- int Value = Int32.Parse(Console.ReadLine());
- if (Value <= 2 && Value >= 0)
- {
- Index = Value;
- }
- else
- {
- Console.WriteLine("Введите значение от 0 до 2!");
- CheckingValue();
- }
- }
- catch(Exception)
- {
- Console.WriteLine("Введите значение от 0 до 2!");
- CheckingValue();
- }
- return Index;
- }
- public void PrintVariants(QuestionaryForNewAdeptsItem newItem)
- {
- for (int j = 0; j < newItem.AnswerVariation.Length; j++)
- {
- Console.WriteLine("[{0}]>{1}", j, newItem.AnswerVariation[j]);
- }
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Interview Dialog = new Interview();
- Door[] doors = new Door[] { new Door(), new Door(), new Door() };
- Console.WriteLine("Совершенно очевидно, что мы не берём в наш орден кого попало. Поэтому заполни вот эту анкету, " +
- "и мы примем решение, брать тебя или нет");
- string[] answers1 = new string[] { "Человек", "Брандлмуха", "Кхаджит" };
- QuestionaryForNewAdeptsItem firstQuest = new QuestionaryForNewAdeptsItem("Кто вы?", answers1);
- string[] answers2 = new string[] { "Победить Аразота", "Стать богатым", "Найти боевых товарищей" };
- QuestionaryForNewAdeptsItem secondQuest = new QuestionaryForNewAdeptsItem("Что вы хотите?", answers2);
- string[] answers3 = new string[] { "Я отличный воин", "Я добротный маг", "Я могу работать в кузнице" };
- QuestionaryForNewAdeptsItem thirdQuest = new QuestionaryForNewAdeptsItem("Чем вы можете помочь ордену?", answers3);
- QuestionaryForNewAdeptsItem[] questionary = new QuestionaryForNewAdeptsItem[] { firstQuest, secondQuest, thirdQuest };
- Dialog.GenerateDialog(questionary, doors);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment