IT 117: Introduction to Scripting
Homework 10

Due

Thursday, October 23rd at 11:59 PM

What You Need to Do

Setup On Your Machine

Specification

Methods

__init__


get_vineyard


get_type


get_year


get_rating


set_rating


__str__


__gt__


__lt__


__eq__


__ne__

Test Code

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)

Output

Suggestions


  1. Create the file hw10.py.
    Write the class header for Wine.
    Write the constructor for this class.
    Make sure the constructor sets the value for each attribute, including rating.
    The value for year should be stored as an integer.
    Copy the test code to the bottom of the script.
    Comment out all line in the test code except the first.
    You comment out a line by making # the first character on the line.
    Run the script.
    Fix any errors you find.
  2. Create get_vineyard.
    Uncomment the 2nd line of the test script by removing the #.
    Run the script.
    Fix any errors you find.
  3. Create get_type.
    Uncomment the 3rd line of the test script.
    Run the script.
    Fix any errors you find.
  4. Create get_year.
    Uncomment the 4th line of the test script.
    Run the script.
    Fix any errors you find.
  5. Create get_rating.
    Uncomment the 5th line of the test script.
    Run the script.
    Fix any errors you find.
  6. Create set_rating.
    Uncomment the next two lines of the test script.
    Run the script.
    Fix any errors you find.
  7. Create __str__.
    Uncomment the next three lines of the test script.
    Run the script.
    Fix any errors you find.
  8. Create __gt__ which returns True if the year of the object is greater than the year of the other object.
    Uncomment the next line of the test script.
    Run the script.
    Fix any errors you find.
  9. Create __lt__ which returns True if the year of the object is less than the year of the other object.
    Uncomment the next line of the test script.
    Run the script.
    Fix any errors you find.
  10. Create __eq__ which returns True if the year of the object is equal the year of the other object.
    Uncomment the next line of the test script.
    Run the script.
    Fix any errors you find.
  11. Create __ne__ which returns True if the year of the object is not equal the year of the other object.
    Uncomment the next line of the test script.
    Run the script.
    Fix any errors you find.

Testing on Your Machine

Copy the Script to Unix

Testing the Script on Unix (Optional)

Copyright © 2020 Glenn Hoffman. All rights reserved. May not be reproduced without permission.