Question: Python 3!!! Fill in the code to create a working copy of Oregon Trail --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- import random class Person(object): def __init__(self, name : str):

Python 3!!!

Fill in the code to create a working copy of Oregon Trail

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

import random

class Person(object):

def __init__(self, name : str): """ Initializes a Person with their name, and sets their health to 100 :param name: str - The name of the settler :return: """ pass

def __str__(self): """ :return: str Format with the name_-_health of the person """ return ""

class Wagon(object):

def __init__(self, food : int): """ Sets up an instance of the wagon. :param food: The amount of food in pounds on the wagon. :return: :attributes to set food : int - Food passed in as paramter mile : int - How many miles the wagon has travelled Initialize to 0. settlers : list - Create an empty list of the settlers ( instances of Person ) pace : int - How fast the settlers will be moving. 1 - slow, 2 - moderate, 3 - fast rations : int - Rationing setting for the setllers 1 - normal ration, 2 - small ration, 3 - limited rations day : int - The day of the adventure. Starts at 1. """ self.settlers = [] pass

def pace_str(self): """ Returns a string representation of the pace :return: str - If pace is 1, return 'slow' If pace is 2, return 'moderate' If pace is 3, return 'fast' """ return ""

def ration_str(self): """ Return a string representation of the rations :return: str - If ration is 1, return 'normal' If ration is 2, return 'small' If ration is 3, return 'starving' """ return ""

def group_health(self): """ Returns back a string of how the settlers are doing. :return: str - If the average health of all the settlers alive is > 80, then return 'good' If the average is > 50 return 'fair' otherwise, return 'poor' """ return ""

def __str__(self): """ Returns a String representation of the wagon Shown below :return: - str

Wagon is at 0 mile on day 1 You have 2000 pounds of food left You are moving at moderate pace with normal rations Settlers are in good health

""" return ""

def can_move(self): """ Returns True if there are any settlers alive, False otherwise :return: bool """ return True

def arrived(self): """ Returns True if they've made it the 2170 miles to Oregon, False otherwise :return: bool """ return True

def alive(self): """ Returns True if there are settlers alive, False if not :return: bool """ return True

def game_over(self): """ Returns True if the game is over. The game is over if they made it to oregon, or all the settlers are dead. Otherwise it returns False :return: bool """ return True

def feed_settlers(self): """ Decrements the food and feeds the settlers If rations is 1, then each settler eats 3 pounds of food / day If rations is 2, then each settler eats 2 pounds of food / day If rations is 3, then each settler eats 1 pound of food / day :return: None """ pass

def adjust_health(self): """ Adjusts the health of all the settlers depending on rationing and pace. Less food, faster pace depletes their health faster. If a settler health is <= 0, then they are dead and removed from the wagon. RIP

The amount each settler loses in health is a random number.

pace 1 | 2 | 3 | --------------------------------------------------------- ration 1 | randint(0, 1) | randint(0, 2) | randint(0, 3) | 2 | randint(0, 2) | randint(0, 4) | randint(0, 6) | 3 | randint(0, 3) | randint(0, 6) | randint(0, 9) |

:return: None """ pass

def move(self): """ Moves the wagon by the game rules The player only moves if they can move and they haven't arrived yet. The number of miles covered if they can is random and dependent on pace If the pace is 1, then they move from 5 - 10 miles inclusive If the pace is 2, then they move from 13 - 17 miles inclusive If the pace is 3, then they move from 18 - 23 miles inclusive If they haven't arrived, then you should call feed_settlers and adjust health. The day should get incremented. :return: None """ pass

def rest(self, days): """ Rests the Group for a given number of days. Each day of rests returns back 2 health to each settler. ( Don't forget to feed them each day ) :param days: int - How many days to Rest :return: None """

def play_trail(wagon): """ Iterates over trail until they get to the destination or lose """ while not wagon.game_over():

print(wagon) choice = 1 # Get the players choice from menu if choice == "1": wagon.move() elif choice == "2": # change Pace pace_choice = 1 # Get new pace from user wagon.pace = int(pace_choice) elif choice == "3": # Change Rations ration_choice = 1# Get new Ration choice from user wagon.ration = int(ration_choice) elif choice == "4": rest_days = 3 # Get number of days to rest from user. wagon.rest(rest_days) elif choice == "5": # output the state of the settlers print("Settlers ") for settler in wagon.settlers: print(settler) wagon = Wagon(2000) wagon.settlers.append( Person("Player1")) wagon.settlers.append( Person("Player2")) wagon.settlers.append( Person("Player3")) wagon.settlers.append( Person("Player4")) wagon.settlers.append( Person("Player5")) play_trail(wagon)

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!