2-dimensional Arrays A 2-dimensional array has rows and columns It is actually an “array of arrays” A Tic-Tac-Toe board is an example of a 3 by 3 2-d array.

Slides:



Advertisements
Similar presentations
Creating Tables The basics, nothing pretty, but it works.
Advertisements

Two-Dimensional Arrays Chapter What is a two-dimensional array? A two-dimensional array has “rows” and “columns,” and can be thought of as a series.
A Case Study  Some Advice on How to Go about Solving Problems in Prolog  A Program to Play Connect-4 Game.
Arrays Around Us. Ask yourself… Why is it important to use arrays to help me multiply? Where in real life can I apply this new concept?
Tic Tac Toe Game Design Using OOP
Wireless Phone Tic-Tac-Toe Josh Morelli. Project Description The purpose is to illustrate the interfacing of hardware and wireless phones using standard.
Introduction to Programming Using simple games to convey introductory concepts MERLOT International Conference 2004 Tracey Jensen Assistant Professor,
CHAPTER 10 FUN AND GAMES Group 1: Xiangling Liu.
DATA STRUCTURES AND ALGORITHMS.  The project that we worked on is a well known game called “Tic Tac Toe”.  We implemented this game using a binary tree.
Microsoft® Small Basic Advanced Games Estimated time to complete this lesson: 1 hour.
Conditionals Lab Dan Maselko. Overview  Gain familiarity with working with conditionals  Become familiar with using the modulus operator  Understand.
Arrays. INTRODUCTION TO ARRAYS Just as with loops and conditions, arrays are a common programming construct and an important concept Arrays can be found.
Presented by : Ashin Ara Bithi Roll : 09 Iffat Ara Roll : 22 12th Batch Department of Computer Science & Engineering University of Dhaka.
Welcome to the basics of chess. This is a graphically designed program that will help you learn how to play chess. By Amir and Mike, 9B.
Chapter 7 Multidimensional Arrays. Defining a two dimensional array elementType[][] arrayName; // Java pro elementType arrayName[][]; // C++ alternate.
Intro to Microsoft Excel The Microsoft Excel window will open up ready for you to create a new spreadsheet 1 The ribbon, which sits above the spreadsheet,
1 CSE1301 Computer Programming: Lecture 23 Algorithm Design (Part 1)
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 14 – Student Grades Application: Introducing.
Computer Science 1620 Multi-Dimensional Arrays. we used arrays to store a set of data of the same type e.g. store the assignment grades for a particular.
Chapter 9 Introduction to Arrays
© The McGraw-Hill Companies, 2006 Chapter 16 Two-dimensional arrays.
Seek The Multiplication Treasure Copy this problem. Multiply the factors in the top row by the digit in the ones place in the second factor.
It is as easy as playing tic-tac-toe!. Make the vertical and horizontal lines of a tic- tac-toe game.
Groups of the Periodic Table
CPS120: Introduction to Computer Science Arrays. Arrays: A Definition A list of variables accessed using a single identifier May be of any data type Can.
Indian Institute of Technology Hyderabad SOS - The Game A Project by Paritosh J Chandran Prakhar Bharadwaj Ganesh Mahidhar Nagarjun Srinivasan.
11 Finding Winners Using Arrays Session 8.2. Session Overview  Find out how the C# language makes it easy to create an array that contains multiple values.
Multiplication Mania Let’s practice your multiplication facts.
Boggle Game: Backtracking Algorithm Implementation
Click your mouse for next slide Dreamweaver – Setting up your Page The first way to ensure that you have a consistent design is to use table to set up.
Connect Four AI Robert Burns and Brett Crawford. Connect Four  A board with at least six rows and seven columns  Two players: one with red discs and.
1 Chapter 2 - Algorithms and Design print Statement input Statement and Variables Assignment Statement if Statement Flowcharts Flow of Control Looping.
For loops in programming Assumes you have seen assignment statements and print statements.
A Classic Game of Strategy for the 21 st Century.
Making Python Pretty!. How to Use This Presentation… Download a copy of this presentation to your ‘Computing’ folder. Follow the code examples, and put.
Two-Dimensional Arrays That’s 2-D Arrays Girls & Boys! One-Dimensional Arrays on Steroids!
Lesson 10 - Mail Merge and Reviewing Documents Advanced Microsoft Word.
CPS120: Introduction to Computer Science Lecture 15 Arrays.
Lesson 1 History of Chess Why We Teach Chess Goal of Chess.
Lookup Function (Think of a Book Index).  Need to fill based on what is in the these fields Array table.
18/12/ Arrays 2D Arrays Defining, Declaring & Processing.
A Levoy PowerPoint Presentation
Warship C++: An entity of Battleship
Problem Decomposition and Abstraction. Problem Solving Which one is easier:  Solving one big problem, or  Solving a number of small problems?
All About Spread sheets By Negin Oghabi Bakhshayeshi.
Groups of the Periodic Table. CONCLUSION…front of 13 1.Why is “shape” not a good test for determining if an element is a metal or a nonmetal? 2.You have.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Student Grades Application Introducing Two-Dimensional Arrays and RadioButton.
CompSci Backtracking, Search, Heuristics l Many problems require an approach similar to solving a maze ä Certain mazes can be solved using the.
Multiplying with 9 MAFS.3.OA.3.7 MAFS.3.OA.4.9.
Checkers A Matlab Project by Spenser Davison, Edward Dyakiw, Justin Pezzi, and Scott Wu.
COMP 110: Spring Announcements Lab 7 was due today Binary Expression Assignment due Friday.
CS 115 Lecture 17 2-D Lists Taken from notes by Dr. Neil Moore.
© 207 M. Tallman. © 2007 M. Tallman Array- objects or symbols displayed in rows and columns. 3 Rows 4 Columns of 4 of 3.
A 2-D Array is a structure that storage space both vertically and horizontally. Thus, the array has both rows and columns. 2-D Arrays are used to create.
2-D Lists Taken from notes by Dr. Neil Moore
Connect K Richard Fang rfangAI.
Pasa números Divide students in to teams and have each team sit in a row. Give each student a dry erase marker and something to erase with. Each team gets.
Witzzle Pro The Rules of the Game.
5 × 7 = × 7 = 70 9 × 7 = CONNECTIONS IN 7 × TABLE
5 × 8 = 40 4 × 8 = 32 9 × 8 = CONNECTIONS IN 8 × TABLE
4 × 6 = 24 8 × 6 = 48 7 × 6 = CONNECTIONS IN 6 × TABLE
5 × 6 = 30 2 × 6 = 12 7 × 6 = CONNECTIONS IN 6 × TABLE
10 × 8 = 80 5 × 8 = 40 6 × 8 = CONNECTIONS IN 8 × TABLE MULTIPLICATION.
Align The Stars Continue.
3 × 12 = 36 6 × 12 = 72 7 × 12 = CONNECTIONS IN 12 × TABLE
5 × 12 = × 12 = × 12 = CONNECTIONS IN 12 × TABLE MULTIPLICATION.
2-D Lists Taken from notes by Dr. Neil Moore
5 × 9 = 45 6 × 9 = 54 7 × 9 = CONNECTIONS IN 9 × TABLE
3 × 7 = 21 6 × 7 = 42 7 × 7 = CONNECTIONS IN 7 × TABLE
Presentation transcript:

