1 DIG 3134 – Lecture 11: Two Dimensional Arrays And Dynamic Controls AND CONSTANTS Michael Moshell University of Central Florida Internet Software Design.

Slides:



Advertisements
Similar presentations
JQuery MessageBoard. Lets use jQuery and AJAX in combination with a database to update and retrieve information without refreshing the page. Here we will.
Advertisements

CATHERINE AND ANNIE Python: Part 3. Intro to Loops Do you remember in Alice when you could use a loop to make a character perform an action multiple times?
KompoZer. This is what KompoZer will look like with a blank document open. As you can see, there are a lot of icons for beginning users. But don't be.
© Keith Vander Linden, How did you ever do without it? - from the first VisiCalc ad, 1979.
Using CourseCompass Features You must already be registered or enrolled in a current class.
ITC 240: Web Application Programming
Mrs. Chapman. Tabs (Block Categories) Commands Available to use Script Area where you type your code Sprite Stage All sprites in this project.
CS1061 C Programmuing Lecture 12 Arrays A. O’Riordan, 2004.
Homework Reading –Finish K&R Chapter 1 (if not done yet) –Start K&R Chapter 2 for next time. Programming Assignments –DON’T USE and string library functions,
Mr. Wortzman. Tabs (Block Categories) Available Blocks Script Area Sprite Stage All sprites in this project.
1 Spidering the Web in Python CSC 161: The Art of Programming Prof. Henry Kautz 11/23/2009.
1 DIG 3134 – Lecture 3 Forms Michael Moshell University of Central Florida Media Software Design.
CHAPTER 11 Tables. How Are Tables Used Data Display  Very tidy and very useful Better Text Alignment  Putting text in tables allows you to format indents.
Homework Reading Programming Assignments
1 iSee Player Tutorial Using the Forest Biomass Accumulation Model as an Example ( Tutorial Developed by: (
Announcements Project 2 Available Tomorrow (we will send mail) Will be due 11:59PM October 9 th (Sunday) Week 6 ( I will be traveling this week) Review.
Triangle Town Hi, I’m Elke. Pleased to be your guide through Triangle Town. Don’t ever worry about getting lost. I’ll stay with you the whole time.
Design IS 101Y/CMSC 101 Computational Thinking and Design Tuesday, October 15, 2013 Carolyn Seaman University of Maryland, Baltimore County.
REVIEW 2 Exam History of Computers 1. CPU stands for _______________________. a. Counter productive units b. Central processing unit c. Copper.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Chapter 6: Modifying Pixels by Position. Chapter Learning Goals.
 Embeds Java code  In HTML tags  When used well  Simple way to generate dynamic web-pages  When misused (complex embedded Java)  Terribly messy.
1 Functions 1 Parameter, 1 Return-Value 1. The problem 2. Recall the layout 3. Create the definition 4. "Flow" of data 5. Testing 6. Projects 1 and 2.
Return To Index Excel Microsoft Excel Basics Lesson 05 Creating & Saving A Simple Formula Force = Mass * AccelerationForce = Mass * Acceleration.
CSC Intro. to Computing Lecture 13: PALGO. Announcements Midterm is in one week  Time to start reviewing  We will do more review in class Tuesday.
How to start Milestone 1 CSSE 371 Project Info There are only 8 easy steps…
Summary of what we learned yesterday Basics of C++ Format of a program Syntax of literals, keywords, symbols, variables Simple data types and arithmetic.
TRICKS Ankur Club. VERTICALLY AND CROSSWISE you do not need to the multiplication tables beyond 5 X 5  Suppose you need 7 x 6 = 42 7 is 3 below 10 and.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
1 DIG 3134 Lecture 5: Functions Michael Moshell University of Central Florida Media Software Design.
1 DIG 3134 Lecture 7: Designing and Debugging Programs Michael Moshell University of Central Florida Media Software Design.
CS 4720 Dynamic Web Applications CS 4720 – Web & Mobile Systems.
Tables Web Authoring. This kind of a table THISIs aTABLE THISIs aTABLE THISIs aTABLE THISIs aTABLE.
1 DIG Lecture 2 (Game) The Acey-Deucey Game Michael Moshell University of Central Florida Media Software Design.
1 BUILDING JAVA PROGRAMS CHAPTER 2 Pseudocode and Scope.
Two-Dimensional Arrays That’s 2-D Arrays Girls & Boys! One-Dimensional Arrays on Steroids!
1 DIG 3134 – Lecture 4: Arrays and Strings Michael Moshell University of Central Florida Media Software Design.
1 DIG 3134 Lecture 9. Dynamic HTML Controls Michael Moshell University of Central Florida Media Software Design.
Relations And Functions. A relation is a set of ordered pairs {(2,3), (-1,5), (4,-2), (9,9), (0,-6)} This is a relation The domain is the set of all x.
Updated on: September 4, 2010 CIS67 Foundations for Creating Web Pages Professor Al Fichera.
U:/msu/course/cse/103 Day 21, Slide 1 CSE 103 Makeups –If you didn’t take one over the weekend, take one TUESDAY or WEDNESDAY!
Intermediate 2 Computing Unit 2 - Software Development.
1 Media Software Design DIG 3134 Fall 2012 Lecture 15: Graphics J. Michael Moshell University of Central Florida Original image* by Moshell et al.
Simulation and Modeling: Predator-Prey Processing Lab IS 101Y/CMSC 101 Computational Thinking and Design Tuesday, September 23, 2014 Carolyn Seaman Susan.
Higher Dimensions. x Let's say we use a pencil to mark a point on paper. x is this point. We pick a direction and move the pencil along this direction.
Functions.  Assignment #2 is now due on Wednesday, Nov 25 th  (No Quiz)  Go over the midterm  Backtrack and re-cover the question about tracing the.
Compsci 101.2, Fall Plan for October 22 l Images, tuples, RGB color model  Image processing by understanding API  Image processing with tuples.
1 DIG 3134 Lecture 6: Maintaining State Michael Moshell University of Central Florida Media Software Design.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
Ajax Dice Game Part 1. We saw that we could use the jQuery load() function, to dynamically load a piece of an html document into another html document.
CS190/295 Programming in Python for Life Sciences: Lecture 6 Instructor: Xiaohui Xie University of California, Irvine.
Creating Data Sheets. When you see a Red circle or a next button, like this, that means we want you to click on something. These are the same steps you’ll.
PHP Form Processing * referenced from
Top Secret For teachers’ eyes only STAAR Writing: Understanding the Narrative Prompt Jacob M. Lightbody © 2012.
M1G Introduction to Programming 2 2. Creating Classes: Game and Player.
Logical Operators.  Quiz  Let's look at the schedule  Logical Operators 2.
1 DIG 3134 Lecture 8: Reading and Writing Text Files Michael Moshell University of Central Florida Media Software Design.
Design IS 101Y/CMSC 101 Computational Thinking and Design Thursday, October 9, 2014 Carolyn Seaman Susan Martin University of Maryland, Baltimore County.
Chapter 6 Functions The Tic-Tac-Toe Game. Chapter Content In this chapter you will learn to do the following: 0 Write your own functions 0 Accept values.
Part 1 Learning Objectives To understand that variables are a temporary named location to store data and that programmers work with different data types.
Loops BIS1523 – Lecture 10.
Intro to PHP & Variables
Web Systems Development (CSC-215)
More Selections BIS1523 – Lecture 9.
In Class Program: Today in History
Computer Simulation with Concert Tour Entrepreneur
Homework Reading Programming Assignments Finish K&R Chapter 1
Summary of what we learned yesterday
Selection Statements Chapter 3.
Presentation transcript:

1 DIG 3134 – Lecture 11: Two Dimensional Arrays And Dynamic Controls AND CONSTANTS Michael Moshell University of Central Florida Internet Software Design

2222 The Conceptual Pathway PART ONE 2 dimensional array $Grid[$x][$y] $Miketable[$i][$j] – you can use any name, any indices This can be thought of as a Matrix of cells, like a Spreadsheet. Indices (plural of 'index') Can be numbers 1,2,3 or Strings like A, B, C. I recommend numbers, because 'for' loops are easy

33333 The Conceptual Pathway PART ONE 2 dimensional array What happens if we run this code? //$mtable[$i][$j] For ($i=1; $i<=6; $i++) { $mtable[$i][2]=34; } (Our convention: the first index ($i) is always “across”, the second “down”)

44444 The Conceptual Pathway PART ONE 2 dimensional array What happens if we run this code? //$mtable[$i][$j] For ($i=1; $i<=6; $i++) { $mtable[$i][2]=34; } (Our convention: the first index ($i) is always “across”, the second “down”)

55555 The Conceptual Pathway PART ONE 2 dimensional array What happens if we THEN run this code? //$mtable[$i][$j] For ($i=1; $i<=6; $i++) { $mtable[$i][2]=$i; } (Our convention: the first index ($i) is always “across”, the second “down”)

66666 The Conceptual Pathway PART ONE 2 dimensional array What happens if we THEN run this code? $mtable[$i][$j] For ($i=1; $i<=6; $i++) { $mtable[$i][2]=$i; } (Our convention: the first index ($i) is always “across”, the second “down”)

77777 In-Class Exercise Modify this code to produce the second image $mtable[$i][$j] For ($i=1; $i<=6; $i++) { $mtable[$i][2]=$i; } (Our convention: the first index ($i) is always “across”, the second “down”)

88888 The Conceptual Pathway PART ONE 2 dimensional array What happens if we run this code? //$mtable[$i][$j] For ($i=1; $i<=6; $i++) { $mtable[$i][$i]=34; }

99999 The Conceptual Pathway PART ONE 2 dimensional array What happens if we run this code? //$mtable[$i][$j] For ($i=1; $i<=6; $i++) { $mtable[$i][$i]=34; }

10 Homework #1: Due NEXT TUESDAY (ready for “gotcha” in class) Create a loop to construct this pattern in the array. (Yes, you could use two loops. But it is possible to do this with ONE loop.) I’ll take two, if you can’t figure out one

11 The Conceptual Pathway PART ONE Nested LOOPs! Now it gets INTERESTINGer // $mtable[$i][$j] for ($i=1; $i<=6; $i++) { for ($j=1; $j<=6; $j++) { $mtable[$i][$j]=34; } wordpress.com What will this produce?

12 The Conceptual Pathway PART ONE 2 dimensional LOOP! Now it gets INTERESTINGer // $mtable[$i][$j] for ($i=1; $i<=6; $i++) { for ($j=1; $j<=6; $j++) { $mtable[$i][$j]=34; } wordpress.com

13 The Conceptual Pathway PART ONE 2 dimensional LOOP! Now it gets INTERESTINGer // $mtable[$i][$j] for ($i=1; $i<=6; $i++) { for ($j=1; $j<=6; $j++) { $mtable[$i][$j]=34; } History of $i and $j wordpress.com $i$j etc

14 Homework #2: Modify the code so that it makes a MULTIPLICATION TABLE Like this one! // $mtable[$i][$j] for ($i=1; $i<=6; $i++) { for ($j=1; $j<=6; $j++) { $mtable[$i][$j]=?? } wordpress.com

15 Now let's see shipaint.php Well, it's really just a crude PAINT PROGRAM, but it will get us started. Look at ship01.php

16 The Conceptual Pathway PART ONE create a dimensional array ‘render it’ as an HTML table use to set color and size of squares HOMEWORK #3: Carefully analyze shipaint.php and be ready to EXPLAIN and HAND SIMULATE any line of code in this program.

17 Goal: Build a simple Battleship Game Players take turns enter x, y, (b or g) Play the test game (shipstarter.php) Read the Requirements X  Y

18 Project 3 Specification Go read the specification for Project 3 Discuss the stages from 80% to 90% Discuss the options above 90% Then we move forward to review the example code shipstarter.php is your starter kit for Project3. You may use this code as part of your submission (but you don't have to.)

19 A note about $_SESSION I’m seeing lots of CONFUSED Code like $_SESSION['linenumber']=$_SESSION['linenumber']+1; in the middle of your code. I recommend: Bring in all SESSION stuff at top of main, into scalar variables like this: $linenumber=$_SESSION['linenumber']; Then in the program, as needed: $linenumber++; Put away all SESSION data at the bottom $_SESSION['linenumber’]=$linenumber;

20 Upward Toward 90% Providing an Alphabetic Top Margin HINT 1: We need functions to convert 1 to A, 2 to B etc. and (to process inputs) also, A to 1, and B to 2 etc. Key Fact: There are two built-in functions in PHP to help us. $n=ord('A'); print "ASCII for 'A' is $n"; this will print ASCII for 'A' is 65

21 Upward Toward 90% Two key functions: ord and chr $n=ord('A'); A  65 and $c=chr(65); 65  A

22 Upward Toward 90% Providing an Alphabetic Top Margin #numtochar: maps 1 to A, 2 to B, etc. function numtochar($numin) { $numa=ord('A'); //we want numin=1 to produce chr('A'), so $numout=$numa+$numin-1; // now if numin=1, numout = chr('A') $charout=chr($numout); // and if numin=2, numout = chr('B') etc. return $charout; } #numtochar

23 Upward Toward 90% Hints 2 and 3 * Go read the document "project3.hints.doc"

24 The Conceptual Pathway HINT FOUR Dynamic generation of radio buttons You've seen this trick before, in the pundex program. But now, we need to do it in two dimensions. I want a bunch of radio buttons like this: … etc…. until A total of 100 radio buttons, one fieldname.

25 Dynamic radio buttons QUESTION: How can I get two pieces of information (x and y) From one radio button? ANSWER: Put the info into a string, and unpack it later. To produce this stuff: … Here's the trick - put this in your drawgrid 2d loop - print " ";

26 Unpacking the info QUESTION: How can I get two pieces of information (x and y) From one string like 1.2? ANSWER: Bang! - - explode it. $f=$_POST['fillhere']; // (why $f? why the $f not!!?) // (I just like f for 'fillhere') If ($f) { $fparts=explode('.',$f); $x=$fparts[0]; $y=$fparts[1]; } // now you can do $Grid[$x][$y]=whatever color

27 And Finally... QUESTION: What's WHITE? BLUE? LIGHTBLUE? These are Defined Colors in HTML (147 of ‘em!) But... how can they be passing through to the browser WITH NO QUOTES AROUND ‘EM? $Ships[$x][$y]=GOLD; It’s an Ancient Flaw in PHP. ‘twould be better as: $Ships[$x][$y]=‘GOLD’; // straight quotes of course

28 And Then.... QUESTION: What do we do next? 1)The practice (homework) problems, for next week 2)Start building Project 3. It’s due on 8 November (for show-and-tell); 10 November for grading. AND if you have less than 150 on the MIDTERM, You need to undergo the Remedial Process to salvage your grade. See Prof for Details. Limited Time Offer.