跳至主要內容

Lab 7 - Street Craps

AI悦创原创2023年10月29日1v1python 1v1数据结构一对一留学生辅导留学生作业辅导northeastern一对一辅导东北大学Python辅导东北大学Python一对一辅导大约 4 分钟...约 1084 字

Street craps

img
img

In class we looked at a simple card game implemented using object-oriented programming. For this lab, you'll adapt that structure to create a simple dice game based on the classic signifier of misspent youth: street craps.

The rules of street craps are as follows. The shooter rolls two dice. If the first roll is 2, 3, or 12 the shooter loses. If the first roll is 7 or 11, the shooter wins. If the first roll is anything else, that value becomes the shooter's "point". The shooter continues to roll the dice until either the "point" comes up again, in which case the shooter wins, or until a 7 comes up, in which case the shooter loses.

You'll implement this game in four files:

Running the game

A few examples of the game in action are shown below:

Implementation

As mentioned above, use the Blackjack code from the lectures as a reference to get started.

Avoid duplicating code, and make sure any piece of information has a single canonical source, to which other objects refer if they need that information. For example, the PairOfDice object's current_value() value should depend directly on (and refer to) the current_values of its Die objects. Likewise, the PairOfDice object should not be responsible for generating any random numbers; this is the responsibility of the Die objects. Every object should have its own distinct responsibilities, and should refer to other objects when it needs data that they are responsible for.

You can trigger the action of rolling a die when the user presses enter by simply using an input() statement to wait for the user's input and then discarding the value (i.e., not passing it to a variable).

Submission

Place all module files together in a directory called dice_game and zip the directory. Submit dice_game.zip to Canvas.

公众号:AI悦创【二维码】

AI悦创·编程一对一

AI悦创·推出辅导班啦,包括「Python 语言辅导班、C++ 辅导班、java 辅导班、算法/数据结构辅导班、少儿编程、pygame 游戏开发、Web、Linux」,全部都是一对一教学:一对一辅导 + 一对一答疑 + 布置作业 + 项目实践等。当然,还有线下线上摄影课程、Photoshop、Premiere 一对一教学、QQ、微信在线,随时响应!微信:Jiabcdefh

C++ 信息奥赛题解,长期更新!长期招收一对一中小学信息奥赛集训,莆田、厦门地区有机会线下上门,其他地区线上。微信:Jiabcdefh

方法一:QQ

方法二:微信:Jiabcdefh

你认为这篇文章怎么样?
  • 0
  • 0
  • 0
  • 0
  • 0
  • 0
评论
  • 按正序
  • 按倒序
  • 按热度
通知
关于编程私教&加密文章