Download presentation
Presentation is loading. Please wait.
Published byGwendoline Pierce Modified over 9 years ago
1
1 University of Utah – School of Computing Computer Science Writing Tic Tac Toe H. James de St. Germain University of Utah
2
University of Utah – School of Computing University of Utah 2 GUI vs. Game Repeat after me: -The GUI is not the Game The STATE of the game is enough information to rebuild the game knowing nothing else. It is “easy” to go from STATE GUI. It is very hard to go from GUI STATE
3
University of Utah – School of Computing University of Utah 3 State GUI State: Dog -Height: 2 ft -Weight: 20 pds -Color: aqua -Type: Chow
4
University of Utah – School of Computing University of Utah 4 GUI State State???? What is it? How big? Color? Type?
5
University of Utah – School of Computing University of Utah 5 Tic Tac Toe Lets conceive of all the information and rules to tell someone else how to play: -Tic Tac Toe
6
University of Utah – School of Computing University of Utah 6 Assumptions We have a “function” which will draw the game on the computer screen.
7
University of Utah – School of Computing University of Utah 7 OBJECT An object in Programming is a container of information. class TicTacToe // is how it begins What information is necessary to tell someone else the STATE of a game?
8
University of Utah – School of Computing University of Utah 8 Example: Pseudo Object class Student { -Name -Age -Uid -GPA -etc }
9
University of Utah – School of Computing University of Utah 9 Class TicTacToe Fill in the class “member variables” here: But WAIT! -Member variables can only contain a few “types” of information
10
University of Utah – School of Computing University of Utah 10 10 Data Types Numbers Characters Booleans Arrays (or Lists of information) Objects (combinations of the above)
11
University of Utah – School of Computing University of Utah 11 11 Class TicTacToe Fill in the class “member variables” here: class TicTacToe { }
12
University of Utah – School of Computing University of Utah 12 12 Computer as Scratch Paper whos_turn
13
University of Utah – School of Computing University of Utah 13 13 Actions (Algorithm) We will now work on a recipe that someone could follow to play TicTacToe. Remember, all references to the STATE of the game must refer to our “member variables” on the previous slide.
14
University of Utah – School of Computing University of Utah 14 14 TicTacToe Algorithm
15
University of Utah – School of Computing University of Utah 15 15 Recap All instructions in an algorithm must refer to the DATA stored in variables All variables have a specific DATA TYPE limiting what they can store A computer’s memory is like a piece of paper with little boxes on it.
16
University of Utah – School of Computing University of Utah 16 16 Final Thought When writing a computer program, you should be able to write down a list of instructions that your friend can follow without you to explain anything
17
University of Utah – School of Computing University of Utah 17 17 Questions Discussion!
18
University of Utah – School of Computing University of Utah 18 18 Fin
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.