Question: Python 5. The Doctor program described in Chapter 5 combines the data model of a doctor and the operations for handling user interaction. Restructure this

Python

5. The Doctor program described in Chapter 5 combines the data model of a doctor and the operations for handling user interaction. Restructure this program according to the model/view pattern so that these areas of responsibility are assigned to separate sets of classes. The program should include a Doctor class with an interface that allows one to obtain a greeting, a signoff message, and a reply to a patients string. The rest of the program, in a separate main program module, handles the users interactions with the Doctor object. You may develop either a terminal-based user interface or a GUI.

6. Convert the DiceDemo program discussed in this chapter to a completed craps game application, using the Player data model class you developed in Project 6. A screen shot of a possible window is shown in Figure 9-7.

Python 5. The Doctor program described in Chapter 5 combines the data

7. The play method in the Player class of the craps game plays an entire game without interaction with the user. Revise the Player class so that its user can make individual rolls of the dice and view the results after each roll. The Player class no longer accumulates a list of rolls, but saves the string representation of each roll after it is made. Add new methods rollDice, getRollsCount, isWinner, and isLoser to the Player class. The last three methods allow the user to obtain the number of rolls and to determine whether there is a winner or a loser. The last two methods are associated with new Boolean instance variables. Two other instance variables track the number of rolls and the string representation of the most recent roll. Another instance variable tracks whether or not the first roll has occurred. At instantiation, the roll, rollsCount, atStartup, winner, and loser variables are set to their appropriate initial values. All game logic is now in the rollDice method. This method rolls the dice once, updates the state of the Player object, and returns a tuple of the values of the dice for that roll. Include in the module the playOneGame and playManyGames functions, suitably updated for the new interface to the Player class.

Craps Game Totalt8 Total 10 Total 6 Total4 Total 7 You lose! Roll New game Craps Game Totalt8 Total 10 Total 6 Total4 Total 7 You lose! Roll New game

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!