Machine Exercise 2 generate computer ID, machine id

Source: Internet
Author: User

Machine Exercise 2 generate computer ID, machine id

Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;
Using System. Threading. Tasks;

Namespace MyID
{
Class Computer
{
Private string type;

Public string Type
{
Get {return type ;}
Set {type = value ;}
}
Private string id;

Public string Id
{
Get {return id ;}
Set {id = value ;}
}
Private string buyDate;

Public string BuyDate
{
Get {return buyDate ;}
Set {buyDate = value ;}
}

}
}

 

Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;
Using System. Threading. Tasks;

Namespace MyID
{
Class Manner
{
Public void setID (Computer [] comps)
{
Random random = new Random ();
Foreach (Computer item in comps ){
Item. Id = item. Type + "-" + random. Next );
}
}
}
}

 

Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;
Using System. Threading. Tasks;

Namespace MyID
{
Class Program
{
Static void Main (string [] args)
{
Manner myManner = new Manner ();

Computer [] commp Uter = new Computer [3] {
New Computer (),
New Computer (),
New Computer ()

};
Commp Uter [0]. Type = "hpCq-217Tx ";
Commp Uter [0]. BuyDate = "2013-10-5 ";
Commp Uter [1]. Type = "Mc240CH/";
Commp Uter [1]. BuyDate = "2014-11-11 ";
Commp Uter [2]. Type = "SYNW18H/w ";
Commp Uter [2]. BuyDate = "2020-11-22 ";
Console. WriteLine ("************* before setting the computer ID *************");
Console. WriteLine ("computer model \ t computer ID \ t purchase time ");
Foreach (Computer item in commp Uter)
{
Console. WriteLine ("{0} \ t {1} \ t {2}", item. Type, item. Id, item. BuyDate );
}
Console. WriteLine ("\ n ");
MyManner. setID (comatrix Uter );
Console. WriteLine ("************* after setting the computer ID *************");
Console. WriteLine ("computer model \ t computer ID \ t purchase time ");
Foreach (Computer item in commp Uter ){
Console. WriteLine ("{0} \ t {1} \ t {2}", item. Type, item. Id, item. BuyDate );
}
Console. ReadLine ();
}

}
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.