There is one deliverable for this assignment
This method must have the following header:
def __init__(self, vineyard, type, year):The constructor should set the value of rating to the empty string.
This method must have the following header:
def get_vineyard(self):Returns the value of vineyard.
This method must have the following header:
def get_type(self):Returns the value of type.
This method must have the following header:
def get_year(self):Returns the value of year.
This method must have the following header:
def get_rating(self):Returns the value of rating.
This method must have the following header:
def set_rating(self, rating):Assigns a value to the rating attribute.
This method must have the following header:
def __str__(self):Returns a string containing all attribute values.
This method must have the following header:
def __gt__(self, other):Returns True if the the object's value for year is greater than the other object's value for year.
This method must have the following header:
def __lt__(self, other):Returns True if the the object's value for year is less than the other object's value for year.
This method must have the following header:
def __eq__(self, other):Returns True if the the object's value for year is equal to the other object's value for year.
This method must have the following header:
def __ne__(self, other):Returns True if the the object's value for year is not equal to the other object's value for year.
Open an a text editor and create the file hw10.py.
You can use the editor built into IDLE or a program like Sublime.
Your hw10.py file must contain the following test code at the bottom of the file:
w1 = Wine("Pahkmeyer", "Merlot", 1999) print("vineyard: ", w1.get_vineyard()) print("type: ", w1.get_type()) print("year: ", w1.get_year()) print("rating: ", w1.get_rating()) w1.set_rating(95) print(w1) print("rating: ", w1.get_rating()) w2 = Wine("Hartwell", "Merlot", 2000) print(w2) print("w1 > w2 :", w1 > w2) print("w1 < w2 :", w1 < w2) print("w1 == w2 :", w1 == w2) print("w1 != w2 :", w1 != w2)
You should see
$ ./hw10.py vineyard: Pahkmeyer type: Merlot year: 1999 rating: Pahkmeyer Merlot 1999 rating: 95 Hartwell Merlot 2000 w1 > w2 : False w1 < w2 : True w1 == w2 : False w1 != w2 : True
Write this program in a step-by-step fashion using the technique of incremental development.
In other words, write a bit of code, test it, make whatever changes you need to get it working, and go on to the next step.
True
if the year of the object is greater than the year of the other object. True
if the year of the object is less than the year of the other object. True
if the year of the object is equal the year of the other object. True
if the year of the object is not equal the year of the other object. cd it117
cd hw
mkdir hw10
ls
cd it117/hw/hw10
chmod 755 hw10.py
./hw10.py
vineyard: Pahkmeyer type: Merlot year: 1999 rating: Pahkmeyer Merlot 1999 rating: 95 Hartwell Merlot 2000 w1 > w2 : False w1 < w2 : True w1 == w2 : False w1 != w2 : True
Copyright © 2020 Glenn Hoffman. All rights reserved. May not be reproduced without permission.