Você está na página 1de 4

Bachelor of Computing Systems

ITPR5.500 Introduction to Programming

Assignment 2 - Semester 1 2014

Date due: 6 June 2014 @ 5pm


Weighting: 40%
Marks: 100

Instructions:
Students are to attempt all tasks in the assignment.

Marks will be awarded for logic design, efficient use of code, creativity, and
documentation. The completed application will be submitted in soft copy and
should include all documentation as specified in this assignment. Keep a
backup copy at least until you have your mark.

This assignment must be delivered by 5pm on the due date, and must have
been presented during a lab session in the same week.
Assignment 2

MyPlaylists
Problem description
You need to create playlists that consist of song references along with some extra data. The
actual song (an MP4 or WAV file is not included, and does not play a role in this assignment).
The implementation is completely done in either Snap or Python, and no other resources are
needed. Discuss with your lecturer which programming language you are allowed to use.

The MyPlaylist object can contain multiple MySong objects. MyPlaylist also contains methods
for adding, removing, showing, and accessing its MySong objects. Each MySong object
contains a song title, the artist's name, and a 'like' indicator. A 'like' indicator is a value that
represents how much you like this song. MySong objects also contain methods for setting the
title, name, and like indicator, changing the like indicator, and undoing the last modification to
the like indicator.
You need to implement the MyPlaylist object with its MySong objects, and a simple
application that allows the user to interface with MyPlaylist objects. More details per feature
are given below.

Requirements
The MyPlaylist object and the contained MySong objects need to be explicitly created using
the concept of constructors and methods. These programming concepts will be discussed
extensively during class sessions. It is also described in the Snap manual in the section
"Building Objects Explicitly". Below are the details you need to implement at least. You may
need to implement more methods to complete all requirements.

The MyPlaylist object contains a list of MySong objects, a method to add another MySong
object, a method to remove a MySong object by its title, a method to show the list of song
titles, and a method to access a MySong object by its title. All these features are local to the
MyPlaylist object.

_mySongs: this is a list only available to the MyPlaylist object, and is initially empty.
Its role is to contain MySong objects.

add(): this is a method that requires a MySong object as a parameter. This method
will add the given MySong object to the _mySongs list.

showTitles(): this is a method that requires no parameters. The method will show
the song titles it currently contains.

remove(): this is a method that requires a song title as a parameter. It will then find
the MySong object in _mySongs with the given title, and remove it from the list.
Implement a solution in case the title cannot be found.

getMySong(): this is a method that requires a song title as a parameter. It will then
return the MySong object in _mySongs with the given title. Implement a solution in
case the title cannot be found.

A MySong object contains a song title, an artist's name, and a likes inidicator. You may
assume that the song title is unique (i.e. there will only be one song with this title). A MySong
object further contains methods to set the title and artist's name, to edit the likes indicator, and
to undo the likes indicator edit. All these features are local to a MySong object.

_songTitle: this is a variable that contains the song title of this MySong object.
Initially the title is "Song title".
_artistName: this is a variable that contains the name of the artist of this song.
Initially the name is "Artist name".

_likeIndicator: this is a variable that contains a number between 1 and 5 (inclusive)


or -1. The higher the number, the more you like this song. The value is set to -1
initially, meaning "no like indicator set".

setTitleAndArtist(): this is a method that requires a song title and an artist's name
as parameters. It will then set _songTitle to the given title, and _artistName to the
given name. You do not need to verify that this title is unique.

setLike (): this is a method that requires a number between 1 and 5 as a parameter.
Any other number (even -1) is not accepted and consequently this method will not
change anything. Otherwise, this method will set the _likeIndicator to the given
(valid) number.

undoSetLike(): this is a method with no parameters. It will undo the result of the last
setLike() call (it will set the _likeIndicator back to what it was). You can only undo
the last change. Calling the undoSetLike() again will have no effect until you first
have set the _likeIndicator again with setLike().

The application allows a user to use your MyPlaylist implementation. Your application is
represented by a sprite, and this sprite will ask the user what to do. The user can then choose
from the features you have in MyPlaylist.

Use only the Snap environment or Python interpreter and use only your own code. Do not
copy code from someone else or the internet. Evidence of copied code will be treated as
plagiarism.

The application must be easy to use in all respects. The program logic should be
straightforward and not unnecessarily complex. The code should be tidy and have the proper
comments attached to the appropriate code blocks, explaining the idea/design of the code
block, and how it relates to other parts of your code. You may assume the reader can read
code, so provide value-add in your comments.

Delivery
You need to discuss your progress on this assignment with your lecturer every week. This is
typically done during the lab sessions. If you cannot make it to a lab session, make sure you
still discuss your work with your lecturer in that week. These discussions are part of the
marking schedule.
During the lab session in the week this assignment is due, you have to demonstrate your
application. The lecturer may then ask you questions about your code. (And you're expected
to answer these).

Hand in
• Pictures of all your code, annotated with their scope (i.e. the sprite it belongs to, or "for all
sprites"). Use the feature "scripts pic…" in Snap. Python users are exempted from this
requirement.
• The complete Snap project or Python project of your assignment. That is your exported
.xml file for Snap users. It is your .py file(s) for Python users.

You must deliver your assignment through the EITOnline course website which contains a link
called "Assignment 2 Upload Link". You will upload a single zip file containing all deliverables
as described above. Keep a copy of your solution until you have your mark.
Introduction to Programming

Assignment 2 Marking Guide Name

 Material handed in as specified /5

 MyPlaylist class implementation / 25


 all features implemented according to specification / 10
 code is straightforward, avoiding overhead / 10
 coding conventions applied /5

 MySong class implementation / 25


 all features implemented according to specification / 10
 code is straightforward, avoiding overhead / 10
 coding conventions applied /5

 Application using object features / 25


 all features available through the user interface / 10
 code is straightforward, avoiding overhead / 10
 coding conventions applied /5

 Weekly discussions / 10

 Final demonstration / 10

TOTAL _____ / 100

Você também pode gostar