.NET 4.x Как исправить ошибку компиляции "Не удалось найти тип или имя пространства имен"? - C#
Формулировка задачи:
Листинг программы
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Voin
- {
- class Voini
- {//просто записать дамаг ребят через паблик и все епт
- public int UronTor = 49;
- public int UronChelovek = 5;
- public int UronHeleznChelovek = 48;
- public int UronKapitanAmerika = 35;
- public int UronHalk = 99;
- public string name { get; set; }
- public int bron { get; set; }
- public int hp { get; set; }
- public Voini(string name, int b, int h)
- {
- bron = b;
- hp = h;
- }
- }
- class Tor : Voini
- {
- public Tor (string name, int b, int h) : base(name, b, h)
- {
- Console.WriteLine("подсказка:\n1-Тора ударит халк\n2-тора ударит железный человек\n3-тора ударит обычный человек\n4-тора ударит капитан америка ");
- int j = Convert.ToInt32(Console.ReadLine());
- if (j == 1)
- {
- h = h + b - UronHalk;
- }
- else if (j == 2)
- {
- h = h + b - UronHeleznChelovek;
- }
- else if (j == 3)
- {
- h = h + b - UronChelovek;
- }
- else if (j == 4)
- {
- h = h + b - UronKapitanAmerika;
- }
- Console.WriteLine("У тора осталось " + h, "здоровья");
- }
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- int f;
- Console.WriteLine("ведите , что вы хотите замутить");
- f = Convert.ToInt32(Console.ReadLine());
- if (f == 1)
- {
- Tor t = new Tor("Тор", 2, 100);
- }
- Console.ReadKey();
- }
- }
Решение задачи: «.NET 4.x Как исправить ошибку компиляции "Не удалось найти тип или имя пространства имен"?»
textual
Листинг программы
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace _2
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<Voin> list = new List<Voin>();
- Voin IliaMurometz = new Voin("Илья Муромец", 100, 300, 120);
- list.Add(IliaMurometz);
- Voin Halk = new Voin("Халк", 50, 150, 100);
- list.Add(Halk);
- Voin Joda = new Voin("Мастер Йода", 80, 50, 50);
- list.Add(Joda);
- Console.WriteLine("Война (1) или мир (2)?");
- int wp = Int32.Parse(Console.ReadLine());
- while (wp==1)
- {
- Console.Clear();
- Console.WriteLine("Воины:");
- for (int i = 0; i < list.Count; i++)
- {
- if (list[i].health>0)
- Console.WriteLine((i + 1).ToString() + " - " + list[i]);
- }
- Console.WriteLine("Кто бьет?");
- int who = Int32.Parse(Console.ReadLine())-1;
- Console.WriteLine("Кого бьет?");
- int whom = Int32.Parse(Console.ReadLine())-1;
- Console.WriteLine(list[who].name + " бьет " + list[whom].name);
- list[who].TrachBach(list[whom]);
- Console.WriteLine(list[whom].PrintHelth);
- Console.WriteLine("Война (1) или мир (2)?");
- wp = Int32.Parse(Console.ReadLine());
- }
- Console.ReadKey();
- }
- }
- class Voin
- {
- public string name { get; set; }
- public int bron { get; set; }
- public int health { get; set; }
- public int uron { get; set; }
- public Voin(string name, int bron, int health, int uron)
- {
- this.name = name;
- this.bron = bron;
- this.health = health;
- this.uron = uron;
- }
- public int TrachBach(Voin vrag)
- {
- vrag.health = vrag.health + vrag.bron - uron;
- if (vrag.health < 0) vrag.health = 0;
- return vrag.health;
- }
- public string PrintHelth
- {
- get
- {
- if (health == 0) return name + " издох!";
- return "У " + name + " есть еще порох в пороховницах и " + health.ToString() + " здоровья!";
- }
- }
- public override string ToString()
- {
- return string.Format("{0}, здоровья {1}", name, health);
- }
- }
- }
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д