SlideShare a Scribd company logo
Class 10 – Arrays
Agenda
 Lateral Thinking Warm-up
 Project 1 Results, Issues
 Discussion: SAAD - Problem Solving with Code
 Discussion/Demo: Intro to Arrays
 Intro to Assignment 7: Daily Agenda
 Intro to Project 2: Battleship
 Task assignment
 Rubric
 Project Work and Wrap-up
System Analysis & Design
 Problem Solving with Code
 Tools
 IPO (outside in)
 Pseudocode (linear, integrative)
 Flowchart (linear, integrative)
 Models & Approaches
 SDLC
 3-tier (n-tier)
 MVC (OOP)
SAAD – 3-tier (n-tier)
 Presentation
 Logic
 Data
SAAD - MVC
 Model
 View
 Controller
MVVM – the NeXt Generation
 Model
 View
 View-Model
 Data Binding
 Service Structure
MVC, N-Tier, MVVM – who
cares?
 Moving towards OOP
 Clean division of work between functional
units
 Example: Calculator Converter: Model? View?
Controller?
 Project 2 – later tonight…
Intro to Arrays
 What is an array?
 A collection of related data
 Similar to a set of mailboxes at a site
 The site is the array, each mailbox represents an
element
 The mailbox may contain a specific value or object
 The contents can be strings, integers, or even
another array
 Addressed using brackets or parentheses (zero-
based)
 Can be examined iteratively or uniquely
Arrays Illustrated
 Single Dimension
 Array=days_of_week(7)
 2-Dimensional (table)
 Array=address_book(4,7)
Mon Tues Wed Thurs Fri Sat Sun
fname lname addr city prov post Email
joe smith 123 My Street Halifax NS B1B 1B1 joe@test.com
jane jones 1 Main Dr Dartmouth NS B7B 7B7 jane@mymail.com
pat white 21 Goode Dr. Halifax NS B1A 2C3 pat@hotmail.com
sam davis 19 Smith Dr. Timberlea NS B9G 2K8 sam@mailstop.com
Creating and Accessing Arrays
 Single Dimension
a = Array.new # an empty array
a = [] # same as above
puts a => nil (no output)
a[0]=“hello” # assigns the value
a[1]=“ world”
puts a[0] + a[1]
puts a
x = [1,”green”,”martian”]
Array Properties and Methods
 Properties
a=[“hello”, 1, “world”,2,”!”]
 a.last => “!”
 a.first => “hello”
 a[0].class => String
 a[1].class => Fixnum
 a.at(1) => 1
 a.length => 5
Array Properties and Methods
 Methods
a.push (“my friend”) => [ “hello”, 1,
“world”,2,”!”,”my friend”]
a.pop => [ “hello”, 1, “world”,2,”!”]
a.sort => [1,2, “!”,”hello”,”world”]
a.reverse = [“!”,2,”world”,1,”hello”]
a.sort! => applied to array (permanent change)
a.delete_at(2) => [ “hello”, 1, 2,”!”]
a.each do |variable|
end => iterates through the array
Creating and Accessing Arrays
 Practice
Handout: Exercise 10-1, Creating and
Accessing an Array
2-Dimensional Arrays
 Creating
 x=Array.new(4) {Array.new(7)}
 a=[[1,"green"],[2,"red"],[3,"blue"]]
 Accessing & Assigning
 myval= a[1][0] => “green”
 x[2][4]=“Halifax”
 a[1][1]=“orange”
Iterating Through Arrays
 Using each
rows=5
cols=5
countr=0
mtrx=Array.new(rows) {Array.new(cols)}
mtrx.each do |myvar|
myvar.each do |ovar|
ovar=countr
countr=countr+1
end
end
Iterating Through Arrays
 Using for
rows=5
cols=5
countr=0
for x in (0..rows-1)
for y in (0..cols-1)
mtrx[x][y]=countr
countr=countr+1
end
end
Creating and Accessing Arrays
 Practice
Handout: Exercise 10-2, Creating and
Accessing a multi-dimensional
Array
Assignment 7: Daily Agenda
 Use a 2D Array to hold details
 Prompt for time (hour only)
 Prompt for appointment
 Prompt for location
 Assign inputs to elements
 Continue to prompt until user types in a blank
in the time slot
 Sort the Agenda and then generate Daily
