Assignment - Locations For this assignment, we will be creating our location class and then a few locations to subclass from it. Most of these classes will be rather short so you can put them all in locations.py if you would like Create the Location class Create the Town class Create the Palace and Lumbermill classes Location Class The Location class establishes the basic properties of a location: manager - holds the character that manages the location foreColor - holds the fore color of the location backColor - holds the back color of the location Enter() - default method for entering a location. By default, the manager should greet you and all text displayed should use the foreColor and backColor of the location. Exit() - default method for leaving a location. By default, the manager should say bye to you and all text displayed should use the foreColor and backColor of the location. Upkeep() - default method that is called when time is advanced Town Class The Town class will inherit from the Location class and will contain all our locations:

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Assignment - Locations
For this assignment, we will be creating our location class and then a few locations to subclass from it. Most of these classes will be rather short so you can put them all in locations.py if you would like
Create the Location class
Create the Town class
Create the Palace and Lumbermill classes

Location Class
The Location class establishes the basic properties of a location:

manager - holds the character that manages the location
foreColor - holds the fore color of the location
backColor - holds the back color of the location
Enter() - default method for entering a location. By default, the manager should greet you and all text displayed should use the foreColor and backColor of the location.
Exit() - default method for leaving a location. By default, the manager should say bye to you and all text displayed should use the foreColor and backColor of the location.
Upkeep() - default method that is called when time is advanced

Town Class
The Town class will inherit from the Location class and will contain all our locations:

palace - create a Palace location and store it here
lumbermill - create a Lumbermill location and store it here
Enter() - Print a menu for all the locations available. Call the Enter() method of the appropriate location. Also, display the current date (see below)
Exit() - If you leave the town, it should exit the program.
Upkeep() - Trigger the upkeep method of all locations

Palace class
The Palace class will inherit from the Location class.

Give option to deposit gold (add some gold to your Player when generating). Show currently deposited gold when inside the palace
Give an option to rest. After rest, trigger the upkeep of all locations.
The manager of the palace is the player.
You should not greet yourself when entering or exiting...
Lumbermill class
The Lumbermill class will inherit from the Location class.

add the following properties
rate - this is wood per day
capacity - this is max wood you can hold
stock - this is the current amount of wood you have
Enter() - As well as greeting you, the screen should also display rate, capacity and stock.
Upkeep() - This should add the value of rate to your stock. Do not exceed capacity


Displaying the date - I decided on a system where we will follow the seasons and advacing time will advance 1 week. We will start on Week 1 of Spring. Everytime the player rests, it should advance 1 week. After 13 weeks, reset back to 1 and advance the season.

To bring this all together, you should create a player and then have them Enter() the Town.

Zip your python files and submit.

Expert Solution
Step 1

Due to complexity of the question we have attempted a partial answer to your question outlining the important aspects of the requirements - namely, the Location, Town and Palace classes. The code for the same is given below:

from datetime import datetime, timedelta
 
class Location:
def __init__(self, foreColor,backColor,name):
self._manager = ''
self._foreColor = foreColor
self._backColor = backColor
self._time = datetime.now()
self._name = name
 
def Enter(self,manager):
self._manager = manager
self._time = datetime.now()
print('Its '+ str(self._time))
print('Welcome from '+self._manager)
 
def Exit(self):
print('Bye!')
 
def UpKeep(self):
self._time += timedelta(hours=2)
print(self._time)
 
class Town(Location):
def __init__(self,foreColor,backColor,name, palace,lumbermill):
super().__init__(foreColor,backColor,name)
self._locations = []
self._locations.append(palace)
self._locations.append(lumbermill)
 
def Enter(self):
for i in self._locations:
print(i._name)
i.Enter(str(i))
def Exit(self):
for i in self._locations:
i.Exit()
def UpKeep(self):
for i in self._locations:
i.UpKeep()
 
class Palace(Location):
def __init__(self, foreColor,backColor,name):
super().__init__(foreColor,backColor,name)
 
if __name__ == '__main__':
loc1 = Location('red','blue','loc1')
loc1.Enter("john")
loc1.UpKeep()
loc1.Exit()
 
palace1 = Palace('red','blue','a palace')
lumbermill1 = Location('brown','brown','a lumbermill')
town1 = Town('green','white','a town',palace1,lumbermill1)
town1.Enter()
town1.UpKeep()
town1.Exit()
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY