Compare and contrast how primitives and arrays are treated when passed as parameters.
Complete graphic organizers and a worksheet
Extra credit: complete a Pokémon Challenge
Read BJP 7.3 and 7.4 up to “Command-Line Arguments”
Complete exercises #9, 10
Projector and computer with this page: http://www.legendarypokemon.net/javacalc.html
Whiteboard and markers
Classroom copies of WS 4.4
Instructor copy of WS 4.4 Answer
The “worksheet” for today is a 5-page work packet, so if your school has long lines/production time for the copy machine, plan ahead!
Section | Total Time |
Bell-work and attendance | 5min |
Student activity | 25–30min |
Student trade & check | 5min |
Whole group review & paper submission | 15min |
Hook your class today with the concept of a “backwards” class structure. Using only the information gleaned from last night’s reading (and perhaps some help from a friend), students should work through as much of the worksheet as they can in the time allotted (~30 minutes). Finish the class with whole-class note taking on the topics that were challenging in the sheet.
Have students start working on WS 4.4 in pairs or alone. Use a timer to help students pace themselves.
After 25–30 minutes give students a few minutes to check each others’ work.
As a whole group, ask students for questions they had on the worksheet. Use the answer key included on this to guide instruction.
Collect worksheets at the end of class.
If you have been using Parson Problems throughout the year, your students will be familiar with the format of Question 8 on the worksheet. For other classes, this may be the first time they’ve been asked to rearrange provided code. Read through the problem out loud with the class, then read through the lines of code in the bottom half of the question. Each line of code (even the lone bracket) can be shuffled and re-arranged to provide the correct code sequence.
Student success in this lesson relies heavily on students’ having been able to read and comprehend the prior nights’ reading. In ELL classrooms, encourage students to open their books and work with the text in front of them, and pair students of differing language abilities.
If you know your students’ reading abilities will not allow for a lesson like this, conduct the lesson as a whole-group, teaching a segment of the chapter and pausing to let students work on a question before moving forward.
The worksheet matches up sequentially with section 7.3, so you can have students read along with your in the book as you work through the sheet, and/or you can allow advanced students to work on their own as you help the rest of class.
There will probably be a lot of variation in how long it takes students to complete today’s assignment.
Ask students who finish early to design a hands-on demonstration that uses the array whiteboards (and any other materials around the room) to explain the proper answers to the questions on the worksheet. If they come up with any cool demos, use them during student review at the end of the class.
Be ready with a Pokemon Challenge for the students that speed through the assignment:
This java based calculator (http://www.legendarypokemon.net/javacalc.html) uses median IVs (initial values) and input EVs (effort values) to calculate a Pokemon’s stats on a given level.
Write a method called medianIV that accepts an array of integer IVs as its parameter and returns the median of the numbers in the array.
The median number is the number that appears in the middle of the list if you arrange the elements in order. You can assume that the array is of odd size (so that one element is found in the middle), and that the numbers in the array are between 0 and 99, inclusive. For example, the median of [5, 9, 4, 10, 11]
is 9, and the median of [0, 8, 1, 89, 48, 27, 30]
is 27.
Hint: Check out the Tally program in chapter 7 for some ideas on what code to use.
The Java based calculator that uses median IVs and input EVs to calculate a Pokemon's stats on a given level provides you with an in depth look of how complex some calculations can get in these types of games. As you continue to think about your final project in the course, consider how you will use calculations to determine a characters health or attack values.
CSE 142, Array Initializer (3:26–5:43) https://www.youtube.com/watch?v=DieHL2VO83k&start=206
CSE 142, Passing array as parameter (5:44–9:05) https://www.youtube.com/watch?v=DieHL2VO83k&start=344
CSE 142, Arrays.toString() (21:19–25:27) https://www.youtube.com/watch?v=DieHL2VO83k&start=1278
CSE 142, Values vs reference (25:28–39:18) https://www.youtube.com/watch?v=DieHL2VO83k&start=1528
CSE 142, modifying array when passed as parameter (39:19–43:41) https://www.youtube.com/watch?v=DieHL2VO83k&start=2359
Lesson 4.04 Reference Semantics (TEALS Discourse account required)