using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 上机练习2
{
public class Computer
{
public string xingHao { get; set; }
public string day { get; set; }
public string id { get; set; }
public Computer() { }
public Computer(string xingHao, string id, string day)
{
this.xingHao = xingHao;
this.day = day;
this.id = id;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 上机练习2
{
class Program
{
static void Main(string[] args)
{
Computer[] comp = new Computer[3];
comp[0]=new Computer("111","","2013-1-1");
comp[1] = new Computer("222","","2013-1-1");
comp[2] = new Computer("333","","2013-1-1");
Console.WriteLine("--设置计算机ID前--");
Console.WriteLine("计算机型号"+"\t"+"计算机ID"+"\t"+"购买日期");
for (int i = 0; i < comp.Length; i++)
{
Console.WriteLine("\t"+comp[i].xingHao+"\t"+"\t"+comp[i].id+"\t"+comp[i].day);
}
Random r = new Random();
int[] random = new int[10];
for (int i = 0; i < random.Length; i++)
{
random[i] = r.Next(1000, 10000);
}
for (int i = 0; i < comp.Length; i++)
{
comp[i].id = comp[i].xingHao + "-" + random[i];
}
Console.WriteLine("--生成计算机ID后--");
Console.WriteLine("计算机型号" + "\t" + "计算机ID" + "\t" + "购买日期");
for (int i = 0; i < comp.Length; i++)
{
Console.WriteLine("\t" + comp[i].xingHao + "\t" +comp[i].id+ "\t"+comp[i].day);
}
Console.ReadLine();
}
}
}
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 上机练习2{ public class Computer { public string xingHao {