HOME | CSCI 1710 | CSCI 1900 | CSCI 2150 | CSCI 2910 | CSCI 4717 | CSCI 4956 | CSCI 5011 | RESEARCH | ||||||||||||||||
I just thought you would like to know that I will be including a "cheat sheet" of sorts with tomorrow's exam. Basically, I will include the following SQL/MySQL syntax as part of the front page of the exam. I didn't want this to be a memorization-heavy exam. Focus more on how to create the MySQL statements rather than memorizing their syntax. Note that none of the semi-colons have been added for their command line usage.
INSERT INTO tablename (fieldname [, fieldnames]) VALUES (value [, values])
DELETE FROM tablename WHERE fieldname=value
UPDATE tablename SET fieldname=value WHERE fieldname=value
USE database
SHOW TABLES
CREATE TABLE tablename (field1 data_type [NULL/NOT NULL], field2 data_type [NULL/NOT NULL], ...)
DROP TABLE tablename
SELECT [ ALL | DISTINCT] *| COLUMN1[, COLUMN2 ] FROM TABLE1 [ , TABLE2 ] WHERE [CONDITION1 | EXPRESSION1][ AND|OR CONDITION2 | EXPRESSION2 ] ORDER BY fieldname [, fieldnames] [ASC|DESC]
LIMIT [start,] size
I have posted some study material for this Tuesday's quiz on our web site on the Test Aids page.
Some people have been having some difficulties with the first project. The problems they are experiencing are not necessarily with the programming, rather it is with the odd logic required to initialize the program, i.e., randomize the image. I did not intend for the project to be a struggle for those who don't enjoy the challenge of a good algorithm development. (Yeah, there are a few of us who think it's really cool when we can get numbers to jump through hoops for us.)
Anyway, I wanted to give those who are having troubles with the random image a foot hold. Here's some helpful advice.
The algorithm I used is based on viewing the individual cells of the table in order from left to right and top to bottom. This allows me to use single dimensional arrays to refer to the "properties" of all of the table's cells.
+-----------+-----------+-----------+-----------+
| | | | |
| cell_0 | cell_1 | cell_2 | cell_3 |
| | | | |
+-----------+-----------+-----------+-----------+
| | | | |
| cell_4 | cell_5 | cell_6 | cell_7 |
| | | | |
+-----------+-----------+-----------+-----------+
| | | | |
| cell_8 | cell_9 | cell_10 | cell_11 |
| | | | |
+-----------+-----------+-----------+-----------+
When I initialize the table with images, I insert an onClick event that calls a function like userClickedCell(cell) where the cell argument is the cell number from 0 to 11.
I have also similarly numbered the images. Okay, so the images aren't really numbered, but they have an order when the image is solved.
I've then created an array called cell_contains_image_number(). The index of this array corresponds to the cell number. The integer contained in each element of the array is the image number.
This array can be used for three things: to randomize the images, to determine which image is currently being displayed in a particular cell, and to check if the image has been solved. (Checking for a solved image is as simple as making sure the value stored in each element of the cell_contains_image_number() array is equal to its index.
If I know what row and column a user has clicked on, I can figure out which image is currently in that cell from the row and column values.
image_currently_displayed = cell_contains_image_number((4 * row) + column);
In order to figure out where the blank cell is, all I have to do is search for the element of cell_contains_image_number() that equals 0, i.e., the integer that represents image_00.gif. This could be done with code as simple as:
var empty_cell=-1;
for(counter = 0; counter < 12; counter++)
if(cell_contains_image_number(counter) == 0) empty_cell=counter;
Note that there is a more elegant solution using a do-while loop, but the above code works just fine.
Okay, so using a single dimensional array makes it harder to check if the user has clicked on an image that is adjacent to the empty cell. It still shouldn't be all that bad though. Checking what row and column the "clicked-on" cell involves some basic integer math.
function getColumn(cell)
{
return(cell%4);
}
function getRow(cell)
{
return(Math.floor(cell/4));
}
Now for the hard part, randomizing the array. I made a simple while loop:
var cell_contains_image_number = new Array(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
var image_pos_to_init;
for(image_number_to_assign = 0; image_number_to_assign < 12; image_number_to_assign++)
{
do
{
image_pos_to_init = Math.floor(Math.random() * 12.0);
}while (cell_contains_image_number[image_pos_to_init] != -1)
cell_contains_image_number[image_pos_to_init] = image_number_to_assign;
}
document.write("<h1>Array equals: " + cell_contains_image_number.toString() + "<h1>");
The last line is not part of the code. I've included it only to display the resulting array when it's completed.
I hope this helps.
Project 1 has been defined! You are going to be putting together the modern day version of the old number tile slider game. A description of this game along with some of the math that goes behind it can be found at MATH 308 Euclidean Geometry Project from the Mathematics Department of the University of British Columbia on a page put together by Hazel Grant. Instead of numbers, however, you are going to use pictures. You can find 12 images on the documents section of Blackboard for our class. These twelve images make up a complete single image of three rows and four columns. Note that if the images are initially randomized, it is possible to have put them into an unsolvable order.
Your JavaScript code must do the following:
You may also get bonus points for additional features such avoiding the creation of an unsolvable puzzle, but this is by no means a requirement.
The project is due February 27th by the beginning of class. Good luck!
thursday's lecture will include topics on form validation. One of the in class exercises involves reviewing a library of form validation routines written in JavaScript. I have provided links to this library both with the header description and without.
It has come to my attention that some of you are in need of WS-FTP on your home machines. To download a copy of WS-FTP to be used only for ETSU-related activities, visit ETSU's download site. Double click on the ws_ftp32.exe file, and when prompted, save the file to a folder on your harddrive. After the file downloads, execute the file by double-clicking on it from Windows Explorer and follow the directions to install it on your machine.
Just a reminder that we will be having a quiz on Tuesday over the CSS material we covered in class today. All of the questions will come from the material on the CSS Refresher Worksheet that we used in class. Expect to see about 10 to 15 short answer/multiple choice/true-false questions. Don't bother memorizing the property names; I'll give you the ones you need.
In an effort to avoid using PowerPoint, I have created a set of worksheets for our review of cascading style sheets tomorrow. I will bring a few copies to class, but our copier broke this afternoon, so I will not have enough copies for everyone. If you could, please print out the worksheets from the link below.
http://faculty.etsu.edu/tarnoff/ntes2910/CSS/CSS_worksheets.pdf
Welcome to class! We are going to spend this semester learning ways to add dynamic content to your XHTML web pages.
Before we get started, I need you to verify that your e-mail address is set up correctly on Blackboard. I use this system to e-mail you updates throughout the semester regarding class. I cannot take responsibility for messages you did not receive because you were not looking at your z-account e-mail.
[ News ] [ Syllabus ] [ Notes ] [ Exercises ] [ Test aids ] [ Blackboard ] [ Other links ]