IT 117: Introduction to Scripting
Homework 8
Due
Sunday, April 2nd at 11:59 PM
Deliverables
There is one deliverable for this assignment
Make sure the script obeys all the rules in the
Script Requirements page.
Specification
In your hw8.py define the class LP that has the following attributes
The class must have the following methods
- get_title
- get_label
- get_artist
- print_lp
get_title
This method returns the value of the title attribute.
get_label
This method returns the value of the label attribute.
get_artist
This method returns the value of the artist attribute.
print_lp
This method prints a string consisting of the value of the title attribute,
followed by a comma and a space, the value of the label
attribute,
followed by a comma and a space, and the value of the artist
attribute.
Script for this assignment
Open an a text editor and create the file
hw8.py.
You can use the editor built into IDLE or a program like Sublime.
Test Code
Your hw8.py file must contain the following test code at the
bottom of the file:
lp = LP("The London Concert", "Sony Classical", "Wynton Marsalis")
print(lp.get_title())
print(lp.get_label())
print(lp.get_artist())
lp.print_lp()
Run the script.
You should see
$ ./hw8.py
The London Concert
Sony Classical
Wynton Marsalis
The London Concert, Sony Classical, Wynton Marsalis
Suggestions
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.
- Create the file hw8.py.
Write the class header for LP.
Write the constructor for this class.
Make sure the constructor has parameters for each attribute.
Make sure the constructor sets the value foe each attribute.
Add the first line of the test code to the bottom of the file.
Run the script.
Fix any errors you find.
- Create the method get_title.
Add the second line of the test code to the bottom of the file.
Run the script.
Fix any errors you find.
- Create the method get_label.
Add the third line of the test code to the bottom of the file.
Run the script.
Fix any errors you find.
- Create the method get_artist.
Add the fourth line of the test code to the bottom of the file.
Run the script.
Fix any errors you find.
- Create the method print_lp.
Add the last line of the test code to the bottom of the file.
Run the script.
Fix any errors you find.
Testing on Your Machine
- Open IDLE
- Use the Open command in IDLE to open hw8.py
- Under the Run menu, select Run Module
- Your output should look something like this
Unix Setup
- Log in to users3.cs.umb.edu
You will be in your home directory.
- Go to your it117 directory
cd it117
- Go to your hw directory
cd hw
- Create a directory for this exercise
mkdir hw8
- Check that the directory was created
ls
Copy the file to Unix
- Open FileZilla and connect to
users3.cs.umb.edu
You will have to connect using your Unix username and password.
- Copy the file to the to it117/hw/hw8
Testing the script on Unix
Copyright © 2020 Glenn Hoffman. All rights reserved. May not be reproduced without permission.