Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

#!/usr/bin/env python3 # -*- coding: utf-8 -*- # pylint: disable=E0401 # pylint: disable=E0401 """ Welcome In Pig Dice!. The game is easy. Try to roll the dice and not gitting values 1 and 6, or you...

1 answer below »
#!/us
in/env python3
# -*- coding: utf-8 -*-
# pylint: disable=E0401
# pylint: disable=E0401
"""
Welcome In Pig Dice!.
The game is easy. Try to roll the dice and not gitting
values 1 and 6, or you lose your score and turn.
The winner who reach 50 points first.
To start the game,
Enter 'start 1' to play against the compute
'start 2' to play with two players.
If you choose to play against the computer, you are able to change the
level when ever you want.
I expect to change your name by entering 'name (Your Name)'
Prese help or ? to get more about commands
"""
import shell
if __name__ == '__main__':
print(__doc__)
shell.Shell().cmdloop()

# !/us
in/env python3
# -*- coding: utf-8 -*
"""
Controls the intelligence computer player.
According to chosen level the class make decision for next movement.
"""
import random
class Intelligence():
"""Intelligence Class."""
orders = (True, False, True)
def __init__(self, level):
"""Initialize levels."""
XXXXXXXXXXself.level = level
def act_easy(self):
"""Return decision as an easy level."""
XXXXXXXXXXreturn random.choice(self.orders)
def act_normal(self, player):
"""Control decision when level is Normal."""
XXXXXXXXXXif player.get_score() < 10:
XXXXXXXXXXprint("Computer: Hmmmmm, my score is low anyway!!")
XXXXXXXXXXreturn True
XXXXXXXXXXreturn self.act_easy()
def act_hard(self, value):
"""Notice that the computer has ability to cheat."""
XXXXXXXXXXif self.cheat_decison() and value not in (1, 6):
XXXXXXXXXXprint("Computer: I think my score gonna be higher now!")
XXXXXXXXXXreturn True
XXXXXXXXXXif self.cheat_decison() and value in (1, 6):
XXXXXXXXXXprint("bst bst --> Computer CHEATS!!")
XXXXXXXXXXreturn False
XXXXXXXXXXprint("Computer: I'm NOT a cheater like you!!")
XXXXXXXXXXreturn self.act_easy()
def get_inti_decision(self, player, dice_value):
"""Return a method using cu
ying approach to set level."""
XXXXXXXXXXif self.level == "normal":
XXXXXXXXXXreturn self.act_normal(player)
XXXXXXXXXXif self.level == "hard":
XXXXXXXXXXreturn self.act_hard(dice_value)
XXXXXXXXXXreturn self.act_easy()
def cheat_decison(self):
"""
XXXXXXXXXXCreate computer decision about cheating.
XXXXXXXXXXUse same boolean tuple to init decision.
"""
XXXXXXXXXXreturn random.choice(self.orders)

#!/us
in/env python3
# -*- coding: utf-8 -*
# pylint: disable=E0401
"""Player Class to control player objects create in game."""
from intelligence import Intelligence
class Player():
"""Player Class."""
reaction = Intelligence(None)
def __init__(self, name, decision):
"""Accept player's name and create score."""
XXXXXXXXXXself.name = name
XXXXXXXXXXself.score = 0
XXXXXXXXXXself.score_list = []
XXXXXXXXXXself.decision = decision
def change_score(self, score):
"""Change player score according to dice dance."""
XXXXXXXXXXif score not in (1, 6):
XXXXXXXXXXself.score += score
XXXXXXXXXXelse:
XXXXXXXXXXprint("OBS!!\n")
XXXXXXXXXXself.score *= 0
def set_name(self, name):
"""Change plyer name."""
XXXXXXXXXXself.name = name
def set_level(self, level):
"""Set computer's level."""
XXXXXXXXXXself.reaction.level = level
def get_name(self):
"""Return player name."""
XXXXXXXXXXreturn self.name
def get_score(self):
"""Return player score."""
XXXXXXXXXXreturn self.score
def set_score_list(self, num):
"""Set score list."""
XXXXXXXXXXself.score_list.append(num)
def get_score_list(self):
"""Return score list."""
XXXXXXXXXXreturn self.score_list

Hello
I want you to help me write unit test for main.py and shell.py classes respectively as I have so many stuff to do please.
Answered Same Day Mar 16, 2021

Solution

Pratap answered on Mar 17 2021
145 Votes
1. main.pt has no functions or method. It is used to execute the command loop.
So main.py doesn't include in testing.
2. As of shell.py, some of the methods doesn't return any values. Those inturn calls other functions/methods.
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here