我需要一些想法在我的項目中實現。 我需要爲此列表上的人員分配一個票號。將數字分配給列表的成員
ListaUtente.Add(new Utente(100001, "John", 914754123, "[email protected]", GetRandomColor()));
ListaUtente.Add(new Utente(100002, "Peter", 974123214, "[email protected]", GetRandomColor()));
ListaUtente.Add(new Utente(100003, "Tidus", 941201456, "[email protected]", GetRandomColor()));
ListaUtente.Add(new Utente(100004, "Poppy",, "[email protected]", GetRandomColor()));
Utente類是:
class Utente
{
// Class Atributes
private int numUtenteSaude;
private String nome;
private int telefone;
private String email;
private ConsoleColor color;
public Utente(int numUtenteSaude, String nome, int telefone, String email, ConsoleColor color)
{
this.numUtenteSaude = numUtenteSaude;
this.nome = nome;
this.telefone = telefone;
this.email = email;
this.color = color;
}
public void display()
{
Console.ForegroundColor = this.color;
Console.WriteLine("Pessoa: Numero Utente Saude: " + numUtenteSaude + " Telefone: " + telefone + " " + "Nome:" + nome + " Email: " + email);
}
public override string ToString()
{
return String.Format("{0} {1} {2} {3} {4}", numUtenteSaude, nome, telefone, email, color);
}
}
這就像一個醫院和人的名單上在到達醫療中心。我需要爲列表中的人員分配票號。 我該怎麼做?
添加房產門票號碼?你根本沒有告訴我們這個問題 – EpicKip
也許只是使用一個初始設置爲零的靜態int變量。每次創建Utente時,都會爲其分配變量的值並將其增加。這就像我可以理解的從你的問題回答。正如@EpicKip提到的那樣,你要問什麼不是很清楚。 –
@HoriaComan我在我的程序上有一個菜單。我需要一個條目,如:「將票分配給Utente」,並且它會爲列表中的人員分配票號。 – Dany4k