2-dimensional Arrays A 2-dimensional array has rows and columns It is actually an “array of arrays” A Tic-Tac-Toe board is an example of a 3 by 3 2-d array Syntax: type[][] name = new type[rows][columns]

A loop inside a loop is called a nested loop Almost always, we use nested for-loops to process through a 2-d array Demo2dArray

Assignment #1 (Alpha) Create and display a 9-by-16 table. Place the letter k in each “cell.” Display the table. Now, place a randomly-generated lowercase letter in each cell. Display the table again. Hints… –RandomNumberDemo –Ascii

Assignment #2 (Classroom) Create a classroom diagram: 5 rows, 6 columns. Place a dash in each cell. There are 12 students in the class. Ask the user where each student wants to sit, and then place an ‘s’ in that spot. After each student is placed, display the classroom. Error checking: –Don’t allow the user to choose a spot that’s already taken. –Prevent OutOfBounds exceptions. AT ALL COSTS.

Assignment #3 (Connect3) You know the game Connect 4. Create a version of this game called Connect 3: it uses a 3 by 4 table, and the first player to connect 3 in a row (horizontal, vertical, or diagonal) wins. Remember, it is a 2-player game, and each player chooses a column to drop a piece into. “Gravity” pulls each piece to the lowest spot available. Allow the user to play multiple times if they want to.