Agenda by iterating through the array
Project 2: Battleship
 Simple Version
 8 x 8 grid (A-H, 1-8)
 2 ships each player
 Each ship assigned to a particular grid location
 10 shots each player
 A shot to the location of a vessel sinks it
 Draw grid and results after each shot
 “~” is unknown, “!” is sunk, “0” is a miss
 If two of the ships of any player are sunk, the other player
wins, end game
 If after ten shots one player has more ships than the other,
he/she wins, otherwise it’s a tie.
Wrap-up
 Summary
 Arrays
 Analysis & Design
 Assignment
 Project
 Next Week
 Brief intro to Classes
 Business Problems with Fishbone Diagram
 Project Time*
Practice/ Set-up
 Use this time to attempt the assignment to
prepare you for the project, OR
 Begin to set up your tasks, OR
 See me about any issues with grades, etc. OR
 Do any research you need to get the
assignment or project completed.
 GREAT TIP SITE:
 http://www.techotopia.com/index.php/Understanding_

More Related Content

PPT
Class 10 Lecture Notes
PPTX
R Intro Workshop
PDF
The Ring programming language version 1.7 book - Part 78 of 196
PDF
The Ring programming language version 1.6 book - Part 76 of 189
PDF
Introduction [1] - Software Testing Techniques (CIS640)
PPT
Common errors
PDF
The Ring programming language version 1.3 book - Part 56 of 88
PDF
The Ring programming language version 1.2 book - Part 53 of 84
Class 10 Lecture Notes
R Intro Workshop
The Ring programming language version 1.7 book - Part 78 of 196
The Ring programming language version 1.6 book - Part 76 of 189
Introduction [1] - Software Testing Techniques (CIS640)
Common errors
The Ring programming language version 1.3 book - Part 56 of 88
The Ring programming language version 1.2 book - Part 53 of 84

What's hot (13)

PDF
Object-Oriented Programming (OOP)
PDF
The Ring programming language version 1.4 book - Part 20 of 30
KEY
Building a Mongo DSL in Scala at Hot Potato
PDF
Java OOP Programming language (Part 5) - Inheritance
PPTX
Dev Concepts: Object-Oriented Programming
PDF
The Ring programming language version 1.8 book - Part 7 of 202
PPTX
Session 4#
PPTX
[OOP - Lec 09,10,11] Class Members & their Accessing
PPTX
Introduction to machine_learning
PDF
The Ring programming language version 1.10 book - Part 86 of 212
PDF
Redis Day TLV 2018 - Graph Distribution
PPTX
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
Object-Oriented Programming (OOP)
The Ring programming language version 1.4 book - Part 20 of 30
Building a Mongo DSL in Scala at Hot Potato
Java OOP Programming language (Part 5) - Inheritance
Dev Concepts: Object-Oriented Programming
The Ring programming language version 1.8 book - Part 7 of 202
Session 4#
[OOP - Lec 09,10,11] Class Members & their Accessing
Introduction to machine_learning
The Ring programming language version 1.10 book - Part 86 of 212
Redis Day TLV 2018 - Graph Distribution
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
Ad

Viewers also liked (6)

PDF
Manual for Troubleshooting Formulas & Functions in Excel
PPT
Deck Project Phase II
PPTX
Atlantic Woodworkers Website Strategy
PPT
Class 11 lecture notes
PDF
How to analyze and tune sql queries for better performance percona15
PPT
Program Renewal for NSCC Schools 2010-11
Manual for Troubleshooting Formulas & Functions in Excel
Deck Project Phase II
Atlantic Woodworkers Website Strategy
Class 11 lecture notes
How to analyze and tune sql queries for better performance percona15
Program Renewal for NSCC Schools 2010-11
Ad

Similar to Class 10 Arrays (20)

