Ejemplo n.º 1
0
 public static void writeDefaultHighScores()
 {
     Player[] p = new Player[10];
     //khoi tao 10 nguoi player ban dau
     for (int i = 0; i < 10; i++)
     {
         p[i] = new Player("An Vu ", 0);
     }
     //goi ham viet danh sach 10 nguoi choi vua khoi tao tren len filename
     //dua mang danh sach 10 nguoi choi ve kieu Layer
     writeHighScores(new PlayerList(p));
 }
Ejemplo n.º 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (this.textBox1.Text == "")
         MessageBox.Show(this, "Your name must not be blank!", "Error", MessageBoxButtons.OK,
             MessageBoxIcon.Error);
     else
     {
         Player p = new Player(this.textBox1.Text,diem);
         HighScoreFunctions.insert(p);
         this.Close();
         new FormHighScore().ShowDialog();
     }
 }
Ejemplo n.º 3
0
 //ham sap xep
 public static void insert(Player p)
 {
     PlayerList pl = readHighScores();
     int i, j;
     if (p.scores < pl.list[9].scores)
     {
         MessageBox.Show("Diem Cua Ban Khong Du De Vao Top", "Thong Bao", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     for (i = 0; i < 10; i++)
         if (Player.less(pl.list[i], p))
             break;
     for (j = 9; j >= i+1; j--)
         pl.list[j] = pl.list[j - 1];
     pl.list[i] = p;
     writeHighScores(pl);
 }
Ejemplo n.º 4
0
 //tao danh sach cac Player
 public PlayerList(Player[] list)
 {
     this.list = list;
 }
Ejemplo n.º 5
0
 //ham so sanh diem so giua hai nguoi choi
 //ham so sanh nay co kieu bool
 public static bool less(Player p1, Player p2)
 {
     if (p1.scores != p2.scores)
         return p1.scores < p2.scores;
     return p1.scores < p2.scores;
 }