IT 117: Intermediate Scripting
Homework 9


Due Sunday, November 12th at 11:59 PM

Deliverables

There is one deliverable for this assignment: It must be in an hw9 directory, which you must create inside a hw directory inside you it117 directory.

Make sure the script obeys all the rules in the Script Requirements page.

Specification

In your hw9.py define the class Book that has the following hidden fields
All but the description field are set by the constructor.

You must create accessor methods for all fields.

You must create a mutator method for description.

You must also create an __str__ method that returns a string with the values of the first five fields.

In the same file you must have a loop which will read in values from the file book.txt which has six lines, each one containing a value for one of the fields.

You must then copy the following test code into your script
b1 = Book(title, sub_title, author, publisher, copyright)
b1.set_description(description)
print('Title:', b1.get_title())
print('Sub_title:', b1.get_sub_title())
print('Author:', b1.get_author())
print('Publisher:', b1.get_publisher())
print('Copyright:', b1.get_copyright())
print('Description:', b1.get_description())
print(b1)

Testing

I have created the file book.txt in the directory /home/ghoffman/course_files/it117_files.

Your output should look something like this
Title: Guns, Germs, and Steel
Sub_title: The Fates of Human Societies
Author: Jared Diamond
Publisher: Norton
Copyright: 1997
Description: How the accident of geography influences the development of technology
Guns, Germs, and Steel: The Fates of Human Societies, Jared Diamond, Norton (1997)
Be sure to run this script on the Unix machine so you know it works in the environment in which I will run it when I score your homework.