I'm trying to make a simple console application game. The code is a bit messy and I hope anyone can point out anything wrong.
using System;
using System.Collections.Generic;
namespace CalculatePoints
{
class Program
{
static void Main(string[] args)
{
Game game = new Game();
game.PlayGame();
}
}
class Game
{
private List<Player> player = new List<Player>();
public void AddPlayer(string name)
{
Player person = new Player(name);
player.Add(person);
}
public void PlayGame()
{
Console.Write("enter amount of player: ");
int playerAmount = Convert.ToInt32(Console.ReadLine());
for (int i = 0; i < playerAmount; i++)
{
Console.Write("enter player name: ");
string playerName = Console.ReadLine();
AddPlayer(playerName);
}
Console.WriteLine("game start");
foreach (Player name in player)
{
Console.WriteLine(name + " turn ");
Console.WriteLine("enter score 1:");
int score1 = Int32.Parse(Console.ReadLine());
Console.WriteLine("enter score 2:");
int score2 = Int32.Parse(Console.ReadLine());
Console.WriteLine("enter score 3:");
int score3 = Int32.Parse(Console.ReadLine());
Throw result = new Throw(score1, score2, score3);
Console.WriteLine(result.GetScore());
}
Console.ReadKey();
}
}
class Player
{
public string Name { get; set; }
public List<Throw> throwList = new List<Throw>();
public Player(string name = "")
{
Name = name;
}
public override string ToString()
{
return Name;
}
}
class Throw
{
private int throwOne;
private int throwTwo;
private int throwThree;
public Throw(int throwOne = 0, int throwTwo = 0, int throwThree = 0)
{
this.throwOne = throwOne;
this.throwTwo = throwTwo;
this.throwThree = throwThree;
}
public int GetScore()
{
return throwOne + throwTwo + throwThree;
}
public override string ToString()
{
return string.Format("Your total score is {0}", GetScore());
}
}
}