namespace DZ_4 { class Program { static void Main(string[] args) { TeamLeader pr1 = new TeamLeader(); pr1.Condition();//проверяем состояние стройки: построен или нет фундамент Basement bsm = new Basement(); bsm.Installation(); pr1.Condition();//проверяем состояние стройки: построен или нет фундамент (ОПЯТЬ ВОЗВРАЩАЕТ, ЧТО ФУНДАМЕНТ НЕ ПОСТРОЕН) } class TeamLeader { public void Condition()//метод для проверки состояния строительства { House b = new House(); b.Condition();//метод для проверки постройки фундамента } } class House : TeamLeader { private int Bsement { get; set; } public new void Condition() { if (Bsement == 1) { Console.WriteLine("Фундамент построен"); } else { Console.WriteLine("Фундамент не построен"); } } public void Result(int b) { Bsement = b; } } class Basement : House { public void Installation()//отрисовка фундамента { Console.WriteLine("Солнце всходит - пора за работу!"); System.Threading.Thread.Sleep(4000); Console.BackgroundColor = ConsoleColor.DarkBlue; Console.Clear(); for (int i = 0; i <= 50; i++) { Console.Write("_"); System.Threading.Thread.Sleep(40); } Console.WriteLine(); for (int i = 0; i <= 5; i++) { Console.Write("I"); for (int j = 0; j <= 48; j++) { Console.Write(" "); } Console.WriteLine("I"); System.Threading.Thread.Sleep(40); } System.Threading.Thread.Sleep(100); Console.BackgroundColor = ConsoleColor.Blue; for (int i = 0; i <= 50; i++) { Console.Write("-"); System.Threading.Thread.Sleep(40); } Console.WriteLine(); Console.WriteLine("Стоп!"); Result(1);//передаем флажок об окончании строительства } } } } When you call the Condition () method of the TeamLeader pr1 instance again, after drawing the foundation and setting the completion flag, the method returns 0, that is, the "foundation is not built." What is the catch and how to fix it?
BsementtoConditionyou create a new instance of the house with a zeroBsementvalue. - Alexey ShimanskyHouseinside the baseTeamLeaderobject is most likely wrong. Describe in more detail your task. - VladD