1 / 16

計算機程式及實習 期末報告 題目 :OOXX 的遊戲

計算機程式及實習 期末報告 題目 :OOXX 的遊戲. 機械工程系 奈米ㄧ甲 學號 :49914102 學生 : 周彥岑. OOXX. 每個人都玩過的簡易小遊戲,比雙方的心機與腦力,事處近兩人感情的小遊戲。. 摘要. 一 . OOXX 基本遊戲規則: 1. 一人每回合只能走一次,並且不能夠反悔 2. 當某方成功連成一條線時及為獲勝方. 系統分析. 需要判定該到哪方執行遊戲 本遊戲需要判定出輸贏所以需要許多條件式判定勝利。 判定條件為當點選 1 時程式自動判斷是否有 123 或 159 或 147 聯成一條線。下面以此類推. 表面設計. Button1~9.

rainer
Download Presentation

計算機程式及實習 期末報告 題目 :OOXX 的遊戲

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 計算機程式及實習期末報告題目:OOXX的遊戲 機械工程系 奈米ㄧ甲 學號:49914102 學生:周彥岑

  2. OOXX • 每個人都玩過的簡易小遊戲,比雙方的心機與腦力,事處近兩人感情的小遊戲。

  3. 摘要 一. OOXX基本遊戲規則: 1.一人每回合只能走一次,並且不能夠反悔 2.當某方成功連成一條線時及為獲勝方

  4. 系統分析 • 需要判定該到哪方執行遊戲 • 本遊戲需要判定出輸贏所以需要許多條件式判定勝利。 判定條件為當點選1時程式自動判斷是否有123或159或147聯成一條線。下面以此類推

  5. 表面設計 Button1~9 laber1 Button10~11

  6. 程式碼 Public Class OOXX遊戲 Dim x = 0 ‘宣告X=0(判定輪到誰) Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click x = x + 1 ‘第進行第X回 Button1.Enabled = False If x Mod 2 = 1 Then ‘判斷X為奇數則為O玩家,假如不是則為X玩家 Button1.Text = "O" If Button1.Text = Button2.Text AndAlso Button1.Text = Button3.Text _ OrElse Button1.Text = Button4.Text AndAlso Button1.Text = Button7.Text _ OrElse Button1.Text = Button5.Text AndAlso Button1.Text = Button9.Text Then Label1.Text = "贏家是" + Button1.Text ‘判定點選後是否有連成一線1的連線號碼有123、147、159 End If Else Button1.Text = "X" If Button1.Text = Button2.Text AndAlso Button1.Text = Button3.Text _ OrElse Button1.Text = Button4.Text AndAlso Button1.Text = Button7.Text _ OrElse Button1.Text = Button5.Text AndAlso Button1.Text = Button9.Text Then Label1.Text = "贏家是" + Button1.Text End If End If End Sub

  7. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click x = x + 1‘第進行第X回 Button2.Enabled = False If x Mod 2 = 1 Then Button2.Text = "O" If Button2.Text = Button1.Text AndAlso Button2.Text = Button3.Text _ OrElse Button2.Text = Button5.Text AndAlso Button2.Text = Button8.Text _ Then ‘判定點選後是否有連成一線,2的連線號碼有123、258 Label1.Text = "贏家是" + Button2.Text End If Else Button2.Text = "X" If Button2.Text = Button1.Text AndAlso Button2.Text = Button3.Text _ OrElse Button2.Text = Button5.Text AndAlso Button2.Text = Button8.Text _ Then Label1.Text = "贏家是" + Button2.Text ‘ End If End If End Sub

  8. Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click x = x + 1‘第進行第X回 Button3.Enabled = False If x Mod 2 = 1 Then Button3.Text = "O" If Button3.Text = Button1.Text AndAlso Button3.Text = Button2.Text _ OrElse Button3.Text = Button6.Text AndAlso Button3.Text = Button9.Text _ OrElse Button3.Text = Button5.Text AndAlso Button3.Text = Button7.Text Then Label1.Text = "贏家是" + Button3.Text ‘判定點選後是否有連成一線,3的連線號碼有123、369、357 End If Else If Button3.Text = Button1.Text AndAlso Button3.Text = Button2.Text _ OrElse Button3.Text = Button6.Text AndAlso Button3.Text = Button9.Text _ OrElse Button3.Text = Button5.Text AndAlso Button3.Text = Button7.Text Then Label1.Text = "贏家是" + Button3.Text `同上 End If End If End Sub

  9. Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click x = x + 1 ‘第進行第X回 Button4.Enabled = False If x Mod 2 = 1 Then Button4.Text = "O" If Button4.Text = Button5.Text AndAlso Button4.Text = Button6.Text _ OrElse Button4.Text = Button1.Text AndAlso Button4.Text = Button7.Text Then ‘判定點選後是否有連成一線,4的連線號碼有147、456 Label1.Text = "贏家是" + Button4.Text End If Else Button4.Text = "X" If Button4.Text = Button5.Text AndAlso Button4.Text = Button6.Text _ OrElse Button4.Text = Button1.Text AndAlso Button4.Text = Button7.Text Then Label1.Text = "贏家是" + Button4.Text End If End If End Sub

  10. Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click x = x + 1 ‘第進行第X回 Button5.Enabled = False If x Mod 2 = 1 Then Button5.Text = "O" If Button5.Text = Button2.Text AndAlso Button5.Text = Button8.Text _ OrElse Button5.Text = Button4.Text AndAlso Button5.Text = Button6.Text _ OrElse Button5.Text = Button1.Text AndAlso Button5.Text = Button9.Text _ OrElse Button5.Text = Button3.Text AndAlso Button5.Text = Button7.Text Then ‘判定點選後是否有連成一線,5的連線號碼有159、258、357、456 Label1.Text = "贏家是" + Button5.Text End If Else Button5.Text = "X" If Button5.Text = Button2.Text AndAlso Button5.Text = Button8.Text _ OrElse Button5.Text = Button4.Text AndAlso Button5.Text = Button6.Text _ OrElse Button5.Text = Button1.Text AndAlso Button5.Text = Button9.Text _ OrElse Button5.Text = Button3.Text AndAlso Button5.Text = Button7.Text Then Label1.Text = "贏家是" + Button5.Text End If End If End Sub

  11. Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click x = x + 1‘第進行第X回 Button6.Enabled = False If x Mod 2 = 1 Then Button6.Text = "O" If Button6.Text = Button5.Text AndAlso Button6.Text = Button4.Text _ OrElse Button6.Text = Button3.Text AndAlso Button6.Text = Button9.Text Then ‘判定點選後是否有連成一線,6的連線號碼有369、456 Label1.Text = "贏家是" + Button6.Text End If Else Button6.Text = "X" If Button6.Text = Button5.Text AndAlso Button6.Text = Button4.Text _ OrElse Button6.Text = Button3.Text AndAlso Button6.Text = Button9.Text Then Label1.Text = "贏家是" + Button6.Text End If End If End Sub

  12. Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click x = x + 1‘第進行第X回 Button7.Enabled = False If x Mod 2 = 1 Then Button7.Text = "O" If Button7.Text = Button1.Text AndAlso Button7.Text = Button4.Text _ OrElse Button7.Text = Button5.Text AndAlso Button7.Text = Button3.Text _ OrElse Button7.Text = Button8.Text AndAlso Button7.Text = Button9.Text Then ‘判定點選後是否有連成一線,7的連線號碼有147、753、789 Label1.Text = "贏家是" + Button7.Text End If Else Button7.Text = "X" If Button7.Text = Button1.Text AndAlso Button7.Text = Button4.Text _ OrElse Button7.Text = Button5.Text AndAlso Button7.Text = Button3.Text _ OrElse Button7.Text = Button8.Text AndAlso Button7.Text = Button9.Text Then Label1.Text = "贏家是" + Button7.Text End If End If End Sub

  13. Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click x = x + 1 ‘第進行第X回 Button8.Enabled = False If x Mod 2 = 1 Then Button8.Text = "O" If Button8.Text = Button2.Text AndAlso Button8.Text = Button5.Text _ OrElse Button8.Text = Button7.Text AndAlso Button8.Text = Button9.Text _ Then ‘判定點選後是否有連成一線,8的連線號碼有258、789 Label1.Text = "贏家是" + Button8.Text End If Else Button8.Text = "X" If Button8.Text = Button2.Text AndAlso Button8.Text = Button5.Text _ OrElse Button8.Text = Button7.Text AndAlso Button8.Text = Button9.Text _ Then Label1.Text = "贏家是" + Button8.Text End If End If End Sub

  14. Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click x = x + 1‘第進行第X回 Button9.Enabled = False If x Mod 2 = 1 Then Button9.Text = "O" If Button9.Text = Button8.Text AndAlso Button9.Text = Button7.Text _ OrElse Button9.Text = Button3.Text AndAlso Button9.Text = Button6.Text _ OrElse Button9.Text = Button5.Text AndAlso Button9.Text = Button1.Text Then ‘判定點選後是否有連成一線,9的連線號碼有369、951、789 Label1.Text = "贏家是" + Button9.Text End If Else Button9.Text = "X" If Button9.Text = Button8.Text AndAlso Button9.Text = Button7.Text _ OrElse Button9.Text = Button3.Text AndAlso Button9.Text = Button6.Text _ OrElse Button9.Text = Button5.Text AndAlso Button9.Text = Button1.Text Then Label1.Text = "贏家是" + Button9.Text End If End If End Sub

  15. Private Sub button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click Button1.Enabled = True Button1.Text = "" Button2.Enabled = True Button2.Text = "" Button3.Enabled = True Button3.Text = "" Button4.Enabled = True‘全部回歸原始 Button4.Text = "" Button5.Enabled = True Button5.Text = "" Button6.Enabled = True Button6.Text = "" Button7.Enabled = True Button7.Text = "" Button8.Enabled = True Button8.Text = "" Button9.Enabled = True Button9.Text = "" x = 0 Label1.Text = "" End Sub Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click Exit Sub End Sub End Class

  16. 心得感想 一個感覺最簡單的遊戲卻發現了需要許多的定義才能使這遊戲完成,耳且做完後也有種成就感是能在一個簡單的遊戲中找到許多需要的定義。

More Related