I210-python代写
时间:2022-12-09
I210: Information Infrastructure I
Mastery Project 3
Always backup your work to a system that you don’t control, such as
OneDrive or Google Drive, in case something goes wrong with Canvas.
These put a timestamp on your work that can be used to prove when it was
done. We cannot accept timestamps from your local machine.
You are responsible for making sure your work is submitted by the due date
on Canvas, so it is strongly advised that you verify the submission once you’ve
turned it in. We accept Mastery Projects up to 24 hours late, for a 20% penalty.
As a reminder, while working on this project, you may use anything on the
Canvas section for I210, as well as Zybooks. You may use any notes (physical
or online) taken for I210.
Using code you found online from outside of this class or code that you did
not write that is not Zybooks code or from our Canvas section is likely to
constitute academic misconduct. If you are unsure, ask first.
If you have questions about what we want you to do in this Mastery Project,
ask in Q & A community. If you get stuck writing your code and need help,
come to an Office Hour. Start early so that there’s as much time as possible to
get help!
Mastery Project 3 requires you to use pieces from all the lessons in this
course, so you won’t be able to complete all elements until you’ve done
this material. Keep an eye out for pieces that you’ll need!
1Shelter Management
In this project, we will be writing code for an animal adoption agency to
provide a visitlist where prospective adopters can add the animals they want
to visit and probably adopt. Adopters can see the visitlist, delete animals from
the list, then adopt one of the animals from their visitlist, most likely after they
visit these animals at the shelter. In this project we create a class Visit, the
instances of which would be visitclass objects. We also create an Animal class
for animals in the shelter.
You will use pieces we’ve already written, including: people.py, and
data_handling.py – please make sure you download a copy of these from the
MP3 folder. You will also need two more starter files: animal.py and visit.py
Please note: The data_handling.py file, and in particular table_print function
is updated. Make sure you familiarize yourself with the updated features of
this function.
1 Image taken from: https://www.cuteanimalnames.com/wp-content/uploads/2019/08/cute-animals-1.jpg
on November 9th, 2021
There are 4 parts to Mastery Project 3:
1. Initial setup and Visit class
Put the 4 files we’ve given you into the same directory.
Define a Visit class, that creates visitlist objects with the following
attributes:
- A number (integer) to uniquely identify each of the visitlists
- A list containing the animals the person wants to visit for a possible
adoption
- The person who is interested in visiting (Person object)
- Whether or not the adoption has been completed (Boolean)
Write a method that allows people to add new animal objects to the
visitlist, as long as:
- The object we’re trying to add really is an animal object
- The exact same animal isn’t already in the list
- The animal has not been adopted yet
Write a method that allows people to delete an existing animal object
from the visitlist, as long as:
- The animal we’re trying to delete is in the visitlist
Write a method to allow people to adopt an animal from the visitlist
(setting that animal as adopted, and the visit list as a completed
adoption), as long as:
- The animal has not been adopted yet
- The visitlist has not been marked as completed adoption yet
- The animal is in the visitlist
You will need imports for animal and people for this to work.
PLEASE NOTE: For simplicity assume that a person can only make one
adoption per visitlist. So if someone needs to make more than one
adoption, they can (and should) have more than one visitlist.
2. Visitlist protection and outputs
Add a class attribute (a list) that tracks all current visitlists. When a visitlist
is created, instead of manually giving it a number, the visitlist numbers
should start at 1 and auto-increment (increase by 1) after that. (Hint: use a
class attribute to track this)
Complete the constructor and the string method in Visit class.
Add encapsulation to all attributes in the Visit class. Add getters and
setters as needed to perform the other tasks the Visit class requires.
Write a method that can display all the animals with their attributes in a
visitlist. (Hint: import data_handling and use table_print for output) When
a visitlist is marked as completed adoption, call this method to print all the
animals in the visitlist, and also print the person’s name and the visitlist
number.
Write a function to add animal to visitlist, as long as:
- The object we’re trying to add really is an Animal (Belong to the class
Animal)
- The exact same animal isn’t already in the list
- The animals has not been adopted yet
- The person has not adopted an animal yet
Write a method that allows people to delete an existing animal object from
the visitlist.
Write a method to to allow a person to make an adoption of an animal
object (setting the animal as adopted, and setting the visitlist as completed
adoption), as long as:
- The adoption has not been completed yet for that visitlist
- The animal is in the visitlist
- The animal has not been adopted yet
3. Animal reporting and testing
In animal.py, add a method or methods that can produce the following
pieces of reporting (output generally used to interrogate the data):
Which animal kind is the most popular (i.e. shows up in the most visit
lists)?
Given the kind and age as input, report all of the animals who are not
adopted of that kind with the age that is less than or equal to the
given age. Use table print for the report.
(Hint: Both of these questions require you to look at ALL animals, so why
not use a static method?)
Write a method that overloads “==” for animal objects when their
name, age, kind, and colors are the same.
Furthermore, in main of both animal.py and visit.py, create test data that
tests ALL pieces of your code. You should create at least 3 people, more
animal than we have created for you, and at least 5 visitlists with multiple
animals each. Make sure you test at least for the following aspects of your
code:
a. add an animal to a visitlist that has already been added
b. add an animal to a visitlist that has already been adopted
c. trying to adopt an animal when the visitlist has already been marked
as completed adoption
d. Trying to add an animal to the visitlist that does not exist in the
shelter
e. Trying to delete an animal that is not in the visit
4. BONUS: Creativity
What else can you make the visit class do? Are there other classes you
can add that extend the functionality? What other reporting would be
useful? Impress us with your creativity!
In each section, functionality will account for about 70% of the grade.
10% of the points will be awarded for proper use of functions. Please do
not write the entire project in main! Any discrete piece of the problem should
be in a function.
10% of the points will be for observation of programming conventions,
good naming, commenting, not duplicating code, etc. We expect you to
produce well-written, well-organized code, not just code that works.
The last 10% is for completing the turn-in sheet on the next page, which
you should submit along with your Python program.
I210 Turn-In Sheet: Mastery Project 3
Fill in the sheet anywhere there is a yellow arrow! This is IN ADDITION to your Python files.
→ Your name:
For this assignment, please submit:
1. This “turn in” worksheet (completed - required)
2. Your Mastery Project 3, named MP3-YourLastName-YourFirstName.py
Part 1 (2 pts)
→ How did you import the other classes into visit.py?
→ How did you check to make sure an object was really an Animal?
Part 2 (3 pts)
→What class attributes did you use? Were they protected using
encapsulation?
→ What getters and/or setters did you add to the Visit class?
→ Did you use table_print() or something else for output?
Part 3 (4 pts)
→ How did you compute the most popular animal?
→ How did you compute the most popular adopted animal kind?
→ What other questions could you answer with the data you created?
→ Did you use one static method or several?
Overall (1 pts)
→ How did you approach testing your code in main to make sure it
checked all of your validation?
Bonus (Optional)
→ What did you add to the code? What can your version of these files
do that wasn’t required?
essay、essay代写