using System; using System.Collections.Generic; using System.Linq; using System.Text;namespace ConsoleApplication14 { public class Star { public int X; public int Y; Random r = new Random(); public int x; public int y; public Star(int num) { for (int i = 0; i < num; i++) { int g = r.Next(5); int k = r.Next(5); char[] shapes = { '+', '*', '&', '。', '#' }; Console.ForegroundColor = (ConsoleColor)g; Console.SetCursorPosition(r.Next(100), r.Next(20)); Console.Write("{0}", shapes[k]); } } public Star(int x, int y) { // TODO: Complete member initialization this.x = x; this.y = y; } public virtual void Show(int x, int y) { X = x; Y = y; Console.SetCursorPosition(x, y); } internal void Show() { throw new NotImplementedException(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text;namespace ConsoleApplication14 { class Meteor:Star { public Meteor(int x, int y): base(x, y) { Console.WriteLine() ; } public override void Show(int x, int y) { base.Show(); while (true) { X = x; Y = y; Console.SetCursorPosition(x+1, y+1); } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading;namespace ConsoleApplication14 { class Program { List<Star> Stars = new List<Star>(); static void Main(string[] args) { Console.WriteLine("输入星星数:"); int num = Convert.ToInt32(Console.ReadLine()); Console.Clear(); Star Star1 = new Star(num); Console.ReadLine(); } } }
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace ConsoleApplication14
{
public class Star
{
public int X;
public int Y;
Random r = new Random();
public int x;
public int y;
public Star(int num)
{
for (int i = 0; i < num; i++)
{
int g = r.Next(5);
int k = r.Next(5);
char[] shapes = { '+', '*', '&', '。', '#' };
Console.ForegroundColor = (ConsoleColor)g;
Console.SetCursorPosition(r.Next(100), r.Next(20));
Console.Write("{0}", shapes[k]);
}
} public Star(int x, int y)
{
// TODO: Complete member initialization
this.x = x;
this.y = y;
}
public virtual void Show(int x, int y)
{
X = x;
Y = y;
Console.SetCursorPosition(x, y);
} internal void Show()
{
throw new NotImplementedException();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace ConsoleApplication14
{
class Meteor:Star
{
public Meteor(int x, int y): base(x, y)
{
Console.WriteLine() ;
}
public override void Show(int x, int y)
{
base.Show();
while (true)
{
X = x;
Y = y;
Console.SetCursorPosition(x+1, y+1);
}
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;namespace ConsoleApplication14
{
class Program
{
List<Star> Stars = new List<Star>();
static void Main(string[] args)
{
Console.WriteLine("输入星星数:");
int num = Convert.ToInt32(Console.ReadLine());
Console.Clear();
Star Star1 = new Star(num);
Console.ReadLine();
}
}
}