using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Starcraft
{
internal class App
{
//생성자
public App()
{
Board board = new Board();
Console.WriteLine(board);
while (true)
{
var info = Console.ReadKey();
if(info.Key == ConsoleKey.LeftArrow)
{
board.Left();
for (int i = 0; i < board.size.Length; i++)
{
Console.Write("{0} ", board.size[i]);
}
}
if (info.Key == ConsoleKey.RightArrow)
{
board.Right();
for (int i = 0; i < board.size.Length; i++)
{
Console.Write("{0} ", board.size[i]);
}
}
//if (info.Key == ConsoleKey.UpArrow)
//{
// Console.WriteLine("qd");
//}
//if (info.Key == ConsoleKey.DownArrow)
//{
// Console.WriteLine("wd");
//}
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.AccessControl;
using System.Text;
using System.Threading.Tasks;
namespace Starcraft
{
internal class Board
{
public int[] size;
public Board()
{
int[] size = new int[4];
this.size = size;
Random random = new Random();
int Index = random.Next(size.Length);
this.size[Index] = (random.Next(1,3))*2;
for(int i=0; i<size.Length; i++)
{
Console.Write("{0} ",size[i]);
}
}
public void Left()
{
for(int i =0; i < size.Length; i++)
{
if (size[i] != 0)
{
if (size[i] == size[0])
{
}
else
{
size[0] = size[i];
size[i] = 0;
}
}
else
{
}
}
}
public void Right()
{
for (int i = 0; i < size.Length; i++)
{
if (size[i] != 0)
{
if (size[i] == size[size.Length-1])
{
}
else
{
size[size.Length-1] = size[i];
size[i] = 0;
}
}
else
{
}
}
}
//public Up()
//{
//}
//public Down()
//{
//}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Starcraft
{
internal class Program
{
static void Main(string[] args)
{
//new키워드 : App클래스의 인스턴스 생성하고 생성자를 호출함
new App();
}
}
}