main.cs
Код: Выделить всё
namespace StackOverflow
{
class Program
{
static void Main(string[] args)
{
while (true)
{
var post = new Post();
post.UpVote();
post.DownVote();
post.CurrentVoteValue();
Console.Write("Do you want to quit? press(Y/N) : ");
char quit= Convert.ToChar(Console.ReadLine());
if (quit== 'Y' || quit == 'y')
break;
else if (quit == 'N' || quit == 'n')
continue;
}
}
}
}
< /code>
post.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading.Tasks;
namespace StackOverflow
{
public class Post
{
private string _title { get; set; }
private string _description { get; set; }
private DateTime _created;
private int _like;
private int _dislike;
private List _likeVoters;
private List _dislikeVoters;
public Post()
{
Console.Write("Input title post = ");
_title = Console.ReadLine();
Console.Write("Input Description post = ");
_description = Console.ReadLine();
_created = DateTime.Now;
Console.WriteLine("This post {0}", _created);
Console.Write("Do you like this post? (Y/N) : ");
char opinion = Convert.ToChar(Console.ReadLine());
if(opinion == 'Y' || opinion == 'y')
_like++;
else if (opinion == 'N' || opinion == 'N')
_dislike++;
}
public List UpVote()
{
_likeVoters = new List();
_likeVoters.Add(_like);
return _likeVoters;
}
public List DownVote()
{
_dislikeVoters = new List();
_dislikeVoters.Add(_dislike);
return _dislikeVoters;
}
public void CurrentVoteValue()
{
var like = UpVote();
var dislike = DownVote();
Console.WriteLine(like);
Console.WriteLine(dislike);
}
}
}
>
Подробнее здесь: https://stackoverflow.com/questions/734 ... ystem-int3