star类可以显示出一颗星星,现在要新建一个流星类重写star的show方法,显示出一个移动的星星。。求助
`主函数
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Collections;
namespace 满天星星
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入星星数量:");
int num = Convert.ToInt32(Console.ReadLine());
Random r = new Random();
char[] shapes = { '!', '@', '#', '$', '%', '^', '&', '*' };
for (int i = 0; i < num; i++)
{
Star star = new Star(shapes[r.Next(8)], r.Next(52), r.Next(52), r.Next(15));
star.PrintStar();
}
}
}
}
star类
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 满天星星
{
class Star
{
public int x;
public int y;
public int yanse;
public char shape;
public Star()
{
shape = '*';
}
public Star(char Z, int x, int y,int k)
{
this.x = x;
this.y = y;
this.yanse = k;
this.shape = Z;
}
public virtual void PrintStar()
{
Console.SetCursorPosition(x, y);
Console.ForegroundColor = (ConsoleColor)(int)yanse;
Console.Write("{0}", shape);
}
}
}