![]() |
![]() Spring Semester 2004
|
Thu May 6
Mon May 3
Date: Sun, 2 May 2004 14:02:27 -0500 (EST) From: Adrian German <dgerman@cs.indiana.edu> To: A348 Spr. 2004 Distr. List <dgerman@indiana.edu> Subject: A348 final exam update Dear A348 Friends, I am writing to let you know that I will keep help sessions Mon-Tue-Wed of next week between 8-9pm in LH016. In addition to the individual appointments. For the final exam: a) a Javascript implementation b) a servlet implementation (sessions or hidden fields) and c) a JSP implementation (with hidden fields if (b) used sessions and sessions if (b) used hidden fields) would be enough. Three more implementations (only one of which could use hidden fields) would safely account for the project. Anything else that you do would just give you extra points. The final exam on Thu is based on simple questions like these: http://www.cs.indiana.edu/classes/a348-dger/spr2003/exams/questions.html Exam is open book. Please let me know if you have any questions. ... Adrian
Fri-Sun Apr 30-May 2
Date: Sat, 1 May 2004 21:58:40 -0500 (EST) From: Adrian German <dgerman@cs.indiana.edu> To: A348 Spr. 2004 Distr. List <dgerman@indiana.edu> Subject: individual appts for the finals week Dear A348/A548 friends, Times for the individual appointments next week are listed at: http://burrowww.cs.indiana.edu:17600/cgi-bin/spr2004finalAppts/schedule Please choose a time so we can discuss. Our meetings will be short. I will also start sending individual messages soon. Hoping your weekend is coming along fine and wishing you a great finals week. ... Adrian
Mon-Thu Apr 26-29
That was the first, and it became this (in close to 5 mins.):import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class One extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); String user = request.getParameter("user"); int good = 0, totl = 0; String message = ""; if (user == null) { message = "Welcome.<p>"; } else { good = Integer.parseInt(request.getParameter("good")); totl = Integer.parseInt(request.getParameter("totl")); int answer; try { answer = Integer.parseInt(request.getParameter("answer")); } catch (Exception e) { answer = 0; } int key = Integer.parseInt(request.getParameter("key")); if (answer == key) { good += 1; } else { } totl += 1; message = "Your score: " + good + " out of " + totl + "<p>"; } int one, two; one = (int)(Math.random() * 200 - 100); two = (int)(Math.random() * 200 - 100); PrintWriter out = response.getWriter(); out.println( message + "What is " + one + " + " + two + "?<p>" + "<form method=GET action=" + request.getContextPath() + request.getServletPath() + ">" + "Please type the answer here: <input type=text name=answer> <p> " + "When finished press <input type=submit value=Proceed>" + "<input type=hidden name=good value=" + good + ">" + "<input type=hidden name=totl value=" + totl + ">" + "<input type=hidden name=key value=" + (one + two) + ">" + "<input type=hidden name=user value=yes>" + "</form>" ); } }
<% String user = request.getParameter("user"); int good = 0, totl = 0; String message = ""; if (user == null) { message = "Welcome.<p>"; } else { good = Integer.parseInt(request.getParameter("good")); totl = Integer.parseInt(request.getParameter("totl")); int answer; try { answer = Integer.parseInt(request.getParameter("answer")); } catch (Exception e) { answer = 0; } int key = Integer.parseInt(request.getParameter("key")); if (answer == key) { good += 1; } else { } totl += 1; message = "Your score: " + good + " out of " + totl + "<p>"; } int one, two; one = (int)(Math.random() * 200 - 100); two = (int)(Math.random() * 200 - 100); %> <%=message%> What is <%=one%> + <%=two%> ?<p> <form method=GET action=<%=request.getContextPath()+request.getServletPath()%> > Please type the answer here: <input type=text name=answer> <p> When finished press <input type=submit value=Proceed> <input type=hidden name=good value=<%=good%> > <input type=hidden name=totl value=<%=totl%> > <input type=hidden name=key value=<%=(one + two)%> > <input type=hidden name=user value=yes> </form>
Thu-Sun Apr 22-25
Date: Wed, 21 Apr 2004 23:25:08 -0500 (EST) From: Adrian German <dgerman@cs.indiana.edu> To: A348 Spr. 2004 Distr. List <dgerman@indiana.edu> Subject: A348/A548 this week Dear A348/A548 Friends, Fulya will be teaching the lecture tomorrow and Shakila will help me with the lab on Friday morning. I am off to Boston for a conference (NKS 2004, http://www.wolframscience.com/conference/2004/) and presentation and will be returning Sun night. Many thanks to Fulya and Shakila for their help. Fulya has several options tomorrow: a) help with Homework 6, 7 starting from the JSP we discussed Tuesday b) demonstrate Java RMI concepts c) help Muna (Adhamy) make a demo of her project. Muna has graciously agreed to demonstrate her A348 project to the class. It is a web chat using Flash MX on the client, and a custom open source Java server on the server side. Excellent work! Thank you, Muna, in advance for your presentation tomorrow. As mentioned in class this week you should give top priority to the programs for the final. It's a lot of work and for that reason a lot of it could count for the 15% of the semester project grade as well. So just start as soon as possible and work fast and post your programs quickly so you can get most of it out of your way. The JSP discussed Tuesday has been posted under this week's lab notes. Wishing you well---we will see you when I return to Bloomington. ... Adrian
Thu Apr 22
<% int count, right; String message = "Hello and welcome to the addition quiz!"; if (session.getAttribute("count") == null || request.getParameter("reset") != null) { session.setAttribute("count", new Integer(0)); count = 0; session.setAttribute("right", new Integer(0)); right = 0; } else { count = ((Integer)(session.getAttribute("count"))).intValue(); right = ((Integer)(session.getAttribute("right"))).intValue(); try { if (Integer.parseInt(request.getParameter("answer")) == ((Integer)(session.getAttribute("answerKey"))).intValue()) right += 1; else right += 0; } catch (Exception e) { } count += 1; message = right + " out of " + count; if (count == 10) { message = "Final result: " + message + ". New game started "; count = 0; right = 0; } else message = "Your performance thus far: " + message; session.setAttribute("count", new Integer(count)); session.setAttribute("right", new Integer(right)); } int one = (int) (Math.random() * 100 - 50), two = (int) (Math.random() * 100 - 50); session.setAttribute("answerKey", new Integer(one + two)); %> <html> <body> <form action="<%=request.getContextPath() + request.getServletPath()%>"> <%=message%> <p> Question <%=count+1%>. <%=one%> + <%=two%> = <input type="text" name="answer"> <p> <input type="submit" value="Proceed"> <input type="submit" name="reset" value="Reset"> <p> </form> </body> </html>It is clean and compact, and a pleasure to study (I hope).
(The long lines, you ask? Aye (for one) am really really happy it's so easy to use them on the web.)
Mon-Wed Apr 19-21
Fri-Sun Apr 16-18
Here's a link to the document that will be updated as we collect the proposals.
Wed-Thu Apr 14-15
Date: Thu, 15 Apr 2004 00:51:01 -0500 (EST) From: Adrian German <dgerman@cs.indiana.edu> To: A348 Spr. 2004 Distr. List <dgerman@indiana.edu> Subject: a348/a548 final exam Dear A348/A548 Friends, The final exam starts today, right now. You are to: a) choose a problem, state it clearly, post it on the web board b) make sure nobody else has posted that problem before you c) the problem must be like the vending machine, paper-rock-scissors, or the addition quiz that we are working on for the last three assignments, something reasonable but unique. Each of you will have to have a problem to work on. Each one a different problem. And then: d) solve the problem in nine ways: 1. using CGI with hidden fields 2. using CGI with sessions in MySQL 3. using PHP with hidden fields 4. using PHP with sessions 5. using Javascript in a browser 6. using Java servlets with hidden fields 7. using Java servlets with sessions 8. using Java Server Pages with hidden fields and 9. using Java Server Pages with sessions Have this done by the time we get together on the date posted in INSITE for the final exam (May 6 or so). We will continue to present new material in class but the labs will be dedicated from now on to making sure you can work on the final and you're reasonably clear on what you need to do and can do it with a small amount of help. So please start by posting the problems on the web board. I will endorse them or turn them down. The sooner you get your problem endorsed the faster you can start working on it. The longer it takes you to get started the harder will be to come up with a problem, but maybe the posted problems will be able to give you ideas. So let's get started. Make sure the chosen problems have not been solved in class before or their solutions have not been posted to the class web site. Thu in class we will solve Homework 5, 6, 7 completely. Next Tue we will be talking about projects. The semester ends in a couple of weeks. ... Adrian
Thu Apr 8
We'll work on a different problem and will provide 5 implementations, as required.
Here's a link to the molecule applets.
Mon-Wed Apr 5-7
This was OK to define the problem but not that usable and/or operational.burrowww.cs.indiana.edu% cat Five.java import java.io.*; class Five { public static void main(String[] args) throws Exception { int attempts = 0; int score = 0; String message = null; // "Welcome to the game."; while (true) { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int a = (int)(Math.random() * 200 - 100), b = (int)(Math.random() * 200 - 100); System.out.print("What is " + a + " + " + b + " ?> "); int result = Integer.parseInt(in.readLine()); attempts += 1; if (result == (a + b)) { score += 1; } else { System.out.println("That was wrong."); } if (attempts == 10) { attempts = 0; score = 0; message = "Welcome to the game."; } else { System.out.println(score + " / " + attempts); } } } }burrowww.cs.indiana.edu%
Here's how we changed it to match the pattern:
import java.io.*; class Six { public static void main(String[] args) throws Exception { // define the state and what not int attempts = 0; int score = 0; int a = 0, b = 0, result = 0; String message = null; // "Welcome to the game."; // what not: that's how we read String incoming = null; while(true) { // another device (created with every single access) BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); // check the state if (message == null) { // new user: initialize state message = "How are you? Welcome to the game."; attempts = 0; score = 0; a = (int)(Math.random() * 200 - 100); b = (int)(Math.random() * 200 - 100); result = a + b; message += "\nWhat is " + a + " + " + b + " ?: "; } else { // not a new user // read the input you need int user = Integer.parseInt(incoming); // then process the state (update it with this input) attempts += 1; if (result == user) { score += 1; } else { message = "Not good."; } if (attempts == 10) { attempts = 0; score = 0; message += "\nEnd of game.\nNew game has started."; } else { message += "\n" + score + " / " + attempts; } a = (int)(Math.random() * 200 - 100); b = (int)(Math.random() * 200 - 100); result = a + b; message += "\nWhat is " + a + " + " + b + " ?: "; } // store the state: no need for that here // show the state: we put everything we want to show in the message System.out.print(message); // get ready for more input incoming = in.readLine(); } // on the web the process is user-driven, here we need this infinite loop } }
Sat-Sun Apr 3-4
Copying an existing table into a new table could be done this way.
Mon-Fri Mar 29-Apr 2
Final exam review from last year.
Sun Mar 28
Wed-Sat Mar 24-27
<? function get_book_cats($isbn) { $conn = db_connect(); $query = "select dgerman_php_catboo.catid, catname from dgerman_php_categories, dgerman_php_catboo where '$isbn' = dgerman_php_catboo.isbn and dgerman_php_categories.catid = dgerman_php_catboo.catid"; $result = @mysql_query($query); if (! $result) return false; $num_cats = @mysql_num_rows($result); if ($num_cats == 0) return false; $cat_array = array(); for ( $count = 0; $row = @mysql_fetch_array($result); $count++ ) $cat_array[$count] = $row; if (! is_array($cat_array)) { echo "No categories currently available. <br>"; } foreach ($cat_array as $row) { $url = "show_cat.php?catid=".($row["catid"]); $title = $row["catname"]; do_html_url($url, $title); } } ?>
Tue Mar 23
Thu-Mon Mar 11-22
Wed Mar 10
Date: Wed, 10 Mar 2004 13:16:00 -0500 (EST) From: Adrian German <dgerman@cs.indiana.edu> To: A348 Spr. 2004 List <dgerman@indiana.edu> Subject: Exam, Homework, Labs The lab this week will be for catching up only. No new notes will be posted for it. Lab Nine therefore is after the break (I will post some notes on it today, it's on Javascript, and the document object model). Lab Eight is due after the break and we will explain it tomorrow in class. For the four versions of the vending machine problem you have until Friday morning 8:00am to finish them completely. Tomorrow in class we will finish the discussion on CGI/Perl with DBI.pm, that we didn't finish yesterday. I posted the code for a simple calculator that keeps state on the server side and stamps the transactions to avoid the problem we illustrated in class: we don't want to see any change in the server-side state when we reload the page and resubmit a transaction. That's one way to make transactions idempotent with respect to reloading: adding age to the id of a transactuion. Please let me know if you have questions or concerns. I am working on the grades and will be updating them all quite soon. ... Adrian P.S. If you haven't finished Homework Four we are still accepting them until Fri 8am. Just make sure you post your source code along with a link to the working program and perhaps a short description of how you wrote the program on the website. I will try to update the assignments template on my demo web site for that (I have not made any updates since the week of the the individual appointments).
Mon-Tue Mar 8-9
<? session_start();
if (session_is_registered("acc")) {
if ($stamp == $stampCopy) {
$acc += $arg;
$stamp += 1;
}
} else {
session_register("acc");
session_register("stamp");
$acc = 0;
$stamp = 1;
}
?>
<html><head><title></title></head><body
bgcolor="white">
<form method="get" action="<?=$SCRIPT_NAME?>">
Your accumulator is now: <?=$acc?> <p>
Please enter the amount to deposit: <input type="text" name="arg"> <p>
When done please press <input type="submit" value="Proceed">
<input type="hidden" name="stampCopy" value="<?=$stamp?>">
</form>
</body></html>
Work with it here.
Sat-Sun Mar 6-7
Here's how I would get started on the Paper-Rock-Scissors game in CGI/MySQL.
Perhaps these examples will help you finish Homework Four and the take-home part of the Exam.
Wed-Fri Mar 3-5
Date: Fri, 5 Mar 2004 09:52:50 -0500 (EST) From: Adrian German <dgerman@cs.indiana.edu> To: A348 Spr. 2004 Distr. List <dgerman@indiana.edu> Subject: A348/A548 Midterm Exam I will try to post the grades today for the exam you took last night. It will count as 40% of the midterm grade. For the rest 60% you need to implement the vending machine in four ways and post the programs and the source code on-line for me to check, by Tue-Thu next week. Also, Tue we will discuss the CGI/MySQL implementation of your Homework Four, so you can update your code/programs after that if you need to. We then move to Javascript and DHTML. ... Adrian
Mon-Tue Mar 1-2
So what's the benefit of the last approach if it's that long and complicated?
Sat-Sun Feb 28-29
(Just so you can be prepared).
Fri Feb 27
Ryan Hardy. Solo.
Thu Feb 26
Remember that the programs have the computer contribution muted.
(The reason being to clearly indicate the difference between the two methods of keeping state).
Wed Feb 25
The program we developed yesterday in class (source code here).
Mon-Tue Feb 23-24
Creating a table that has a combination of columns as the primary key:
Don't forget that the columns that comprise the key must becreate table catboo ( isbn char(6), catid int unsigned, primary key (isbn, catid) )
not null
.
Sun Feb 22
Here's the source code of the program we developed in class on Thu.Date: Sat, 21 Feb 2004 20:02:07 -0500 (EST) From: Adrian German <dgerman@cs.indiana.edu> To: A348 Spring 2004 Distr. List <dgerman@indiana.edu> Subject: A348 Update (Grades, Exam, Quizzes) Dear A348/A548 Friends, Having completed a first round of grading for everything up to and including Lab Assignment Four I posted two solutions to the Second Homework Assignment so you can study them. They're listed on the What's New? page under Sat Feb 21, please look them over. The exam is on March 5. To prepare for it there will be two short quizzes in class: one on Feb 26, the other one on Mar 2. Each time for about 15'. The task would be to implement the solution to a problem like the one you worked on for your Homework Two. The quizzes will be open-book, open-notes, as will the exam. Quizzes will act as a filter to your Homework Two grade, for me, and also as bonus. So they will help (if you do well on them) and they should also support your preparation for the exam (which has one in-class component on Mar 5, and one take-home component, that must be finalized by Tue Mar 9). Hope your weekend is coming along fine. Please let me know if you need any help, or if you have any questions please let me know. ... Adrian P.S. Help with Homework Three has been posted Thu morning (Feb 19) and this coming week we're working on PHP and Homework Four, including CGI with server-side state using MySQL (for which Lab Notes Six should be of help but especially Lecture Notes Eleven). Lats, but not least, don't forget the virtual library, that can help at times significantly---when you need more details about the topics mentioned in the posted notes.
Sat Feb 21
I will have more details on this soon.
Meanwhile I hope you'll find them useful in your work on Homework Four.
Tue-Fri Feb 17-20
A description of the Midterm Exam has been posted.
Homework Four text is final now.
Lecture Notes Twelve is finalized too (updated three links).
Remember software is available in /l/www/classes/a348/software
as always.
You might need to create additional storage space for PHP installation.
Here now are scripts and information on Homework Three and Lab Five.
Script to create tables and populate them with data:
Here it is in action, together with the data it needs:#!/usr/bin/perl use DBI; $DB = "DBI:mysql:a348"; # data source name (database) $username = "a348"; # username $password = "a348AG"; # password $dbh = DBI->connect($DB, $username, $password, {PrintError => 0}) || die "Couldn't open database: ", $DBI::errstr; print "I have opened the database...\n"; $query = qq{ create table dgerman_HW3_players ( username varchar(8) primary key, firstName varchar(20), lastName varchar(20), picture varchar(120), address varchar(120), city varchar(30), state varchar(2), playerRatePerMatch decimal(12, 2) ) }; print " Getting ready to create dgerman_players... "; $dbh->do($query) || die $dbh->errstr; print "done.\n Getting ready to create dgerman_matches... "; $query = qq{ create table dgerman_HW3_matches ( matchID varchar(30) primary key, dateRound varchar(20), venue varchar(20), ticketPrice decimal(12, 2) ) }; # $dbh->do($query) || die $dbh->errstr; print "done.\n Getting ready to create dgerman_venues... "; $query = qq{ create table dgerman_HW3_venues ( location varchar(30) primary key, address varchar(30), city varchar(30), state varchar(2), leasingRate decimal(12, 2), capacity int(20) ) }; # $dbh->do($query) || die $dbh->errstr; print "done.\n Getting ready to create dgerman_spectators... "; $query = qq{ create table dgerman_HW3_spectators ( customer_id varchar(25) primary key, logo_picture varchar(20), address varchar(30), city varchar(30), state varchar(2) ) }; # $dbh->do($query) || die $dbh->errstr; print "done.\n Getting ready to populate tables with data. \n"; open (INPUT, "players_data"); $line = <INPUT>; @names = split(/,/, $line); while ($line = <INPUT>) { ($uname, $first, $last, $pic, $addr, $city, $st, $rate) = split(/,/, $line, 8); $st =~ s/\s//g; chop($rate); $query = qq{ insert into dgerman_HW3_players values ('$uname', '$first', '$last', '$pic', '$addr', '$city', '$st', $rate ) }; # print $query, "\n"; $dbh->do($query) || die $dbh->errstr; } close(INPUT);
Here's what the database looks like now (and two queries):burrowww.cs.indiana.edu% ls -l total 6 -rw-r--r-- 1 dgerman faculty 704 Feb 19 11:50 players_data -rwx------ 1 dgerman faculty 2438 Feb 19 11:50 script burrowww.cs.indiana.edu% ./script I have opened the database... Getting ready to create dgerman_players... done. Getting ready to create dgerman_matches... done. Getting ready to create dgerman_venues... done. Getting ready to create dgerman_spectators... done. Getting ready to populate tables with data. burrowww.cs.indiana.edu% cat players_data username, firstName, lastName, picture , address , city , state, playerRatePerMatch cbarkley, Charles , Barkley , some URL, Sir Charles Avenue , Phoenix , AZ , 450.00 lbird , Larry , Bird , some URL, Freedom Lick Rd. , Naples , FL , 350.00 mjordan , Michael , Jordan , some URL, Jordan Air Way , Chicago , IL , 500.00 rmiller , Reggie , Miller , some URL, Miller Time Road , Indianapolis, IN , 150.00 tduncan , Tim , Duncan , some URL, Duncan at the Tim , Houston , TX , 210.00 tkukoc , Toni , Kukoc , some URL, Petar Zrinski Street, New Zagreb , PA , 50.00 burrowww.cs.indiana.edu%
Now you need to extract data from (and present it into) a browser.mysql> describe dgerman_HW3_players; +--------------------+---------------+------+-----+---------+-------+---------------------------------+ | Field | Type | Null | Key | Default | Extra | Privileges | +--------------------+---------------+------+-----+---------+-------+---------------------------------+ | username | varchar(8) | | PRI | | | select,insert,update,references | | firstName | varchar(20) | YES | | NULL | | select,insert,update,references | | lastName | varchar(20) | YES | | NULL | | select,insert,update,references | | picture | varchar(120) | YES | | NULL | | select,insert,update,references | | address | varchar(120) | YES | | NULL | | select,insert,update,references | | city | varchar(30) | YES | | NULL | | select,insert,update,references | | state | char(2) | YES | | NULL | | select,insert,update,references | | playerRatePerMatch | decimal(12,2) | YES | | NULL | | select,insert,update,references | +--------------------+---------------+------+-----+---------+-------+---------------------------------+ 8 rows in set (0.00 sec) mysql> select firstName, lastName, city, playerRatePerMatch from dgerman_HW3_players; +-----------+----------+---------------+--------------------+ | firstName | lastName | city | playerRatePerMatch | +-----------+----------+---------------+--------------------+ | Charles | Barkley | Phoenix | 450.00 | | Larry | Bird | Naples | 350.00 | | Michael | Jordan | Chicago | 500.00 | | Reggie | Miller | Indianapolis | 150.00 | | Tim | Duncan | Houston | 210.00 | | Toni | Kukoc | New Zagreb | 50.00 | +-----------+----------+---------------+--------------------+ 6 rows in set (0.00 sec) mysql> select * from dgerman_HW3_players; +----------+-----------+----------+-----------+-----------------------+---------------+-------+--------------------+ | username | firstName | lastName | picture | address | city | state | playerRatePerMatch | +----------+-----------+----------+-----------+-----------------------+---------------+-------+--------------------+ | cbarkley | Charles | Barkley | some URL | Sir Charles Avenue | Phoenix | AZ | 450.00 | | lbird | Larry | Bird | some URL | Freedom Lick Rd. | Naples | FL | 350.00 | | mjordan | Michael | Jordan | some URL | Jordan Air Way | Chicago | IL | 500.00 | | rmiller | Reggie | Miller | some URL | Miller Time Road | Indianapolis | IN | 150.00 | | tduncan | Tim | Duncan | some URL | Duncan at the Tim | Houston | TX | 210.00 | | tkukoc | Toni | Kukoc | some URL | Petar Zrinski Street | New Zagreb | PA | 50.00 | +----------+-----------+----------+-----------+-----------------------+---------------+-------+--------------------+ 6 rows in set (0.01 sec) mysql>
You can try this script here.#!/usr/bin/perl use DBI; use CGI; $q = new CGI; print "Content-type: text/html\n\n"; $DB = "DBI:mysql:a348"; # data source name (database) $username = "a348"; # username $password = "a348AG"; # password $dbh = DBI->connect($DB, $username, $password, {PrintError => 0}) || die "Couldn't open database: ", $DBI::errstr; $query = "select * from dgerman_HW3_players"; $sth = $dbh->prepare($query) || die $dbh->errstr; $sth->execute() || die $sth->errstr; print qq{ <table border cellpadding=2> <tr><th> Username <th> First Name <th> Last Name <th> Picture <th> Address <th> City <th> State <th> Player rate per match }; while (my $row = $sth->fetch) { my(@values) = @$row; print "<tr>"; foreach $value (@values) { print "<td>$value"; } } print "</table>"; $sth->finish;
Here's a smaller query:
You can try this script here.#!/usr/bin/perl use DBI; use CGI; $q = new CGI; print "Content-type: text/html\n\n"; $DB = "DBI:mysql:a348"; # data source name (database) $username = "a348"; # username $password = "a348AG"; # password $dbh = DBI->connect($DB, $username, $password, {PrintError => 0}) || die "Couldn't open database: ", $DBI::errstr; $query = "select * from dgerman_HW3_players"; $sth = $dbh->prepare($query) || die $dbh->errstr; $sth->execute() || die $sth->errstr; print qq{ <table border cellpadding=2> <tr> <th> First Name <th> Last Name <th> City <th> Player rate per match }; while (my $row = $sth->fetch) { my(@values) = @$row; print "<tr>"; foreach $i (1, 2, 5, 7) { print "<td>", $values[$i]; } } print "</table>"; $sth->finish;
Mon Feb 16
Fri-Sun Feb 13-15
Fulya's section up to date with grades. The other three to follow up soon.
Wed-Thu Feb 11-12
There are also some queries developed but they're not necessarily the answers.
Here's the source for the
SQL notes.
I used the old edition though.
Homework Three information posted (needed for Lab Five tables).
Fri-Tue Feb 6-10
Lab Notes Five will get you started with Homework Three.
Homework Four is like Homework Two only in PHP.
Lab Assignment Six is also like Homework Two.
Lab Seven will be a review before the Midterm exam.
Lab Four can be done with just sixteen
(my example for Homework Two).
Here's the code to remind you of it.
Links in Lecture Notes Nine have been updated.
Links in Lecture Notes Ten and Eleven also updated.
Fri Feb 6
What the caterpillar calls the end of the world, the master calls a butterfly. Richard Bach (1936-, American Author)
Thu Feb 5
Here's a template
we promised on Tuesday (this template uses CGI.pm
).
Wed Feb 4
Here's an example on how to turn in Homework Two.Date: Wed, 4 Feb 2004 22:12:18 -0500 (EST) From: Adrian German <dgerman@cs.indiana.edu> To: A348/A548 Spr. 2004 Distr. List <dgerman@indiana.edu> Subject: Homework Two I just want to announce that Homework Two has been extended a week. You will also neeed to provide two implementations: a) a CGI script in Perl that uses the CGI.pm library and b) a CGI script in Perl that makes no use of the CGI.pm library I also updated my demo assignments template at http://burrowww.cs.indiana.edu:17600/ This will hopefully help with the posting of the code as well as the rest of the what and how needs to be posted for each assignment. ... Adrian
Please use
lbird
dribl
to get in to my
sample protected
folder).
Mon-Tue Feb 2-3
There is a little bit more help with Homework Two planned for Tue night, still.
Sat-Sun Jan 31 -Feb 1
#!/usr/bin/perl use CGI; $q = new CGI; print $q->header, $q->start_html; # $balance is my state # $message is in state also $message = $q->param('message'); $balance = $q->param('balance'); if ( $message eq "" ) { $balance = 0; $message = "Welcome, your balance is $balance."; } else { $balance = $q->param('user') + $q->param('balance'); $message = "After your transaction your balance is: $balance."; } print qq{ $message <p> <form action="http://burrowww.cs.indiana.edu:17600/cgi-bin/0129/two"> Please indicate your choice: <input="text" name="user"> <p> When you're done please press <input type="submit" value="Proceed"> <input type="hidden" name="balance" value="$balance"> <input type="hidden" name="message" value="$message"> </form> }; print $q->end_html;
Fri Jan 30
passwd
file should look like:
dgerman:2oVrNAce3DuCs
Here's where you can read more about
the CGI.pm
package.
Thu Jan 29
Here's the pattern we announced, used to implement the guess the number in 10 tries game:
#!/usr/bin/perl use CGI; $query = new CGI; # data is collected $me = $ENV{SCRIPT_NAME}; #-----------------(outside of the pattern)--- # Step 0. Define state: (1) number to guess, # (2) no. of attempts (thus far) but also # (3) the last message we posted (for the user) # # Step 1. Retrieve state. $number = $query->param('number'); $attempts = $query->param('attempts'); $message = $query->param('message'); # this helps with state is empty? # # Step 2. Check if state is empty (missing numbers are treated as zero!) # That's why we check message instead... if (! $message) { # Step 2.1 State is empty---so we need to initialize it. $number = int(rand(100)); $message = "Welcome to the game."; $attempts = 0; # thus far. # } else { # Step 2.2 State is not empty. Process it using user input. # Step 2.2.1 Get user input. # $guess = $query->param('guess'); # Step 2.2.2 Process (update/change) state. # $attempts += 1; if ($guess > $number) { $message = "Please try lower."; } elsif ($guess < $number) { $message = "Please try higher."; } else { $message = "Congratulations, you won."; $number = int(rand(100)); $attempts = 0; # new game starts $message .= "<p> Welcome to a new game. "; # concatenation } if ($attempts >= 10) { # you lost... $message = "Darn. You're out of tries. You lose."; $number = int(rand(100)); $attempts = 0; # new game starts $message .= "<p> Welcome to a new game. "; # concatenation } # else just keep going } # Steps 3-4. Store and report the state. # print $query->header; print $query->start_html; print qq{<form action=$me>}, # state is reported below qq{ $message <p> The number to guess is $number (for debugging purposes) <p> Your attempts so far:}, $attempts + 0, qq{ (out of 10) <p> }, # state is stored for later below qq{ <input type="hidden" name="message" value="$message"> <input type="hidden" name="number" value="$number"> <input type="hidden" name="attempts" value="$attempts"> }, # and we're getting ready for more input... qq{ Your guess: <input type="text" name="guess"> <p> When ready please press <input type="submit" value="Proceed"> </form> }; print $query->end_html;
Wed Jan 28
Here's the program we developed in class yesterday.Date: Wed, 28 Jan 2004 10:28:31 -0500 (EST) From: Adrian German <dgerman@cs.indiana.edu> To: A348/A548 Spr. 2004 Distr. List <dgerman@indiana.edu> Subject: A348/A548 Update Dear A348/A548 Friends, I posted the solution to "Guess the number in 10 tries" problem implemented using the pattern described last night. It's on the What's New? page under Thu Jan 29. Tomorrow in class we will actually solve Homework Two. I am not going to post the code we will develop in class, but we will go very slowly so if you want to take notes as we develop the code you're more than welcome. Let me know if you need help or have any questions. The grades for Homework One and Lab Assignment One will soon be posted in OnCourse. We should briefly discuss them in lab, this week. Also Lab Notes Three will be finalized in a few minutes. Thanks and all the best. ... Adrian
#!/usr/bin/perl use CGI; $query = new CGI; # data is collected $me = $ENV{SCRIPT_NAME}; #-----------------(outside of the pattern)--- $fun = $query->param('fun'); $arg = $query->param('arg'); # report the state print $query->header; print $query->start_html; print qq{<form action=$me> $message <p> $me <p> ($fun, $arg) <p> Function: <select name="fun"> <option value="non"> Click me! <option value="add"> Deposit <option value="sub"> Withdraw </select> <p> Amount <input type="text" name="arg"> <p> When finished please press <input type="submit" value="Proceed"> </form> }; print $query->end_html;
Tue Jan 27
An actual working prototype for Homework Two has been posted.
Fri-Mon Jan 23-26
Date: Sat, 24 Jan 2004 11:57:01 -0500 (EST) From: Adrian German <dgerman@cs.indiana.edu> To: A348 Spring 2004 Distr. List <dgerman@cs.indiana.edu> Subject: A348/A548 Homework Two, Project, Week Three Update Dear A348/A548 Friends, Homework Two has been posted. A very important week is coming up. It will build the foundation for the rest of the semester. Have patience with yourselves if you find it difficult. Effort invested in this upcoming week will pay off many times over during the rest of the semester. We also need to talk about Semester Projects on Tue in class. Let me know if you need any help and have a great weekend. ... Adrian
Wed-Thu Jan 21-22
Tue Jan 20
Mon Jan 19
Notice the first Lab is due Thu-Fri, and first Homework the Mon after.
Assignments web page template has been posted
(will be updated throughout the semester).
Please install it on your web sites, so we can better grade your assignemnts.
Sun Jan 18
Here's a diagram from some time ago. Here's the script we're using to grade your Lab One archives:
#!/usr/bin/perl $username = $ARGV[0]; if ($username eq "") { `yes | rm -ir wh* exp* `; print `ls -ld * `; exit; } `cp /u/$username/public/whoa.tar.gz . `; `gunzip whoa.tar.gz`; `tar xvf whoa.tar`; print `du -a exp*`; print `more exp*/doc*/doc?.txt`; print "Should I delete it? "; $answer = <STDIN>; if ($answer eq "yes") { `yes | rm -ir wh* exp* ` ; print ` ls -ld * `; }
Sat Jan 17
Don't forget to move the file there, first (fromburrowww.cs.indiana.edu% chmod 711 ~ burrowww.cs.indiana.edu% chmod 755 ~/public burrowww.cs.indiana.edu% chmod 644 ~/public/whoa.tar.gz
lab1
).
Fri Jan 16
Thu Jan 15
http://library.books24x7.com/topics.asp
Congratulations to Zaw and Arpit Doshi for inaugurating the Spring 2004 A348 Message Board.
Wed Jan 14
Distribution list created, message sent to the list:
Date: Wed, 14 Jan 2004 23:20:32 -0500 (EST) From: Adrian German <dgerman@cs.indiana.edu> To: A348 Spring 2004 Distr. List <dgerman@indiana.edu> Subject: Welcome to A348/A548! Dear A348/A548 Friends, The web site for the class is at http://www.cs.indiana.edu/classes/a348 and it has been updated a bit with still more to come. The first lab is tomorrow (and on Friday). Try to create a burrowww account by then, if not, you will be guided during the lab. The first set of notes indicate that we'll focus on working with Unix, setting up a lab assignment due next week which will be also presented in lecture tomorrow. So for the time being there's nothing to do except to try to create the burrowww account by going to http://accounts.ucs.indiana.edu Thanks for your interest and participation. Many thanks to Zack (Steve?) Lipp for his contribution to the first lecture, we'll be looking for volunteers for the lectures throughout. If you have any questions, run into any problems, or need any help please let us know. Welcome to the class and we hope you will enjoy it and find it useful. ... Adrian
Tue Jan 13
Mon Jan 12
A348/A548