using ConsoleApp;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp.Menu
{
///
/// An abstract class that define the components of a selection-type menu.
///
/// The return type of the currently selected item
public abstract class SelectMenu : IMenuDisplay
{
protected int _currentLine = 0;
protected int _maxLines = 0;
///
/// The currently selected item.
///
public T? CurrentSelected { get; protected set; }
///
/// The current line selected in the menu.
///
public int CurrentLine
{
get => _currentLine;
protected set
{
_currentLine = value;
if (_currentLine > _maxLines)
{
_currentLine = _maxLines;
}
if (_currentLine < 0)
{
_currentLine = 0;
}
return;
}
}
public int SelectNextLine() { return ++CurrentLine; }
public int SelectPrevioustLine() { return --CurrentLine; }
public abstract void UpdateDisplay();
}
}