generated from admin/template
119 lines
3.1 KiB
Markdown
119 lines
3.1 KiB
Markdown
# Отчет
|
|
using System;
|
|
|
|
namespace Evolutionlaba
|
|
{
|
|
class PokemonStage
|
|
{
|
|
//1
|
|
public string Name { get; set; }
|
|
public string Type { get; set; }
|
|
public int RequiredLevel { get; set; }
|
|
public PokemonStage(string name, string type, int requiredLevel)
|
|
{
|
|
Name = name;
|
|
Type = type;
|
|
RequiredLevel = requiredLevel;
|
|
}
|
|
public void ShowInfo()
|
|
{
|
|
Console.WriteLine($"{Name} {Type} Required Level {RequiredLevel}");
|
|
}
|
|
public override string ToString()
|
|
{
|
|
return $"{Name} {Type} Required Level {RequiredLevel}";
|
|
}
|
|
//2
|
|
class EvolutionNode
|
|
{
|
|
public PokemonStage Data { get; set; }
|
|
public EvolutionNode Next { get; set; }
|
|
|
|
public EvolutionNode(PokemonStage data)
|
|
{
|
|
Data = data;
|
|
Next = null;
|
|
}
|
|
|
|
}
|
|
|
|
class EvolutionLine
|
|
{
|
|
public EvolutionNode Head { get; set; }
|
|
public int Count { get; private set; }
|
|
public EvolutionLine()
|
|
{
|
|
Head = null;
|
|
Count = 0;
|
|
}
|
|
}
|
|
|
|
public void AddFirst(PokemonStage stage)
|
|
{
|
|
var node = new EvolutionNode(stage);
|
|
if (Head == null)
|
|
{
|
|
Head = node;
|
|
}
|
|
else
|
|
{
|
|
var currect = Head;
|
|
while (currect.Next != null)
|
|
{
|
|
currect = currect.Next;
|
|
}
|
|
currect.Next = node;
|
|
}
|
|
|
|
Count++;
|
|
}
|
|
|
|
public void PrintAll()
|
|
{
|
|
var current = Head;
|
|
int index = 1;
|
|
while (current != null) ;
|
|
{
|
|
Console.WriteLine($"{index}. {current.Data.Name} (Ур. {current.Data.RequiredLevel}, {current.Data.Type})");
|
|
current = current.Next;
|
|
index++;
|
|
}
|
|
}
|
|
|
|
public void PrintChain()
|
|
{
|
|
if (Head == null)
|
|
{
|
|
Console.WriteLine("(пусто)");
|
|
return;
|
|
}
|
|
|
|
var current = Head;
|
|
while (current != null)
|
|
{
|
|
Console.WriteLine(current.Data.Name);
|
|
if (current.Next != null)
|
|
Console.WriteLine("->");
|
|
current = current.Next;
|
|
}
|
|
Console.WriteLine();
|
|
}
|
|
// заждание возвращение 2
|
|
public PokemonStage? Find(string name)
|
|
{
|
|
var current = Head;
|
|
while (current.Data.Name == name)
|
|
return current.Data;
|
|
current = current.Next;
|
|
|
|
}
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|