CS 230 Spring 2007 Assignment 10
– More Files– 100
points
Assigned: 04/04/2007
Due: 04/18/2007 at the start of class
Pre-Lab (Do Before Lab): Bring materials – a way to
save a copy for you and a copy to turn in. Plan out tasks, objects, and events needed
for program. Write pseudocode for the main buttons and for functions /
independent sub procedures.
.
Main Assignment:
LaSoogle Labs is developing an online radio station in which
you create your own personal radio station and music is streamed to you based
on what you like and don’t like (like other services already out there). Your
program is a simplification dealing with ranking songs (only). .
·
The program should get
from a file (songs.txt) a list of songs and display them in a list box.
·
When the user selects
a song from the song list box, the song information should be displayed in two
read-only text boxes or in labels. Separate the song title and artist (the
file format is to divide these using the word “by” instead of a comma.)
·
When a user specifies
a rating (0-5) AND selects a “Rate” button, write the rating (song, artist and
rating) to a comma-delimited text file for later tabulation (add it to those
already in the file), and remove the song from the list box of songs. (DO NOT
have the rating recorded immediately upon selection in case of inadvertent
click).
·
Provide the rate
capability, a clear (clear song and artist, set rating to default, and clear
any selection in the list box (see below)), and an exit capability.
·
A sample interface is
provided on page 2. Don’t let that constrain your creativity. Use it to help
understand what I see as the inputs and outputs.
Hand in:
- Floppy disk or CD-R with an entire folder containing all
files related to the project (or e-mail with zipped attachment containing
all files related to the project).
- Please set the name of the project to something
other than the default name (WindowsApplication1, …). It is
helpful if you use a name that identifies you as well as the assignment
(e.g. yourlastname assignment 10).
- Use Windows to copy the whole folder, instead of trying
to “Save As”.
- Print out of your code.
Task Details:
- In clearing, to clear
the selection of an item in the list box you can use: listboxname.SelectedItem = Nothing. “nothing” is a built in value – typing it
in (nothing) you should see it turn blue.
- Validation:
·
It is permissible (recommended)
to use a combo box to obtain the user’s rating of a song. You can avoid the
need to validate rating at all if you:
1.
use a DropDownStyle property
value of DropDownList – which makes it impossible for the user to type in
values of their own, and
2.
always ensure that the combo
box has a default value. When loading the form and when clearing, set
cmboboxname.SelectedIndex = thenumberoftheitemyouwanttobethedefault (starts
counting with zero)
·
If the rating is done as a
regular text box, you must validate as always.
·
You need to ensure that a
song has been selected before accepting a rating (display a msgbox complaining
if not)
- After the Rate button
has been recorded, give the listener some kind of confirmation (e.g. a
msgbox) and automatically clear the song and artist choices and set the
rating back to default.
- Remove the successfully
rated song from the list box using listboxname.Items.Remove(itemtoremove)
where itemtoremove is the item to be removed. If the item will still be
selected, this could be listboxname.ItemSelected
- When you remove the
song from the songs listbox (and when you clear the list box selection for
the clear button), that will result automatically in a change to the item
selected property of the list box, triggering an event. Your event
procedure for that event needs to protect against that crashing your
program (the selected item will be set to “nothing”. To test if a selected
item is nothing you cannot test for = Nothing. You need to do a test
checking: listboxname.SelectedItem is Nothing
- You must
use the filename specified above, so I can easily test a bunch of
different programs in a row. Sample files are provided on the assignments
page of my www site. In the spirit of thorough testing of programs, you
should try other versions of files as well.
- We have covered
procedures and functions – I recommend that you continue to use them (e.g.
extracting a line of text from the text in a file).
- MAKE SURE YOUR PROGRAM
WORKS! (i.e. gets the correct answers). It doesn’t have to just run, it
needs to always run correctly! It should correctly handle
anything the user does. Think up some
different examples to test the program on.
Miscellaneous
- You must turn on
Option Explicit and Option Strict.
- Put YOUR NAME, e-mail
address, date, and purpose of the program in comments at the beginning of
the program. The purpose should be what the program is supposed to do, not
the learning goals. Comments are indicated with a single quote (everything
after the single quote is only for humans)
- You MUST include
comments that explain your program in order to get full credit.
- Define numbers
(especially those that appear more than once and/or could change sometime
in the future) as named constants.
- Remember to use
meaningful variable names
- Remember to indent to
show the structure of the program (VB usually does this correctly).
- Name all textboxes, list
boxes, comboboxes, and buttons meaningfully, and use conventions for starting
their names.
- Make textboxes that
user should never enter a value in (results / outputs) “Read Only”.
- Put your name on
the form as a Label or as part of the form title.
- Try to use good user
interface design. Make clear what user needs to do and what the answers
mean. Make error messages as clear and helpful as possible!