This assignment is due Tuesday, April 28 before class time. Do this assignment on turing.cs.niu.edu or hopper.cs.niu.edu. It is worth 100 points. No late homework.
Submission:
To receive credit for this assignment you must turn in a hardcopy of your script AND a machine-readable version using the following rules.
Hardcopy: (Same rules as before.) Assignments must be stapled. Written homework must be turned in at the beginning of the class period to be considered on time. Print programs using non-proportional type (e.g., Courier) in at least 10 point size. You may use proportional type for answers to questions, but make sure the type size is at least as large as what you are reading (i.e., 12 point). This means that you may not print 2-up. Homework should be turned in on 8 1/2 x 11 paper and must be stapled together. The upper right corner of the first page should contain (a) your name, (b) CS330, (c) the assignment number, (d) the date. If you cannot attend class, written assignments will be considered on time if they are left under my office door provided they are received before class time.
Machine-readable: (a) Name your script hw4-xxxx, where xxxx = the first four letters of your last name. (If your last name has fewer than four letters, just use your last name.) (b) Email your script as an attachment to your TA at z139048. Note: no machine name, just the z-number. Email from turing/hopper cannot go outside the cluster; this form will send email within the cluster, regardless of which machine your account is located on. (c) Your script must be mailed as an attachment, not included in the body of the email. (d) The subject line should also say hw4-xxxx.
One email program you can use is alpine. (This is the one used by Linus Torvalds, the originator of linux.) Start it with the alpine command. The first time you will get a message about being counted as an alpine user. After that, use 'c' to compose your email, then fill in the "to" address (z139048), the name of your attachment, and the subject. Then say "hi" to your TA in the body of the email, just so it won't be blank. Finally, use 'x' to send your message, confirming with 'y' when asked.
The first parameter is always the database being queried. The second parameter is always the command that will be executed. Any parameters that follow are specific to the command that was issued.
The general syntax of script invocation is:
autodb dbname command param1 ... paramN
where:
dbname
is the name of the file that contains the database records
command
is one of: create, add, view or delete
param1
... paramN
are paramemters to the specified command
create title text
dbname
.
Any text following the create command will become the first line in the database file.
If no text is given, the default is "Automobile Database".add make model year color
view all
view single number
view range number1 number2
Automobile Database Ford, Mustang, 2008, blue with white stripes Mitsubishi, Lancer, 2009, white Toyota, Camry LE, 2004, black Porsche, Cayenne S, 2007, redAn example "view range 2 3" output looks like this:
Automobile Database Mitsubishi, Lancer, 2009, white Toyota, Camry LE, 2004, black
delete all
delete single number
delete range number1 number2
For example, the database file for the above "view all" command would contain:
Automobile Database Ford, Mustang, 2008, blue with white stripes Mitsubishi, Lancer, 2009, white Toyota, Camry LE, 2004, black Porsche, Cayenne S, 2007, red
a132436@turing:~/unix/assign4$ ./autodb DB create Example for Assignment New database created a132436@turing:~/unix/assign4$ ./autodb DB add Ford Mustang 2008 "blue with white stripes" Successfully added a record to the database a132436@turing:~/unix/assign4$ ./autodb DB add Mitsubishi Lancer 2009 white Successfully added a record to the database a132436@turing:~/unix/assign4$ ./autodb DB add Toyota "Camry LE" 2004 black Successfully added a record to the database a132436@turing:~/unix/assign4$ ./autodb DB add Porsche "Cayenne S" 2007 red Successfully added a record to the database a132436@turing:~/unix/assign4$ ./autodb DB view all Example for Assignment Ford, Mustang, 2008, blue with white stripes Mitsubishi, Lancer, 2009, white Toyota, Camry LE, 2004, black Porsche, Cayenne S, 2007, red a132436@turing:~/unix/assign4$ ./autodb DB delete single 2 1 record deleted a132436@turing:~/unix/assign4$ ./autodb DB view all Example for Assignment Ford, Mustang, 2008, blue with white stripes Toyota, Camry LE, 2004, black Porsche, Cayenne S, 2007, red a132436@turing:~/unix/assign4$ cat DB Example for Assignment Ford, Mustang, 2008, blue with white stripes Toyota, Camry LE, 2004, black Porsche, Cayenne S, 2007, red