PPTX
Data Structures - Array presentation .pptx
PPTX
Different type of Arrays and multidimensional arrays
PPT
Lecture 2a arrays
PPT
PDF
Homework Assignment – Array Technical DocumentWrite a technical .pdf
PPTX
ADVANCED DATA STRUCTURES AND ALGORITHMS.pptx
PPTX
Understanding of Arrays and its types along with implementation
PPTX
Data Structures - Lecture 1 - Unit 1.pptx
PPTX
Plc (1)
PDF
Plc (1)
PPTX
introduction of Data strutter and algirithm.pptx
PDF
Data-Structure-using-C-Rajesh-Pandey.pdf
PPT
Chapter 2.2 data structures
PPTX
Module_3_Arrays - Updated.pptx............
PPTX
2301107005 - ADNAN PP.pptx array of objects
PDF
(2) collections algorithms
PDF
12000121037.pdf
PPTX
PDF
M v bramhananda reddy dsa complete notes
Data Structures - Array presentation .pptx
Different type of Arrays and multidimensional arrays
Lecture 2a arrays
Homework Assignment – Array Technical DocumentWrite a technical .pdf
ADVANCED DATA STRUCTURES AND ALGORITHMS.pptx
Understanding of Arrays and its types along with implementation
Data Structures - Lecture 1 - Unit 1.pptx
Plc (1)
Plc (1)
introduction of Data strutter and algirithm.pptx
Data-Structure-using-C-Rajesh-Pandey.pdf
Chapter 2.2 data structures
Module_3_Arrays - Updated.pptx............
2301107005 - ADNAN PP.pptx array of objects
(2) collections algorithms
12000121037.pdf
M v bramhananda reddy dsa complete notes

More from Stephen Parsons (14)

PPTX
Chairs Report to LSCRS 2012 AGM
PPT
Class 7 lecture notes
PPTX
Class 6a ruby math
PPTX
Class 6 truth tables and boolean math
PPTX
Class 5 - Set Theory and Venn Diagrams
PPTX
Class 4 IPO and Intro to Ruby
PPTX
Class 3 Binary & Hexadecimal
PPTX
Class 2 Math I
PPT
Class 1 introduction to logic & problem solving
PPTX
Portfolio Of A Community
PPT
Cause & effect analysis part 2
PPT
Cause & effect analysis part 1
PPT
Class 9 Lecture Notes
PPT
Class 8 Lecture Notes
Chairs Report to LSCRS 2012 AGM
Class 7 lecture notes
Class 6a ruby math
Class 6 truth tables and boolean math
Class 5 - Set Theory and Venn Diagrams
Class 4 IPO and Intro to Ruby
Class 3 Binary & Hexadecimal
Class 2 Math I
Class 1 introduction to logic & problem solving
Portfolio Of A Community
Cause & effect analysis part 2
Cause & effect analysis part 1
Class 9 Lecture Notes
Class 8 Lecture Notes

Recently uploaded (20)

PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Pre independence Education in Inndia.pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
GDM (1) (1).pptx small presentation for students
PDF
01-Introduction-to-Information-Management.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Computing-Curriculum for Schools in Ghana
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Classroom Observation Tools for Teachers
PPTX
Cell Types and Its function , kingdom of life
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Microbial disease of the cardiovascular and lymphatic systems
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Pre independence Education in Inndia.pdf
Complications of Minimal Access Surgery at WLH
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Microbial diseases, their pathogenesis and prophylaxis
GDM (1) (1).pptx small presentation for students
01-Introduction-to-Information-Management.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
Renaissance Architecture: A Journey from Faith to Humanism
Computing-Curriculum for Schools in Ghana
STATICS OF THE RIGID BODIES Hibbelers.pdf
Classroom Observation Tools for Teachers
Cell Types and Its function , kingdom of life
Anesthesia in Laparoscopic Surgery in India
Final Presentation General Medicine 03-08-2024.pptx
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Pharmacology of Heart Failure /Pharmacotherapy of CHF
school management -TNTEU- B.Ed., Semester II Unit 1.pptx

