360 字
2 分鐘

興大物件導向程式設計 Assignment Ch07 完整版題目

什麼叫作「完整版」題目?#

在此篇文章中出現的內容為中興大學物件導向程式設計課派發的 Assignment Ch07 作業。

原本照理講打開 iLearning 3.0 就該看到「完整」的題目了,但此次作業的題目中常出現 Fig6.8 這類的字樣,卻沒見到圖片本身,需要自行去原文參考書或者查閱上課的 PDF 檔。

本篇文章會把作業的題幹和圖檔一併附上,方便查閱。

7.18 (Game of Craps)#

Write an application that runs 1,000,000 games of craps (Fig. 6.8) and answers the following questions:

  • a) How many games are won on the first roll, second roll, …,twentieth roll and after the twentieth roll?

  • b) How many games are lost on the first roll, second roll, …,twentieth roll and after the twentieth roll?

  • c) What are the chances of winning at craps? [Note: You should discover that craps is one of the fairest casino games. What do you suppose this means?]

  • d) What is the average length of a game of craps?

  • e) Do the chances of winning improve with the length of the game?

Fig.6.8

Fig-6-8_1 Fig-6-8_2 Fig-6-8_3 Fig-6-8_4 Fig-6-8_5 Fig-6-8_6 Fig-6-8_7 Fig-6-8_8

7.30 (Card Shuffling and Dealing)#

Modify Fig. 7.11 to deal a five-card poker hand. Then modify class DeckOfCards of Fig. 7.10 to include methods that determine whether a hand contains:

  • a) a pair
  • b) two pairs
  • c) three of a kind (e.g., three jacks)
  • d) four of a kind (e.g., four aces)
  • e) a flush (i.e., all five cards of the same suit)
  • f) a straight (i.e., five cards of consecutive face values)
  • g) a full house (i.e., two cards of one face value and three cards of another face value)

[Hint: Add methods getFace and getSuit to class Card of Fig. 7.9.]

Fig.7.11

Fig-7-11_1 Fig-7-11_2

Fig.7.10

Fig-7-10_1 Fig-7-10_2 Fig-7-10_3 Fig-7-10_4

Fig.7.9

Fig-7-9_1

7.31 (Card Shuffling and Dealing)#

Use the methods developed in Exercise 7.30 to write an application that deals two five-card poker hands, evaluates each hand and determines which is better.

興大物件導向程式設計 Assignment Ch07 完整版題目
https://blog.pytreedao.com/posts/nchu-java-oop-assignment-ch07-problems/
作者
Pytree
發布於
2024-04-10
許可協議
CC BY-NC-SA 4.0
最後更新於 2024-04-10,距今已過 648 天

部分內容可能已過時

評論區

目錄