aasdfasdfasdfasdfasdf
1
.gitignore
vendored
@ -19,3 +19,4 @@
|
||||
/Assignments/JavaScript/Chapter3Examples/nbproject/private/
|
||||
/Assignments/JavaScript/lab12js/nbproject/private/
|
||||
/Assignments/JavaScript/MP09_CalebFontenot/nbproject/private/
|
||||
/Assignments/JavaScript/MP10_CalebFontenot/nbproject/private/
|
||||
|
3
Assignments/JavaScript/MP10_CalebFontenot/.bowerrc
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"directory": "public_html/bower_components"
|
||||
}
|
9
Assignments/JavaScript/MP10_CalebFontenot/Gruntfile.js
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/ClientSide/Gruntfile.js to edit this template
|
||||
*/
|
||||
module.exports = function (grunt) {
|
||||
// Project configuration.
|
||||
grunt.initConfig({
|
||||
});
|
||||
};
|
13
Assignments/JavaScript/MP10_CalebFontenot/bower.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "MP10_CalebFontenot",
|
||||
"version": "1.0.0",
|
||||
"main": "path/to/main.css",
|
||||
"ignore": [
|
||||
".jshintrc",
|
||||
"**/*.txt"
|
||||
],
|
||||
"dependencies": {
|
||||
},
|
||||
"devDependencies": {
|
||||
}
|
||||
}
|
10
Assignments/JavaScript/MP10_CalebFontenot/gulpfile.js
Normal file
@ -0,0 +1,10 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/ClientSide/gulpfile.js to edit this template
|
||||
*/
|
||||
|
||||
var gulp = require('gulp');
|
||||
|
||||
gulp.task('default', function () {
|
||||
// place code for your default task here
|
||||
});
|
@ -0,0 +1,5 @@
|
||||
file.reference.MP10_CalebFontenot-public_html=public_html
|
||||
file.reference.MP10_CalebFontenot-test=test
|
||||
files.encoding=UTF-8
|
||||
site.root.folder=${file.reference.MP10_CalebFontenot-public_html}
|
||||
test.folder=${file.reference.MP10_CalebFontenot-test}
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||
<type>org.netbeans.modules.web.clientproject</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/clientside-project/1">
|
||||
<name>MP10_CalebFontenot</name>
|
||||
</data>
|
||||
</configuration>
|
||||
</project>
|
8
Assignments/JavaScript/MP10_CalebFontenot/package.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "MP10_CalebFontenot",
|
||||
"version": "1.0.0",
|
||||
"keywords": ["util", "functional", "server", "client", "browser"],
|
||||
"author": "caleb",
|
||||
"contributors": [],
|
||||
"dependencies": {}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
Click nbfs://nbhost/SystemFileSystem/Templates/Other/html.html to edit this template
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>Table Generator</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<script>
|
||||
document.write("<table>");
|
||||
// Write table header
|
||||
document.write("<tr><th>Trip Name</th><th>Miles Driven</th><th>Gallons Used</th><th>Miles Per Gallon</th></tr>");
|
||||
do {
|
||||
var tripName = prompt("Enter data for Trip Name collum");
|
||||
var milesDriven = prompt("Enter data for Miles driven collum");
|
||||
var gallonsUsed = prompt("Enter data for Gallons used collum");
|
||||
var mpg = prompt("Enter data for Miles Per Gallon collum");
|
||||
document.write("<tr>");
|
||||
document.write("<td>" + tripName + "</td>");
|
||||
document.write("<td>" + milesDriven + " Mi. </td>");
|
||||
document.write("<td>" + gallonsUsed + " gallons</td>");
|
||||
document.write("<td>" + mpg + " MPG</td>");
|
||||
document.write("</tr>");
|
||||
var iterate = prompt("add more data? (Type true/false)");
|
||||
} while (iterate === "true");
|
||||
document.write("</table>");
|
||||
</script>
|
||||
<style>
|
||||
table, th, td {
|
||||
border: 1px solid;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
</html>
|
@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
Click nbfs://nbhost/SystemFileSystem/Templates/ClientSide/html.html to edit this template
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>TODO supply a title</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<script>
|
||||
var input = prompt("Enter a number to calculate its factorial.");
|
||||
var output = 1;
|
||||
for (var i = input; i > 1; i--) {
|
||||
output *= i;
|
||||
}
|
||||
document.write("The factorial of " + input + " is " + output);
|
||||
</script>
|
||||
</head>
|
||||
</html>
|
@ -0,0 +1,36 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
Click nbfs://nbhost/SystemFileSystem/Templates/ClientSide/html.html to edit this template
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>Bacteria cultivation calculator</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<style>
|
||||
table, th, td {
|
||||
border: 1px solid;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
var initialBacteria = prompt("Enter the initial bacteria.");
|
||||
var bacteria = initialBacteria;
|
||||
document.write("<table>");
|
||||
// Write table header
|
||||
document.write("<tr><th>Initial Bacteria Present:</th><th>"+initialBacteria +"</th></tr>");
|
||||
document.write("<tr><th>Bacteria</th><th>Day</th></tr>");
|
||||
for (var i = 1; i <= 10; i++) {
|
||||
document.write("<tr>");
|
||||
bacteria = initialBacteria * Math.pow(2, (i / 10)) ;
|
||||
bacteria = Math.trunc(bacteria);
|
||||
document.write("<td>" + bacteria + "</td>");
|
||||
document.write("<td>" + i + "</td>");
|
||||
document.write("</tr>");
|
||||
}
|
||||
document.write("</table>");
|
||||
</script>
|
||||
</head>
|
||||
|
||||
</html>
|
@ -0,0 +1,42 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
Click nbfs://nbhost/SystemFileSystem/Templates/ClientSide/html.html to edit this template
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>TODO supply a title</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<style>
|
||||
table, th, td {
|
||||
border: 1px solid;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
var name, attendance, homework, midterm, final, grade, iterate;
|
||||
document.write("<table>");
|
||||
// Write table header
|
||||
document.write("<tr><th>Name</th><th>Attendance</th><th>Homework</th><th>Midterm</th><th>Final</th><th>Course Grade</th></tr>");
|
||||
do {
|
||||
name = prompt("Enter name:");
|
||||
attendance = prompt("Enter attendance grade:");
|
||||
homework = prompt("Enter homework grade:");
|
||||
midterm = prompt("Enter midterm grade:");
|
||||
final = prompt("Enter final grade:");
|
||||
iterate = prompt("Done entering data? (Type true/false)");
|
||||
grade = (midterm*0.3)+(final*0.4)+(homework*0.2)+(attendance*0.1);
|
||||
document.write("<tr>");
|
||||
document.write("<td>" + name + "</td>");
|
||||
document.write("<td>" + attendance + "</td>");
|
||||
document.write("<td>" + homework + "</td>");
|
||||
document.write("<td>" + midterm + "</td>");
|
||||
document.write("<td>" +final + "</td>");
|
||||
document.write("<td>" + grade + "</td>");
|
||||
document.write("</tr>");
|
||||
} while (iterate === "false");
|
||||
document.write("</table>");
|
||||
</script>
|
||||
</head>
|
||||
</html>
|
BIN
Assignments/JavaScript/ch05/ch05/.DS_Store
vendored
Executable file
BIN
Assignments/JavaScript/ch05/ch05/border.jpg
Executable file
After Width: | Height: | Size: 1.3 KiB |
BIN
Assignments/JavaScript/ch05/ch05/bracelet1.jpg
Executable file
After Width: | Height: | Size: 3.0 KiB |
BIN
Assignments/JavaScript/ch05/ch05/bracelet2.jpg
Executable file
After Width: | Height: | Size: 2.3 KiB |
BIN
Assignments/JavaScript/ch05/ch05/bracelet3.jpg
Executable file
After Width: | Height: | Size: 2.9 KiB |
142
Assignments/JavaScript/ch05/ch05/carla/carla.css
Executable file
@ -0,0 +1,142 @@
|
||||
body {
|
||||
background-color: #FFFFFF;
|
||||
background-image: url(background.gif);
|
||||
color: #0000FF;
|
||||
font-family: Geneva, Arial, Helvetica, sans-serif;
|
||||
font-size: 14px;
|
||||
}
|
||||
#container { margin-left: auto;
|
||||
margin-right: auto;
|
||||
width:85%;
|
||||
min-width:700px;
|
||||
}
|
||||
|
||||
|
||||
#logo {
|
||||
text-align:center;
|
||||
margin: 0;
|
||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||
padding-top: 30px;
|
||||
padding-bottom: 20px;
|
||||
|
||||
}
|
||||
#nav {
|
||||
float: left;
|
||||
width: 200px;
|
||||
padding-top: 10px;
|
||||
text-align:left;
|
||||
color: #FF0000;
|
||||
font-size: 14px;
|
||||
}
|
||||
#nav a {
|
||||
text-decoration:none;
|
||||
margin: 15px;
|
||||
display: block;
|
||||
color: #FF0000;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
}
|
||||
#content {
|
||||
margin-left: 150px;
|
||||
padding: 30px;
|
||||
overflow:auto;
|
||||
border: medium groove #0000FF;
|
||||
line-height: 135%;
|
||||
|
||||
}
|
||||
|
||||
.floatright {padding-left:20px;
|
||||
float:right;
|
||||
}
|
||||
.floatleft {
|
||||
float:left;
|
||||
padding: 2px 30px 20px;
|
||||
}
|
||||
#footer {
|
||||
font-size: 16px;
|
||||
font-style: normal;
|
||||
text-align: justify;
|
||||
border-top: thin none;
|
||||
padding-top: 20px;
|
||||
padding-bottom: 20px;
|
||||
color: #FF0000;
|
||||
font-family: Georgia, "Times New Roman", Times, serif;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
h2 { text-transform: uppercase;
|
||||
color: #0000FF;
|
||||
font-size: 36px;
|
||||
border-bottom: 1px none;
|
||||
margin-right: 20px;
|
||||
}
|
||||
h3 {
|
||||
color: #0000FF;
|
||||
border-bottom: thin none;
|
||||
margin-right: auto;
|
||||
text-align: left;
|
||||
padding-top: 20px;
|
||||
padding-right: 100px;
|
||||
padding-bottom: 20px;
|
||||
padding-left: 100px;
|
||||
border-top-style: none;
|
||||
border-right-style: none;
|
||||
border-left-style: none;
|
||||
}
|
||||
.details { padding-left:20%;
|
||||
padding-right:20%;
|
||||
}
|
||||
|
||||
|
||||
img {border:0 none; }
|
||||
|
||||
|
||||
.content {
|
||||
margin: 20px;
|
||||
padding: 20px;
|
||||
}
|
||||
a {
|
||||
color: #FF0000;
|
||||
text-decoration: none;
|
||||
margin: 15px;
|
||||
color: #FF0000;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
}
|
||||
a:hover {
|
||||
color: #FFFF00;
|
||||
background-color: #0000FF;
|
||||
}
|
||||
h4 {
|
||||
line-height: 150%;
|
||||
margin-right: 20%;
|
||||
margin-left: 15%;
|
||||
text-align: center;
|
||||
}
|
||||
h1 {
|
||||
font-family: Geneva, Arial, Helvetica, sans-serif;
|
||||
font-size: 36pt;
|
||||
text-align: center;
|
||||
margin-right: 15%;
|
||||
margin-left: 20%;
|
||||
}
|
||||
p {
|
||||
font-family: Georgia, "Times New Roman", Times, serif;
|
||||
font-size: 14px;
|
||||
line-height: 120%;
|
||||
font-weight: bold;
|
||||
color: #0000FF;
|
||||
}
|
||||
.flt_img {
|
||||
float: none;
|
||||
padding-top: 3px;
|
||||
padding-right: 20px;
|
||||
padding-bottom: 3px;
|
||||
padding-left: 20px;
|
||||
}
|
||||
specialh4 {
|
||||
line-height: 150%;
|
||||
margin-right: 20%;
|
||||
margin-left: 15%;
|
||||
text-align: center;
|
||||
}
|
91
Assignments/JavaScript/ch05/ch05/carla/carla_grammar.html
Executable file
@ -0,0 +1,91 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Carla's Classroom | Create Your Story</title>
|
||||
<link href="carla.css" rel="stylesheet" type="text/css" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<style type="text/css">
|
||||
<!--
|
||||
.style1 {font-size: 24px}
|
||||
.style2 {font-size: 24px; font-style: italic; line-height: 80%; }
|
||||
-->
|
||||
</style>
|
||||
<script>
|
||||
function getSentence()
|
||||
{
|
||||
var mySub = " "; var myVerb = " "; var myObj = " "; var sentence = false; var idNum = " ";
|
||||
var i = 0; var subject = false; var verb = false; var object = false; var newSentence = " ";
|
||||
for(i = 1; i < 7; i++)
|
||||
{
|
||||
mySub = prompt("Please pick a word from the list as the subject: ", " ");
|
||||
myVerb = prompt("Please pick a word from the list as the verb: ", " ");
|
||||
myObj = prompt("Please pick a word from the list as the object: ", " ");
|
||||
while(sentence != true)
|
||||
{
|
||||
if((mySub == "teacher")|| (mySub == "boy") || (mySub == "dog") || (mySub == "girl") || (mySub == "bike") || (mySub == "cat"))
|
||||
{ subject = true; }
|
||||
else
|
||||
mySub = prompt("Please pick a different word for the subject: ", " ");
|
||||
if((myVerb == "jumps") || (myVerb == "rides") || (myVerb == "loves") || (myVerb == "stands") || (myVerb == "flies") || (myVerb == "swims"))
|
||||
{ verb = true; }
|
||||
else
|
||||
myVerb = prompt("Please pick a different word for the verb: ", " ");
|
||||
if((myObj == "up") || (myObj == "me") || (myObj == "underwater") || (myObj == "out") || (myObj == "down") || (myObj == "fast"))
|
||||
{ object = true; }
|
||||
else
|
||||
myObj = prompt("Please pick a different word for the object: ", " ");
|
||||
sentence = true;
|
||||
}
|
||||
if((subject == true) && (verb == true) && (object == true))
|
||||
{
|
||||
newSentence = "The " + mySub + " " + myVerb + " " + myObj + ".";
|
||||
idNum = "sentence" + i;
|
||||
document.getElementById(idNum).innerHTML = newSentence;
|
||||
}
|
||||
sentence = false; subject = false; verb = false; object = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
|
||||
<img src="images/owl_logo.jpg" class="floatleft" />
|
||||
<h2>Create Your Story </h2>
|
||||
<h2 class="style2"> A Grammar Lesson</h2>
|
||||
<p> </p>
|
||||
<div style ="clear:both;"></div>
|
||||
<div align="left"><blockquote>
|
||||
<p><a href="index.html"><img src="images/owl_button.jpg" />Home</a>
|
||||
<a href="carla.html"><img src="images/carla_button.jpg" />Meet Carla </a>
|
||||
<a href="reading.html"><img src="images/read_button.jpg" />Reading</a>
|
||||
<a href="writing.html"><img src="images/write_button.jpg" />Writing</a>
|
||||
<a href="math.html"><img src="images/arith_button.jpg" />Arithmetic</a>
|
||||
<br /></p></blockquote></div>
|
||||
<div id="content">
|
||||
<table width = "95%" align="center">
|
||||
<tr><td>
|
||||
<table width= "60%" align = "center">
|
||||
<tr><td colspan = 6>Here are your words: </td></tr>
|
||||
<td>teacher</td><td>jumps</td><td>down</td><td>boy</td><td>flies</td><td>out</td></tr>
|
||||
<tr><td>dog</td><td>me</td><td>loves</td><td>girl</td><td>stands</td><td>underwater</td></tr>
|
||||
<tr><td>bike</td><td>rides</td><td>up</td><td>cat</td><td>swims</td><td>fast</td></tr>
|
||||
|
||||
<tr><td colspan = 6> <input type="button" id="sentence" value="begin" onclick="getSentence();" />
|
||||
</td></tr></table></tr></td>
|
||||
<tr><td><p>My Story</p></td></tr>
|
||||
<tr><td id = "sentence1">sentence 1</td></tr>
|
||||
<tr><td id = "sentence2">sentence 2</td></tr>
|
||||
<tr><td id = "sentence3">sentence 3</td></tr>
|
||||
<tr><td id = "sentence4">sentence 4</td></tr>
|
||||
<tr><td id = "sentence5">sentence 5</td></tr>
|
||||
<tr><td id = "sentence6">sentence 6</td></tr>
|
||||
</table>
|
||||
</div>
|
||||
<div id="footer"> <h3><span class="style1">*</span>Carla's Motto: Never miss a chance to teach -- and to learn!
|
||||
</h3>
|
||||
<span class="specialh4"></span>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
BIN
Assignments/JavaScript/ch05/ch05/carla/images/arith_big.jpg
Executable file
After Width: | Height: | Size: 3.6 KiB |
BIN
Assignments/JavaScript/ch05/ch05/carla/images/arith_button.jpg
Executable file
After Width: | Height: | Size: 1.0 KiB |
BIN
Assignments/JavaScript/ch05/ch05/carla/images/carla_button.jpg
Executable file
After Width: | Height: | Size: 2.6 KiB |
BIN
Assignments/JavaScript/ch05/ch05/carla/images/carla_pic.jpg
Executable file
After Width: | Height: | Size: 6.6 KiB |
BIN
Assignments/JavaScript/ch05/ch05/carla/images/owl_button.jpg
Executable file
After Width: | Height: | Size: 527 B |
BIN
Assignments/JavaScript/ch05/ch05/carla/images/owl_logo.jpg
Executable file
After Width: | Height: | Size: 7.6 KiB |
BIN
Assignments/JavaScript/ch05/ch05/carla/images/read_button.jpg
Executable file
After Width: | Height: | Size: 1.8 KiB |
BIN
Assignments/JavaScript/ch05/ch05/carla/images/write_button.jpg
Executable file
After Width: | Height: | Size: 1.2 KiB |
BIN
Assignments/JavaScript/ch05/ch05/carla/images/writing_big.jpg
Executable file
After Width: | Height: | Size: 8.0 KiB |
43
Assignments/JavaScript/ch05/ch05/carla/reading.html
Executable file
@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<title>Carla's Classroom | Reading Lessons</title>
|
||||
<link href="carla.css" rel="stylesheet" type="text/css" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<style type="text/css">
|
||||
<!--
|
||||
.style1 {font-size: 24px}
|
||||
.style2 {font-size: 18px}
|
||||
.style3 {
|
||||
color: #0000FF;
|
||||
font-size: 18px;
|
||||
}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
|
||||
<img src="images/owl_logo.jpg" class="floatleft" />
|
||||
<h1 id="logo"><em>Carla's Classroom</em></h1>
|
||||
<p> </p>
|
||||
<div align="left">
|
||||
<blockquote>
|
||||
<p><a href="index.html"><img src="images/owl_button.jpg" />Home</a>
|
||||
<a href="carla.html"><img src="images/carla_button.jpg" />Meet Carla </a>
|
||||
<a href="reading.html"><img src="images/read_button.jpg" />Reading</a>
|
||||
<a href="writing.html"><img src="images/write_button.jpg" />Writing</a>
|
||||
<a href="math.html"><img src="images/arith_button.jpg" />Arithmetic</a>
|
||||
<br /></p></blockquote>
|
||||
</div>
|
||||
<div id="content">
|
||||
<p><img src="images/carla_pic.jpg" width="83" height="108" class="floatleft" /> Reading Lessons: </p>
|
||||
<p><a href = "carla_grammar.html">Create Your Own Story: A Grammar Lesson</a></p>
|
||||
</div>
|
||||
<div id="footer"> <h3><span class="style1">*</span><span class="style3">Carla's Motto: </span><span class="style2">Never miss a chance to
|
||||
teach -- and to learn!</span></h3>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
27
Assignments/JavaScript/ch05/ch05/ex_5_1.html
Executable file
@ -0,0 +1,27 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 5.1</title>
|
||||
<script>
|
||||
function getSum()
|
||||
{
|
||||
var score = 0; var sum = 0;
|
||||
while (score != -999)
|
||||
{
|
||||
sum = sum + score;
|
||||
score = parseInt(prompt("Enter a score or enter -999 when you're finished:"," "));
|
||||
}
|
||||
document.write("The sum of these scores is: " + sum + ".");
|
||||
}
|
||||
</script>
|
||||
</<head>
|
||||
<body>
|
||||
<table align ="center" width ="70%"><tr><td colspan ="2">
|
||||
<h1> </h2>
|
||||
<h1>Exam 1 Scores</h1>
|
||||
<h3>Click to enter students' scores</h3>
|
||||
<p><input type="button" id="scores" value="Enter the scores" onclick="getSum();" /></p>
|
||||
</td></tr>
|
||||
</table></body>
|
||||
</html>
|
||||
|
28
Assignments/JavaScript/ch05/ch05/ex_5_11.html
Executable file
@ -0,0 +1,28 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 5.11</title>
|
||||
<script>
|
||||
function getThrees()
|
||||
{
|
||||
var i=0;
|
||||
for (i=0; i<=100; i++)
|
||||
{
|
||||
if ((i/3) != parseInt(i/3))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
document.write(i + " ");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<table align ="center" width ="70%"><tr><td colspan ="2">
|
||||
<h1> </h2>
|
||||
<h1>Count By Threes</h1>
|
||||
<p><input type="button" id="scores" value="Count by Threes from 0 to 100" onclick="getThrees();" /></p>
|
||||
</td></tr>
|
||||
</table></body>
|
||||
</html>
|
||||
|
33
Assignments/JavaScript/ch05/ch05/ex_5_12.html
Executable file
@ -0,0 +1,33 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 5.12</title>
|
||||
<script>
|
||||
function getGroup()
|
||||
{
|
||||
var i=0;
|
||||
var name = " "; students = 0; var i = 0;
|
||||
var score = 0;
|
||||
document.write("<table width = '60%' align = 'center'><tr><td>Students who must retake the exam</td></tr>");
|
||||
students = parseInt(prompt("How many students took this exam? ", " "));
|
||||
for (i = 0; i < students; i++)
|
||||
{
|
||||
name = prompt("Enter the student's name: "," ");
|
||||
score = parseInt(prompt("Enter the student's score: " , " "));
|
||||
if (score >= 95)
|
||||
continue;
|
||||
document.write("<tr><td>" + name + "</td></tr>");
|
||||
}
|
||||
document.write("</table>");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<table align ="center" width ="70%"><tr><td colspan ="2">
|
||||
<h1> </h2>
|
||||
<h1>Students who must do the retake</h1>
|
||||
<p><input type="button" id="scores" value="Get List of Retake Students" onclick="getGroup();" /></p>
|
||||
</td></tr>
|
||||
</table></body>
|
||||
</html>
|
||||
|
30
Assignments/JavaScript/ch05/ch05/ex_5_13.html
Executable file
@ -0,0 +1,30 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 5.13</title>
|
||||
<script>
|
||||
function getLoops()
|
||||
{
|
||||
var x = 0; var y = 0; var z = 0;
|
||||
for (x = 1; x < 4; x++)
|
||||
{
|
||||
document.write("<h3>Pass " + x + "</h3>");
|
||||
for (y = 1; y < 10; y+=3)
|
||||
{
|
||||
z = x + y;
|
||||
document.write("<p>" + x + " + " + y + " = " + z + "</p>");
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</<head>
|
||||
<body>
|
||||
<table align ="center" width ="70%"><tr><td colspan ="2">
|
||||
<h1> </h2>
|
||||
<h1>Desk Checking a Program With Nested Loops</h1>
|
||||
<h3>Click to begin the program</h3>
|
||||
<p><input type="button" id="desk check" value="begin" onclick="getLoops();" /></p>
|
||||
</td></tr>
|
||||
</table></body>
|
||||
</html>
|
||||
|
35
Assignments/JavaScript/ch05/ch05/ex_5_14.html
Executable file
@ -0,0 +1,35 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 5.14</title>
|
||||
<script>
|
||||
function getLoops()
|
||||
{
|
||||
var y = 3; var count1 = 1; var count2 = 1;
|
||||
do
|
||||
{
|
||||
x = count1 + 1; count2 = 1;
|
||||
document.write("<h3>Pass Number: " + count1 + "</h3>");
|
||||
while(count2 <= y)
|
||||
{
|
||||
z = y * x;
|
||||
document.write("<p> x = " + x + ", y = " + y + ", z = " + z + "</p>");
|
||||
x++;
|
||||
count2++;
|
||||
}
|
||||
count1++;
|
||||
}
|
||||
while(count1 < y)
|
||||
}
|
||||
</script>
|
||||
</<head>
|
||||
<body>
|
||||
<table align ="center" width ="70%"><tr><td colspan ="2">
|
||||
<h1> </h2>
|
||||
<h1>Desk Checking a Program With Nested Loops</h1>
|
||||
<h3>Click to begin the program</h3>
|
||||
<p><input type="button" id="desk check" value="begin" onclick="getLoops();" /></p>
|
||||
</td></tr>
|
||||
</table></body>
|
||||
</html>
|
||||
|
38
Assignments/JavaScript/ch05/ch05/ex_5_15.html
Executable file
@ -0,0 +1,38 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 5.15</title>
|
||||
<script>
|
||||
function getReceipts()
|
||||
{
|
||||
var week = 0; var day = 0; var subtotal = 0; var count = 0;
|
||||
receipt = 0;
|
||||
total = 0;
|
||||
for (week = 1; week < 3; week++)
|
||||
{
|
||||
document.write("<h3>Week " + week + "</h3>");
|
||||
count = 1; subtotal = 0;
|
||||
for (day = 1; day < 8; day++)
|
||||
{
|
||||
receipt = parseFloat(prompt("Enter the receipts for day " + day + ": " , ""));
|
||||
document.write("amount for day " + count + ": $ " + receipt.toFixed(2) + "<br />");
|
||||
subtotal = subtotal + receipt;
|
||||
count++;
|
||||
}
|
||||
document.write("<p>Week " + week + " subtotal is $ " + subtotal.toFixed(2) + "</p>");
|
||||
total = total + subtotal;
|
||||
}
|
||||
document.write("<p>The total amount for these weeks is $ " + total.toFixed(2) + "</p>");
|
||||
}
|
||||
</script>
|
||||
</<head>
|
||||
<body>
|
||||
<table align ="center" width ="70%"><tr><td colspan ="2">
|
||||
<h1> </h2>
|
||||
<h1>Subtotals</h1>
|
||||
<h3>Click to enter receipts</h3>
|
||||
<p><input type="button" id="nesting" value="Enter receipts" onclick="getReceipts();" /></p>
|
||||
</td></tr>
|
||||
</table></body>
|
||||
</html>
|
||||
|
44
Assignments/JavaScript/ch05/ch05/ex_5_16_war.html
Executable file
@ -0,0 +1,44 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 5.17</title>
|
||||
<script>
|
||||
function goToWar()
|
||||
{
|
||||
var name1 = " "; var name2 = " ";
|
||||
name1 = prompt("Enter your name: ", " ");
|
||||
name2 = prompt("Enter your name: ", " ");
|
||||
var playerOne = 0; var playerTwo = 0; var oneCard = 0; var twoCard = 0; var count = 1;
|
||||
document.write("<table width = 40% align='center'><tr><td colspan = '2'><h3>The Game of War</h3></td></tr>");
|
||||
while ((playerOne < 10) && (playerTwo < 10))
|
||||
{
|
||||
oneCard = Math.floor(Math.random() * 13 + 1);
|
||||
twoCard = Math.floor(Math.random() * 13 + 1);
|
||||
if(oneCard > twoCard)
|
||||
playerOne++;
|
||||
else
|
||||
if(twoCard > oneCard)
|
||||
playerTwo++;
|
||||
document.write("<tr><td colspan = '2'> </td></tr><tr><td colspan = '2'>Deal Number" + count + ": </td</tr>");
|
||||
document.write("<tr><td>" + name1 + "'s card: " + oneCard + " -- Score: " + playerOne + "</td>");
|
||||
document.write("<td>" + name2 + "'s card: " + twoCard + " -- Score: " + playerTwo + "</td></td>");
|
||||
count++;
|
||||
}
|
||||
if ((playerOne ==10) && (playerTwo != 10))
|
||||
document.write("<tr><td colspan = '2'><h3>The winner is " + name1 + "!</h3></td></tr>");
|
||||
if ((playerTwo == 10) && (playerOne != 10))
|
||||
document.write("<tr><td colspan = '2'><h3>The winner is " + name2 + "!</h3></td></tr>");
|
||||
document.write("</table>");
|
||||
}
|
||||
</script>
|
||||
</<head>
|
||||
<body>
|
||||
<table align ="center" width ="70%"><tr><td>
|
||||
<h1> </h2>
|
||||
<h1>Play a Card Game: War</h1>
|
||||
<h3>Click to begin the game</h3>
|
||||
<p><input type="button" id="war" value="begin the game" onclick="goToWar();" /></p>
|
||||
</td></tr>
|
||||
</table></body>
|
||||
</html>
|
||||
|
81
Assignments/JavaScript/ch05/ch05/ex_5_17.html
Executable file
@ -0,0 +1,81 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 5.17</title>
|
||||
<script>
|
||||
function getSquare()
|
||||
{
|
||||
var side = 0; row = 1; col = 1; symbol = "* ";
|
||||
symbol = prompt("Pick a keyboard symbol for your square, such as a * or # ", " ");
|
||||
side = prompt("How big is the side of your square? The value must be a positive number: "," ");
|
||||
side = parseInt(side);
|
||||
while (side < 1)
|
||||
{
|
||||
side = prompt("How big is the side of your square? The value must be a positive number: "," ");
|
||||
side = parseInt(side);
|
||||
}
|
||||
for (row = 1; row <= side; row++)
|
||||
{
|
||||
for (col = 1; col <= side; col++)
|
||||
document.write(symbol + " ");
|
||||
document.write("<br />");
|
||||
}
|
||||
}
|
||||
function getRectangle()
|
||||
{
|
||||
var width = 0; var length = 0; row = 1; col = 1; symbol = "* ";
|
||||
symbol = prompt("Pick a keyboard symbol for your rectangle, such as a * or # ", " ");
|
||||
width = prompt("What is the width? The value must be a positive number: "," ");
|
||||
width = parseInt(width);
|
||||
while (width < 1)
|
||||
{
|
||||
width = prompt("What is the width? The value must be a positive number: "," ");
|
||||
width = parseInt(width);
|
||||
}
|
||||
length = prompt("What is the length? The value must be a positive number: "," ");
|
||||
length = parseInt(length);
|
||||
while (length < 1)
|
||||
{
|
||||
length = prompt("What is the length? The value must be a positive number: "," ");
|
||||
length = parseInt(length);
|
||||
}
|
||||
for (row = 1; row <= width; row++)
|
||||
{
|
||||
for (col = 1; col <= length; col++)
|
||||
document.write(symbol + " ");
|
||||
document.write("<br />");
|
||||
}
|
||||
}
|
||||
function getTriangle()
|
||||
{
|
||||
var row = 1; var base = 1; var symbol = "* "; var col = 0;
|
||||
symbol = prompt("Pick a keyboard symbol for your triangle, such as a * or # ", " ");
|
||||
base = prompt("How big is the base of your triangle? The value must be a positive number: "," ");
|
||||
base = parseInt(base);
|
||||
while (base < 1)
|
||||
{
|
||||
base = prompt("How big is the base of your triangle? The value must be a positive number: "," ");
|
||||
base = parseInt(base);
|
||||
}
|
||||
for (row = 1; row <= base; row++)
|
||||
{
|
||||
for(col = 1; col <= row; col++)
|
||||
document.write(symbol + " ");
|
||||
document.write("<br />");
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
</<head>
|
||||
<body>
|
||||
<table align ="center" width ="70%"><tr><td colspan ="2">
|
||||
<h1> </h2>
|
||||
<h1>Shapes</h1>
|
||||
<h3>Pick a Shape</h3>
|
||||
<p><input type="button" id="square" value="Draw a square" onclick="getSquare();" />
|
||||
<input type="button" id="triangle" value="Draw a triangle" onclick="getTriangle();" />
|
||||
<input type="button" id="rectangle" value="Draw a rectangle" onclick="getRectangle();" /></p>
|
||||
</td></tr>
|
||||
</table></body>
|
||||
</html>
|
||||
|
29
Assignments/JavaScript/ch05/ch05/ex_5_18.html
Executable file
@ -0,0 +1,29 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 5.18</title>
|
||||
<script>
|
||||
function getName()
|
||||
{
|
||||
var name = " "; count = 0; symbol = "* ";
|
||||
symbol = prompt("Pick a keyboard symbol to border your name, such as a * or # ", " ");
|
||||
name = prompt("What is your name? "," ");
|
||||
for (count = 1; count <= (name.length + 4); count++)
|
||||
document.write(symbol + " ");
|
||||
document.write("<br />");
|
||||
document.write(symbol + " " + symbol + " " + name + " " + symbol + " " + symbol);
|
||||
document.write("<br />");
|
||||
for (count = 1; count <= (name.length + 4); count++)
|
||||
document.write(symbol + " ");
|
||||
}
|
||||
</script>
|
||||
</<head>
|
||||
<body>
|
||||
<table align ="center" width ="70%"><tr><td colspan ="2">
|
||||
<h1> </h2>
|
||||
<h1>Name in a Box</h1>
|
||||
<p><input type="button" id="name" value="Put your name in a box" onclick="getName();" /></p>
|
||||
</td></tr>
|
||||
</table></body>
|
||||
</html>
|
||||
|
28
Assignments/JavaScript/ch05/ch05/ex_5_19.html
Executable file
@ -0,0 +1,28 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 5.19</title>
|
||||
<script>
|
||||
function getName()
|
||||
{
|
||||
var name = " "; count = 0;
|
||||
name = prompt("What is your name? "," ");
|
||||
for (count = 1; count <= (name.length + 4); count++)
|
||||
document.write("<img src = 'border.jpg' /> ");
|
||||
document.write("<br />");
|
||||
document.write("<h1> <img src = 'border.jpg' /> " + "<img src = 'border.jpg' /> " + " " + name + " " + "<img src = 'border.jpg' /> " + "<img src = 'border.jpg' /> </h1> ");
|
||||
document.write("<br />");
|
||||
for (count = 1; count <= (name.length + 4); count++)
|
||||
document.write("<img src = 'border.jpg' /> ");
|
||||
}
|
||||
</script>
|
||||
</<head>
|
||||
<body>
|
||||
<table align ="center" width ="70%"><tr><td colspan ="2">
|
||||
<h1> </h2>
|
||||
<h1>Name in a Box</h1>
|
||||
<p><input type="button" id="name" value="Put your name in a box" onclick="getName();" /></p>
|
||||
</td></tr>
|
||||
</table></body>
|
||||
</html>
|
||||
|
30
Assignments/JavaScript/ch05/ch05/ex_5_2.html
Executable file
@ -0,0 +1,30 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 5.2</title>
|
||||
<script>
|
||||
function getAverage()
|
||||
{
|
||||
var score = 0; var sum = 0; var count = 0; var average = 0;
|
||||
while (score != -999)
|
||||
{
|
||||
sum = sum + score;
|
||||
count++;
|
||||
score = parseInt(prompt("Enter a score or enter -999 when you're finished:"," "));
|
||||
}
|
||||
average = sum/(count - 1);
|
||||
document.write("<p>The sum of these scores is: " + sum + ".</p>");
|
||||
document.write("<p>The average of these scores is: " + average + ".</p>");
|
||||
}
|
||||
</script>
|
||||
</<head>
|
||||
<body>
|
||||
<table align ="center" width ="70%"><tr><td colspan ="2">
|
||||
<h1> </h2>
|
||||
<h1>Exam 1 Scores</h1>
|
||||
<h3>Click to enter students' scores</h3>
|
||||
<p><input type="button" id="scores" value="Enter the scores" onclick="getAverage();" /></p>
|
||||
</td></tr>
|
||||
</table></body>
|
||||
</html>
|
||||
|
19
Assignments/JavaScript/ch05/ch05/ex_5_20.html
Executable file
@ -0,0 +1,19 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 5.20</title>
|
||||
</head>
|
||||
<body>
|
||||
<table align ="center" width ="70%"><tr><td colspan ="2">
|
||||
<h1> </h2>
|
||||
<h1>The Rollover</h1>
|
||||
<h3>To change the image, roll your mouse over it</h3>
|
||||
<table align="center" width = "70%"><tr><td id = "photo" name = "photo">
|
||||
<a href = '#' onmouseover = "document.photo.src = 'troll.jpg';"
|
||||
onmouseout = "document.photo.src = 'wizard.jpg';">
|
||||
<img src = "wizard.jpg" alt = "the winner" name = "photo" /> </a>
|
||||
</td></tr>
|
||||
<tr><td><h3>Change me!</h3></td></tr>
|
||||
</table></body>
|
||||
</html>
|
||||
|
18
Assignments/JavaScript/ch05/ch05/ex_5_21.html
Executable file
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 5.21</title>
|
||||
</head>
|
||||
<body>
|
||||
<table align ="center" width ="70%"><tr><td colspan ="2">
|
||||
<h1> </h2>
|
||||
<h1>Change the Image</h1>
|
||||
<h3>To change the image, double-click on it</h3>
|
||||
<table align="center" width = "70%"><tr><td id = "photo" name = "photo">
|
||||
<a href = '#' ondblclick = "document.photo.src = 'troll.jpg';">
|
||||
<img src = "wizard.jpg" alt = "the winner" name = "photo" /></a>
|
||||
</td></tr>
|
||||
<tr><td><h3>Change me!</h3></td></tr>
|
||||
</table></body>
|
||||
</html>
|
||||
|
38
Assignments/JavaScript/ch05/ch05/ex_5_22.html
Executable file
@ -0,0 +1,38 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 5.22</title>
|
||||
<script>
|
||||
function getSwap()
|
||||
{
|
||||
var again = "y";
|
||||
var pic = "troll";
|
||||
while (again == "y")
|
||||
{
|
||||
if (pic == "wizard")
|
||||
{
|
||||
document.getElementById('photo').innerHTML = "<img src = 'troll.jpg' />";
|
||||
pic = "troll";
|
||||
var again = prompt("See new image? y/n?", " ");
|
||||
}
|
||||
if (pic == "troll")
|
||||
{
|
||||
document.getElementById('photo').innerHTML = "<img src = 'wizard.jpg' />";
|
||||
pic = "wizard";
|
||||
var again = prompt("See new image? y/n?", " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<table align ="center" width ="70%"><tr><td colspan ="2">
|
||||
<h1> </h2>
|
||||
<h1>Swapping Images</h1>
|
||||
<p><input type="button" id="swap" value="Push me to change the image" onclick="getSwap();" /></p>
|
||||
<table align="center" width = "70%"><tr><td id = "photo" name = "photo">
|
||||
<img src = "troll.jpg" alt = "troll" name = "myPhoto" />
|
||||
</td></tr>
|
||||
</table></body>
|
||||
</html>
|
||||
|
38
Assignments/JavaScript/ch05/ch05/ex_5_23.html
Executable file
@ -0,0 +1,38 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 5.23</title>
|
||||
<script>
|
||||
function getSwap()
|
||||
{
|
||||
var again = "y";
|
||||
var pic = "troll";
|
||||
while (again == "y")
|
||||
{
|
||||
if (pic == "wizard")
|
||||
{
|
||||
document.getElementById('photo').innerHTML = "<img src = 'troll.jpg' />";
|
||||
pic = "troll";
|
||||
var again = prompt("See new image? y/n?", " ");
|
||||
}
|
||||
if (pic == "troll")
|
||||
{
|
||||
document.getElementById('photo').innerHTML = "<img src = 'wizard.jpg' />";
|
||||
pic = "wizard";
|
||||
var again = prompt("See new image? y/n?", " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<table align ="center" width ="70%"><tr><td colspan ="2">
|
||||
<h1> </h2>
|
||||
<h1>Swapping Images</h1>
|
||||
<p><input type="button" id="swap" value="Push me to change the image" onclick="getSwap();" /></p>
|
||||
<table align="center" width = "70%"><tr><td id = "photo" name = "photo">
|
||||
<img src = "troll.jpg" alt = "troll" name = "myPhoto" />
|
||||
</td></tr>
|
||||
</table></body>
|
||||
</html>
|
||||
|
10
Assignments/JavaScript/ch05/ch05/ex_5_23a.htm
Executable file
@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 5.23a: Page One</title>
|
||||
</head>
|
||||
<body>
|
||||
<h3>See what's on the next page...</h3>
|
||||
<p><input type="button" id="pageOne" value="This button will take you to the next page"
|
||||
onclick = "location.href = 'page_two.html'"; /></p>
|
||||
</body>
|
||||
</html>
|
10
Assignments/JavaScript/ch05/ch05/ex_5_23b.htm
Executable file
@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 5.23b: Page Two</title>
|
||||
</head>
|
||||
<body>
|
||||
<h3>You can go back too...</h3>
|
||||
<p><input type="button" id="pageTwo" value="This button will take you back to the previous page"
|
||||
onclick = "location.href = 'page_one.html'"; /></p>
|
||||
</body>
|
||||
</html>
|
31
Assignments/JavaScript/ch05/ch05/ex_5_27.html
Executable file
@ -0,0 +1,31 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Exercise 5.27</title>
|
||||
<script>
|
||||
function loopIt()
|
||||
{
|
||||
var x = 0; var y = 0;
|
||||
while (x < 3)
|
||||
{
|
||||
y = 1;
|
||||
while(y < 2)
|
||||
{
|
||||
document.write("Hello there <br /> ");
|
||||
y++;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
</<head>
|
||||
<body>
|
||||
<table align ="center" width ="70%"><tr><td colspan ="2">
|
||||
<h1> </h2>
|
||||
<h1>Loop Exercises</h1>
|
||||
<p><input type="button" id="name" value="Press to begin" onclick="loopIt();" /></p>
|
||||
</td></tr>
|
||||
</table></body>
|
||||
</html>
|
||||
|
41
Assignments/JavaScript/ch05/ch05/ex_5_3.html
Executable file
@ -0,0 +1,41 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 5.3</title>
|
||||
<script>
|
||||
function getStats()
|
||||
{
|
||||
var score = 0; var sum = 0; var count = 1; var average = 0;
|
||||
var high = 0; var low = 0;
|
||||
score = parseInt(prompt("Enter a score or enter -999 when you're finished:"," "));
|
||||
low = score;
|
||||
high = score;
|
||||
while (score != -999)
|
||||
{
|
||||
sum = sum + score;
|
||||
count++;
|
||||
score = parseInt(prompt("Enter a score or enter -999 when you're finished:"," "));
|
||||
if (score > high)
|
||||
high = score;
|
||||
if ((score < low) && (score != -999))
|
||||
low = score;
|
||||
}
|
||||
average = parseInt(sum/(count - 1));
|
||||
document.write("<p>The number of scores entered is: " + (count - 1) + ".</p>");
|
||||
document.write("<p>The sum of these scores is: " + sum + ".</p>");
|
||||
document.write("<p>The average of these scores is: " + average + ".</p>");
|
||||
document.write("<p>The lowest score is: " + low + ".</p>");
|
||||
document.write("<p>The highest score is: " + high + ".</p>");
|
||||
}
|
||||
</script>
|
||||
</<head>
|
||||
<body>
|
||||
<table align ="center" width ="70%"><tr><td colspan ="2">
|
||||
<h1> </h2>
|
||||
<h1>Exam 1 Scores</h1>
|
||||
<h3>Click to enter students' scores</h3>
|
||||
<p><input type="button" id="scores" value="Enter the scores" onclick="getStats();" /></p>
|
||||
</td></tr>
|
||||
</table></body>
|
||||
</html>
|
||||
|
36
Assignments/JavaScript/ch05/ch05/ex_5_4.html
Executable file
@ -0,0 +1,36 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 5.4</title>
|
||||
<script>
|
||||
function getStats()
|
||||
{
|
||||
var question = " "; var oddCount = 0; var evenCount = 0; var count = 0;
|
||||
var name = " ";
|
||||
name = (prompt("What is this student's name?"," "));
|
||||
alert("At each prompt enter 'y' if the student got the question correct or 'n' for incorrect");
|
||||
for (count = 1; count < 21; count++)
|
||||
{
|
||||
question = (prompt("Question " + count + ": ", " "));
|
||||
if ((question == "n") && ((count % 2) == 0))
|
||||
evenCount++;
|
||||
if ((question == "n") && ((count % 2) != 0))
|
||||
oddCount++;
|
||||
}
|
||||
document.write("<p>Results for " + name + ":</p>");
|
||||
document.write("<p>Out of the 20 questions on this exam: </p>");
|
||||
document.write("<p>The number of odd questions missed is: " + oddCount);
|
||||
document.write("<p>The number of even questions missed is: " + evenCount);
|
||||
}
|
||||
</script>
|
||||
</<head>
|
||||
<body>
|
||||
<table align ="center" width ="70%"><tr><td colspan ="2">
|
||||
<h1> </h2>
|
||||
<h1>Exam 1 Scores</h1>
|
||||
<h3>Click to enter students' scores</h3>
|
||||
<p><input type="button" id="scores" value="Enter the scores" onclick="getStats();" /></p>
|
||||
</td></tr>
|
||||
</table></body>
|
||||
</html>
|
||||
|
37
Assignments/JavaScript/ch05/ch05/ex_5_5.html
Executable file
@ -0,0 +1,37 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 5.5</title>
|
||||
<script>
|
||||
function floatToInteger()
|
||||
{
|
||||
var floatNum = 0; var newValue = 0;
|
||||
var change = " ";
|
||||
floatNum = prompt("Enter any number or enter -99 to quit:", "");
|
||||
while (floatNum != -99)
|
||||
{
|
||||
document.write("<p>You originally entered: " + floatNum + "</p>");
|
||||
newValue = parseInt(floatNum);
|
||||
document.write("<p>The result of pareseInt(X) is: " + newValue + "</p>");
|
||||
newValue = Math.floor(floatNum);
|
||||
document.write("<p>The result of Math.floor(X) is : " + newValue + "</p>");
|
||||
newValue = Math.ceil(floatNum);
|
||||
document.write("<p>The result of Math.ceil(X) is : " + newValue + "</p>");
|
||||
newValue = Math.round(floatNum);
|
||||
document.write("<p>The result of Math.round(X) is : " + newValue + "</p>");
|
||||
floatNum = prompt("Enter any number or enter -99 to quit:", "");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<table align ="center" width ="70%"><tr><td colspan ="2">
|
||||
<h1> </h2>
|
||||
<h1>Using Math Methods to Convert Floating Point Numbers to Integers</h1>
|
||||
<tr><td><p> </p>
|
||||
<p><input type="button" id="integers" value="Begin" onclick="floatToInteger();" /></p>
|
||||
</td></tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
|
62
Assignments/JavaScript/ch05/ch05/ex_5_6.html
Executable file
@ -0,0 +1,62 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 5.6</title>
|
||||
<script>
|
||||
function getStats()
|
||||
{
|
||||
var score = 0; var sum = 0; var count = 1; var average = 0;
|
||||
var high = 0; var low = 0;
|
||||
score = parseInt(prompt("Enter a score or enter -999 when you're finished:"," "));
|
||||
low = score;
|
||||
high = score;
|
||||
while (score != -999)
|
||||
{
|
||||
sum = sum + score;
|
||||
count++;
|
||||
score = parseInt(prompt("Enter a score or enter -999 when you're finished:"," "));
|
||||
if (score > high)
|
||||
high = score;
|
||||
if ((score < low) && (score != -999))
|
||||
low = score;
|
||||
}
|
||||
average = Math.round(sum/(count - 1));
|
||||
document.write("<p>The number of scores entered is: " + (count - 1) + ".</p>");
|
||||
document.write("<p>The average of these scores is: " + average + ".</p>");
|
||||
document.write("<p>The lowest score is: " + low + ".</p>");
|
||||
document.write("<p>The highest score is: " + high + ".</p>");
|
||||
}
|
||||
function getStudent()
|
||||
{
|
||||
var question = " ";
|
||||
var name = " ";
|
||||
name = (prompt("What is this student's name?"," "));
|
||||
var oddCount = 0; var evenCount = 0; var count = 0;
|
||||
alert("At each prompt enter 'y' if the student got the question correct or 'n' for incorrect");
|
||||
for (count = 1; count < 21; count++)
|
||||
{
|
||||
question = (prompt("Question " + count + ": ", " "));
|
||||
if ((question == "n") && ((count % 2) == 0))
|
||||
evenCount++;
|
||||
if ((question == "n") && ((count % 2) != 0))
|
||||
oddCount++;
|
||||
}
|
||||
document.write("<p>Results for " + name + ":</p>");
|
||||
document.write("<p>Out of the 20 questions on this exam: </p>");
|
||||
document.write("<p>The number of odd questions missed is: " + oddCount);
|
||||
document.write("<p>The number of even questions missed is: " + evenCount);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<table align ="center" width ="70%"><tr><td colspan ="2">
|
||||
<h1> </h2>
|
||||
<h1>Exam 1</h1>
|
||||
<h3>Get a summary of exam results</h3>
|
||||
<p><input type="button" id="scores" value="Class results" onclick="getStats();" /></p>
|
||||
<h3>Get an individual student's results</h3>
|
||||
<p><input type="button" id="studentscores" value="Student results" onclick="getStudent();" /></p>
|
||||
</td></tr>
|
||||
</table></body>
|
||||
</html>
|
||||
|
66
Assignments/JavaScript/ch05/ch05/ex_5_7.html
Executable file
@ -0,0 +1,66 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 5.7</title>
|
||||
<script>
|
||||
function getStats()
|
||||
{
|
||||
var score = 0; var sum = 0; var count = 1; var average = 0;
|
||||
var high = 0; var low = 0;
|
||||
score = parseInt(prompt("Enter a score or enter -999 when you're finished:"," "));
|
||||
while (isNaN(score))
|
||||
{
|
||||
score = parseInt(prompt("Enter a valid score or enter -999 when you're finished:"," "));
|
||||
}
|
||||
low = score;
|
||||
high = score;
|
||||
while (score != -999)
|
||||
{
|
||||
sum = sum + score;
|
||||
count++;
|
||||
score = parseInt(prompt("Enter a score or enter -999 when you're finished:"," "));
|
||||
if (score > high)
|
||||
high = score;
|
||||
if ((score < low) && (score != -999))
|
||||
low = score;
|
||||
}
|
||||
average = Math.round(sum/(count - 1));
|
||||
document.write("<p>The number of scores entered is: " + (count - 1) + ".</p>");
|
||||
document.write("<p>The average of these scores is: " + average + ".</p>");
|
||||
document.write("<p>The lowest score is: " + low + ".</p>");
|
||||
document.write("<p>The highest score is: " + high + ".</p>");
|
||||
}
|
||||
function getStudent()
|
||||
{
|
||||
var question = " ";
|
||||
var name = " ";
|
||||
name = (prompt("What is this student's name?"," "));
|
||||
var oddCount = 0; var evenCount = 0; var count = 0;
|
||||
alert("At each prompt enter 'y' if the student got the question correct or 'n' for incorrect");
|
||||
for (count = 1; count < 21; count++)
|
||||
{
|
||||
question = (prompt("Question " + count + ": ", " "));
|
||||
if ((question == "n") && ((count % 2) == 0))
|
||||
evenCount++;
|
||||
if ((question == "n") && ((count % 2) != 0))
|
||||
oddCount++;
|
||||
}
|
||||
document.write("<p>Results for " + name + ":</p>");
|
||||
document.write("<p>Out of the 20 questions on this exam: </p>");
|
||||
document.write("<p>The number of odd questions missed is: " + oddCount);
|
||||
document.write("<p>The number of even questions missed is: " + evenCount);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<table align ="center" width ="70%"><tr><td colspan ="2">
|
||||
<h1> </h2>
|
||||
<h1>Exam 1</h1>
|
||||
<h3>Get a summary of exam results</h3>
|
||||
<p><input type="button" id="scores" value="Class results" onclick="getStats();" /></p>
|
||||
<h3>Get an individual student's results</h3>
|
||||
<p><input type="button" id="studentscores" value="Student results" onclick="getStudent();" /></p>
|
||||
</td></tr>
|
||||
</table></body>
|
||||
</html>
|
||||
|
88
Assignments/JavaScript/ch05/ch05/ex_5_9_10.html
Executable file
@ -0,0 +1,88 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 5.9 and 10</title>
|
||||
<script>
|
||||
function getOrder()
|
||||
{
|
||||
document.write('<table width="60%" align = "center">');
|
||||
var count = 1; var num = 0; cost = 0; var sub = 0;
|
||||
var item = " "; var choice = " ";
|
||||
document.write('<tr><td><img src="images/jewel_box1.jpg" /></td></tr>');
|
||||
shop();
|
||||
function shop()
|
||||
{
|
||||
while (item != "X")
|
||||
{
|
||||
item = prompt("Enter the letter of item number " + count + " or enter 'X' when you are finished.");
|
||||
num = parseInt(prompt("How many do you want (enter 0 if done)?", " "));
|
||||
document.write('<tr>');
|
||||
sub = cost;
|
||||
switch (item)
|
||||
{
|
||||
case "A":
|
||||
case "B":
|
||||
cost = cost + (num * 5.95);
|
||||
break;
|
||||
case "C":
|
||||
cost = cost + (num * 8.95);
|
||||
break;
|
||||
case "D":
|
||||
cost = cost + (num * 12.95);
|
||||
break;
|
||||
case "E":
|
||||
cost = cost + (num * 14.95);
|
||||
break;
|
||||
case "F":
|
||||
cost = cost + (num * 18.95);
|
||||
break;
|
||||
case "G":
|
||||
cost = cost + (num * 15.95);
|
||||
break;
|
||||
case "H":
|
||||
case "I":
|
||||
cost = cost + (num * 21.95);
|
||||
break;
|
||||
}
|
||||
count++;
|
||||
if (item != "X")
|
||||
{
|
||||
document.write("<td>You ordered " + num + " of item " + item + " <br /> The total cost so far is $ " + cost.toFixed(2) + "</td>");
|
||||
document.write('</tr>');
|
||||
}
|
||||
else
|
||||
break;
|
||||
if ((cost > 100) && (choice == " "))
|
||||
{
|
||||
alert("Your next purchase will put your order over $100 and shipping costs triple.");
|
||||
choice = prompt("Do you want to continue shopping anyway? Enter 'y' or 'n':" , " ");
|
||||
}
|
||||
if (choice == "y")
|
||||
shop();
|
||||
if (choice == "n")
|
||||
{
|
||||
document.write("<td>Your last item has been removed. Your present total is $ " + sub.toFixed(2) + "</td>");
|
||||
break;
|
||||
}
|
||||
}
|
||||
document.write('</table>');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</<head>
|
||||
<body>
|
||||
<table align ="center" width ="70%" ><tr><td colspan ="3">
|
||||
<h1>Order Your Jewelry Now!</h1>
|
||||
<tr><td><img src = "ring1.jpg" alt ="ring1" /> <br /> A: ring 1, cost: $ 5.95 </td>
|
||||
<td><img src = "ring2.jpg" alt ="ring2" /> <br /> B: ring 2, cost: $ 5.95 </td>
|
||||
<td><img src = "ring3.jpg" alt ="ring3" /> <br /> C: ring 3, cost: $ 8.95 </td></tr>
|
||||
<tr><td> <img src = "bracelet1.jpg" alt = "bracelet1" /> <br /> D: bracelet 1, cost: $ 12.95 </td>
|
||||
<td> <img src = "bracelet2.jpg" alt = "bracelet2" /> <br /> E: bracelet 2, cost: $ 14.95 </td>
|
||||
<td> <img src = "bracelet3.jpg" alt = "bracelet3" /> <br /> F: bracelet 3, cost: $ 18.95 </td></tr>
|
||||
<tr><td><img src = "pendant1.jpg" alt ="pendant1" /> <br /> G: pendant 1, cost: $ 15.95 </td>
|
||||
<td><img src = "pendant2.jpg" alt ="pendant2" /> <br /> H: pendant 2, cost: $ 21.95 </td>
|
||||
<td><img src = "pendant3.jpg" alt ="pendant3" /> <br /> I: pendant 3, cost: $ 21.95 </td></tr>
|
||||
<tr><td colspan="3"><p><br /><input type="button" id="order" value="Place your order" onclick="getOrder();" /></p></td></tr>
|
||||
</table></body>
|
||||
</html>
|
||||
|
BIN
Assignments/JavaScript/ch05/ch05/greg/.DS_Store
vendored
Executable file
115
Assignments/JavaScript/ch05/ch05/greg/battleground.html
Executable file
@ -0,0 +1,115 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Greg's Gambits | The Battleground</title>
|
||||
<link href="greg.css" rel="stylesheet" type="text/css" />
|
||||
<script type="text/javascript">
|
||||
function battleIt()
|
||||
{
|
||||
var heroPlay = 0; var heroPts = 100; var trollPts = 100; var trollPlay = 0;
|
||||
var rocks = "magic rocks"; var sword = "the sword"; var arrow = "bow and arrow";
|
||||
var heroChoice = " "; var trollChoice = " ";
|
||||
document.getElementById("trollPts").innerHTML = (trollPts);
|
||||
document.getElementById("heroPts").innerHTML = (heroPts);
|
||||
document.getElementById("playerWeapon").innerHTML = ("Your weapon: ");
|
||||
document.getElementById("trollWeapon").innerHTML = ("The troll's weapon: ");
|
||||
document.getElementById("winner").innerHTML = (" ");
|
||||
//loop repeats until troll or player get 130 points
|
||||
while ((trollPts < 130) && (heroPts < 130))
|
||||
{
|
||||
// get player's weapon
|
||||
heroPlay = parseInt(prompt("What weapon do you choose? Enter 1 for magic rocks (enter 1), 2 for the sword, or 3 for the bow and arrow: (Enter 4 to leave the game at any time)" , " "));
|
||||
if (heroPlay == 4) break;
|
||||
// get troll's weapon
|
||||
trollPlay = Math.floor(Math.random() * 3 + 1);
|
||||
// assign weapon to player and troll
|
||||
if (trollPlay == 1)
|
||||
trollChoice = rocks;
|
||||
if (trollPlay == 2)
|
||||
trollChoice = sword;
|
||||
if (trollPlay == 3)
|
||||
trollChoice = arrow;
|
||||
if (heroPlay == 1)
|
||||
heroChoice = rocks;
|
||||
if (heroPlay == 2)
|
||||
heroChoice = sword;
|
||||
if (heroPlay == 3)
|
||||
heroChoice = arrow;
|
||||
//display weapon selections
|
||||
document.getElementById("playerWeapon").innerHTML = ("Your weapon: " + heroChoice);
|
||||
document.getElementById("trollWeapon").innerHTML = ("The troll's weapon: " + trollChoice);
|
||||
alert("This round of the battle begins now!");
|
||||
//find the winner
|
||||
if (((trollPlay == 1) && (heroPlay == 3)) || ((trollPlay == 2) && (heroPlay == 1)) || ((trollPlay == 3) && (heroPlay == 2)))
|
||||
{
|
||||
document.getElementById("winner").innerHTML = ("<img src='images/troll.jpg' />");
|
||||
trollPts = trollPts + 10;
|
||||
heroPts = heroPts - 10;
|
||||
document.getElementById("trollPts").innerHTML = (trollPts);
|
||||
document.getElementById("heroPts").innerHTML = (heroPts);
|
||||
}
|
||||
if (((heroPlay == 1) && (trollPlay == 3)) || ((heroPlay == 2) && (trollPlay == 1)) || ((heroPlay == 3) && (trollPlay == 2)))
|
||||
{
|
||||
document.getElementById("winner").innerHTML = ("<img src='images/wizard.jpg' />");
|
||||
trollPts = trollPts - 10;
|
||||
heroPts = heroPts + 10;
|
||||
document.getElementById("trollPts").innerHTML = (trollPts);
|
||||
document.getElementById("heroPts").innerHTML = (heroPts);
|
||||
}
|
||||
if (((heroPlay == 1) && (trollPlay == 1)) || ((heroPlay == 2) && (trollPlay == 2)) || ((heroPlay == 3) && (trollPlay == 3)))
|
||||
{
|
||||
document.getElementById("winner").innerHTML = ("This round is a tie. New weapons must be chosen...");
|
||||
}
|
||||
}
|
||||
//display the final winner
|
||||
if (heroPlay == 4)
|
||||
document.getElementById("winner").innerHTML = ("It's true: when you run, you live to fight another day. See you again soon!");
|
||||
if (trollPts >= 130)
|
||||
document.getElementById("winner").innerHTML = ("The battle has been fought valiently but the troll has beaten you. Go home and nurse your wounds.");
|
||||
if (heroPts >= 130)
|
||||
document.getElementById("winner").innerHTML = ("The battle has been fought valiently and you have prevailed! Congratulations!");
|
||||
}
|
||||
</script>
|
||||
<style type="text/css">
|
||||
<!--
|
||||
.style1 {font-size: 18px}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="container">
|
||||
<img src="images/superhero.jpg" width="120" height="120" class="floatleft" />
|
||||
<h1 align="center">The Battleground</h1>
|
||||
<div style ="clear:both;"></div>
|
||||
<div id="nav">
|
||||
<p><a href="index.html">Home</a>
|
||||
<a href="greg.html">About Greg</a>
|
||||
<a href="play_games.html">Play a Game</a>
|
||||
<a href="sign.html">Sign In</a>
|
||||
<a href="contact.html">Contact Us</a></p>
|
||||
</div>
|
||||
<div id="content">
|
||||
<table width = "85%" cellpadding="5" cellspacing="0" border = "0">
|
||||
<tr><td><img src="images/wizard.jpg" width="120" height="168" /></td>
|
||||
<td><img src="images/troll.jpg" width="120" height="168" /></td></tr>
|
||||
<tr><td><span class="style1">Wizard uses: </span></td>
|
||||
<td><span class="style1">Troll uses: </span></td></tr>
|
||||
<tr><td id = "playerWeapon" span class="style1">Weapon goes here</span></td>
|
||||
<td id = "trollWeapon" span class="style1">Weapon goes here</span></td></tr>
|
||||
<tr><td colspan = 2><span class="style1">The winner is:</span></td></tr>
|
||||
<tr><td colspan = 2 id="winner" align = "center" class="style1"> </td></tr>
|
||||
<tr><td><span class="style1">Wizard points: </span></td>
|
||||
<td><span class="style1">Troll points:</span></td></tr>
|
||||
<tr><td class="style1" id = "heroPts">100</td> <td class="style1" id = "trollPts">100</td></tr>
|
||||
<tr><td><input type="button" id="battle" value="Let the battle begin!" onclick="battleIt()"; /> </td>
|
||||
<td><input type="button" id="return" value="Return to battle instructions" onclick="location.href = 'greg_battle.html'"; /></td>
|
||||
</table>
|
||||
</div>
|
||||
<div id="footer">Copyright © 2013 Greg's Gambits<br />
|
||||
<a href="mailto:yourfirstname@yourlastname.com">yourfirstname@yourlastname.com</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
125
Assignments/JavaScript/ch05/ch05/greg/greg.css
Executable file
@ -0,0 +1,125 @@
|
||||
body { background-color: #000040;
|
||||
background-image: url(background.gif);
|
||||
color: #88ffff;
|
||||
font-family: Verdana, Arial, sans-serif;
|
||||
}
|
||||
#container { margin-left: auto;
|
||||
margin-right: auto;
|
||||
width:80%;
|
||||
min-width:700px;
|
||||
}
|
||||
|
||||
|
||||
#logo {
|
||||
text-align:center;
|
||||
margin: 0;
|
||||
font-family: Geneva, Arial, Helvetica, sans-serif;
|
||||
padding-top: 30px;
|
||||
padding-bottom: 20px;
|
||||
|
||||
}
|
||||
#nav {
|
||||
float: left;
|
||||
width: 200px;
|
||||
padding-top: 10px;
|
||||
text-align:left;
|
||||
color: #88FFFF;
|
||||
font-size: 12px;
|
||||
}
|
||||
#nav a {text-decoration:none;
|
||||
margin: 15px;
|
||||
display: block;
|
||||
color: #88FFFF;
|
||||
font-size: 12px;
|
||||
}
|
||||
#content {
|
||||
margin-left: 150px;
|
||||
padding: 30px;
|
||||
overflow:auto;
|
||||
border: medium groove #88FFFF;
|
||||
line-height: 135%;
|
||||
|
||||
}
|
||||
|
||||
.floatright {padding-left:20px;
|
||||
float:right;
|
||||
}
|
||||
.floatleft {
|
||||
float:left;
|
||||
padding: 30px 0px 20px;
|
||||
}
|
||||
#footer { font-size: .60em;
|
||||
font-style: italic;
|
||||
text-align: center;
|
||||
border-top: 2px double #000040;
|
||||
padding-top: 20px;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
h2 { text-transform: uppercase;
|
||||
color: #88ffff;
|
||||
font-size: 1.2em;
|
||||
border-bottom: 1px none;
|
||||
margin-right: 20px;
|
||||
}
|
||||
h3 {
|
||||
color: #88ffff;
|
||||
font-size: 1.2em;
|
||||
border-bottom: 1px solid #000000;
|
||||
margin-right: auto;
|
||||
text-align: left;
|
||||
padding-top: 10px;
|
||||
padding-right: 20px;
|
||||
padding-bottom: 10px;
|
||||
padding-left: 20px;
|
||||
line-height: 120%;
|
||||
}
|
||||
.details { padding-left:20%;
|
||||
padding-right:20%;
|
||||
}
|
||||
|
||||
|
||||
img {border:0; }
|
||||
|
||||
|
||||
.content {
|
||||
margin: 20px;
|
||||
padding: 20px;
|
||||
height: 3700px;
|
||||
width: 500px;
|
||||
}
|
||||
a {text-decoration:none;
|
||||
margin: 15px;
|
||||
display: block;
|
||||
color: #88FFFF;
|
||||
font-size: 12px;
|
||||
}
|
||||
a:hover {
|
||||
color: #000040;
|
||||
background-color: #88ffff;
|
||||
}
|
||||
span {
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
font-family: "Courier New", Courier, mono;
|
||||
color: #88ffff;
|
||||
background-position: center center;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse
|
||||
}
|
||||
td {
|
||||
border: 2px solid #88ffff;
|
||||
width: 5em;
|
||||
color: #88ffff;
|
||||
}
|
||||
.nobdr {
|
||||
border: none;
|
||||
cell-padding: 5px;
|
||||
}
|
||||
p {
|
||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||
font-size: 12px;
|
||||
}
|
57
Assignments/JavaScript/ch05/ch05/greg/greg_battle.html
Executable file
@ -0,0 +1,57 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Greg's Gambits | Battle the Evil Troll</title>
|
||||
<link href="greg.css" rel="stylesheet" type="text/css" />
|
||||
<style type="text/css">
|
||||
<!--
|
||||
.style1 {font-size: 18px}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="container">
|
||||
<img src="images/superhero.jpg" width="120" height="120" class="floatleft" />
|
||||
<h1 align="center"><em>Battle the Evil Troll</em></h1>
|
||||
|
||||
<div style ="clear:both;"></div>
|
||||
<div id="nav">
|
||||
<p><a href="index.html">Home</a>
|
||||
<a href="greg.html">About Greg</a>
|
||||
<a href="play_games.html">Play a Game</a>
|
||||
<a href="sign.html">Sign In</a>
|
||||
<a href="contact.html">Contact Us</a></p>
|
||||
</div>
|
||||
<div id="content">
|
||||
<table width = "85%" cellpadding="5" cellspacing="0" border = "0">
|
||||
<tr><td colspan = 4><span class="style1">In this game you will battle the evil troll. You can choose
|
||||
your weapon from the three shown -- a set of magic rocks that are a lot stronger and heavier than they
|
||||
look, an extremely sharp sword, or a crossbow and arrow. Unfortunately, you do not know ahead of time
|
||||
what weapon the troll will use. You each begin with 100 points. For each round of the battle, the winner
|
||||
takes 10 points from the loser. When either of you reaches 200 points, the battle is over and one of you
|
||||
will lie dead. The winner is determined by the list shown below. Push the button when you are ready
|
||||
to begin the battle and ... Good luck!</span></td></tr>
|
||||
<tr><td width = 20%><p><img src="images/wizard.jpg" width="120" height="168"></p>
|
||||
<p> <span class="style1">Wizard</span></p></td>
|
||||
<td width=20%><p><img src="images/troll.jpg" width="120" height="168"></p>
|
||||
<p><span class="style1">Troll</span></p></td>
|
||||
<td width = 10%> </td>
|
||||
<td width = 50%> <span class="style1"><p>Weapons</p>
|
||||
<p><img src="images/rock.jpg" width="100" height="70" /> magic rocks</p>
|
||||
<p><img src="images/sword.jpg" width="100" height="70" /> sword</p>
|
||||
<p><img src="images/arrow.jpg" width="100" height="70" /> bow & arrow</span></p></td></tr>
|
||||
<tr><td colspan = 4><span class="style1">Note: <br />
|
||||
The rocks can deflect the arrow. <br />
|
||||
The sword beats the rocks. <br />
|
||||
The arrow beats the sword.</span></td></tr>
|
||||
</table>
|
||||
<input type="button" id="battle" value="Begin the battle!" onclick="location.href = 'battleground.html'"; />
|
||||
</div>
|
||||
<div id="footer">Copyright © 2013 Greg's Gambits<br />
|
||||
<a href="mailto:yourfirstname@yourlastname.com">yourfirstname@yourlastname.com</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
BIN
Assignments/JavaScript/ch05/ch05/greg/images/arrow.jpg
Executable file
After Width: | Height: | Size: 4.6 KiB |
BIN
Assignments/JavaScript/ch05/ch05/greg/images/rock.jpg
Executable file
After Width: | Height: | Size: 7.5 KiB |
BIN
Assignments/JavaScript/ch05/ch05/greg/images/superhero.jpg
Executable file
After Width: | Height: | Size: 5.0 KiB |
BIN
Assignments/JavaScript/ch05/ch05/greg/images/sword.jpg
Executable file
After Width: | Height: | Size: 3.7 KiB |
BIN
Assignments/JavaScript/ch05/ch05/greg/images/troll.jpg
Executable file
After Width: | Height: | Size: 8.6 KiB |
BIN
Assignments/JavaScript/ch05/ch05/greg/images/wizard.jpg
Executable file
After Width: | Height: | Size: 5.9 KiB |
46
Assignments/JavaScript/ch05/ch05/greg/play_games.html
Executable file
@ -0,0 +1,46 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<title>Greg's Gambits | Games Menu</title>
|
||||
<link href="greg.css" rel="stylesheet" type="text/css" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
|
||||
<img src="../images/superhero.jpg" width="120" height="120" class="floatleft" />
|
||||
<h1 id="logo"><em>Play A Game</em></h1>
|
||||
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
<div id="nav">
|
||||
<p><a href="index.html">Home</a>
|
||||
<a href="greg.html">About Greg</a>
|
||||
<a href="play_games.html">Play a Game</a>
|
||||
<a href="sign.html">Sign In</a>
|
||||
<a href="contact.html">Contact Us</a></p>
|
||||
</div>
|
||||
<div id="content">
|
||||
<p>Menu of Available Games </p>
|
||||
<table width="90%" border="0" cellpadding="5">
|
||||
<tr>
|
||||
<td width="50%"><a href="greg_tales.html">Greg's Tales</a> </td>
|
||||
<td width="50%"><a href ="gregs_fortune.html">Madame Vadoma Sees All</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="50%"><a href="greg_encoder.html">The Secret Message Encoder</a> </td>
|
||||
<td><a href="greg_battle.html">Battle With the Troll</a> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<p> </p>
|
||||
</div>
|
||||
<div id="footer">Copyright © 2013 Greg's Gambits<br />
|
||||
<a href="mailto:yourfirstname@yourlastname.com">yourfirstname@yourlastname.com</a></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
13
Assignments/JavaScript/ch05/ch05/page_one.html
Executable file
@ -0,0 +1,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Page One</title>
|
||||
</head>
|
||||
<body>
|
||||
<table width = 80% align = "center"><tr><td>
|
||||
<h1> </h1>
|
||||
<h3>See what's on the next page...</h3>
|
||||
<p><input type="button" id="pageOne" value="This button will take you to the next page"
|
||||
onclick = "location.href = 'page_two.html'"; /></p>
|
||||
</td></tr></table>
|
||||
</body>
|
||||
</html>
|
13
Assignments/JavaScript/ch05/ch05/page_two.html
Executable file
@ -0,0 +1,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Page Two</title>
|
||||
</head>
|
||||
<body>
|
||||
<table width = 80% align = "center"><tr><td>
|
||||
<h1> </h1>
|
||||
<h3>You can go back too...</h3>
|
||||
<p><input type="button" id="pageTwo" value="This button will take you back to the previous page"
|
||||
onclick = "location.href = 'page_one.html'"; /></p>
|
||||
</td></tr></table>
|
||||
</body>
|
||||
</html>
|
BIN
Assignments/JavaScript/ch05/ch05/pendant1.jpg
Executable file
After Width: | Height: | Size: 2.3 KiB |
BIN
Assignments/JavaScript/ch05/ch05/pendant2.jpg
Executable file
After Width: | Height: | Size: 2.7 KiB |
BIN
Assignments/JavaScript/ch05/ch05/pendant3.jpg
Executable file
After Width: | Height: | Size: 2.3 KiB |
BIN
Assignments/JavaScript/ch05/ch05/ring1.jpg
Executable file
After Width: | Height: | Size: 2.1 KiB |
BIN
Assignments/JavaScript/ch05/ch05/ring2.jpg
Executable file
After Width: | Height: | Size: 2.0 KiB |
BIN
Assignments/JavaScript/ch05/ch05/ring3.jpg
Executable file
After Width: | Height: | Size: 2.3 KiB |
BIN
Assignments/JavaScript/ch05/ch05/troll.jpg
Executable file
After Width: | Height: | Size: 8.6 KiB |
BIN
Assignments/JavaScript/ch05/ch05/wizard.jpg
Executable file
After Width: | Height: | Size: 5.9 KiB |