Class 10 Arrays

  • 1. Class 10 – Arrays
  • 2. Agenda  Lateral Thinking Warm-up  Project 1 Results, Issues  Discussion: SAAD - Problem Solving with Code  Discussion/Demo: Intro to Arrays  Intro to Assignment 7: Daily Agenda  Intro to Project 2: Battleship  Task assignment  Rubric  Project Work and Wrap-up
  • 3. System Analysis & Design  Problem Solving with Code  Tools  IPO (outside in)  Pseudocode (linear, integrative)  Flowchart (linear, integrative)  Models & Approaches  SDLC  3-tier (n-tier)  MVC (OOP)
  • 4. SAAD – 3-tier (n-tier)  Presentation  Logic  Data
  • 5. SAAD - MVC  Model  View  Controller
  • 6. MVVM – the NeXt Generation  Model  View  View-Model  Data Binding  Service Structure
  • 7. MVC, N-Tier, MVVM – who cares?  Moving towards OOP  Clean division of work between functional units  Example: Calculator Converter: Model? View? Controller?  Project 2 – later tonight…
  • 8. Intro to Arrays  What is an array?  A collection of related data  Similar to a set of mailboxes at a site  The site is the array, each mailbox represents an element  The mailbox may contain a specific value or object  The contents can be strings, integers, or even another array  Addressed using brackets or parentheses (zero- based)  Can be examined iteratively or uniquely
  • 9. Arrays Illustrated  Single Dimension  Array=days_of_week(7)  2-Dimensional (table)  Array=address_book(4,7) Mon Tues Wed Thurs Fri Sat Sun fname lname addr city prov post Email joe smith 123 My Street Halifax NS B1B 1B1 joe@test.com jane jones 1 Main Dr Dartmouth NS B7B 7B7 jane@mymail.com pat white 21 Goode Dr. Halifax NS B1A 2C3 pat@hotmail.com sam davis 19 Smith Dr. Timberlea NS B9G 2K8 sam@mailstop.com
  • 10. Creating and Accessing Arrays  Single Dimension a = Array.new # an empty array a = [] # same as above puts a => nil (no output) a[0]=“hello” # assigns the value a[1]=“ world” puts a[0] + a[1] puts a x = [1,”green”,”martian”]
  • 11. Array Properties and Methods  Properties a=[“hello”, 1, “world”,2,”!”]  a.last => “!”  a.first => “hello”  a[0].class => String  a[1].class => Fixnum  a.at(1) => 1  a.length => 5
  • 12. Array Properties and Methods  Methods a.push (“my friend”) => [ “hello”, 1, “world”,2,”!”,”my friend”] a.pop => [ “hello”, 1, “world”,2,”!”] a.sort => [1,2, “!”,”hello”,”world”] a.reverse = [“!”,2,”world”,1,”hello”] a.sort! => applied to array (permanent change) a.delete_at(2) => [ “hello”, 1, 2,”!”] a.each do |variable| end => iterates through the array
  • 13. Creating and Accessing Arrays  Practice Handout: Exercise 10-1, Creating and Accessing an Array
  • 14. 2-Dimensional Arrays  Creating  x=Array.new(4) {Array.new(7)}  a=[[1,"green"],[2,"red"],[3,"blue"]]  Accessing & Assigning  myval= a[1][0] => “green”  x[2][4]=“Halifax”  a[1][1]=“orange”
  • 15. Iterating Through Arrays  Using each rows=5 cols=5 countr=0 mtrx=Array.new(rows) {Array.new(cols)} mtrx.each do |myvar| myvar.each do |ovar| ovar=countr countr=countr+1 end end
  • 16. Iterating Through Arrays  Using for rows=5 cols=5 countr=0 for x in (0..rows-1) for y in (0..cols-1) mtrx[x][y]=countr countr=countr+1 end end
  • 17. Creating and Accessing Arrays  Practice Handout: Exercise 10-2, Creating and Accessing a multi-dimensional Array
  • 18. Assignment 7: Daily Agenda  Use a 2D Array to hold details  Prompt for time (hour only)  Prompt for appointment  Prompt for location  Assign inputs to elements  Continue to prompt until user types in a blank in the time slot  Sort the Agenda and then generate Daily Agenda by iterating through the array
  • 19. Project 2: Battleship  Simple Version  8 x 8 grid (A-H, 1-8)  2 ships each player  Each ship assigned to a particular grid location  10 shots each player  A shot to the location of a vessel sinks it  Draw grid and results after each shot  “~” is unknown, “!” is sunk, “0” is a miss  If two of the ships of any player are sunk, the other player wins, end game  If after ten shots one player has more ships than the other, he/she wins, otherwise it’s a tie.
  • 20. Wrap-up  Summary  Arrays  Analysis & Design  Assignment  Project  Next Week  Brief intro to Classes  Business Problems with Fishbone Diagram  Project Time*
  • 21. Practice/ Set-up  Use this time to attempt the assignment to prepare you for the project, OR  Begin to set up your tasks, OR  See me about any issues with grades, etc. OR  Do any research you need to get the assignment or project completed.  GREAT TIP SITE:  http://www.techotopia.com/index.php/Understanding_

Editor's Notes

  • #6: Model: The model contains the core information for an application. This includes the data and validation rules as well as data access and aggregation logic. View: The view encapsulates the presentation of the application, and in ASP.NET this is typically the HTML markup. Controller: The controller contains the control-flow logic. It interacts with the Model and Views to control the flow of information and execution of the application.