Download presentation
Presentation is loading. Please wait.
Published byBrenda Tyler Modified over 8 years ago
1
SE1011 Week 9, Class 3 Today Arrays with Loops! Homework SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 1
2
Muddiest Points Do static variables keep their values even when a different instance of the class is called?static crashes causes by order of checks with nulls involved short-circuit operators how to you create an array?arrays Can only a static method access a static variable?static Do we have to take the exam if we are happy with our half exam scores?exam Does anyone ever strictly use top-down or bottom-up design? Or does everyone always use a combination of the twodesign Is there a way to do what a static class variable does, without actually using the static class variable?static is it possible to design using only top-down or bottom-up?design What is an array and how do you use it?arrays everything was clear to me SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 2
3
More on arrays // Initialize an array int[] squares = {0, 1, 4, 9, 16, 25}; // Get the length of an array int howManySquares = squares.length; SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 3
4
Write what this code prints int[] cards = {1,2,3,4}; int i = 0; System.out.println("All the cards:"); while(i < cards.length) { System.out.println(i+": "+cards[i]); i++; } SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 4
5
Write what this code prints System.out.println("Again:"); i = 0; while(i < cards.length) System.out.println(i+": "+cards[i]); i++; System.out.println("Thanks for visiting!"); SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 5
6
Write what this code prints System.out.println("Again:"); i = 0; while(i < cards.length) i++; System.out.println(i+": "+cards[i]); System.out.println("Thanks for visiting!"); SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 6
7
Example Codingbat Problem zeroMax(…) zeroMax SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 7
8
Array Homework Array-1: Basic arrays. No Loops Array-1 makeEnds(…) makeEnds Array-2: One Loop Array-2 isEverywhere(…) isEverywhere withoutTen(…) withoutTen Array-3: Two or more loops, more complex logic Array-3 maxMirror (…) maxMirror Hint: To debug, return a number. 8
9
A codingbat Progress Graph maxSpan(…) maxSpan SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 9
10
An epic progress graph SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 10 http://codingbat.com/done/epic
11
SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 11
12
Acknowledgement This course is based on the text Introduction to Programming with Java by Dean & Dean, 2 nd Edition SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 12
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.