generated from admin/template
Добавить works/algo/Readme.md
This commit is contained in:
@@ -0,0 +1,118 @@
|
|||||||
|
# Отчет
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user