table of contents - teals · unit 5: object-oriented programming (4 weeks) lesson 5.00: test review...

484
1.1 1.2 1.3 1.4 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 2.10 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 Table of Contents Introduction Video Tutorials Curriculum Map Curriculum Assets Unit 1: Programming & Java (2 weeks) Lesson 1.01: Using Eclipse & Practice It Lesson 1.02: Algorithms & Computational Thinking Lesson 1.03: String & Console Output Lesson 1.04: Common Errors & Comments Lesson 1.05: Static Methods & Method Calls (1/2) Lesson 1.06: Static Methods & Method Calls (2/2) Lesson 1.07: Programming Project Lesson 1.08: Finding & Fixing Errors Lesson 1.09: Review Lesson 1.99: (Unit 1 Test) Unit 2: Working with Data & Basic Control Flow (3 weeks) Lesson 2.00: Test Review & Reteach Lesson 2.01: Basic Data Concepts Lesson 2.02: Declaring & Assigning Variables Lesson 2.03: String Concatenation & Increment Decrement Operators Lesson 2.04: Mixing Types & Casting Lesson 2.05: for Loops Lesson 2.06: nested for Loops Lesson 2.07: Scope & Pseudocode Lesson 2.08: Programming Project 1

Upload: others

Post on 13-Aug-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

1.1

1.2

1.3

1.4

2.1

2.2

2.3

2.4

2.5

2.6

2.7

2.8

2.9

2.10

3.1

3.2

3.3

3.4

3.5

3.6

3.7

3.8

3.9

TableofContentsIntroduction

VideoTutorials

CurriculumMap

CurriculumAssets

Unit1:Programming&Java(2weeks)Lesson1.01:UsingEclipse&PracticeIt

Lesson1.02:Algorithms&ComputationalThinking

Lesson1.03:String&ConsoleOutput

Lesson1.04:CommonErrors&Comments

Lesson1.05:StaticMethods&MethodCalls(1/2)

Lesson1.06:StaticMethods&MethodCalls(2/2)

Lesson1.07:ProgrammingProject

Lesson1.08:Finding&FixingErrors

Lesson1.09:Review

Lesson1.99:(Unit1Test)

Unit2:WorkingwithData&BasicControlFlow(3weeks)Lesson2.00:TestReview&Reteach

Lesson2.01:BasicDataConcepts

Lesson2.02:Declaring&AssigningVariables

Lesson2.03:StringConcatenation&IncrementDecrementOperators

Lesson2.04:MixingTypes&Casting

Lesson2.05:forLoops

Lesson2.06:nestedforLoops

Lesson2.07:Scope&Pseudocode

Lesson2.08:ProgrammingProject

1

Page 2: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

3.10

3.11

3.12

3.13

4.1

4.2

4.3

4.4

4.5

4.6

4.7

4.8

4.9

4.10

4.11

4.12

4.13

4.14

4.15

4.16

4.17

4.18

4.19

4.20

4.20.1

4.21

Lesson2.09:ProgrammingProject

Lesson2.10:Finding&FixingErrors

Lesson2.11:Review

Lesson2.99:(Unit2Test)

Unit3:AdvancedData&ControlFlow(4weeks)Lesson3.00:TestReview&Reteach

Lesson3.01:Parameters

Lesson3.02:LimitationsofParameters&MultipleParameters

Lesson3.03:ReturnValues

Lesson3.04:ProgrammingProject

Lesson3.05:UsingObjects&StringProcessing

Lesson3.06:InteractivePrograms&ScannerObjects

Lesson3.07:PokémonBattleProgrammingProject

Lesson3.08:Finding&FixingErrors

Lesson3.09:RelationalOperators&if/else

Lesson3.10:Nestedif/elseStatements

Lesson3.11:ReducingRedundancy

Lesson3.12:CumulativeAlgorithms

Lesson3.13:whileLoops

Lesson3.14:RandomNumbers

Lesson3.15:Fencepost&SentinelLoops

Lesson3.16:BooleanLogic(2Days)

Lesson3.17:Finding&FixingErrors

Lesson3.18:Review

Lesson3.99:(Unit3test)

Test2Guide

Lesson3.XX:FracCalc

Unit4:Arrays,Lists,&Files(4weeks)

2

Page 3: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

5.1

5.2

5.3

5.4

5.5

5.6

5.7

5.8

5.9

5.10

5.11

5.12

6.1

6.2

6.3

6.4

6.5

6.6

6.7

6.8

6.9

7.1

7.2

7.3

7.4

Lesson4.00:TestReview&Reteach

Lesson4.01:ArrayBasics

Lesson4.02:For-EachLoop&ArraysClass

Lesson4.03:Printing,Searching,&TestingforEquality(2Days)

Lesson4.04:ReferenceSemantics

Lesson4.05:ShiftingValues&ArraysofObjects

Lesson4.06:NestedLoopAlgorithms&RectangularArrays

Lesson4.07:ArrayList

Lesson4.08:Finding&FixingErrors

Lesson4.09:MagpieLab(5Days)

Lesson4.10:Review

Lesson4.99:(Unit4test)

Unit5:Object-OrientedProgramming(4weeks)Lesson5.00:TestReview&Reteach

Lesson5.01:ObjectOrientedProgramming

Lesson5.02:ObjectState&Behavior

Lesson5.03:ObjectInitialization:Constructors

Lesson5.04:Encapsulation

Lesson5.05:Finding&FixingErrors

Lesson5.06:PictureLab(9Days)

Lesson5.07:Review

Lesson5.99:(Unit5test)

Unit6:Inheritance&Polymorphism(4weeks)Lesson6.00:TestReview&Reteach

Lesson6.01:InheritanceBasics(2Days)

Lesson6.02:OverridingMethods&AccessingInheritedCode

Lesson6.03:InteractingwiththeObjectSuperclass

3

Page 4: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

7.5

7.6

7.7

7.8

7.9

7.10

7.11

7.11.1

7.12

8.1

8.2

8.3

8.4

8.5

8.6

8.6.1

9.1

9.2

9.3

9.4

9.5

9.6

9.7

9.8

9.9

Lesson6.04:Polymorphism

Lesson6.05:Has-aRelationships

Lesson6.06:Interfaces

Lesson6.07:ProgrammingProject(5Days)

Lesson6.08:Finding&FixingErrors

Lesson6.09:Review

Lesson6.99:(Unit6test)

Test5Guide

Lesson6.XX:TextExcel

Unit7:Searching&Sorting(3weeks)Lesson7.00:TestReview&Reteach

Lesson7.01:SearchingAlgorithms

Lesson7.02:SortingAlgorithms

Lesson7.03:ElevensLab(16Days)

Lesson7.04:Review

Lesson7.99:(Unit7test)

Test6Guide

Unit8:Recursion(2weeks)Lesson8.00:TestReview&Reteach

Lesson8.01:ThinkingRecursively

Lesson8.02:WritingRecursiveSolutions

Lesson8.03:MechanicsofRecursion

Lesson8.04:MergeSort

Lesson8.05:Finding&FixingErrors

Lesson8.06:Review

Lesson8.07:(Unit8quiz)

Lesson8.08:QuizReview&Reteach

Unit9:APTestReview(3weeks)

4

Page 5: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

10.1

11.1

11.2

12.1

12.2

12.3

12.4

Lesson9.00:ReviewingfortheAPExam

Unit10:Post-APExamProjects(4–5weeks)SpaceBattleArena

TEALSMinecraftModding

AppendixAboutThisCurriculum

Changelog

Contributing

Acknowledegments

5

Page 6: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

AbouttheAPComputerScienceACurriculumTheTEALSProgramhasdesignedthesecurriculummaterialsfortheuseofteachersandvolunteertechprofessionalsinhighschoolclassrooms.Anyteacherwithpriorprogrammingexperience(oraccesstoacomputerscienceprofessional)canusethiscurriculumtoteachtheAPComputerScienceAcourse.

ThiscurriculumisbasedonandalignedwithProfessorStuartReges'courseattheUniversityofWashington,CSE142.ThecourseusesthetextbookBuildingJavaPrograms:ABacktoBasicsApproach,byStuartRegesandMartyStepp.ThecourseisalignedwiththeAPComputerScienceAstandards.TEALShasreceivedAPAuditcertificationforpreviousversionsofthecourseandsyllabus.Sincethesematerialsarenewin2015–2016,TEALSwillapplytohavethenewsyllabusapproved.OncetheCollegeBoardapprovesthenewsyllabus,partnerschoolsmayusethe“claimidentical”functionoftheAPAuditwebsitetoobviatetheneedfortheirowncurriculumaudit.

Thiscurriculumusesprinciplesofuniversaldesignforlearning(UDL).Thecurriculumwaswrittenforandtestedinclassroomswithdiverselearners;studentswithindividualizededucationplans,Englishlanguagelearners,studentswhohavereceivedsub-optimalmathorlanguageinstructioninthepast,studentswhoaregifted/talented,studentswhoareotherwise“outsidetheaverage.”SeeAdditionalResourcesformoreinformationonuniversaldesignforlearning.

AccessingtheCurriculumTheAPComputerScienceACurriculumGitBookislocatedathttps://www.gitbook.com/book/tealsk12/ap-computer-science-a/details.

Forcontributionstothecurriculum,theAPComputerScienceAGitHubrepositoryislocatedathttps://github.com/TEALSK12/apcsa.

UsingthecurriculumEachclassroomhasdifferentphysical,cultural,academic,andschedulingneeds.Therefore,wehavetriedtocreateacollectionoflessonsandmaterialsthatareadaptabletomostsituations.TEALSvolunteersandclassroomteacherswillfinddifferentaspectsofthe

Introduction

6

Page 7: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

curriculumuseful;youshouldexpecttoskipovercertainnotestofocusontheinformationthatismostusefultoyou.

WehaveprovidedclassroommanagementtipsandengagementtipsforTEALSvolunteers,whoarenewtotheclassroomsetting.Experiencedteachersandvolunteerswilllikelychoosetoskipsuchdetailsandfocusonthestep-by-steplecturenotes.

YoumaybrowsetheCurriculumMapforanoverviewofthepacing,objectives,andassessments.

YearRoundPacing

Thetable-of-contents(includedwithIntroductionmaterials)containscourse-grainedtimeestimatesonthescaleofweeksanddayssoteacherscanplanaccordingly.Units6and8includeextradaysinthetime-estimatesoteacherscanre-adjusttheirunitplansiftheyhaveshiftedduetounexpectedclasscancellationsordrift.

DailyStructure

Everyclassroomisdifferent,andweexpectthatinstructorswilladaptthedailystructureoftheclasstosuittheirstudents'needs.Thatsaid,we'vedesignedmostofthelessonsusingthefollowingdailystructure:

Hook&Instruction

Eachlessonplanbeginswithoneorseveraloptionsforshort(fromsecondsto5minutes)engagingormystifyingactivitiesthatintroducestudentstothetopicstobeintroducedlaterinthelesson.

Lecturenotes,studentprompts,andquick-assessments(withanswers)areoutlinedinsubsection“Introduction.”Ifyouareteachinginaflippedclassroom,thissectioncanbepre-recordedforstudentstoviewathome.Foradditionalresourcesonflippingyourclassroom,pleasereferto“AdditionalResources”below.

StudentPractice

Studentpractice/activitiesareoutlinedwithstep-by-stepinstructionsincludingpacingsuggestionsandalternativestoppingpoints.Anyspecialmaterialsorpreparationneededforthehook,lecture,oractivityarelistedintheMaterials&Prepsection.

Warmup/DoNow/Boardwork/Ticket-to-leave

Introduction

7

Page 8: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Sinceeachclassroomprogressesatdifferentrates,wehavenotincludedwarm-upandcool-downquestions(thoughtimehasbeenscheduledinthePacingGuideforoneorbothoftheseactivities).Youshouldchooseyourquestionsbasedonthetopicsyoufeltweremostchallengingorconfusingforyourstudents.Agoodsourceforshort-answerandmultiplechoicequestionsistheBarron'sAPComputerScienceAreviewbook,whichTEALSshipstoeachAPCSAvolunteer.

Scaffolding

TheGlossaryofEducationReformdefinesscaffoldingas:

Avarietyofinstructionaltechniquesusedtomovestudentsprogressivelytowardstrongerunderstandingand,ultimately,greaterindependenceinthelearningprocess.

Instructorsprovidesuccessivelevelsoftemporarysupportthathelpstudentsreachhigherlevelsofcomprehensionthantheywouldhavebeenabletoachievewithoutassistance.Supportisgraduallyremovedasstudentsmovetowardsmastery,whichoccurswhenstudentsdemonstrateskillsandknowledgewithoutanyoutsideassistance.

TheUniversityofWashingtoncourseCSE142andassociatedtextbookdonotcontainmuchscaffolding.ThiscurriculumattemptstowrapthecontentoftheUWcoursewithscaffoldingappropriateforhighschoolclasses.Someclassesmaynotrequirescaffolding,andotherclassesmayneedevenmorescaffoldingthanthosestepssuggestedwithinthelessonplan.

Examples

Mostlecturenotesandclassroomexamplesareslightlymodifiedversionsoftheexamplesoutlinedinthetextbook.Whentheclassneedsadditionalexamples,orre-teaching,instructorscanreferdirectlytothetextbookforafreshsetofsimilarexamplesandexplanations.The"additionalresources"sectionofthisdocumentlistssomeothersourcesforexamplesandlabs.

Referencestothetextbook

SomeclassroomsareusingearliereditionsoftheBuildingJavaProgramstextbook.Toavoidconfusion,wehavewrittenallreadingandpracticeassignmentsbychapterandsectionratherthanpagenumber.Incaseswherepracticeproblemsorassignmentsdifferbetweeneditions,wehavecopiedthoseassignments(withreference)intoprintabledocuments.

HomeworkAssignments

Introduction

8

Page 9: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Aswritten,thehomeworkassignmentscontainmaterialtobeassigned,butarenotphrasedintermsoflearninggoals.Teachersshouldchoosespecificlearninggoalsfortheevening'sworkdependingonstudentprogressandtimingwithintheweekandschoolyear,thenphrasetheassignmentintermsoflearninggoals,notoutput.

Forexample,ratherthan"readsection3.1"assignthereadingbysaying"fortomorrow,bepreparedtopassdataintomethodsusingparameters.Section3.1inthetextbookwillshowyouhow."

Pokémon

Throughoutthecourse,thiscurriculumincludeslabassignmentsusingthePokémonuniverseasasubject-matterdomain(oftenreplacingtextbookassignmentsonlesssalienttopicslikecompoundinterest).ThePokémonstorylineandgamerulesarefamiliartomaleandfemalestudentsfromallsocioeconomicbackgrounds,availableacrossthedigitaldivideasbothacardgameandavideogame,andareavailablein10differentlanguages(English,Spanish,Portuguese,Dutch,French,German,Italian,Korean,Chinese,andJapanese).

Becausethegamereliesonstatistics,modulooperators,andtheunderlying32-bitintegerthatcharacterizesanygivenPokémon,wewillbeusingthisthemetointroducestudentstomuchoftheAPCSAcurriculum.StudentswillbeenteringtheAPCSAcoursewithvaryingdegreesofmathliteracy,andframingmathematicalchallengesinthisfamiliarframeworkishelpfulforavoidingstereotypethreatandmathanxiety.

TolearnmoreaboutthePokémonstoryline,gamerules,underlyingformulae,andcharacters,visithttp://bulbapedia.bulbagarden.net/.ForamoregeneralintroductiontothePokémonfranchise,visithttp://www.pokemon.com/.

APTestPreparation

ThecurriculumisdesignedwithAPTestPrepinmind.AlloftheUnittestsareintheAPexamformat.Inclasseswheremanystudentswilltaketheexam,instructorsshouldgraduallyadjustthetestingenvironmenttomimicthatoftheexam:

Alwaysprovide/allowtheAPJavaQuickReference

Movefromopen-note(see“TrickyCodeCheatSheet”)toclosed-note

TheAPexamhas40multiplechoicequestionsin75minutes(≈2minutesperquestion).Ontheearliertests,startataslowerpace(perhaps4minutesperquestion).Asthecourseprogresses,worktoapaceevenfasterthantheactualtest(90secondsperquestion).

Introduction

9

Page 10: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Vocabulary

Acomprehensivevocabularylistforeachunitisprovidedforteacherstogeneratewordwallsintheirclassroom.Someclassroomswillbeabletoomitcertainvocabularywords;asoffered,thelistsofferedincludewordsthatEnglishlanguagelearnersandstudentswithprevioussub-optimalinstructionmayfindchallenging.

Error-CheckingLessons

Oneclassperiodineachunithasbeendevotedtostudentcorrectionandresubmissionofwork.Whileitmaybetemptingto“winback”classtimebyskippingthesesessions,westronglyencourageteacherstoleavethesesessionsin.

Whenstudentshavetheopportunitytofixtheirworkandearnbackfullorpartialcredit,itgivesstudentsagencyovertheirgradeandteachesstudentstoexamineandreflectupontheirownlearning.Onapracticalnote,whenerror-checkinglessonsareincluded,teachersneedonlygradeanswersascorrect/incorrect,sincestudentswillbechallengedwithfindingandfixingtheerrorsontheirownlater.Finally,studentsthathaveansweredallormostoftheirworkcorrectlyreceiveadayofftodosilentwork/playontheirown,whichpositivelyreinforcesstudentstoputintheinitialefforttowinadayoff.

VideoTutorialsTimingandPacing—AdjustinglessonsandthecurriculummapforthespeedofyourlearnersProjectsandLabs—ChoosingnwhetheryourclasscompletestheAPlabsortheprojects(FracCalc/TextExcel)SupportingVisual-SpatialLearners—UsingthephysicalspaceinyourclassroomtoenhancelearningParson'sProblems—Assessinghigh-levelprogrammingskillsquicklywithParson'sProblemsGrudgeball—ReviewingmaterialbyplayingaclassgameofGrudgeball

DigitalToolsAssociatedwithThisCurriculum

IntegratedDesignEnvironment(IDE)—Eclipse

CodinginJavarequirestheJavaDevelopmentKitandatexteditororIDE.TherearemanyJavaIDEsavailable.CurrentlymostoftheTEALSclassroomsuseEclipse.Unit1includesdirectionsforinstallingEclipse.

Introduction

10

Page 11: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Practice-It!

ProfessorsMartySteppandJessicaMillercreatedthePractice-ItonlinetoolthatallowsstudentstocompleteJavaexercisesfromtheBJPtextbookandgetimmediatefeedbackontheirresults.DetailedinstructionsforteacherandstudentregistrationonthesiteareincludedinUnit1lessons.

Asofthe2015–2016schoolyear,TEALSclassesdonothaveaccesstothePractice-Itdashboardfortrackingstudentprogressontheexercises.Instead,instructorscanuseoneofthefollowingmethods:

1. Studentstakescreenshotsoftheirtotalcorrectproblems(atableisavailableontheirhomedashboard),andsubmitthescreenshotsbyemailorformsubmissiononyourchosenlearningmanagementsystem.

2. ImplementthePractice-ItGradeRetrievalToolcreatedbyMauricioDelCarpio(ofBishopBlanchetHighSchool).Step-by-stepinstructionsforinstallationareincludedinthePracticeItGradeRetrievaldocumentincludedwiththeotherIntroductionmaterials.

DetectingCheatingwithMOSS

Althoughthecurriculumdoesnotspecificallyoutlineanapproachformonitoringcheating,manyteachershavefounditeasier,faster,andlessstressfultouseafreeplagiarism-detectionprogramofferedbyStanfordathttp://theory.stanford.edu/~aiken/moss/.TeacherswillstillneedtomanuallyinspectcodeflaggedbyMOSS,buttheprogramdoescatchcommontacticsincludingrenamingvariablesandreorderingmethods.

Occasionally,teachershavedifficultyregisteringforanaccount.Ifthisoccurs,youareencouragedtoemailtheprogram'screatorAlexAikendirectly,[email protected].

AdditionalResources

Thefreeweb-basedgameCodeHunt(http://www.codehunt.com)offersopportunitiesforstudentstofindandfixerrorsby“discoveringthemissingcodesegments.”Assignments/Levelsareautomaticallygraded,andstudentscancompeteagainsteachothertohonetheirprogrammingskills.

SimilartoPracticeIt,CodingBat(http://www.codingbat.com)offersJavapracticeproblemswithinstantfeedbackforstudents.TheproblemsinCodingBataredistinctfromthoseintheBuildingJavaProgramstextbook.CodingBathasateacher

Introduction

11

Page 12: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

dashboard,andasystemofbadgestomotivatelearners.Instructorscanalsouploadtheirownsetsofjavaproblemsfortheirclassestocomplete.

Ifyouareinterestedinlearningmoreaboutprinciplesofuniversaldesignforlearning,pleasevisithttp://www.udlcenter.org/aboutudl/udlguidelines.

EmergingEdTechhascollectedasampleof20digitaltoolstoincreasecollaborationintheclassroom.Oneofthemmightbeperfectforyourclassroom:

See20FunFreeToolsforInteractiveClassroomCollaboration.OthertoolsforcollaborationthathavebeensuccessfullyusedinTEALSclassroomsincludeTwiddla,Vyew,Skype,andGoogleHangouts.

Ifyourclassroomdoesnotalreadyhaveadigitalgrademanagementsystem,previousTEALSteachingteamshaveusedMoodle,Canvas,Schoology,ExcelOnline,andGoogleForms.

Tocreatedigital,self-grading,andresponsivequizzes,GoogleFormsandSocrativeofferfreetoolsandtutorialstousetheirsystems.

Ifyouarestationedinahigh-performingschool,orinaschoolwheremanystudentshavealreadymasteredotherprogramminglanguages,youmaywanttoconsiderflipping(orinverting)yourclassroom.Tolearnmoreaboutthetheoryandpracticeofteachinginaflippedclassroom,VanterbiltUniverisityoffersacomprehensiveintroductionandlinkstopracticalresources/exampleshere:http://cft.vanderbilt.edu/guides-sub-pages/flipping-the-classroom.

Youshouldstillbeabletousemostoftheresourcesofferedinthiscurriculum,butyouwillhavetoshufflehowyouusethelessonplans.Somequickrecommendations:

1. Usethelecturenotesasgiven,butrecordthelectureforstudentviewing.

2. Wherelectureactivitieshavebeensuggested(e.g.think-pair-shares),considerembeddingquestionsintoyourlessonplans.

3. Saveclasscompetitionsforin-class,andleavereadingandeasyPractice-it,selfcheck,andworksheetexercisesforhomereview.

Asyoureadthroughthelessonplans,youwillfindseveralclassroomteachingactivitiesandstrategiesappearrepeatedly.BriefvideotutorialsmodelingtheseactivitiescanbefoundwithintheTEALSrepository.Keepaneyeoutforspecificadjustmentstothelessonplansforerror-checkingandtestreview.Whiletheselessonplanslookidenticalatfirstglance,smalladjustmentshavebeenmadeforcontent,timing,andAPtestprep.

Givingfeedbackonthecurriculum

Introduction

12

Page 13: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

TEALSintendsforthiscurriculumtobeastartingpoint;it'sourfirstattemptatacompleteAPCSAcurriculum.We'llcontinueevolvingandadaptingthecurriculumandassociatedmaterialsaswelearnmoreaboutteachingAPCSA.Toparticipateinthisprocess,weinviteTEALSteammembersandindependentteachersusingthiscurriculumtosubmiteditsandsuggestionsviathediscussionforumontheTEALSdashboard,[email protected].

Introduction

13

Page 14: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

APCSAVideoTutorialsThefollowingareasetofvideotutorialstohelpguidenewteachersontheTEALScurriculum.

VideosTimingandPacing:AdjustlessonsandthecurriculummapforthespeedofyourlearnersProjectsandLabs:ChoosewhetheryourclasscompletestheAPLabsortheProjects(FracCalc/TextExcel)Space:UsingthephysicalspaceinyourclassroomtoenhancelearningParson'sProblems:Assessinghigh-levelprogrammingskillsquicklywithParson'sProblemsGrudgeball:ReviewmaterialsusingbyplaingagameofGrudgeball

VideoTutorials

14

Page 15: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

APCSACurriculumMapThefollowingcurriculummapisaday-by-daylistingoftheAPComputerSciencecourseinchronologicalorder.Eachrowrepresentsonedayofclass,basedonamedium-pacedclass.Readingsfromthetextbookandhomeworkassignmentsareincludedonthedaywhentheyshouldbeassigned.RefertotheIntroductiondocumentforinformationabouthowtoadjustthispacingforyourspecificclassroom.

ContentsUnit1:Programming&Java(2weeks)Unit2:WorkingwithData&BasicControlFlow(3weeks)Unit3:AdvancedData&ControlFlow(4weeks)Unit4:Arrays,Lists,&Files(4weeks)Unit5:Object-OrientedProgramming(4weeks)Unit6:Inheritance&Polymorphism(4weeks)Unit7:Searching&Sorting(3weeks)Unit8:Recursion(2weeks)Unit9:APTestReview(3weeks)Unit10:Post-APExamProjects(4–5weeks)

Abbreviations

WS—WorksheetSC—Self-Checkproblem(inthetextbook)EX—Exercise(inthetextbook)PP—ProgrammingProject(inthetextbook)

Unit1:Programming&Java(2weeks)Unit1SlidesUnit1WordBank

CurriculumMap

15

Page 16: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

CurriculumAssets

LP Title InClass Reading Homework

1.01 UsingEclipse&Practice-It

WS1.1.1WS1.1.2

ExplorePokémon(pokemon.com,console,website)

1.02Algorithms&ComputationalThinking

PB&J 1.2

ReflectonPB&JassignmentContinueexploringPokémon

1.03 String&ConsoleOutput

Practice-ItSC1.6–9,1.11–14LPWelcome

1.3 EX1.1–5

1.04 CommonErrors&Comments WS1.4 1.4 EX1.6–9

1.05 StaticMethods&MethodCalls

Practice-ItSC1.22,1.23,1.26,1.29

1.5 EX1.11,1.12,1.14,1.16

1.06 StaticMethods&MethodCalls

LPStarFiguresLPPikachuChatter

Outlinech1PP1.1,1.3

1.07 ProgrammingProject PP1.2,1.5 Notecheck(add

summariesifneeded)

1.08 Finding&FixingErrors Fixhomework Review

ch1Submitquestionsforreview

1.09 Review

ReviewquestionsWS1.9Practicetest

Study

[1.99] Unit1TestTest0SectionITest0SectionII

1.01

CurriculumMap

16

Page 17: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson1.01 UsingEclipse&Practice-It

Objectives StudentswillbeabletoopenEclipse,createandsaveafileinEclipse,andusePractice-It.

AssessmentsStudentswilldemonstratePlug-InandUn-Plugproceduresfortheteacher.StudentswillloginandsubmitasampleprobleminPractice-It.

InClass WS1.1.1WS1.1.2

Reading

Homework ExplorePokémon(pokemon.com,console,website)

1.02

Lesson1.02 Algorithms&ComputationalThinking

ObjectivesStudentswillbeabletodefinealgorithms,programs,hardware,software,andoperatingsystems.Studentswillbeabletodescribetherelationshipsbetweentheseconceptsandcomponents.

AssessmentsStudentswillwritesamplealgorithms,assembleanddebugaprogramthatdirectstheinstructortomakeapeanutbutter&jellysandwich.

InClass PB&J

Reading 1.2

Homework ReflectonPB&JassignmentContinueexploringPokémon

1.03

Lesson1.03 String&ConsoleOutput

ObjectivesStudentswillcorrectlyassembleacompleteprogramthatusesaclassheader,body,andmainmethod.Studentswillcorrectlyuseprint,println,andescapesequences.

Assessments StudentswillcreateastarterPokémonprogramStudentswillcompleteseveralPractice-Itquestions.

InClassPractice-ItSC1.6–9,1.11–14LPWelcome

Reading 1.3

Homework EX1.1–5

CurriculumMap

17

Page 18: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

1.04

Lesson1.04 CommonErrors&Comments

ObjectivesStudentswillcreatesimpleprogramswithcommentsStudentswillbeabletolistandapplythestepsnecessaryforavoidingsyntaxerrors.

Assessments Studentswillcompleteaworksheet(WS1.4).Studentswilldevelopapersonalcheck-listforspottingsyntaxerrors.

InClass WS1.4

Reading 1.4

Homework EX1.6–9

1.05

Lesson1.05 StaticMethods&MethodCalls

ObjectivesStudentswilluseproceduraldecompositiontoplancomplexprogramsusingstructurediagrams.Studentswillmanagecomplexitybyusingmethodcalls.

Assessments StudentswillcompletePractice-Itproblems.

InClass Practice-ItSC1.22,1.23,1.26,1.29

Reading 1.5

Homework EX1.11,1.12,1.14,1.16

1.06

Lesson1.06 StaticMethods&MethodCalls

Objectives Studentswillusestructurediagramstoplancomplexprograms.Studentswillmanagecomplexitybyusingmethodcalls.

Assessments StudentswillcompletePractice-Itproblems,studentswillwriteastructuredPikachuprogram.

InClass LPStarFiguresLPPikachuChatter

Reading

Homework Outlinech1PP1.1,1.3

1.07

CurriculumMap

18

Page 19: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson1.07 ProgrammingProject

Objectives Studentswillconstructaprogramcontainingmethodcallsandstaticmethods.

Assessments Studentswillsubmitacomplete,functionalprogrambytheendofclass.

InClass PP1.2,1.5

Reading

Homework Notecheck(addsummariesifneeded)

1.08

Lesson1.08 Finding&FixingErrors

Objectives Studentswillfinderrorsintheirreturnedhomeworkassignments,andcorrecttheircode.

Assessments Studentswillre-submitallhomeworkassignmentswithcorrectedanswers.

InClass Fixhomework

Reading Reviewch1

Homework Submitquestionsforreview

1.09

Lesson1.09 Review

Objectives StudentswillidentifyweaknessesintheirUnit1knowledge.

Assessments Studentswillcreateapersonalizedlistofreviewtopicstoguidetonight’sstudysession.

InClassReviewquestionsWS1.9Practicetest

Reading

Homework Study

1.99

Unit1Test Programming&Java

InClass Test0SectionITest0SectionII

CurriculumMap

19

Page 20: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Unit2:WorkingwithData&BasicControlFlow(3weeks)

Unit2SlidesUnit2WordBankCurriculumAssets

LP Title InClass Reading Homework

2.00 TestReview&Reteach Reviewtest

2.1exceptfor“MixingtypesandCasting”

Testcorrections

2.01 BasicDataConcepts WS2.1 2.2upto“String

Concatenation”

SC2.1-2.3(4th:2.1",2.3,"2.4)

2.02Declaring&AssigningVariables

WS2.2Practice-ItSC2.7,2.11(4th:2.8,"2.13)E2.1

Restof2.2

SC2.5",2.6,2.9,2.12-2.15(4th:2.6,2.7,2.1,2.14-2.17)

2.03

StringConcatenation&IncrementDecrementOperators

Grudgeball Restof2.2 SC2.4(4th:2.5)

2.04 MixingTypes&Casting

WS2.4Poster2.4

2.3upto“NestedforLoops" finishWS2.4

2.05 forLoops

WS2.5Practice-ItSC2.18,2.23,2.24(4th:2.21,2.26,"2.27)

2.3“NestedforLoops”

SC2.19-2.21(4th:2.22-2.24)

2.06 nestedforLoops

Practice-ItSC2.28-2.30(4th:2.31-2.33),E2.5

2.4“Scope”and“Pseudocode"

SC2.26",2.27(4th:2.29,2.30),E2.4

CurriculumMap

20

Page 21: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

2.07 Scope&Pseudocode

WS2.7DiscussPP2.1

Read2.4“ClassConstants”

SC2.31-2.33(4th2.34-2.36)

2.08 ProgrammingProject StartPP2.4 Outlinech2

(omit2.5)

2.09 ProgrammingProject

CompletePP2.4

[TBDpracticequestion]

2.10 Finding&FixingErrors FixHW Reviewch2(omit

2.5)

Submitquestionsforreview

2.11 Review(Reviewquestions)

WS2.11practicetest Study

[2.99] (Unit2Test)

Test1SectionITest1SectionII

2.00

Lesson2.00 TestReview&Reteach

Objectives Studentswillre-learnorstrengthencontentknowledgeandskillsfromUnit1.

Assessments Studentswillre-submittestanswerswithupdatedcorrectionsforpartialorfullcredit,dependingoninstructorpreference.

InClass Reviewtest

Reading 2.1exceptfor“MixingTypesandCasting”

Homework Testcorrections

2.01

CurriculumMap

21

Page 22: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson2.01 BasicDataConcepts

ObjectivesStudentswillbeabletoidentifyandcategorizedatatypes.Studentswillidentifyoperatorsandoperands,andwillcorrectlyapplyrulesorprecedence.

AssessmentsUsingoperator/operandexpressionsets,studentswilluserulesofprecedencetocorrectlywritecodethatyieldsagivenanswer.Usingoperator/operandexpressionsets,studentswillcreatetheirownexpressionsandpredicttheoutput.

InClass WS2.1

Reading 2.2upto“StringConcatenation”

Homework SC2.1–3(4th:2.1,2.3,2.4)

2.02

Lesson2.02 Declaring&AssigningVariables

Objectives Studentswillbeabletoidentify,declare,andassignvariables.

Assessments StudentswillwriteaprogramthatconvertstemperaturefromFarenheittoCelsius.

InClassWS2.2Practice-ItSC2.7,2.11(4th:2.8,2.13)E2.1

Reading Restof2.2

Homework SC2.5,2.6,2.9,2.12–15(4th:2.6,2.7,2.10,2.14–17)

2.03

Lesson2.03 StringConcatenation&IncrementDecrementOperators

Objectives Studentswillapplytherulesofstringconcatenation,studentswillcorrectlyinterpretincrementinganddecrementingstatements.

Assessments Studentswillevaluatestatementsandpredictoutputduringagameofgrudgeball.

InClass Grudgeball

Reading Restof2.2

Homework SC2.4(4th:2.5)

2.04

CurriculumMap

22

Page 23: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson2.04 MixingTypes&Casting

ObjectivesStudentswillbeabletodescribewhichtypesautomaticallyconvertintootherswhenappearingtogetherinexpressions,andpredicthowanexpressionwithmixedtypeswillevaluate.Studentswillbeabletoconverttypesbycasting.

AssessmentsStudentswilluse“ZombieRules”ofprecedencetocorrectlywritecodethatyieldsagivenanswerSudentswillcreatetheirownexpressions&predictoutputbycompletingandtradingworksheets.

InClass WS2.4Poster2.4

Reading 2.3upto“NestedforLoops”

Homework FinishWS2.4

2.05

Lesson2.05 forLoops

Objectives StudentswilltraceloopstopredictprogrambehaviorStudentswillconstructloopstoexecutesimpletasks.

Assessments StudentswilltraceandconstructloopsinPractice-Itproblems.

InClassWS2.5Practice-ItSC2.18,2.23,2.24(4th:2.21,2.26,2.27)

Reading 2.3“NestedforLoops”

Homework SC2.19–21(4th:2.22–24)

2.06

Lesson2.06 NestedforLoops

Objectives StudentswilltracenestedloopstopredictprogrambehaviorStudentswillconstructloopstoexecutesimpletasks.

Assessments StudentswilltraceandconstructnestedloopsinPractice-Itproblems.

InClassPractice-ItSC2.28–30(4th:2.31–33)E2.5

Reading 2.4“Scope”and“Pseudocode”

Homework SC2.26,2.27(4th:2.29,2.30)E2.4

CurriculumMap

23

Page 24: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

2.07

Lesson2.07 Scope&Pseudocode

Objectives Studentswillbeabletoidentifythescopeofavariableandidentifycommonscopeerrors.

Assessments Studentswillcompleteaworksheet.

InClass WS2.7DiscussPP2.1

Reading Read2.4“ClassConstants”

Homework SC2.31–33(4th2.34–36)

2.08

Lesson2.08 ProgrammingProject

Objectives Studentswillplanandconstructastructuredprogramcontainingnestedloops.

Assessments Studentswillsubmitacomplete,functionalprogrambytheendofnextclass.

InClass StartPP2.4

Reading

Homework Outlinech2(omit2.5)

2.09

Lesson2.09 ProgrammingProject

Objectives Studentswillplanandconstructastructuredprogramcontainingnestedloops.

Assessments Studentswillsubmitacomplete,functionalprogrambytheendofnextclass.

InClass CompletePP2.4

Reading

Homework [TBDpracticequestion]

2.10

CurriculumMap

24

Page 25: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson2.10 Finding&FixingErrors

Objectives Studentswillfinderrorsintheirreturnedhomeworkassignments,andcorrecttheircode.

Assessments Studentswillre-submitallhomeworkassignmentswithcorrectedanswers.

InClass Fixhomework

Reading Reviewch2(omit2.5)

Homework Submitquestionsforreview

2.11

Lesson2.11 Review

Objectives StudentswillidentifyweaknessesintheirUnit1knowledge.

Assessments Studentswillcreateapersonalizedlistofreviewtopicstoguidetonight’sstudysession.

InClassReviewquestionsWS2.11Practicetest

Reading

Homework Study

2.99

Unit2Test WorkingwithData&BasicControlFlow

InClass Test1SectionITest1SectionII

Unit3:AdvancedData&ControlFlow(4weeks)

Unit3SlidesUnit3WordBank

CurriculumMap

25

Page 26: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

CurriculumAssetsFracCalc

LP Title InClass Reading Homework

3.00 TestReview&Reteach

AlgorithmforSolvingProblems

3.1upto“LimitationsofParameters”

Testcorrections

3.01 Parameters Practice-ItSC3.1-3.3

"3.1“LimitationsofParameters”,“MultipleParameters”,""ParametersversusConstants"""

SC3.4-3.7

3.02

LimitationsofParameters&MultipleParameters

(Artproject)

"3.1“OverloadingMethods”,3.2""MethodsThatReturnValues"""

Jazzupartprojectandprogram

3.03 ReturnValues

Practice-ItSC3.14-3.16

SC3.17,E3.1

3.04 ProgrammingProject

WS3.4Equestria

3.3upto“InteractiveProgramsandScannerObjects”

SC3.18,3.19

3.05

UsingObjects&StringProcessing

WS3.5

3.3“Interactiveprogramming”and“Sampleinteractiveprogram”

SC3.19-3.21

3.06

InteractivePrograms&ScannerObjects

Practice-ItSC3.24-3.26;E3.12,3.14,3.15

Outlinech3(omit3.4)

3.07

PokémonBattleProgrammingProject

WS3.7LPBattle

Summarizenotessincelastexam

3.08 Finding&FixingErrors

FixHWwebmaker.org

4.1upto“nestedifelsestatements” SC4.1-4.4

3.09RelationalOperators&if/else

OperatorPrecedenceGrudgeball

4.1“Nestedif/else”and“Flowofcontrol”

SC4.7-4.9;E4.1-4.2

3.10Nestedif/elseStatements

WS3.10Teachmini-lessonsPractice-ItSC4.5,4.6,E4.3

4.1,“Factoringif/elsestatements”and“Testingmultipleconditions”

E4.4,4.5

3.11ReducingRedundancy

(Refactoringcompetition) Read4.2

Outlinech4(omit4.4,

CurriculumMap

26

Page 27: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Redundancy petition) 4.5)

3.12 CumulativeAlgorithms

Tallycodeonboard,CollaborativeProgrammingExerciseWS3.12

5.1skip“do/whileloops” PP4.2

3.13 whileLoopsPractice-ItSC5.1-5.4,E5.2WS3.13

5.1”Randomnumbers” E5.2

3.14 RandomNumbers

Practice-ItSC5.5-5.7;E5.4,5.5 5.2 PP5.1

3.15Fencepost&SentinelLoops

WS3.15Teachmini-lessons 5.3 E5.6,5.8

3.1601 BooleanLogic

Practice-ItSC5.27,5.29WS3.16(RPS,Pig)DeMorgan’sLawPoster3.16.1Poster3.16.2

Outlinech5(through5.3)

3.1602 BooleanLogic(Day2)

3.17 Finding&FixingErrors (FixHW) Reviewch3-5

Submitquestionsforreview

3.18 Review(Reviewquestions),WS3.18practicetest

Study

3.99 Unit3testTest2GuideTest2SectionITest2SectionII

3.XX FracCalc

3.00

CurriculumMap

27

Page 28: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson3.00 TestReview&Reteach

Objectives Studentswillre-learnorstrengthencontentknowledgeandskillsfromUnit2.

Assessments Studentswillre-submittestanswerswithupdatedcorrectionsforpartialorfullcredit,dependingoninstructorpreference.

InClass AlgorithmforSolvingProblems

Reading 3.1upto“LimitationsofParameters”

Homework Testcorrections

3.01

Lesson3.01 Parameters

ObjectivesStudentswillcorrectlyconstructformalandactualparameters(arguments).Studentswillpredicttheoutputofprogramsthatuseparameters.

AssessmentsStudentswillteachamini-lessonexplainingtherelationshipbetweenparametersandvaluesstoredinmemory.StudentswillsubmitPractice-Itquestions.

InClass Practice-ItSC3.1–3

Reading 3.1“LimitationsofParameters”,“MultipleParameters”,“ParametersversusConstants”

Homework SC3.4–7

3.02

Lesson3.02 LimitationsofParameters&MultipleParameters

Objectives Studentswillmodifyprogramsusingparametersandclassconstantstocreateoriginalartworks.

Assessments Studentswillcompleteanartprojectand“artiststatement”justifyingtheirprogrammingchoices.

InClass Artproject

Reading 3.1“OverloadingMethods”3.2“MethodsThatReturnValues”

Homework Jazzupartprojectandprogram

3.03

CurriculumMap

28

Page 29: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson3.03 ReturnValues

Objectives Studentswillwriteaprogramthatreturnsvalues.

Assessments StudentswillcompletePractice-ItquestionsandwriteaprogramtomeetaPokémonChallenge.

InClass Practice-ItSC3.14–16

Reading

Homework SC3.17E3.1

3.04

Lesson3.04 ProgrammingProject

Objectives Studentswillwriteaprogramthatusesparameters,themathclass,andreturnsvalues.

Assessments StudentswillsubmitanEquestriaprogrambytheendofclass.

InClass WS3.4Equestria

Reading 3.3upto“InteractiveProgramsandScannerObjects”

Homework SC3.18–19

3.05

Lesson3.05 UsingObjects&StringProcessing

ObjectivesStudentswillbeabletodifferentiatebetweenprimitiveandobjecttypes.Studentswillapply0-indexingandstringprocessingtechniquestopredicttheoutputofaprogram.

Assessments StudentswillcompleteWS3.5

InClass WS3.5

Reading 3.3“InteractiveProgramming”and“SampleInteractiveProgram”

Homework SC3.19–21

3.06

CurriculumMap

29

Page 30: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson3.06 InteractivePrograms&ScannerObjects

Objectives Studentswillwriteprogramsthatacceptuserinputusingascannerobject.

Assessments StudentswillcompletePractice-Itproblems.

InClassPractice-ItSC3.24–26E3.12,14,15

Reading

Homework Outlinech3(omit3.4)

3.07

Lesson3.07 PokémonBattleProgrammingProject

Objectives Studentswillwriteaprogramthatrequestsuserinputandreturnsdata.

Assessments StudentswillwriteaprogramthatcalculatesdamagedonetoPokémoninabattle.

InClass WS3.7LPBattle

Reading

Homework Summarizenotessincelastexam

3.08

Lesson3.08 Finding&FixingErrors

Objectives Studentswillfinderrorsandcorrecttheirpreviouslysubmittedhomeworkandclassworkassignment.

Assessments Studentswillre-submitallhomeworkassignmentswithcorrectedanswers.

InClass Fixhomeworkwebmaker.org

Reading 4.1upto“NestedIf/ElseStatements”

Homework SC4.1–4

3.09

CurriculumMap

30

Page 31: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson3.09 RelationalOperators&if/else

Objectives Studentswillbeabletoevaluaterelationalexpressions,predictandtracetheflowofanifstatement.

Assessments Studentswillevaluaterelationalexpressionsandpracticecorrectifstatementsyntaxduringagameofgrudgeball.

InClass OperatorPrecedenceGrudgeball

Reading 4.1“NestedIf/Else”and“FlowofControl”

Homework SC4.7–9E4.1–2

3.10

Lesson3.10 Nestedif/elseStatements

ObjectivesStudentswillwillbeabletochoosewhichifstatementsotusefordifferentproblemsStudentswillusecorrectsyntaxforthedifferentifstatements.

AssessmentsStudentswillteachamini-lessononsequentialornestedifstatements.StudentswillsubmitseveralPractice-Itquestions.

InClassWS3.10Teachmini-lessonsPractice-ItSC4.5–6E4.3

Reading 4.1,“FactoringIf/ElseStatements”and“TestingMultipleConditions”

Homework EX4.4–5

3.11

Lesson3.11 ReducingRedundancy

Objectives Studentswillsimplifycodeandreduceredundancybyfactoringif/elsestatementsandtestingmultipleconditionssimultaneously.

Assessments Studentswillcompleteaclasscompetition.

InClass Refactoringcompetition

Reading 4.2

Homework Outlinech4(omit4.4,4.5)

3.12

CurriculumMap

31

Page 32: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson3.12 CumulativeAlgorithms

Objectives Studentswillfindandcorrectsyntaxerrorsinconditionalcumulativealgorithms.

Assessments Studentswillwrite,modify,andcorrectprogramswrittenbyothers.

InClass TallycodeonboardCollaborativeProgrammingExerciseWS3.12

Reading 5.1(skip“Do/WhileLoops”)

Homework PP4.2

3.13

Lesson3.13 whileLoops

ObjectivesStudentswilltracewhileloopstopredict(1)thenumberoftimesthebodyexecutesand(2)theoutputofthecode.Studentswillbeabletodifferentiatebetweenwhileloops,ifstatements,andforloops.

Assessments StudentswillcompletePractice-Itquestions.

InClassPractice-ItSC5.1–4E5.2WS3.13

Reading 5.1“RandomNumbers”

Homework EX5.2

3.14

Lesson3.14 RandomNumbers

Objectives Studentswillbeabletowriteexpressionsthatgeneratearandomintegerbetweenanytwovalues.

Assessments StudentswillcompletePractice-Itquestions.

InClassPractice-ItSC5.5–7E5.4–5

Reading 5.2

Homework PP5.1

3.15

CurriculumMap

32

Page 33: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson3.15 Fencepost&SentinelLoops

ObjectivesStudentswillbeabletodescribewhentousefencepostandsentinelloops.Studentswillusepropersyntaxtoconstructthesecontrolstructures.

Assessments Studentswillteachamini-lessonexplainingtherelationshipbetweenparametersandvaluesstoredinmemory.

InClass WS3.15Teachmini-lessons

Reading 5.3

Homework EX5.6,8

3.16.1

Lesson3.16 BooleanLogic(Day1)

Objectives StudentswillworkinpairstowriteagamethatplaysRockPaperScissors.

Assessments Studentswillsubmitaprogramattheendof2or3classperiods.

InClass

Practice-ItSC5.27,5.29WS3.16(RPS,Pig)DeMorgan’sLawPoster3.16.1Poster3.16.2

Reading

Homework Outlinech5(through5.3)

3.16.2

Lesson3.16 BooleanLogic(Day2)

3.17

CurriculumMap

33

Page 34: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson3.17 Finding&FixingErrors

Objectives Studentswillfinderrorsintheirreturnedhomeworkassignments,andcorrecttheircode.

Assessments Studentswillre-submitallhomeworkassignmentswithcorrectedanswers.

InClass Fixhomework

Reading Reviewch3–5

Homework Submitquestionsforreview

3.18

Lesson3.18 Review

Objectives StudentswillidentifyweaknessesintheirUnit3knowledge.

Assessments Studentswillcreateapersonalizedlistofreviewtopicstoguidetonight’sstudysession.

InClass ReviewquestionsWS3.18PracticeTest

Reading

Homework Study

3.99

Unit3Test AdvancedData&ControlFlow

Guide Test2Guide

InClass Test2SectionITest2SectionII

3.XX

Unit3Project FracCalc

InClass FracCalc

CurriculumMap

34

Page 35: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Unit4:Arrays,Lists,&Files(4weeks)Unit4SlidesUnit4WordBankCurriculumAssetsMagpieChatbotLab

LP Title InClass Reading Homework

4.00 TestReview&Reteach Reviewtest 7.1uptoArraysand

MethodsTestcorrections

4.01 ArrayBasics WS4.1Poster4.2

7.1For-EachLoopandTheArraysClass

SC7.1,7.7,7.9

4.02 For-EachLoop&ArraysClass WS4.2 7.2uptoReversing

anArray SC7.12-7.14

4.03

Printing,Searching,&TestingforEquality

WS4.3Mini-lessons

SC7.14-7.17,E7.3

4.03

Printing,Searching,&TestingforEquality(Day2)

7.3 SC7.19-7.21

4.04 ReferenceSemantics

WS4.47.4uptoCommand-LineArguments

E7.9,7.10

4.05 ShiftingValues&ArraysofObjects

SC7.22,7.23,7.25,7.26,7.30;E7.16

7.4NestedArrays,7.5RectangularTwoDimensionalArrays

SC7.27-7.29,E7.14

4.06

NestedLoopAlgorithms&RectangularArrays

WS4.610.1uptoAddingtoandRemovingfromanArrayList

SC[TBD]

4.07 ArrayList GrudgeballPoster4.7

Outlinech7and10.1

4.08 Finding&FixingErrors FixHW Reviewch7,10.1for

Magpielab

Submitquestionsforreview

4.0901

MagpieChatbotLab(day1)

MagpieChatbotLabActivity1&2

Barronsch6

CurriculumMap

35

Page 36: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

4.0902

MagpieChatbotLab(day2)

MagpieChatbotLabActivity2

Barronsch6

4.0903

MagpieChatbotLab(day3)

MagpieChatbotLabActivity3

Barronsch6practicequestions

4.0904

MagpieChatbotLab(day4)

MagpieChatbotLabActivity4

CheckandcorrectBarronsch.6questions

4.0905

MagpieChatbotLab(day5)

MagpieChatbotLabActivity5

CheckandcorrectBarronsch.6questions

4.10 Review

ReviewquestionsWS4.10practicetest

Study

4.99 Unit4test

Test3SectionITest3SectionII

4.00

Lesson4.00 TestReview&Reteach

Objectives Studentswillre-learnorstrengthencontentknowledgeandskillsfromUnit3.

Assessments Studentswillre-submittestanswerswithupdatedcorrectionsforpartialorfullcredit,dependingoninstructorpreference.

InClass Reviewtest

Reading 7.1upto“ArraysandMethods”

Homework Testcorrections

4.01

CurriculumMap

36

Page 37: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson4.01 ArrayBasics

Objectives Studentswilldefine,populate,andaccessarrays.

Assessments StudentswillcompletemanipulativesexercisesonWS4.1.1

InClass WS4.1Poster4.2

Reading 7.1“For-EachLoop”and“TheArraysClass”

Homework SC7.1,7,9

4.02

Lesson4.02 For-EachLoop&ArraysClass

Objectives Studentswilldefine,populate,andaccessarrays.

Assessments StudentswillcompletemanipulativesexercisesonWS4.2

InClass WS4.2

Reading 7.2upto“ReversinganArray”

Homework SC7.12–14

4.03.1

Lesson4.03 Printing,Searching,&TestingforEquality(Day1)

Objectives Studentswillbeabletomanipulatesingle-dimensionarraysusingavarietyofarraytransversalalgorithms.

AssessmentsStudentswillteachamini-lessononprinting,searching/replacing,testingforequality,reversinganarray,orstringtraversal.StudentswillcompleteaquizattheendofDay2.

InClass WS4.3Teachmini-lessons

Reading

Homework SC7.14–17E7.3

4.03.2

CurriculumMap

37

Page 38: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson4.03 Printing,Searching,&TestingforEquality(Day2)

Objectives

Assessments

InClass

Reading 7.3

Homework SC7.19–21

4.04

Lesson4.04 ReferenceSemantics

Objectives Studentswillbeabletocompareandcontrasthowprimitivesandarraysaretreatedwhenpassedasparameters.

Assessments Studentswillcompletegraphicorganizersandaworksheet.SomestudentswillcompleteaPokémonChallengeforextracredit.

InClass WS4.4

Reading 7.4upto“Command-LineArguments”

Homework EX7.9–10

4.05

Lesson4.05 ShiftingValues&ArraysofObjects

Objectives Studentswillbeabletoshiftelementswithinanarrayandconstructarraysofobjects.

Assessments StudentswillcompletePractice-Itquestionsandmodelmemorymanipulationusingarraywhiteboards.

InClass SC7.22,23,25,26,30E7.16

Reading 7.4“NestedArrays”7.5“RectangularTwoDimensionalArrays”

Homework SC7.27–29E7.14

4.06

CurriculumMap

38

Page 39: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson4.06 NestedLoopAlgorithms&RectangularArrays

Objectives StudentswillcorrectlyadjustnestedloopheadersforusewitharraysStudentswillcorrectlyconstructtwo-dimensionalarrays

Assessments StudentswillcompleteWS4.6

InClass WS4.6

Reading 10.1upto“AddingtoandRemovingfromanArrayList”

Homework SC[TBD]

4.07

Lesson4.07 ArrayList

ObjectivesStudentswillconstructcodeusingArrayListStudentswillpredicttheoutputofmethodsthattakearraysasparametersand/orreturnarrays.

Assessments StudentswillevaluatestatementsandpredictoutputduringagameofGrudgeball.

InClass GrudgeballPoster4.7

Reading

Homework Outlinech7and10.1

4.08

Lesson4.08 Finding&FixingErrors

Objectives Studentswillfinderrorsintheirreturnedhomeworkassignments,andcorrecttheircode.

Assessments Studentswillre-submitallhomeworkassignmentswithcorrectedanswers.

InClass Fixhomework

Reading Reviewch7,10.1forMagpielab

Homework Submitquestionsforreview

4.09.1

CurriculumMap

39

Page 40: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson4.09 MagpieLab(Day1)

Objectives Studentswillcompletealong-formlab,usingifstatements,algorithms,theStingclass,arrays,andArrayLists.

AssessmentsStudentswillcompletetheCollegeBoard’sAPCSAMagpieChatbotLab.Studentswillanswerassessmentquestionsonthefourthclassexam.

InClass [Lab:MagpieChatbotLab]MagpieChatbotLabActivity1&2

Reading Barronsch6

Homework

4.09.2

Lesson4.09 MagpieLab(Day2)

Objectives

Assessments

InClass MagpieChatbotLabActivity2

Reading Barronsch6

Homework

4.09.3

Lesson4.09 MagpieLab(Day3)

Objectives

Assessments

InClass MagpieChatbotLabActivity3

Reading

Homework Barronsch6practicequestions

4.09.4

CurriculumMap

40

Page 41: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson4.09 MagpieLab(Day4)

Objectives

Assessments

InClass MagpieChatbotLabActivity4

Reading

Homework CheckandcorrectBarronsch.6questions

4.09.5

Lesson4.09 MagpieLab(Day5)

Objectives

Assessments

InClass MagpieChatbotLabActivity5

Reading

Homework CheckandcorrectBarronsch.6questions

4.10

Lesson4.10 Review

Objectives StudentswillidentifyweaknessesintheirUnit4knowledge.

Assessments Studentswillcreateapersonalizedlistofreviewtopicstoguidetonight’sstudysession.

InClassReviewquestionsWS4.10Practicetest

Reading

Homework Study

4.99

Unit4Test Arrays,Lists&Files

InClass Test3SectionITest3SectionII

CurriculumMap

41

Page 42: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Unit5:Object-OrientedProgramming(4weeks)Unit5SlidesUnit5WordBankCurriculumAssetsPictureLab

LP Title InClass Reading Homework

5.00 TestReview&Reteach Reviewtest 8.1 Test

corrections

5.01ObjectOrientedProgramming

Practice-ItSC8.1-8.5WS5.1.1

8.2upto“MutatorsandAccessors.”

5.02 ObjectState&Behavior WS5.2 8.3upto“The

Keywordthis.”SC8.9-8.11,8.13-8.16

5.03ObjectInitialization:Constructors

WS5.3.1WS5.3.2 8.4

5.04 Encapsulation WS5.4Mini-lessons SC8.22-8.28

5.05 Finding&FixingErrors FixHW Reviewch8for

PictureLab

Submitquestionsforreview

5.0601

PictureLab(day1)

PictureLabActivity1&2PictureLab

Summarizenotessincelastexam

5.0602

PictureLab(day2)

PictureLabActivity3&4,notebookchecks

Outlinech8

5.0603

PictureLab(day3)

PictureLabActivity5,notebookchecks

ReadandhighlightBarronsch2,skipthiskeyword

5.0604

PictureLab(day4)

PictureLabActivity5&6,notebookchecks

Barronsch2exam,skip#20

PictureLab

CurriculumMap

42

Page 43: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

5.0605

PictureLab(day5)

Activity6,Barron'schecks

ReadandhighlightBarronsch5

5.0606

PictureLab(day6)

PictureLabActivity7 SC8.28,8.30

5.0607

PictureLab(day7)

PictureLabActivity8 8.5 FinishPicture

LabActivity8

5.0608

PictureLab(day8)

PictureLabActivity9

Cont.PictureLabActivity9

5.0609

PictureLab(day9)

PictureLabActivity9,cont.

Submitquestionsforreview

5.07 ReviewReviewquestionWS5.7Testpractice

Study

[5.99] (Unit5test) Test4SectionITest4SectionII

5.00

Lesson5.00 TestReview&Reteach

Objectives Studentswillre-learnorstrengthencontentknowledgeandskillsfromUnit4.

Assessments Studentswillre-submittestanswerswithupdatedcorrectionsforpartialorfullcredit,dependingoninstructorpreference.

InClass Reviewtest

Reading 8.1

Homework Testcorrections

5.01

CurriculumMap

43

Page 44: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson5.01 ObjectOrientedProgramming

ObjectivesStudentswillbeabletodescribetherelationshipbetweenclasses,objects,andclientcode.Studentswillbeabletopredicttheoutputofthecodethatusesobjects.

Assessments StudentswillcompletePractice-Itquestions.

InClassPractice-ItSC8.1–5WS5.1.1

Reading 8.2upto“MutatorsandAccessors”

Homework

5.02

Lesson5.02 ObjectState&Behavior

ObjectivesStudentswillbeabletodescribeclasses,objects,andclientcode.Studentswillbeabletopredicttheoutputofthecodethatusesobjects.

Assessments StudentswillcompleteWS5.2individuallyorinpairs.

InClass WS5.2

Reading 8.3upto“TheKeywordthis”

Homework SC8.9–11,13–16

5.03

Lesson5.03 ObjectInitialization:Constructors

ObjectivesStudentswillbeabletodescribeandcreateclasses,objects,andclientcode.Studentswillbeabletopredicttheoutputofthecodethatusesobjects.

Assessments StudentswillcompletePractice-Itquestions.

InClass WS5.3.1WS5.3.2

Reading 8.4

Homework

5.04

CurriculumMap

44

Page 45: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson5.04 Encapsulation

Objectives Studentswillbeabletomanipulatesingle-dimensionarraysusingavarietyofarraytransversalalgorithms.

AssessmentsStudentswillteachamini-lessononprinting,searching/replacing,testingforequality,reversinganarray,orstringtraversal.StudentswillcompleteaquizattheendofDay2.

InClass WS5.4Teachmini-lessons

Reading

Homework SC8.22–28

5.05

Lesson5.05 Finding&FixingErrors

Objectives Studentswillfinderrorsintheirreturnedhomeworkassignments,andcorrecttheircode.

Assessments Studentswillre-submitallhomeworkassignmentswithcorrectedanswers.

InClass Fixhomework

Reading Reviewch8forPictureLab

Homework Submitquestionsforreview

5.06.1

Lesson5.06 PictureLab(Day1)

ObjectivesStudentswillcompletealong-formlab,usingtwodimensionalarraysofobjects,arraytraversingalgorithms,programanalysis,binarynumbers,inheritance,andinterfaces.

Assessments PictureLab

InClass PictureLabActivity1&2PictureLab

Reading

Homework Summarizenotessincelastexam

5.06.2

CurriculumMap

45

Page 46: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson5.06 PictureLab(Day2)

Objectives

Assessments

InClass PictureLabActivity3&4Notebookchecks

Reading

Homework Outlinech8

5.06.3

Lesson5.06 PictureLab(Day3)

Objectives

Assessments

InClass PictureLabActivity5Notebookchecks

Reading ReadandhighlightBarronsch2,skipthiskeyword

Homework

5.06.4

Lesson5.06 PictureLab(Day4)

Objectives

Assessments

InClass PictureLabActivity5&6Notebookchecks

Reading

Homework Barronsch2exam(skip#20)

5.06.5

CurriculumMap

46

Page 47: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson5.06 PictureLab(Day5)

Objectives

Assessments

InClass PictureLabActivity6Barron'schecks

Reading ReadandhighlightBarronsch5

Homework

5.06.6

Lesson5.06 PictureLab(Day6)

Objectives

Assessments

InClass PictureLabActivity7

Reading

Homework SC8.28,30

5.06.7

Lesson5.06 PictureLab(Day7)

Objectives

Assessments

InClass PictureLabActivity8

Reading 8.5

Homework FinishPictureLabActivity8

5.06.8

Lesson5.06 PictureLab(Day8)

Objectives

Assessments

InClass PictureLabActivity9

Reading

Homework Cont.PictureLabActivity9

CurriculumMap

47

Page 48: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

5.06.9

Lesson5.06 PictureLab(Day9)

Objectives

Assessments

InClass PictureLabActivity9,cont.

Reading

Homework Submitquestionsforreview

5.07

Lesson5.07 Review

Objectives StudentswillidentifyweaknessesintheirUnit5knowledge.

Assessments Studentswillcreateapersonalizedlistofreviewtopicstoguidetonight’sstudysession.

InClassReviewquestionsWS5.7Testpractice

Reading

Homework Study

5.99

Unit5Test ObjectOrientedProgramming

InClass Test4SectionITest4SectionII

Unit6:Inheritance&Polymorphism(4weeks)Unit6SlidesUnit6WordBankCurriculumAssets

CurriculumMap

48

Page 49: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

TextExcel

LP Title InClass Reading Homework

6.00 TestReview&Reteach (Reviewtest) 9.1 Testcorrections

6.0101

InheritanceBasics(day1)

WS6.1StartclassposterExample6.1

"9.2upto""DividendStockBehavior"""

Collectimages

6.0102

InheritanceBasics(day2)

Finishclassposter,discuss

6.02

OverridingMethods&AccessingInheritedCode

WS6.2

Restof9.2startingfrom“TheObjectClass.”

6.03InteractingwiththeObjectSuperclass

Practice-ItSC9.3,9.4,9.9,9.10,E9.4;WS6.3Poster6.3

9.3upto“InterpretingInheritanceCode.”

6.04 PolymorphismWS6.4.1WS6.4.2SC9.11-9.17

Restof9.4“Is-aVersusHas-aRelationships.”

SC9.18,9.20

6.05 Has-aRelationships

WS6.5ValueMealexercise?

9.5

6.06 Interfaces[Interfaceexamples]Poster6.6

9.6

GenerateownclasshierarchylikeFinancialhierarchyinbook

6.0701

Programmingproject(day1)

PP9.1,notebookchecks

Outlinech9

6.0702

Programmingproject(day2)

PP9.1,outlinechecks

ReadandoutlineBarronsch4

6.0703

Programmingproject(day3) PP9.3 Barronsch4exam,

self-grade

6.0704

Programmingproject(day4) E9.8

ReadandoutlineBarronsch3

6.07 Programming Barronsch3exam,outline Reviewch9

Submitquestionsfor

CurriculumMap

49

Page 50: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

checks

6.08 Finding&FixingErrors (FixHW) Reviewch9 Submitquestionsfor

review

6.09 Review

ReviewquestionsWS6.5Testpractice

Study

6.99 Unit6test

Test5GuideTest5SectionITest5SectionII

6.XX TextExcel

TextExcelStudentGuideATextExcelStudentGuideBTextExcelStudentGuideCTextExcelTeacherGuide

6.00

Lesson6.00 TestReview&Reteach

Objectives Studentswillre-learnorstrengthencontentknowledgeandskillsfromUnit5.

Assessments Studentswillre-submittestanswerswithupdatedcorrectionsforpartialorfullcredit,dependingoninstructorpreference.

InClass Reviewtest

Reading 9.1

Homework Testcorrections

6.01.1

CurriculumMap

50

Page 51: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson6.01 InheritanceBasics(Day1)

Objectives

StudentswillcorrectlydefineinheritanceStudentswillusepropersyntaxtoextendaclass.Studentswillillustrateis-arelationships.Studentswillproperlyimplementconstructorsofderivedclassesusingsuper.

Assessments StudentswillcompleteaClassHeirarchyPosterasindicatedinWS6.1.

InClassWS6.1StartclassposterExample6.1

Reading 9.2upto“DividendStockBehavior”

Homework Collectimages

6.01.2

Lesson6.01 InheritanceBasics(Day2)

Objectives

Assessments

InClass FinishclassposterDiscussion

Reading

Homework

6.02

Lesson6.02 OverridingMethods&AccessingInheritedCode

ObjectivesStudentswillreplacesuperclassbehaviorbywritingoverridingmethodsinthesubclass.Studentswillwritesubclassmethodsthataccesssuperclassmethods.

Assessments StudentswilladdcodetotheirClassPostersfromthepreviouslesson.

InClass WS6.2

Reading Restof9.2startingfrom“TheObjectClass”

Homework

6.03

CurriculumMap

51

Page 52: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson6.03 InteractingwiththeObjectSuperclass

ObjectivesStudentswillreplacesuperclassbehaviorbywritingoverridingmethodsinthesubclass.Studentswillwritesubclassmethodsthataccesssuperclassmethods.

Assessments StudentswillcompletePractice-ItquestionsStudentswillcompleteaworksheet.

InClass

Practice-ItSC9.3–4,9–10E9.4WS6.3Poster6.3

Reading 9.3upto“InterpretingInheritanceCode”

Homework

6.04

Lesson6.04 Polymorphism

ObjectivesStudentswilldefinepolymorphism.Studentswilltracetheexecutionofmethodsthroughaclasshierarchyandpredictoutput.

Assessments StudentswillcompleteaTracingInheritanceguideandcompleteworksheet6.4.

InClassWS6.4.1WS6.4.2SC9.11–17

Reading Restof9.4“Is-aVersusHas-aRelationships”

Homework SC9.18,20

6.05

CurriculumMap

52

Page 53: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson6.05 Has-aRelationships

ObjectivesStudentswillbeabletoidentifyandexplainwhytwoclasseshaveanis-aorahas-arelationship.Studentswillbeabletocreateahas-arelationshipbetweentwoclasses.

Assessments StudentswillcompleteanAPSectionIIquestion“Trio”

InClass WS6.5ValueMealexercise

Reading 9.5

Homework

6.06

Lesson6.06 Interfaces

Objectives Studentswillimplementanduseinterfaces.

Assessments Studentswillcompleteanin-classcompetition.

InClass InterfaceexamplesPoster6.6

Reading 9.6

Homework GenerateownclasshierarchylikeFinancialhierarchyinbook

6.07.1

Lesson6.07 Programmingproject(Day1)

Objectives Studentswillwritecomplexcodethatusespolymorphism,inheritance,andinterfaces.

Assessments Studentswillsubmitaprogramelectronically.

InClass PP9.1Notebookchecks

Reading

Homework Outlinech9

6.07.2

CurriculumMap

53

Page 54: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson6.07 Programmingproject(Day2)

Objectives

Assessments

InClass PP9.1Outlinechecks

Reading ReadandoutlineBarronsch4

Homework

6.07.3

Lesson6.07 Programmingproject(Day3)

Objectives

Assessments

InClass PP9.3

Reading

Homework Barronsch4exam,self-grade

6.07.4

Lesson6.07 Programmingproject(Day4)

Objectives

Assessments

InClass EX9.8

Reading ReadandoutlineBarronsch3

Homework

6.07.5

CurriculumMap

54

Page 55: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson6.07 Programmingproject(Day5)

Objectives

Assessments

InClass Barronsch3examOutlinechecks

Reading Reviewch9

Homework Submitquestionsforreview

6.08

Lesson6.08 Finding&FixingErrors

Objectives Studentswillfinderrorsintheirreturnedhomeworkassignments,andcorrecttheircode.

Assessments Studentswillre-submitallhomeworkassignmentswithcorrectedanswers.

InClass Fixhomework

Reading Reviewch9

Homework Submitquestionsforreview

6.09

Lesson6.09 Review

Objectives StudentswillidentifyweaknessesintheirUnit6knowledge.

Assessments Studentswillcreateapersonalizedlistofreviewtopicstoguidetonight’sstudysession.

InClassReviewquestionsWS6.5Testpractice

Reading

Homework Study

6.99

CurriculumMap

55

Page 56: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Unit6Test InheritanceandPolymorphism

Guide Test5Guide

InClass Test5SectionITest5SectionII

6.XX

Unit6Project TextExcel

InClass

TextExcelTextExcelStudentGuideATextExcelStudentGuideBTextExcelStudentGuideCTextExcelTeacherGuide

Unit7:Searching&Sorting(3weeks)Unit7SlidesUnit7WordBankCurriculumAssetsElevensLab

LP Title InClass Reading Homework

7.00TestReview&Reteach

Reviewtest 13.1upto“Sorting” Testcorrections

7.01 SearchingAlgorithms

(CSUnpluggedBattleship)WS7.1

13.1“Sorting” SC13.4-13.6,E13.1-13.3

7.02 SortingAlgorithms 13.1“Shuffling”

7.0301

ElevensLab(day1)

ElevensLabActivity1"13.3skip""RecursiveBinarySearch"""

SC13.16-13.21,13.23,13.24

7.0302

ElevensLab(day2)

ElevensLabActivity2(begin)

CurriculumMap

56

Page 57: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

7.0303

ElevensLab(day3)

ElevensLabActivity2(end)

Summarizenotessincelastexam

7.0304

ElevensLab(day4)

ElevensLabActivity3(begin),notebookchecks

Outlinech13

7.0305

ElevensLab(day5)

ElevensLabActivity3(end),notebookchecks

ReadandoutlineBarronsch8

7.0306

ElevensLab(day6)

ElevensLabActivity4Barronsch8exam,self-grade

7.0307

ElevensLab(day7)

ElevensLabActivity5(begin),Barron'schecks

7.0308

ElevensLab(day8)

ElevensLabActivity5(end)

7.0309

ElevensLab(day9)

ElevensLabActivity6 (FixHW)

7.0310

ElevensLab(day10)

ElevensLabActivity7 (FixHW)

7.0311

ElevensLab(day11)

ElevensLabActivity8,re-gradefixedHW

7.0312

ElevensLab(day12)

ElevensLabActivity9(begin),re-gradefixedHW

7.0313

ElevensLab(day13)

ElevensLabActivity9(end),re-gradefixedHW

Submitquestionsforreview

7.0314

ElevensLab(day14)

ElevensLabActivity10,re-gradefixedHW

7.0315

ElevensLab(day15)

ElevensLabActivity11(begin)

7.0316

ElevensLab(day16)

ElevensLabActivity11(end)

7.04 Review Reviewquestions Study

CurriculumMap

57

Page 58: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

7.99 Unit7testTest6GuideTest6SectionITest6SectionII

7.00

Lesson7.00 TestReview&Reteach

Objectives Studentswillre-learnorstrengthencontentknowledgeandskillsfromUnit6.

Assessments Studentswillre-submittestanswerswithupdatedcorrectionsforpartialorfullcredit,dependingoninstructorpreference.

InClass Reviewtest

Reading 13.1upto“Sorting”

Homework Testcorrections

7.01

Lesson7.01 SearchingAlgorithms

Objectives Studentswillcompareandcontrastthedifferentsearchalgorithms.

Assessments Studentswillcompletesomeshortanswerquestions.

InClass CSUnpluggedBattleshipWS7.1

Reading 13.1“Sorting”

Homework SC13.4–6E13.1–3

7.02

Lesson7.02 SortingAlgorithms

Objectives Studentswillcompareandcontrastdifferentsortingmethodsandevaluatetheirrelativespeedandefficiency.

Assessments Studentswillcompletesomeshortanswerquestionsonworksheets.

InClass

Reading 13.1“Shuffling”

Homework

7.03.1

CurriculumMap

58

Page 59: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson7.03 Elevenslab(Day1)

ObjectivesStudentswillcompletealong-formlab,demonstratingeffectiveuseofobjectorientedprogramdesign,programimplementationandanalysis,andstandarddatastructuresandalgorithms.

Assessments ElevensLab

InClass ElevensLabActivity1

Reading 13.3(skip“RecursiveBinarySearch”)

Homework SC13.16–21,23–24

7.03.2

Lesson7.03 Elevenslab(Day2)

Objectives

Assessments

InClass ElevensLabActivity2(begin)

Reading

Homework

7.03.3

Lesson7.03 Elevenslab(Day3)

Objectives

Assessments

InClass ElevensLabActivity2(end)

Reading

Homework Summarizenotessincelastexam

7.03.4

CurriculumMap

59

Page 60: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson7.03 Elevenslab(Day4)

Objectives

Assessments

InClass ElevensLabActivity3(begin)Notebookchecks

Reading

Homework Outlinech13

7.03.5

Lesson7.03 Elevenslab(Day5)

Objectives

Assessments

InClass ElevensLabActivity3(end)Notebookchecks

Reading ReadandoutlineBarronsch8

Homework

7.03.6

Lesson7.03 Elevenslab(Day6)

Objectives

Assessments

InClass ElevensLabActivity4

Reading

Homework Barronsch8exam,self-grade

7.03.7

CurriculumMap

60

Page 61: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson7.03 Elevenslab(Day7)

Objectives

Assessments

InClass ElevensLabActivity5(begin)Barron'schecks

Reading

Homework

7.03.8

Lesson7.03 Elevenslab(Day8)

Objectives

Assessments

InClass ElevensLabActivity5(end)

Reading

Homework

7.03.9

Lesson7.03 Elevenslab(Day9)

Objectives

Assessments

InClass ElevensLabActivity6

Reading

Homework Fixhomework

7.03.10

Lesson7.03 Elevenslab(Day10)

Objectives

Assessments

InClass ElevensLabActivity7

Reading

Homework Fixhomework

CurriculumMap

61

Page 62: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

7.03.11

Lesson7.03 Elevenslab(Day11)

Objectives

Assessments

InClass ElevensLabActivity8Re-gradefixedhomework

Reading

Homework

7.03.12

Lesson7.03 Elevenslab(Day12)

Objectives

Assessments

InClass ElevensLabActivity9(begin)Re-gradefixedhomework

Reading

Homework

7.03.13

Lesson7.03 Elevenslab(Day13)

Objectives

Assessments

InClass ElevensLabActivity9(end)Re-gradefixedhomework

Reading

Homework Submitquestionsforreview

7.03.14

CurriculumMap

62

Page 63: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson7.03 Elevenslab(Day14)

Objectives

Assessments

InClass ElevensLabActivity10Re-gradefixedhomework

Reading

Homework

7.03.15

Lesson7.03 Elevenslab(Day15)

Objectives

Assessments

InClass ElevensLabActivity11(begin)

Reading

Homework

7.03.16

Lesson7.03 Elevenslab(Day16)

Objectives

Assessments

InClass ElevensLabActivity11(end)

Reading

Homework

7.04

CurriculumMap

63

Page 64: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson7.04 Review

Objectives StudentswillidentifyweaknessesintheirUnit7knowledge.

Assessments Studentswillcreateapersonalizedlistofreviewtopicstoguidetonight’sstudysession.

InClass Reviewquestions

Reading

Homework Study

7.99

Unit7Test Searching&Sorting

Guide Test6Guide

InClass Test6SectionITest6SectionII

Unit8:Recursion(2weeks)Unit8SlidesUnit8WordBankCurriculumAssets

CurriculumMap

64

Page 65: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

LP Title InClass Reading Homework

8.00 TestReview&Reteach Reviewtest 12.1upto“Structureof

recursivesolutions”Testcorrections

8.01 ThinkingRecursively

TowerofHanoigame

Restof12.1

8.02WritingRecursiveSolutions

GrudgeballSC12.1-12.4

12.2 SC12.5,12.7-12.9,E12.1

8.03 MechanicsofRecursion

WS8.3TeacherDemo8.3

13.4? SC12.6,12.10,E12.3

8.04 MergeSort ImplementmergeSort

SC13.27-13.30NotebookCheck

8.05 Finding&FixingErrors FixHW Reviewch12.1,12.2

Submitquestionsforreview

8.06 Review Study

8.07 Quiz [Quiz8] Barronsch7

[8.08] QuizReview&Reteach

Reviewquiz Barronsch7

8.00

Lesson8.00 TestReview&Reteach

Objectives Studentswillre-learnorstrengthencontentknowledgeandskillsfromUnit7.

Assessments Studentswillre-submittestanswerswithupdatedcorrectionsforpartialorfullcredit,dependingoninstructorpreference.

InClass Reviewtest

Reading 12.1upto“StructureofRecursiveSolutions”

Homework Testcorrections

8.01

CurriculumMap

65

Page 66: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson8.01 ThinkingRecursively

Objectives Studentswillbeabletodefinerecursion.

Assessments Studentswilldescriberecursivemethodsandcompareiterativeandrecursivemethodsduringaclassdiscussion.

InClass TowerofHanoigame

Reading Restof12.1

Homework

8.02

Lesson8.02 WritingRecursiveSolutions

Objectives Studentswillbeabletoidentifyrecursivemethodsandpredicttheoutput(orreturnvalue)ofrecursivemethods.

Assessments StudentswillevaluatestatementsandpredictoutputduringagameofGrudgeball.

InClass GrudgeballSC12.1–4

Reading 12.2

Homework SC12.5,7–9E12.1

8.03

Lesson8.03 MechanicsofRecursion

Objectives Studentswillbeabletomodelhowrecursivemethodsexecute.

AssessmentsStudentswillwritearecursivemethod,thenmodeltheexecutionofthatmethodfortheinstructor.Studentswillalsomodelamethodwrittenbytheirpeers.

InClass WS8.3TeacherDemo8.3

Reading 13.4

Homework SC12.6,10E12.3

8.04

CurriculumMap

66

Page 67: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson8.04 MergeSort

Objectives StudentswillusemergeSorttosortanArrayList.

Assessments Studentswillbeabletouserecursiontosortalist.

InClass ImplementmergeSort

Reading

Homework SC13.27–30NotebookCheck

8.05

Lesson8.05 Finding&FixingErrors

Objectives Studentswillfinderrorsintheirreturnedhomeworkandclasswork.

Assessments Studentswillre-submitallhomeworkandclassworkassignmentswithcorrectedanswers.

InClass Fixhomework

Reading Reviewch12.1–2

Homework Submitquestionsforreview

8.06

Lesson8.06 Review

Objectives StudentswillidentifyweaknessesintheirUnit8knowledge.

Assessments Studentswillcreateapersonalizedlistofreviewtopicstoguidetonight'sstudysession.

InClass ReviewQuestions

Reading

Homework Study

8.07

Lesson8.07 Review&Quiz

InClass [Quiz8]

8.08

CurriculumMap

67

Page 68: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson8.07 QuizReview&Reteach

Objectives Studentswillre-learnorstrengthencontentknowledgeandskillsfromUnit8.

Assessments Re-submitquizanswerswithupdatedcorrectionsforpartialorfullcredit.

InClass Reviewquiz

Reading

Homework Barronsch7

Unit9:APTestReview(3weeks)CurriculumAssets

9.00

Lesson9.00 ReviewingfortheAPExam

Objectives StudentswillreviewandpreparefortheAPComputerScienceAexam.

Assessments BellevueMasteryTestsAPCS2012SectionII

InClass

Reading

Homework

Unit10:Post-APExamProjects(4–5weeks)

CurriculumMap

68

Page 69: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

WecurrentlyhavetwodifferentcurriculumoptionsforaftertheAPexam,eachofwhichisaself-containedwebsitewithlessons,labsandothersupportingresources:

SpaceBattleArenaTEALSMinecraftModding

CurriculumMap

69

Page 70: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

TEALSAPCSACurriculumAssetsTheTEALSAPCSACurriculumassetsmaybedownloadedfromtheAdditionalCurriculumMaterialssectionoftheTEALSDashboard

[Note:youneedtobeacurrentTEALSvolunteerorclassroomteachertoacesstheTEALSDashboard]

ThelatestversionisTEALS-APCSA-Curriculum-v2.0.2.zip.

Contents/Projects/

/Projects/APCSA-Elevens-v1.X.X.zipTheUnit7ElevensLab.Extractingthisarchive,you'llfindtheTeacherGuide,andthestudent-distributablepackage.GetstartedbyreadingTeacherMaterials/Elevens-Teacher-Guide.pdf.

/Projects/APCSA-FracCalc-v1.X.X.zipTheUnit3FractionalCalculatorProject.Insidethisarchiveyou'llfinddocumentationandstudentstartersourcecode.

/Projects/APCSA-Magpie-v1.X.X.zipTheUnit4MagpieChatbotLab.Insidethisarchiveyou'llfindtheteacherguide,teachersolutionsourcecode,andthedistributablestartercodearchiveforstudents.GetstartedbyreadingMagpie-Teacher-Guide.pdf.

/Projects/APCSA-PictureLab-v1.X.X.zipTheUnit5PictureLab.Thisarchivecontainstheteacherguide,teachersolutioncode,anddistributablestarterpackageforstudents.GetstartedbyreadingTeacherMaterials/pixLab-Teacher-Guide.pdf.

/Projects/APCSA-TextExcel-v1.X.X.zipTheUnit6TextExcelProject.Thisarchivecontainstheteacherguide,teachersolutioncode,anddistributablestarterprojectforstudents.Getstartedbyreadingguides/TextExcelTeacherGuide.docx.

/Unit*/AssetsforeachoftheAPCSAcurriculumunits.Ingeneral,eachWordfilewillhaveacorrespondingPDFequivalent.Worksheetsaregenerallyoftheform"WS#.#.docx"and"WS#.#.pdf".

/Unit1/—AssetsforUnit1:Programming&Java./Unit2/—AssetsforUnit2:WorkingwithData&BasicControlFlow./Unit3/—AssetsforUnit3:AdvancedData&ControlFlow./Unit4/—AssetsforUnit4:Arrays,Lists&Files.

CurriculumAssets

70

Page 71: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

/Unit5/—AssetsforUnit5:Object-OrientedProgramming./Unit6/—AssetsforUnit6:Inheritance&Polymorphism./Unit7/—AssetsforUnit7:Searching&Sorting./Unit8/—AssetsforUnit8:Recursion./Unit9/—AssetsforUnit9:APTestReview.

CurriculumAssets

71

Page 72: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson1.01—UsingEclipse&Practice-ItN.B.THISLESSONISOPTIONAL

Overview

Objectives—Studentswillbeableto…

Describeoneormorecareersrelatedtocomputerscienceandtechnology.Askintelligentquestionsaboutthefieldofcomputerscience.Identify'nextsteps'tolearnmoreaboutcomputerscienceListtheclassexpectationsandwhatisrequiredofthem.

Assessments—Studentswill…

DemonstratePlug-InandUn-PlugproceduresLoginandsubmitasampleprobleminPractice-It

Homework—Studentswill…

Visithttp://www.pokemon.comandplayafewgamesorplayPokémononagamingsystemVisithttp://bulbapedia.bulbagarden.nettofamiliarizeyourselfwiththePokémonfranchise

Materials&PrepProjectorandcomputerStudentComputerswithEclipseinstalledClassroomcopiesofWS1.1.1andWS1.1.2USBDrivesforeachstudent(ifapplicabletoschool)Handout/SlideDeckdemonstratingfilesubmissionprocedure

IfyourschooldoesnothaveadesignatedITspecialistavailabletoinstallEclipseontheclassroomcomputers,WS1.1.1offersstep-by-stepinstallationdirections,withscreenshots.Ifyourstudentshavecomputersathome,orifyourschoolloansthemlaptopsforhomework

Lesson1.01:UsingEclipse&PracticeIt

72

Page 73: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

andlabs,youcanprintoutcopiesofWS1.1.1foryourstudentssotheycaninstallEclipseontheirhomecomputers.

IfyourschooldistributesUSBdrives,modelbestpracticesbywearingyourUSBdriveonyourIDlanyardorkeychain.Studentswillloseand/orforgettheirdrivesunlesstheyareattachedtoanotherobjecttheyusedaily!

Sinceallinstructorshavedifferentpreferencesandrequirementsforfileuploads/sharing,wehavenotincludedaprocedureforfilesubmission.Youshouldprepareahandoutorslidedeckdemonstratingyourprocedureforsubmittingwork,andhavestudentssendyouasamplefiletoassessunderstandingofyourprocedure.10minutesofthislessonhavebeenreservedforyoutoteachtheseprocedures.

PacingGuide

Section TotalTime

Bell-workandattendance 5min

ClassroomIntroductionIcebreakers&Background 20min

Plug-In&Un-PlugProcedureDemonstrationandpractice 10min

Practice-ItAccountsetupandloginpractice 10min

FileSubmissionProcedureDemonstrationandpractice 10min

Procedure

Bell-workandAttendance[5minutes]

ClassroomIntroduction[20minutes]

1. Usingtheslidedeckasabase(editthedecktofityourneeds):

Pollyourclasstolearntheirnames,experience,andrationalebehindtakingthecourse.Gooverbackgroundinformationofthecomputersciencefield.Gooverclassexpectationsandinformation.Touchonschoolrequirements(varies)e.g.syllabus.

Lesson1.01:UsingEclipse&PracticeIt

73

Page 74: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

2. Classicebreakers(variesschooltoschool).

Plug-In&Un-PlugProcedure[10minutes]

1. UsingWS1.1.2,modelthestepsfor:

OpeningEclipseandaworkspaceCreatingandsavingaprogramEjectingtheUSB(ifapplicable)

2. HavestudentsdemonstratethePlugInandUn-PlugproceduresforyoubeforeyoumoveontothePractice-Itexercise.

Ifyourclassroomhasaprojectorhookeduptotheteacher’scomputer,projecteachstepasyoumodelitforthestudents.

Waituntilallstudentshavecompletedastepbeforemovingontoanotherstep.

Expectthisexercisetotake10minutesorlonger.

Practice-It[10minutes]

1. UsingWS1.1.2,modelthestepsforcreatingaPractice-Itaccount.Sinceyouwillprobablyalreadyhaveanaccount,selectastudentaccounttouseasamodel.

2. HaveallstudentssubmitaPractice-ItproblemtodemonstratethattheyknowhowtousePractice-It.

Waituntilallstudentshavecompletedastepbeforemovingontoanotherstep.

Ifyouhaveextratimeinclass,introducea“ScavengerHunt”onPractice-It,andhavestudentsfind:

WheretheiraccountinformationislocatedWherearecordoftheircompletedproblemsarelocatedWherethe3rdSelf-CheckproblemforChapter7islocated

FileSubmissionProcedure[10minutes]

1. Demonstrateyourprocedureforfilesubmission.Useahandoutorslidedecktoillustratethisprocedure.

2. Havestudentssendasamplefiletoassessunderstandingoftheprocedure.

AccommodationandDifferentiation

Lesson1.01:UsingEclipse&PracticeIt

74

Page 75: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Allowstudentstoworkinpairsiftheyarehavingtroubleunderstandingthedirections.Encouragepairstomodelthecorrectprocedureforeachother.Studenthelpersshouldpointtoareasonthescreenratherthantypingorusingthemousetocompletetheaction.

TeacherPriorCSKnowledgeIDEs(IntegratedDevelopmentEnvironments)arewidelyusedinindustrytodevelopsoftware.PriortoIDEs,softwareengineersusedsimpletexteditorstowriteprograms.WhileteachersarewelcometochoosefromawidevarietyofIDEs(seehttps://jaxenter.com/the-top-java-ides-114599.htmlforacomparison)orevenusetexteditors,TEALSsupportsEclipseintheAPCSAcurriculum.WhicheverIDE/editoryouchoose,it’sagoodideatorunthroughafewIDEtutorialstofamiliarizeyourselfwiththeworkflowbeforedemonstratingtotheclass.

TeachingTipsTipsforVolunteers:http://csteachingtips.org/Tips-for-classroom-volunteers

TipsforReducingBias:http://csteachingtips.org/tips-for-reducing-bias

ClassIntroduction:Studentswillendupinyourcomputerscienceclassforavarietyofreasons,hereafewthatarecommon:

MymathteacherrecommendedItakecomputerscienceMyfriendisintheclassIlikecomputersItfitinmyscheduleItshowedupinmyscheduleIt’sanAPclassandwouldlookgoodonmytranscriptIbuildappsinmysparetime

Byknowingthestudent’smotivation,youcanbetterunderstandwherethestudentiscomingfrom.Iusethisinformationtoinformthepaceanddepthoftheinitiallessons.Ialsotrytodeterminethelevelofprogrammingexperienceofeachstudent.Thishelpswithgroupformationinthebeginninglessonswhereyoutrytopairexperiencedstudentswithlessexperiencedstudentstothestudentscanlearnfromtheirpeers.

Misconceptions

Lesson1.01:UsingEclipse&PracticeIt

75

Page 76: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

WhenintroducingtheJavaprogramminglanguage,manystudentswillthinkJavaissynonymouswithJavaScript.Althoughbothareprograminglanguagesandmanyoftheconstructsaretransferablebetweenthetwolanguages,JavaandJavaScriptaretwodifferentlanguages.JavaScriptisusedtodayforbothclientsidewebbrowserscriptingtowebservers.JavaisusedtocreateplatformindependentappsmeaningaprogramwritteninJavawillrunacrossavarietyofoperatingsystems.

ForumdiscussionLesson1.01UsingEclipse&Practice-it(TEALSDiscourseaccountrequired)

Lesson1.01:UsingEclipse&PracticeIt

76

Page 77: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson1.02—Algorithms&ComputationalThinking

Overview

Objectives—Studentswillbeableto…

Definealgorithms,programs,hardware,software,andoperatingsystems.Describetherelationshipsbetweentheseconceptsandcomponents.

Assessments—Studentswill…

WritesamplealgorithmsAssembleanddebugaprogramthatdirectstheinstructortomakeasandwich

Homework—Studentswill…

ReadBJP1.2

Materials&PrepProjectorandcomputerORwhiteboardandmarkerFooditemsforpeanutbutterandjellysandwichUtensilsforsandwichassembly(spoonforjelly,knifeforspreading)Wetwipesorwatertocleanhands

PacingGuide

Lesson1.02:Algorithms&ComputationalThinking

77

Page 78: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Introductiontovocabulary 10min

Explainingactivity,assigningpairs 2min

ActivityRoundOne 10min

ActivityRoundTwo 10–15min

Full-classdiscussionofdebuggingmethods 5min

HWdistribution&exittickets 2min

Procedure

Bell-workandAttendance[5minutes]

IntroductiontoVocabulary[10minutes]

Inthislesson,youwillbeusingyourselfasthemetaphortointroducefundamentalvocabularyinCS.Asahook,youshouldleaveallofthefoodprepmaterialsconspicuouslylaidoutinthefrontoftheclassroom,withoutanyexplanation.

1. Youshouldbeginyourlessonwithaninformal,whole-groupconversationabouthumansbeingthefirst“computers.”Thisisagreatopportunitytousehistory,women’saccomplishmentsinCS,andhumortoofferupanddrillvocabularywithoutonerousrepetition.Somesuggestionsforyouropeningdiscussion:

Computerwasoriginallyajobdescription,andwasfirstusedin1613todescribesomeonewhoperformsmathematicalcalculations.

Earlycomputersweremostlywomen:

Lesson1.02:Algorithms&ComputationalThinking

78

Page 79: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

http://www.officemuseum.com/IMagesWWW/Early_1920s_Veterans_Bureau_Calculating_WWI_Vet_Bonuses_LOC.JPG).

Humancomputershavemanysimilaritiestomechanicalcomputers.Seehowmanyoftheseyourstudentscanpredictwithminimalprompting:

Brain=CPUandprocessingInput=information(data)fromsensingtheenvironmentSensors=eyes,ears,nose,mouth,fingers/skinOutput=behavior,action

Youcanmodelerrorsandexceptionsbydramaticallynarratingandactingoutaconfusingsetofdirectionsandtheresultantmistake.Dependingonyourpersonalstyle,thiscanbeapratfall,embarrassingsocialblunder(realorimagined),orsimplespellingmistake(input:soundingoutawordwithsilentletters,error/output:themisspelledword)

2. Introducethedefinitionofanalgorithm,andinvitethestudentstowriteanalgorithmforyou,thecomputer,tomakeapeanutbutterandjellysandwich.

Analgorithmmaybedefinedas“aprocessorsetofrulestobefollowedincalculationsorotherproblem-solvingoperations”

ExplainingActivityandAssigningPairs(2minutes)

Lesson1.02:Algorithms&ComputationalThinking

79

Page 80: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Givestudentpairs5minutestowriteapeanut-butter-and-jellyalgorithm.Specifythattheyshouldwriteacompletesetofdirectionstodescribetheprocessofmakingthesandwich.

ActivityRound1(10minutes)

1. Askforastudentvolunteertocometothefrontoftheclassroomto“beJava.”

2. Randomlychooseastudent’salgorithmforyourfirsttry,andnarrateas“Java”picksupthe“program”toreadtoyou(thecomputer).PointoutthatwhenJavareadscode,itscompilertranslatesthecodeyoutypeinsothecomputercanreaditinbinary.Bonuspointsifyoucangetthevolunteertoreaddirectionsinaroboticvoice.

3. Askyourstudentvolunteerreadsthedirectionsaloud,followinginstructionsliterally.Repeattheinstructionoutloudasyoumodeltheaction.Usuallystudentsforgettotellyoutoopenthebagofbread,etc.Hamuptheerrors,andstop“executingtheprogram”whenitbecomesclearthatthealgorithmwon’tresultinafunctionalPB&J.Pointoutthatthisisanerrororexception—yourprogramdoesthesamethingwhenitgetsinstructionsthatdon’tmakesense.

4. Repeatthiswith1or2otheralgorithms,thengraciouslyagreetolettheclasstryagain.Makesuretousethephrase“debugging”andhavethestudentsuseitaswell.

ActivityRound2(10–15minutes)

1. Givestudentsanother5minutestocorrecttheiralgorithms.Ifstudentsareon-taskandreallygettingpassionateaboutthejob,givethemafewextraminutes.

2. Have“Java”selectanother“program”fromyourstudents.Asyouexecutetheprogramagain,asktheclasswhatrepresentshardware,software,input,output,processing,andtheprogram.

Full-classDiscussionofDebuggingMethods(5minutes)

1. Askstudentstosharethedifferentwaystheydebuggedtheircode/program/algorithm.(Changingprogramcontent,switchingalgorithmorder,etc.)

2. GivestudentswithsuccessfulalgorithmsthevariousPB&Js(failedandotherwise).

HomeworkDistributionandExitTickets(2minutes)

Distributehomeworkandhavestudentscompleteexittickets.

Lesson1.02:Algorithms&ComputationalThinking

80

Page 81: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

AccommodationandDifferentiationBeforedeliveringthislesson,youshouldcheckwiththeclassroomteachertomakesurenoneofthestudentshaveapeanutallergy.Ifastudentdoeshaveanallergy,findouthowseveretheallergyis(youcanopttomakethisstudentajellysandwich,butiftheallergyissevere,youshouldswitchthedemotoanotherfooditem).

Incertainclassrooms,peanutbutterandjellymightnotbeafamiliarfooditem.Inthesecases,itisbesttodosomeresearchfirsttofigureoutwhatsnackwillbefamiliarenoughtoallyourstudentsthattheycanrecommendanalgorithmforpreparingit.Someitems(suchasNavajofrybread)mightrequireadditionalplanning.Formaximumengagement,trytoselectasnackthat:

Requires3ormoreingredientsRequiresassemblyorpreparation(suchaspeeling,dicing,etc.)UsesingredientsthatarejarredorwrappedAregenerallyconsideredpalatabletomoststudents

InELLclassrooms,youshouldpairstudentstoeasethewriting/compositionburdenofthisactivity.Foradvancedstudents,invitethemtowritealgorithmsforotheractivities,suchasgettingtoschoolontime.

TeacherPriorCSKnowledgeAlgorithmsareoneofthefundamentalconceptsincomputerscience.Algorithmsarefundamentaltosolvingproblemsincomputerscience.

Thelessonplanusesanalogyofthestudentasthecompiler.WhenwritingaJavaprogramthefollowingisthesequenceoffilesandtranslationsthatarecarriedout:

1. ProgrammerusesaneditortocreateJavaprogramandsavesin.javafile

2. Javacompiler(javacprogram)takes.javafileandcompliescodetobytecodeandsavesin.classfile.

3. Javavirtualmachine(javaprogram)runs.classfilebyinterpretingthebytecodeforaspecificmachinebasedontheoperatingsystemandhardware.

Thelessonplanassumestheteacherhaspriorknowledgeofthecomponentsofaphysicalcomputerandcanrelatethemtoaperson.Ifyouarenotfamiliarwiththecomponentsofacomputersystem:

CPUcentralprocessingunit–brainsofthecomputer

Lesson1.02:Algorithms&ComputationalThinking

81

Page 82: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Diskdrive/SSD–longtermstorageRAMrandomaccessmemory–shorttermstorageKeyboard,mouse,touchscreen–inputdevicesDisplay,sound,vibration–outputdevices

TeachingTipsTipsforLecturing:http://csteachingtips.org/tips-for-lecturing

TipsforIntroducingComputerScience:http://csteachingtips.org/Tips-for-introducing-computing

Thelessonplanhastheteacherbethe“computer”thatfollowstheinstructionsreadaloudbythestudent.Youmaybeinclinedtohaveastudentbethecomputer.However,studentsareunpredictableandyoumayormaynotgettheoutcomesyoudesire.Eventhoughthisactivityismeanttobeplayful,studentsillinesscangetoutofhandwhenbuildingtheirP&Jsandwich.Ifyoudochoosetohavestudentsbethecomputer,setupnormslikenothrowingfoodandtheymustcleanupafterthemselves.

Otheralgorithmsyoucanhavestudentswriteincludetyingshoelaces,brushingteeth,openingalocker.

MisconceptionsSometimesstudentsthinkalgorithmsandcomputerprogramsaresynonymous.Whiletheyarerelated,theyarenotsynonymous.Humanshavebeenusingalgorithmstosolveproblemswaybeforecomputereverexisted.Theinventionofthecomputercreatedaplatformforalgorithmscreatedthatcouldbecarriedoutbyamachine.Soacomputerprogramisatoolusedbypeopletoexpressesalgorithmsthatcanbeexecutedbyacomputer.

ForumdiscussionLesson1.02AlgorithmsComputationalThinking(TEALSDiscourseaccountrequired)

Lesson1.02:Algorithms&ComputationalThinking

82

Page 83: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson1.03—String&ConsoleOutput

Overview

Objectives—Studentswillbeableto…

DescribethehistoryofcomputerscienceandJavaandwhythey'reusedtoday.Correctlyassembleacompleteprogramwithaclassheader,body,andmainmethod.Correctlyuseprint,println,andescapesequences.

Assessments—Studentswill…

CreatestarterPokémonprogramCompleteseveralPractice-Itquestions

Homework—Studentswill…

ReadBJP1.3CompleteCh.1exercises1-5

Materials&PrepProjectorandcomputerWhiteboardandmarkerASCIIPokémonart

Pokéball:http://tinyurl.com/pba5x8rPikachu:http://tinyurl.com/oa3g2al

Practice-Itbookmarks(installedonstudentcomputers,ifpossible)

Ifyoudonothaveaprojectorinyourclassroom,printoutpicturesoftheASCIIart,andplacethemaroundtheroom(orondesks)forstudentstopassaround.Makesureyouprintpicturesoutlargeenoughsothatstudentscanseethecharactersthatmakeuptheartwork.

PacingGuide

Lesson1.03:String&ConsoleOutput

83

Page 84: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Introductiontovocabularyandsyntax 10min

Signingup/intoPractice-It 10min

Practice-Itquestions 15min

Pokémonchallenge 10min

Studentstradeworkanddebug 5min

ProcedureInthislesson,youwillintroducethepartsofaprogram,thenhavestudentscreatetheirfirst“HelloWorld”styleprogram.Yourhookforthisclassis2-fold:(1)youshouldpumpupthestudentstowritetheirveryfirstprogramever!(2)HavesamplesofASCIIartavailableforthemtoview,andletthemknowthattheywillbecreatingtheirownpicturestodayaswell.

Bell-workandAttendance[5minutes]

IntroductiontoVocabularyandSyntax[10minutes]

1. BeginyourlecturewithaquickoverviewofJavaandwhywe’reusingit.

BriefhistoryofJavaKeycharacteristicsofJava

2. Lectureonthefollowingtalkingpoints.Studentsshouldbeabletoleadyouthroughthesepoints,asyouarereviewingthematerialsfromthereadingtheycompletedforhomework:

Javaprogramsalwaysbeginwithaclassheader,whichfollowstheserules:Startswith“publicclass”(publicbecauseanyonecanaccessit)Usesacapitalizedname,andalwaysstartswithaletterEndswithanopencurlybracket(thinkofthecurlybracketsasaboxthatholdsbitsofcodetogether;showstudentswheretheclosecurlybracketgoes)

3. Havestudentsvolunteerseverallegitclassheaders,deliberatelymakemistakesforstudentstocatch(suchasleavingoutabracket,capitalizingincorrectly,orstartingclassnamewithanumber).

Ifyourstudentsarehavingtroublegeneratingclassheaders,guidethemthroughthefollowingexamples:

Lesson1.03:String&ConsoleOutput

84

Page 85: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

publicclassMyFile{→correct!PublicclassMyFile{→incorrect,publicshouldbelowercasepublicClassMyFile{→incorrect,classshouldbelowercasepublicclassMyfile{→correct,butnotaseasytoreadfilenamepublicclassWhateverIWant{→correct!publicclassThisWorks2{→numbersareOK!

4. Explainthatthe“meat”oftheprogramcomesfromthemethods(thepartsoftheprogramthattellJavatoexecuteaparticularactionorcomputation)

Youalwaysneedamainmethod,whichstartswithamethodheader:

publicstaticvoidmain(String[]args){

Explicitlypointoutthat:

Thisisanonsenselistofwordsfornow,butthatwe’llreturntowhateachpartmeanslateronCurlybrackets“holdthecodetogether”,andsotherewillalwaysneedtobeaclosedcurlybracketattheendofthemainmethod,justlikethere’saclosingcurlybracketfortheclass

5. Askstudentstovolunteerashortphrasethattheywouldlikefortheirveryfirstprogramtosay(asin"Hello,World!")andusethisphraseinyourfirstprintlnstatement.

Pointoutthatthestatement:

AlwaysendsinasemicolonRepresents1completeorder/commandTellsJavatoprintthewordswithinthequotationmarks,thengotothenextline(ln)

Havestudentscheckthecodeyou’vewrittendownontheboard.Withtheclass,modelhowtocheckcodebyscanningeachline,characterbycharacter,havingstudentsoffertherulesforclassandmethodheaders/body,andstatements.

Erasethe“ln”fromyourprintstatement,andaskstudentstoguesswhatJavawilldowiththatcode(itwon’treturnafteroutputtingthestring).

Finally,bringstudents’attentiontoescapesequences,andaddsomequotationmarkstoyoursamplecodeasanexample.

SigningUp/IntoPractice-It[10minutes]

Lesson1.03:String&ConsoleOutput

85

Page 86: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

WalkyourstudentsthroughPractice-Itaccountsign-up.Studentswillneedaccesstotheiremailaccountstocompletesetup.(Ifyourclassroomdoesnothavecomputers,transferPractice-Itquestionstoaworksheet,andhavestudentscompletethepracticeproblemsbywritingouttheanswers.)

Practice-ItQuestions(15minutes)

HavestudentscompletethefollowingPractice-Itquestions:

1. legalIdentifiers2. outputSyntax3. confounding4. Archie5. downwardSpiral6. DoubleSlash7. Sally8. TestOfKnowledge

PokémonChallenge(10minutes)

Ontheboardorprojector,postthefollowingchallenge:

WriteaprogramcalledWelcomethatoutputsthefollowing:

PikachuwelcomesyoutotheworldofPokémon!

(\__/)

(o^.^)

z(_(")(")

StudentsTradeWorkandDebug(5minutes)

Havestudentstradetheirworkanddebugeachother’sprograms.

IfEclipseisavailable,havestudentsmailyoutheircompletedprogramusingthefilesubmissionprocedureofyourchoice.Otherwise,havestudentssubmitahandwrittenformAFTERtheyhavetradedtheirpaperwithafriendtocheckanddebug.

AccommodationandDifferentiationIfstudentsarestrugglingwiththePokemonchallenge:

Lesson1.03:String&ConsoleOutput

86

Page 87: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

TrypairingupstudentssotheycancheckeachotherastheyworkWritethefirstlineofPikachucodetogetherasaclass,modelingtheuseofescapesequences

Ifyouhavestudentswhoarespeedingthroughthislesson,youshouldencouragethemto:

AddadditionalpicturesortexttotheirWelcomeprogram,Helpastudentthatisstrugglingwiththematerial,Createaposterfortheclassroomwithsteps(analgorithm!)forcheckingcodeforerrors(manytipscanbefoundin§1.3).

AboutPokemonThroughouttheAPCScurriculum,wewillgraduallybebuildingalargerprogramaroundPokemon,whichis:familiartomaleandfemalestudentsfromallsocioeconomicbackgrounds,availableacrossthedigitaldivideasbothacardgameandavideogame,andhasbeentranslatedinto10differentlanguages(English,Spanish,Portuguese,Dutch,French,German,Italian,Korean,Chinese,andJapanese).

Becausethegamereliesonstatistics,modulooperators,andtheunderlying32-bitintegerthatcharacterizesanygivenPokemon,wewillbeusingthisthemetointroducestudentstomuchoftheAPCScurriculum.StudentswillbeenteringtheAPCScoursewithvaryingdegreesofmathliteracy,andframingmathematicalchallengesinthisfamiliarframeworkishelpfulforavoidingstereotypethreatandmathanxiety.

TolearnmoreaboutthePokemonstoryline,gamerules,underlyingformulae,andcharacters,visithttp://bulbapedia.bulbagarden.net.

TeacherPriorCSKnowledgeThe“Helloworld!”programistheclassicfirstprogramtaughtformanybeginnerprogrammingclasses.Itdemonstratesthesimplestwaytogetoutputfromtheprogramtotheuser.TheJava“Helloworld!”programischockfullofsyntaxheavyconstructsthatwouldnotbeparticularlyusefulandundulycomplicatedtoafirst-timelearnertoJava.However,knowingtheseconstructsareinformativetotheteacher:http://www.learnjavaonline.org/en/Hello%2C_World%21.

TeachingTipsTipsForPairProgramming:http://csteachingtips.org/tips-for-pair-programming

Lesson1.03:String&ConsoleOutput

87

Page 88: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

TipsForLabRules:http://csteachingtips.org/tips-for-lab-rulesExplaining“publicstaticvoidmain(String[]args)”wouldbeoverwhelmingformostbeginningJavastudents.It’simportanttoletthestudentsknowthatbytheendofthecoursetheywillknowwhatthelinemeansbutfornowalltheyneedtoknowistostartaJavaprogram,itneedsthisonelineofcode.

MisconceptionsStudentslearnbymakingconnectionstopriorknowledgetheyalreadyknow.Unfortunately,thismaybackfireasinthecaseofthekeywordclass.Whencomputerscientistsusethewordclass,itisautomaticallyassumedthatoneisreferringtoclassinthecontextofobjectorientedprogramming.However,foratypicalhighschoolstudent,classmeanssomethingtotallydifferent:whatclassamIinnow,whathomeworkdoIhaveformathclass,orwhoistheteacheroftheclass.Evenifthestudenthaspriorprogrammingknowledge,theymaynotbefamiliarwiththenotionofaclasswithrespecttoOOP.

VideoCSE142,HelloWorld(29:24–36:09)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=dd78a77d-cd7a-4ff8-b853-5446801946fb&start=1765

ForumdiscussionLesson1.03StringConsoleOutput

Lesson1.03:String&ConsoleOutput

88

Page 89: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson1.04—CommonErrors&Comments

Overview

Objectives—Studentswillbeableto…

Createsimpleprogramswithcommentsandstyle.Listandapplythestepsnecessaryforavoidingsyntaxerrors.

Assessments—Studentswill…

CompleteaworksheetDevelopapersonalchecklistforspottingsyntaxerrors

Homework—Studentswill…

ReadBJP1.4CompleteCh.1Exercises6,7,9

Materials&PrepProjectorandcomputer(ifyouareableto/opttouseEclipsewithyourstudents)WhitepaperandmarkersClassroomcopiesofWS1.4Samplepunchedcardtopassaround(availableoneBay:http://tinyurl.com/nnthazu)Pictures:

Punchcards(http://tinyurl.com/n9zqd3k)Readers(http://tinyurl.com/p34mvmb)Jaquardloom(http://tinyurl.com/n8tmra3)Bug(http://tinyurl.com/ljyguuy)

Ifyouareabletolaminatestudentwork,orhaveplasticsleevesavailableforstudentsthathavebinders,itwouldbeagoodideatoreinforce/preservestudenterror-correctionalgorithms(seetoday’sActivity).Studentsshouldbereferringtothesesheetsofteninthefirstfewmonthsofthecourse,sotheywillgetalotofwear&tear.

Lesson1.04:CommonErrors&Comments

89

Page 90: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Vocabularyandhistoryofbugs 10min

Error-checkingalgorithm 10min

Worksheet 15min

Studentstradework,check,andturnin 5min

ProcedureToday’slessonwillbeacombinationofdrillingthepartsofabasicprogram,andconditioningstudentstocheckforcommonerrors.Tohookyourclass,havepicturesofpunchcardsandpunchcardreadersupwhenstudentsenter.Ifpossible,havephysicalpunchcardsavailabletopassaroundtheroomfortactilelearnersasyouexplaintheoriginsofthephrase“bug”and“debugging.”

Bell-workandAttendance[5minutes]

VocabularyandHistoryofBugs[10minutes]

Beginwithalectureaboutthehistoryofcomputingwithpunchcardsandtheoriginsof“bugs.”

Beforecomputershadkeyboardsortouchscreens,alldatawasinputusingphysicalpunchcards(passaroundcards).Insomesystems,punchcardswereusedallthewayupthroughthe1980s!

Theholesinthecardsrepresenta“0”andthelocationswithoutaholestorea“1.”

Punchcardswereoriginallydesignedforuseinamechanicalloominventedin1801(showpicturesofloom&tapestrydesign).

Whensomethingwasn’tworkinginthephysicalpunchcardsthatcodedtheprogram,userswouldlookforactualbugsinthesystem(showbugpicture).

Nowadays,sinceallofourcodeisdigitallystoredas0sand1s,a“bug”meanswewrotethecodeincorrectly.Todaywe’regoingtocreatechecklistsofthingstolookforinourcodetomakesureitsworkingcorrectly—or“debugging”ourcode.

Lesson1.04:CommonErrors&Comments

90

Page 91: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Syntaxerrors—whenyoudon’tfollowtheorderingrulesofwritingJavacode,whenyoumisspellsomething,orleaveoutpunctuation.

Analogy:inEnglish,wesay“theblackbear.”InSpanish,you’dsay“elosonegro,”andinItalian“l’orsonero,”bothtranslateto“thebearblack.”Therearedifferentrulesforhowyouorderyourwordsindifferentlanguages,andJavahasitsownsetoflanguagerulestoo.Ifyouwritetheequivalentof“thebearblack”inJava,Javawon’tunderstandit,andyou’llgetanerrormessage.(Havestudentsgiveyouanexample.)

Youcanalsocreateconfusionbywriting/saying“thebalckbear”(amisspelling),or“the!black,bear?”(incorrectpunctuation)

Logicerrors—sometimesyoumightwritecodethathastherightsyntax,butdoesn’tdowhatyoumeantforittodo.Inthiscase,theprogramwillrun,butyouwon’tgettherightoutput.Anexampleofthiswouldbeifyouwroteaprintstatementinsteadofaprintln.

Runtimeerrors—theseerrorscanhappenifyougiveJavaacodethathasnosolution,oraccidentallycausesthecomputertocalculateaninfiniteloop.

Insciencefiction,thisisusuallythewaytoshutdowntheevilcomputerthathascomealivetotakeoverhumanity.ExamplescouldbeaskingJavatocalculatepitothelastdigit,ordividingbyzero.Ifyouwanttoshareexampleswithyourclass,navigatetothiscuedStarTrekvideoclip:(https://www.youtube.com/watch?v=5VZRdAUbgCk&feature=youtu.be&t=1m9s),orinvitestudentstoscanthroughthislist:(http://tvtropes.org/pmwiki/pmwiki.php/Main/LogicBomb).

Error-CheckingAlgorithm[10minutes]

1. Havestudentsdistributepaperandmarkerswhileyouexplainthatstudentsaregoingtocreateapersonalalgorithm(orspecificlistofsteps)thattheywillfolloweachtimetheywritecode.Asamplealgorithmmightlooksomethinglikethis:

STEP1:Checkallcodeforspellingerrors.STEP2:Checkallcodeforpunctuationerrors(curlybrackets,brackets,parentheses,semicolons).STEP3:Checkallcodeforsyntaxerrors.…

2. Encouragestudentstowritethealgorithmasachecklist,decisiontree,ormindmap.Explicitlycontrasttheflexibilityofthehumanbrainwhencomparedtocomputers.

Lesson1.04:CommonErrors&Comments

91

Page 92: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Encouragecreativityhere—somestudentsmaycolorcodetheirlist,ortaketheassignmenthometoworkonlettering,illustrationetc.Whatmayfeellikewastedtimeisactuallyaspatialandtactileactivitythathelpsstudentsreinforceandmemorizethestepsneededtocheckcode.Themoreownershipstudentstakeofthislist,themorelikelytheyaretouseitoverthenextfewmonths,whichwillmakeerror-checkinghabitual.

3. Ifyoudonothaveclassroomcopiesofthetextbook,listthefollowingerrorsontheboardasrequiredstepsforstudentstohaveontheircode-checking“algorithm.”Ifyoufeelthatyouhaveenoughtime,havestudentsputtheseontheboard.

FilenamematchesclassnameAllcodeisspelledcorrectlyAllcodeiscapitalizedcorrectlyAllstatementsendinasemicolonKeywordsareincludedStringsareenclosedin“quotationmarks”TherearenoextrapunctuationmarksAllheaderopen-bracesarepairedwithclosed-braces

Worksheet[20minutes]

1. For5minutesgooverdocumentationandpropercommenting.Alsogooveridentifiers,camelCase,anddoashortintroductiontostyle.Stylewillbecoveredin1.08,butit’simportantthattheyareintroducedtoithere.

2. Studentshave15minutestocompleteWS1.4.Astheysolveeachproblem,studentsshouldapplytheirpersonalproofreadingalgorithmtohelpchecktheirsolutionforcorrectness.

Studentstradework,check,andturnin[5minutes]

Attheendofclass,havestudentstradetheirworksheetstocheckeachother’sanswersbeforeturningintheworksheet.

AccommodationandDifferentiationWhileallstudentsshouldwritetheirOWNalgorithm,youshouldencouragestudentstoworkinpairsorsmallgroupssotheycanshareideasandhelpeachotherorganizetheirthoughts.ThisisparticularlyimportantinELLclassrooms,whereemergentEnglishspeakers

Lesson1.04:CommonErrors&Comments

92

Page 93: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

canpairwithadvancedEnglishlearners.Ifsomestudentswanttodothisprojectallontheirown,letthem.

Ifyouhavestudentswhoarespeedingthroughthislesson,youshouldencouragethemto:

CreateamnemonicoracrostictorememberallthestepsforcheckingsyntaxerrorsMakeaposterfortheclassroomillustratingthemnemonicoracrosticHelpanotherstudentwiththeworksheet(explain,notsolve-for-them)

AboutErrorCheckinginEclipseIfyouareabletouseEclipsewithyourstudentsduringthisclassperiod,youmayopttoshowyourstudentshowtointerprettheerrorindicator.

IfyoudogiveyourstudentstheEclipsetoolsatthistime,bewarethatyourstudentswillprobablycopyandpastebetweenEclipseandPractice-It.Onsomesystems,thismaytranslatethespancharacterintoaUnicodespacecharacter.ThiswillcausecodethatworkedinEclipsetoproduceerrorsinPractice-Itorviceversa.Toavoidstudentfrustration,besuretodemonstratehowtocorrectcopied/pastedcodebeforesubmittingtoPractice-It.

TeacherPriorCSKnowledgeFindingerrorsinbothyourowncodeandinstudents’codetakespractice.Iteasyforstudentstogetfrustratedbecausetheircodedoesnotcompileorproducethecorrectoutput.Theywillinevitablecometoyouforhelp.Asyoubecomemoreexperienced,youwillseethesametypesoferrorsbeingrepeatedbymultiplestudents.YouwillbegintorecognizewhattypeofstudentmistakescorrespondtotheJavaerrormessage.

TeachingTipsTipsforEncouragingHelpSeeking:http://csteachingtips.org/tips-for-encouraging-help-seeking

Partoftheaccommodationsisto“encouragestudentstoworkinpairsorsmallgroups”.Whileitisconvenienttogroupstudentsbyproximity,thisdoesnotalwaysleadtogroupswherestudentsarehelpingotherstudents.Asyougettoyourstudents’abilitiesandpersonalities,youcandeliberatelycreategroupstohelpfostercollaboration.Here’safewwaysyoucancreategroups:

Lesson1.04:CommonErrors&Comments

93

Page 94: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Bystrengthwiththestrongerstudentswithotherstrongerstudents,weakerstudentswithweakerstudents

Mixedgroupswithdifferentlevelsineachgroup,ideallynotallthestrongorweakstudentsinthesamegroup.

Randomwhereyouhaveaprogramthatgeneratesrandomgroupswhereyoukeepgeneratingsothetwostudentsthatneedtobeseparatedarenotinthesamegroup.

MisconceptionsWhentroubleshootingstudenterrors,it’simportanttodistinguishbetweensyntaxerrorswhichisproceduralinnatureanderrorsinthealgorithmwhichrequirescorrectioninthelogicofthesolution.Inthebeginningwheretheproblemsarerelativelyeasilytosolve,studentswillhavemostlysyntaxerrorslikemisplaced/missingsemi-colons.Itisimportanttonotalwaysjumptofindingthesyntaxforthestudentbuttohavestudentspracticegoodcodingstylewithproperindenting.Studentsneedtoknowfromthebeginningthatitiscommonifnotexpectedthatsyntaxerrorsarejustpartoftheprocessofwritingcodeanditdoesnothavetobeprefectthefirsttime.

VideoCSE142,CommonErrors(36:10–44:11)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=dd78a77d-cd7a-4ff8-b853-5446801946fb&start=2170

ForumdiscussionLesson1.04CommonErrors&Comments(TEALSDiscourseaccountrequired)

Lesson1.04:CommonErrors&Comments

94

Page 95: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson1.05—StaticMethods&MethodCalls(1/2)

Overview

Objectives—Studentswillbeableto…

Useproceduraldecompositiontoplancomplexprogramsusingstructurediagrams.Managecomplexitybyusingmethodcalls

Assessments—Studentswill…

CompletePractice-Itproblems

Homework—Studentswill…

ReadBJP1.5CompleteCh.1Exercises11,12,14,16

Materials&PrepProjectorandcomputer(ifyouareableto/opttouseEclipsewithyourstudents)WhiteboardandmarkerOverlycomplicateddiagram(http://tinyurl.com/y8a7cry)

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Introductionandnote-taking 15min

Practice-Itquestions 25min

Studentstradework,check,andturnin 5min

Lesson1.05:StaticMethods&MethodCalls(1/2)

95

Page 96: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ProcedureThisclassintroducesmanynew,intertwinedconceptsinoneclassperiod.Theseconceptswillbere-taughtinthenextclass,butyoushouldbeawarethatyourstudentshavealotofinformationtoabsorbinashortamountoftime.Thislessonwillbeagoodlitmustest—ifstudentshavebeendoingtheirreadingandhomework,theclassshouldmovealongsmoothly.Ifstudentsarenotcompletingthereadings,youwillprobablyonlygetthrough~50%ofthematerial.Ifneeded,usethisopportunitytoconvincestudentsofthepaceandcommitmentlevelrequiredfortheclass.

Bell-workandAttendance[5minutes]

IntroductionandNote-Taking[15minutes]

1. Havethecomplicatedalgorithmupontheboard,orprintedoutforstudentstopassaround.Ifyouhaveanyconfusingfurnitureassemblymanuals,oroverlycomplicateddirections,bringthosetopassaroundtoo.

Startclassoffwithawholegroupdiscussionaboutwhytheinstructionsordiagramsareconfusing,andaskstudentswhatstrategiescouldbeusedtomakethemeasiertounderstand.ThediagramlistedinmaterialsisanactualslidefromthePentagon,andillustrateshowtoomuchcomplexitycancauseallmeaningtobelost.Guidetheconversationtowardsdecompositiontobeginyourlecture:

Decomposition:dividingaproblemintosmaller,moremanageablepieces.Proceduraldecomposition:dividingawholeprogramintoaseriesofindividualstepsoractionstoprogram1atatime.Structurediagram:awayoforganizingyourapproachtobuildingalargerprogram.Askstudentstohelpyoudrawastructurediagramforaprogramwiththeoutputshownbelow:

Lesson1.05:StaticMethods&MethodCalls(1/2)

96

Page 97: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

OUTPUT:STRUCTUREDIAGRAM:

+-------+StackedBlocks

||.'.

||.''.

+-------+.''.

.''.

+-------+.''.

||DrawABoxInsertaBlankLine

||.''.

+-------+.'`.

.'`.

+-------+.'`.

||.'`.

||DrawaHorizontalLineDraw2VerticalLines

+-------+

2. Havestudentstake3minutestowritetheDrawBoxesprogramthelongway:

publicclassDrawBoxes{

publicstaticvoidmain(String[]args){

System.out.println("+-------+");

System.out.println("||");

3. Pointouttostudentsthatanythingtheywouldcutandpastetosavetimeoncreatingwouldmakeagoodunittoturnintoa“staticmethod”

Staticmethod—ablockofJavastatementsthatisgivenitsownname(askstudentstopointtoaJavastatement)

Hasthesamestructurewe’refamiliarwithfromthemainmethodwealreadywrote,butwegiveitadifferentnamethan“main”.

4. Askstudentswhatsimpleunitweshouldbuildintoastaticmethod(havethemrefertothestructurediagram),andhavethemsuggestanameforthemethod.

5. Rewritethemethodasaclass,thenshowstudentshowtowritemethodsinmainthatcallthenewstaticmethod.Makesurethatstudentsinserttheprintlnstatementsbetweeneachmethodcall.Itshouldlooksomethinglikethis:

Lesson1.05:StaticMethods&MethodCalls(1/2)

97

Page 98: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

publicclassDrawBoxes3{

publicstaticvoiddrawbox(){

System.out.println("+-------+");

System.out.println("||");

System.out.println("||");

System.out.println("+-------+");

}

publicstaticvoidmain(String[]args){

drawBox();

System.out.println();

drawBox();

System.out.println();

drawBox();

}

}

6. Callonastudenttocometotheboardandphysicallytracetheflowofcontrolwiththemarker.StartthemoffbypointingoutthatJavaalwaysstartswiththemainmethod.

Ifthestudentseemsnervous,encouragetherestoftheclasstocalloutdirectionstothestudent.Makesurestudentsaredrawingtheflowofcontrolontheirownnotesaswell.

Practice-Itquestions[25minutes]

1. HavestudentscompletethefollowingPractice-Itquestions:i. Trickyii. Strangeiii. Confusingiv. Lots-of-errors

Ifyoudonothaveaccesstocomputersinyourclassroom,copythePractice-itquestionstoaworksheetandhavestudentscompletethepracticeproblemsbywritingouttheanswersandusingtheirerror-checkingalgorithmsheets.

Somestudentswilljumprightintothisactivity,butotherswillneedadditionalassistancefromyou.

Atthispointintheschoolyear,wesuggestthatyouinsistonstructurediagramswitheachprogram.Structurediagramsencouragealgorithmicthinkingandthecreationofefficientsolutions;bothofwhicharevitalcomputationalthinkingskills.

Ifneedbe,workon“Tricky”asawholegroup,soyoucanmodelthecorrectstepstoapproachingaproblem.Ifyourclassdecidesonanalgorithmfor“predicttheoutput”typequestions,haveastudentmakethatalgorithmintoaposterforthewholeclasstoreferto.

Lesson1.05:StaticMethods&MethodCalls(1/2)

98

Page 99: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Studentstradework,check,andhandin[5minutes]

Havestudentstradeworkandcheckeachother’sresponsesonPractice-Itbeforesubmitting.

AccommodationandDifferentiationInELLclassrooms,thislessonshouldbedeliveredoverthecourseof2days.Extratimeshouldbespentdrillingstaticmethods,methodsthatcallothermethods,andflowofcontrol.Tryadaptingsomeoftheexamplesfromthebooktoincludestudents’nativelanguagesotheycanfocusonstructuringcodeinsteadoftranslatinglanguage.Oneeasywaytointroducefamiliar,repetitivecontentwouldbetohavestudentsoutputthelyricstoasongwitharefrain.Foraphysicalactivitytodemonstrateflow-of-control,checkoutlessonplan1.6.

Ifyouhavestudentswhoarespeedingthroughthislesson,youshouldencouragethemto:

CompletetheremainingStrange2,Strange3,Complicated2andComplicated3Practice-ItquestionsHavethestudentwriteasampletestquestionwithoutputthatcanbewrittenusingmethodcalls.Besuretheyincludetheanswerkeywiththesamplequestion!

TeacherPriorCSKnowledgeJavahasbothstaticandnon-staticmethods.Staticmethodsallowtheprogrammertocallthemethodwithoutcreatinganobjectfromtheclass.Non-staticmethodscoveredinthe2halfofthecourserequiresanobjectbecreatedfromtheclassbeforecallingthemethod.Because“BuildingJavaPrograms”introducesfunctionsbeforeobjects,methodsinearlylessonplansarestatic.Foradescriptionofthedifferencebetweenstaticandnon-staticmethodsseehttp://beginnersbook.com/2013/05/static-vs-non-static-methods/.

TeachingTipsOneofthebigfundamentalconceptsofproblemsolvingincomputerscienceistheconceptabstraction.Thislessonhasanumberofnewsyntaxconstructsforstudentstocreatemethodsanditisimportanttogivestudentsthebigpictureideaoffactoringcodeandreducingredundancy.

nd

Lesson1.05:StaticMethods&MethodCalls(1/2)

99

Page 100: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Thepractice-itproblemshavestudentstracingcodewheremethodscallothermethods.Givingstudentsawayoftracingcodelikeusingatabletokeeptrackofthemethodcalls.Ifyouareusingablack/whiteboard,werecommendcrossingoutthemethodcallwhenitcompletesinsteadoferasingthenamesothestudentcanreviewtheentireflowofcontrolfrombeginningtoendaftertheexerciseiscomplete.Anothertechniquethatcanbeintroducednowthatcanbeusedlaterwhentheflowofcontrolgetsmorecomplexismemorydiagrams:https://www.youtube.com/watch?v=t-_TeH0dSZs&feature=youtu.be&list=PL0g5FWk3FEqjmrq4ystAvlRyenEF7lUwa

MisconceptionsWhendeclaringamethod,studentswillsometimesincorrectlyaddasemicolontothemethodheader,asinpublicvoidfoo();.StudentshaveamisconceptionthatallstatementsinJavaendinasemicolon.Theyneedtoknowthedistinctionbetweenstatementsthatdoendinsemicolonandstatementsthatbeginblockswithcurlybrackets.Theadditionofthesemicolontothemessageheadercouldalsobestudentsincorrectlypatternmatchingthemethoddeclarationwiththemethodcallwherethereisasemicolon:foo();Thisovergeneralizationcouldleadtosemi-colonbeingincorrectlyplaced.

Formethodswithoutparameters,studentswillsometimesomittheparenthesis().Toclarifythedifferencebetweenvariablesandmethods,alwaysuseparenthesiswhenreferringtomethods.ThiswillreinforcethenotionthatmethodsinJavarequireparenthesis,evenformethodswithzeroparameters.

VideosBJP1-3,ProgrammingwithMethodshttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c1-3

CSE142,StaticMethods(44:12-49:21)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=dd78a77d-cd7a-4ff8-b853-5446801946fb&start=2652

CSE142,ProceduralDecomposition(20:10–29:35)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=b5df64f2-e42f-4943-bab6-29eca0ab8f00&start=1211

CSE142,EliminatingRedundancy(29:36–35:49)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=b5df64f2-e42f-4943-bab6-29eca0ab8f00&start=1775

Lesson1.05:StaticMethods&MethodCalls(1/2)

100

Page 101: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ForumdiscussionLesson1.05StaticMethodsandMethodCalls(TEALSDiscourseaccountrequired)

Lesson1.05:StaticMethods&MethodCalls(1/2)

101

Page 102: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson1.06—StaticMethods&MethodCalls(2/2)

Overview

Objectives—Studentswillbeableto…

Usestructurediagramstoplancomplexprograms.Managecomplexitybyusingmethodcalls.

Assessments—Studentswill…

CompletePractice-ItproblemsWriteastructuredPikachuprogram

Homework—Studentswill…

OutlineCh.1CompleteProgrammingProject#1*&#3(mustincludeastructurediagramforeach)

Materials&PrepProjectorandcomputer(ifyouareableto/opttouseEclipsewithyourstudents)WhiteboardandmarkersRostersforclassteamsBall(preferablyalargeinflatableballorkickball)

Theteamsfortoday’scompetitionshouldbeyourbestguessattieredgrouping(thesegroupswillprobablychangeastheyeargoesonandyoulearnmoreaboutyourstudents).Dependingonthesizeofyourclass,youshouldaimfor4teamsorteamsof4people.

PacingGuide

Lesson1.06:StaticMethods&MethodCalls(2/2)

102

Page 103: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Introduction&challenge 10min

Review/re-teach 5–15min

Pikachuchallenge 10–15min

Studentstradework,check,andturnin 5min

ProcedureToday’sclassre-teachesthemanyconceptsintroducedduringyesterday’slessonondecomposition,staticmethods,andmethodsthatcallothermethodsandgoesovercontrolflow.Sincedifferentstudentswillprogressatdifferentrates,we’llbeginthislessonwithanassessment(intheformofacompetition)todeterminehowmuchre-teachingyouneedtodo.Thecompetitionisreallygroupworkindisguise,andwillencouragestudentstoteachandhelpeachotherwhilewritingthesampleprogram.

Bell-workandAttendance[5minutes]

IntroductionandChallenge[10minutes]

1. Asyourhook,grandlyannounceaclasscompetitionbetweenteamsandannouncetheprizeforthewinningteam(thismightbeTEALSswag,bonusclassroomparticipationpoints,oradditionalraffleentriesintheyear-endTEALSgiveaway).

2. Announceclassteamsandrearrangestudentsasneeded.

3. Announcethe10-minutetimelimit,setthetimer,thenrevealthechallengeonprintedhandoutsorontheprojectorwithgreatfanfare.CHALLENGE:WriteaJavaprogramcalledStarFiguresthatgeneratesthefollowingoutput.YouMUSTincludeastructurediagramoryouranswerwillbedisqualified.Acorrectanswerwillusestaticmethodstoshowstructureandeliminateredundancyinyoursolution.

Lesson1.06:StaticMethods&MethodCalls(2/2)

103

Page 104: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

*****

*****

**

*

**

*****

*****

**

*

**

*****

*****

*

*

*

*****

*****

**

*

**

4. Givestudents10minutestocompletethechallenge,andtakenoteofwhichteamfinishesfirst.Ifstudentsarestruggling,youmayextendthetime,orofferuniversalhelpfultips.Theteamthathasthecorrectanswerfirstwinstheprize.

Review/Teach[5-15minutes]

Reviewstudentanswerstogetherasawholegroup,revisitingconceptstaughtearlierintheweekasmistakescomeup.Wheneverpossible,havestudentsvolunteerthecorrectprocedure,approach,orcode.Encouragestudentstotakenotesduringthisprocesssotheycanreviewtopicsovertheweekend.

Review/TeachOPTIONALINSTRUCTION

Ifstudentsarehavingtroubleunderstandingtheflowofcontrol,youcandothisphysicalactivitywiththem(bonus:thisactivitycanbebuiltonlaterintheyearwhendiscussingreturnvalues).

1. Writeorprojectthefollowingcodeasanexample(havestudentshelpyouwiththeheadersifyouarewriting):

Lesson1.06:StaticMethods&MethodCalls(2/2)

104

Page 105: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

publicclassSquarePants{

publicstaticvoidspongebob(){

System.out.println("Well,itmightbestupid");

}

publicstaticvoidpatrick(){

System.out.print("butit'salso");

}

publicstaticvoidsquidward(){

System.out.println("dumb.");

}

publicstaticvoidmain(String[]args){

spongebob();

patrick();

squidward();

}

}

2. Assignastudenttoeachofthemethods:main,spongebob,patrick,andsquidward,andhavethemcometothefrontoftheclassroom.HaveanotherstudentactasJava;tellthemtheyaretowritetheoutputontheboard(ortypeitifyou’reusingacomputer/projectorsystem).Fromhereonoutyoushouldaddressstudentsbytheircomponentnames(soalwayscallstudentactingasmethodpatrickasPatrick,andsoon).

3. Narratetheflowofcontrolasyoutosstheballtomain.Havemainpasstheballtospongebob(andmakesureJava“outputs”Well,itmightbestupidontheWhiteboardbeforecontrolpassesbacktoMain).

DiscusswiththeclasshowJavaknowstoreturntothenextcallinmain(theclose-bracket),andhavetheclassdirectcontroltopatrick,thenmain,thensquidwardasJavawritestheoutputontheboard.Payspecialattentiontotheprintstatementinthesquidwardmethod,andifkidsmissit,makesomesortof“error”noise.Bonus:encouragethestudentstomaketheerrornoiseforyou.

PikachuChallenge[10-15minutes]

Ontheboardorprojector,havethestudentsfinishtheclasswiththePikachuchallenge:

WriteaprogramcalledPikachuChatterthatoutputsthefollowing:

Lesson1.06:StaticMethods&MethodCalls(2/2)

105

Page 106: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Pikapikapikachupikachupeeeeekapikachu!

(\__/)

(o^.^)

z(_(")(")

Pika?Pikapikapikachupeeeeekachu!

(\__/)

(o^.^)

z(_(")(")

Youcanreusethecodethatyouwroteearlierthisweek.Yourprogramshouldusestaticmethodsandmethodcalls.Youshouldincludeacommentatthestartoftheprogramthatexplainswhatthecodedoes(youmightwanttousethiscodelaterintheyearwhenwebuildalargerPokémonprogram).

Studentstradework,check,andturnin[5minutes]

Attheendofclass,havestudentsreviewoneanother’sPikachuchallengecodesbeforesubmitting.

AccommodationandDifferentiationIfyouhavestudentswhoarespeedingthroughthislesson,youshouldencouragethemto:

CompletetheremainingStrange2,Strange3,Complicated2andComplicated3Practice-Itquestions.

Havethestudentwriteasampletestquestionwithoutputthatcanbewrittenusingmethodcalls.Besuretheyincludetheanswerkeywiththesamplequestion!

Ifyouhavethegoodfortuneofnotneedingtore-teachanyconcepts,youcanmagnanimouslygivestudentsextratimetostartonthehomeworkprogrammingproject#1.Ifyouaredoingalotofre-teachingduringthisclass,andyoufeelthatstudentsneedtheemotionalreward,youmaydropprogrammingproject#1.

VideoBJP1–4,DrawingComplexFigureswithStaticMethodshttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c1-4

Lesson1.06:StaticMethods&MethodCalls(2/2)

106

Page 107: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ForumdiscussionLesson1.06StaticMethodsandMethodCalls(TEALSDiscourseaccountrequired)

Lesson1.06:StaticMethods&MethodCalls(2/2)

107

Page 108: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson1.07—ProgrammingProject

Overview

Objectives—Studentswillbeableto…

Constructaprogramcontainingmethodcallsandstaticmethods.

Assessments—Studentswill…

Submitacomplete,functionalprogrambytheendofclass

Homework—Studentswill…

Checkclassnotesforcompletion,addingdailysummariesifneeded.Studentsmayusethebooktosupplementtheirnotesifneeded.Allstudentsmustturninnotesforeachdayofclass(eveniftheywereabsent).

Materials&PrepProjectorandcomputer(ifyouareableto/opttouseEclipsewithyourstudents)Studentself-helpsystemsuchasC2B4(“seetwobeforeseeingme”)orstudentpairing

Makesureyouaresetuptogradestudentnotebookstodaywhilethestudentsworkontheproject.Ifpossible,youshouldonlycollect3–5notebooksatatimesostudentshavetheirnotebooksavailabletoreferenceduringprogrammingtime.

PacingGuide

Lesson1.07:ProgrammingProject

108

Page 109: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Introduction&classroomprocedurereview 10min

Programmingproject#2,Chapter1 15min

Programmingproject#5,Chapter1 15min

Studentstradework,check,andturnin 5min

ProcedureThesecondweekpartofthisunitwillbespentonreinforcingconceptsandapplyingthetools,procedures,andcodethatwereintroducedlastweek.Whiletheseclassesrequirelittleprepbeforeclass,youshouldsetupasystemthatwillallowstudentstohelpthemselvesandeachothersoyouaren’trunningaroundthecomputerlabthewholetime.

Ifyourcomputertimerequiresyoutomovetoanotherroomortochangeseating,youshouldteachand/orreviewthoseproceduresbeforeintroducingthelabmaterial.Ifyouexpectstudentstosubmitassignmentselectronically,youshouldalsomodelandreviewthoseproceduresbeforestudentsbeginwork.

Bell-workandAttendance[5minutes]

IntroductionandClassroomProcedureReview[10minutes]

1. Introducetheprogramassignment,takingamomenttotalkstrategywithyourclass.

ASSIGNMENT:Sometimeswewritesimilarletterstodifferentpeople.Forexample,youmightwritetoyourparentstotellthemaboutyourclassesandyourfriendsandtoaskformoney.Youmightwritetoafriendaboutyourlovelife,yourclasses,andyourhobbies,andyoumightwritetoyourbrotheraboutyourhobbiesandyourfriendsandtoaskformoney.

Writeaprogramthatprintssimilarletterssuchasthesetothreepeopleofyourchoice.Eachlettershouldhaveatleastoneparagraphincommonwitheachoftheotherletters.Yourmainprogramshouldhavethreemethodcalls,oneforeachofthepeopletowhomyouarewriting.

TIPS:Trytoisolaterepeatedtasksintomethods.Includecommentsinwithyourcodesootherscaneasilyunderstandwhatthecodeissupposedtodo.

Lesson1.07:ProgrammingProject

109

Page 110: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

2. Askyourclassforsuggestionsastohowtotacklethisprogrammingproblem.Studentsshouldsuggestdrawingastructuraldiagram,buildingtheprogramonemethodatatime(iterativedevelopment),andfollowingthecorrectionstepsontheirpersonalalgorithms(debugging).

ProgrammingProject#2,Chapter1[15minutes]

GetstudentsstartedonProgrammingProject#2inChapter1ofthetextbook.Offerstudentshelpaftertheyhavetriedtoanswerthequestionsthemselves:

1. Havethecheckedthebookforexamples?2. Havetheyaskedafriend(ortwo)forhelp?

Ifstudentsseemtobegettingstuckonthesamesegmentofcode,offerahintortipontheboard(silently,withoutdisruptingstudentflow).

Iftheentireclassisstuck,returntowholegroupandworkthroughtheprogrammingchallengetogetherasaclass,havingstudentsofferanincreasingproportionoftheanswersasyoumovealong.

ProgrammingProject#5,Chapter1[15minutes]

IntroduceProgrammingProject#5inChapter1ofthetextbook.Ifyourclassfinishedthefirstassignmentquicklyandeasily,offerlittletonoguidanceonthisproject.

Studentstradework,check,andturnin[5minutes]

Attheendofclass,havestudentsbrieflylookateachother’sprojectsandreviewtheirworkbeforetheysubmit.

AccommodationandDifferentiationIfyouhavestudentswhoarespeedingthroughthislesson,youshouldencouragethemtotackleprogrammingproject#4inthetextbook.

ForumdiscussionLesson1.07ProgrammingProject(TEALSDiscourseaccountrequired)

Lesson1.07:ProgrammingProject

110

Page 111: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson1.07:ProgrammingProject

111

Page 112: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson1.08—Finding&FixingErrors

Overview

Objectives—Studentswillbeableto…

Findandfixerrorsandstyleintheirreturnedhomeworkassignments.Correcttheircode

Assessments—Studentswill…

Re-submitallhomeworkassignmentswithcorrectedanswers.

Homework—Studentswill…

Studyforthetestby:ReviewingallthebluepagesattheendofChapter1Re-readingsectionsasneeded

Submit5questionsforreviewinclasstomorrowusingelectronicsurvey

Materials&PrepAnystudenthomeworkassignmentsthatyouhavenotyetreturnedStudentself-helpsystem(suchasC2B4orstudentpairing)Electronicsurveyforstudentreviewrequests

Whenyougradehomeworkassignments,itwillbemostusefultotheselessonsifyouonlymarkananswerincorrectorcorrect.ELLclassroomsaretheexceptiontothisrule—studentswillbehavingahardenoughtimejustreadingthematerial;youcanspeedalongtheirprocessingbycorrectingoneexample,thenhavingthemlookforsimilarerrorswiththatexample.

Thehomeworktonightasksstudentstosubmit5questionsforreview.Createanelectronicsurveyforstudentstocompletewith6textfields,oneforname,and5forquestionstheyhaveaboutCh.1content.Setatime-deadline(e.g.10pm)bywhichtimestudentsmusthavesubmitted5questionsfromCh.1thattheywouldliketoseereviewedintomorrow’sclass.Ifstudentsdonothavequestions,stipulatethattheystillhavetosubmitsomethingtoreceivecredit,evenifitisonlyquestionstheythinkotherstudentsmayhave.

Lesson1.08:Finding&FixingErrors

112

Page 113: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Introductionandhomeworkdistribution 5min

Lectureonstyle 10min

Studentwork 25min

Studentstradework,check,andsubmit 10min

ProcedureTodaywecontinuereinforcingconceptsandapplyingthetools,procedures,andcodethatwereintroducedlastweek.Studentswillhavetheopportunitytocorrectanyincorrecthomeworkassignments.Ifstudentsdidnothavetimetofinishtheprogrammingprojectsfromyesterday,youmayallowthemtimetoworkonthoseprojectstoday.

Thisisagooddaytoloosenupthevibeintheclassroomabit.Tryplayingmusicsoftlyinthebackgroundtoencouragestudentstorelaxandfocusonspottingerrors.Trytoavoidloud,rhythmicmusic.Rewardyourclassforgoodgrades/behaviorbyallowingthemtoselectmusicfromapre-selectedgroupofPandorastations(orthelike).

Bell-workandAttendance[5minutes]

IntroductionandHomeworkDistribution[5minutes]

1. Returnstudenthomeworkpackets,orhavestudentsplacetheirreturnedhomeworksinapileontheirdesk.

2. Explaintostudentsthattheyhavetheopportunitytogetfullcreditontheirhomeworkgradesbycorrectingthemnow,inclass.Askstudentsforsuggestions/ideasonhowtomakesuretheydon’tmissanyerrors.(Bynowstudentsshouldbeusedtorelyingontheirerrorchecklist/algorithm.)

Lectureonstyle[10minutes]

Addthecaveatthattheymustcorrecttheirstyletoreceivethatcredit.Explainthatstyleisnecessarytoimprovereadabilityandthatyoulosepointsforhavingpoorstyle.

Althoughitwasalreadytouchedonpreviously,tellthemthatidentifiersmustbeproperly

Lesson1.08:Finding&FixingErrors

113

Page 114: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

capitalized.Commentingmustbeproperlyusedthroughout.Linesmustbenolongerthan100preferably80lines.Thereshouldbenoredundantcode.Therearelinkstothefullstyleguidewerecommendontheslides.

StudentWork[25minutes]

Havestudentsworkindividuallytocorrecttheirhomeworkgrades.

Offertimechecksforstudentssotheystayontask.Ifstudentshavenotfinishedtheirprogrammingprojectfromyesterday’sclass,allowthemtodosotoday.

Studentstradework,check,andturnin[10minutes]

Attheendofclass,havestudentstradetheirhomeworkassignmentstoevaluateeachother’scorrectionsbeforesubmission.

AccommodationandDifferentiationIfyouhavestudentswhoarespeedingthroughthislesson,youshouldencouragethemtotackleprogrammingproject5&7inthetextbook.

Ifyouwereunabletofinishgradingstudentnotebooksyesterday,finishthemtodaywhilestudentsareworking.Returnnotebooksbytheendofclasssostudentsmayusethemtostudyfortheexam.

ForumdiscussionLesson1.08FindingandFixingErrors(TEALSDiscourseaccountrequired)

Lesson1.08:Finding&FixingErrors

114

Page 115: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson1.09—Review

Overview

Objectives—Studentswillbeableto…

IdentifyweaknessesintheirUnit1knowledge.

Assessments—Studentswill…

Createapersonalizedlistofreviewtopicstoguidetonight’sstudysession.

Homework—Studentswill…

Studyfortomorrow’stest!

Materials&PrepProjectorandcomputerWhiteboardandmarkerResultsfromelectronicsurveyofreviewtopicsClassroomcopiesofthepracticetestWS1.9

Oncestudentshavesubmittedtheirreviewrequests,assemblethosetopicsintocategoriesandpreparetore-teachthetopicsasneeded.

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Introductionandtestformatorientation 15min

Testreview 30min

Checkstudentstudylists 5min

Lesson1.09:Review

115

Page 116: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ProcedureEngagetheclassinthereviewsessionbypointingoutthatyourreviewtopicshavebeenhandselectedbytheclass.Explainthatyouwillreviewtest-takingstrategiesinadditiontoreviewingsubjectmatter.

Bell-workandAttendance[5minutes]

IntroductionandTestFormatOrientation[15minutes]

1. Clearlyindicatethatyouexpectallstudentstohavealistofreviewtopicstostudythisevening.Periodicallyremindstudentsthatthislistwillbecheckedattheendofclass.

2. Beginbyexplainingtheportionsofthemock-test.Readaloudtheinstructionsoneachpage,andexplainthestrangelayout(thetestisdesignedtolookliketheAPexam,andcontainsallofthedirectionsontheexamsostudentswillnothavetowastetimeunderstandingtheminMay).

3. Solvethesampleproblemsonthetestasawholegroup,encouragingstudentstogiveyoutheanswerswheneverpossible.Answeranyquestionsthatstudentsbringupasyougo.

TestReview[30minutes]

1. Usingtheresultsfromtheelectronicsurvey,addressthevariousreviewtopics,prioritizingquestionsthatpoppedupthemost.

i. Somequestionsyoumayalreadyhaveaddressedwhileworkingthroughthesampletest.

ii. Bereadyforadditionalquestionstopopupasyougo.Saveyourselftheworkanduseoldhomeworkquestionsandstudent-generatedtestquestionsasexamplestoworkthrough.

iii. Jotdownnotesaboutwhichtopicsyoucoveredinreviewsoyoucanadjusttheexamtoreflectthetopicsyourstudentshavelearned.

2. Useacombinationofgroup-solvingquestionsonthewhiteboard,think-pair-share,andtimed-responseasreviewstrategies.

3. Afteryou’vecompletedreviewinganidea,remindtheclassthattheyshouldwritedownthattopiciftheyfeeltheystillhavetoreviewittonight.(Yes,thiswillbearemindereveryfewminutes,butitwillpayofflaterwhenstudentsstartcreatingreviewlistswithoutpromptinglaterintheyear!)

Lesson1.09:Review

116

Page 117: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Checkstudentstudylists[5minutes]

Spendthelast5minutesofclasscheckingeachstudent’sreviewtopiclist.

AccommodationandDifferentiationInELLclasses,youmaywanttochangecode-writingquestionstoParsonsProblems.EducationalresearchshowsahighcorrelationbetweenParsonsscoresandcodewritingscores,andalowcorrelationbetweencodewritingandtracingandbetweenParsonsandtracing.(Inotherwords,ParsonsProblemsaccuratelyassessastudents’abilitytocreatecode.)FormoreinformationonParsonsProblems,checkoutthispaper(https://cseweb.ucsd.edu/classes/fa08/cse599/denny.pdf).

Eveninanon-ELLclass,youmaywanttochangesomeSectionIIquestionstoParsonsproblemsbecause(1)gradingthequestionsiseasier,sincelogicandsyntaxerrorsareeasytodiscern,and(2)studentschallengedbylanguageprocessingareabletomorequicklycompletetheproblem.

TeachingTipsTipsforAssessment:http://csteachingtips.org/tips-for-assessing-programming

ForumdiscussionLesson1.09Unit1Test(TEALSDiscourseaccountrequired)

Lesson1.09:Review

117

Page 118: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson2.00—TestReview&Reteach

Overview

Objectives—Studentswillbeableto…

Re-learnorstrengthencontentknowledgeandskillsfromUnit1.

Assessments—Studentswill…

Re-submittestanswerswithupdatedcorrectionsforpartialorfullcreditCreditdependsoninstructorpreference

Homework—Studentswill…

ReadBJP2.1exceptfor“MixingTypesandCasting”Correctanyincorrecttestanswersbyre-answeringonaseparatesheetofpaper

Togetbackcredit,theymustjustifytheirnewanswersStaplenewanswersheettooldtestandturnintomorrow

Materials&PrepProjectorandcomputerWhiteboardandmarkersCorrectedstudenttestsStudentgrades(postedonline,emailedtostudents,orhandedbackonpaperinclass)Digitalcopyoftestquestionsforprojector

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Classdiscussion(ifneeded) 10min

Testreviewandreteach 30min

Checkstudentnotesandreturntests 5min

Lesson2.00:TestReview&Reteach

118

Page 119: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ProcedureReturnstudentgradesbeforeclassbeginsorwhilestudentsarecompletingthebellwork.

Donotreturnstudents’testsbeforethereviewsession,sinceyouwanttomotivatestudentstopayattentiontotheentirereview,takingsupplementalnotestheentiretime.

Bell-workandAttendance[5minutes]

ClassDiscussion(ifneeded)[10minutes]

1. Ifgradesarelow,invitetheclasstoadiscussionofwhatcanbeimproved.Beginwithstudentcomplaintsandsuggestionstobuildstudentbuy-in.Askstudents:

HowtheyfelttheyweregoingtodobeforethetestWhatsurprisedthemoncetheyweretakingthetestWhattheyfeltworkedinthefirstunit(lessons,reviewstrategies,assignments)Whatdotheythinktheywanttochangeforthesecondunit

2. Onceyoufeelthatadialoguehasbeenestablished,validatestudents’feelings,thenchallengethem(e.g.APcoursesarestressful,butthisisgoodpracticeforcollege,wherethepaceisfasterandprofessorsdon’tgivepersonalizedinstruction).Inanon-judgmental,supportivetone,remindstudentsthattobesuccessfulinthecourse:

Readingismandatory

Homeworkismandatory(Andvaluable!Youwillneverassign“busy”work.)

Tobettermanagetheirtime,studentsshouldplanfor1hourofhomeworkaweeknight,withupto2hoursofhomeworkeachweekend.Ifthisseemsimpossible,theyshouldmeetwithyouortheirguidancecounselortoassesswhethertheycanfitinanAPclassatthistime.

ItisVERYimportanttokeepyourtonesympatheticatthispoint—anoverworked,overstressed,underperformingstudentwillslowyourentireclassdown,andcolorthatstudentagainstCSforthefuture!

TestReviewandReteach[30minutes]

1. Walkthestudentsthrougheachquestiononthetest,glossingoverquestionsthateveryoneansweredcorrectly.

Lesson2.00:TestReview&Reteach

119

Page 120: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

a.Youcanaskforstudentstovolunteeranswers,orcallonstudentsrandomly.Makesurethatstudentsexplaintheirlogicwhentheyanswer.Ifastudentgivesanincorrectanswer,theexplanationwilltellyouwhatyouneedtore-teachorclarify.

b.Donotskipquestionsthateveryoneansweredcorrectly,butdonotspendmorethanthetimeittakestoreadthequestion,andcongratulatestudents’correctanswers.

2. Projectacopyofeachquestionasyoureview—thiswillhelpstudentsrecallthequestion/processtheinformation.

3. Makesurethatstudentsaretakingnotesduringthere-teach,remindingstudentsthatforhomework,theywillhaveanopportunitytowinbacksomeofthepointsontheirexam.

4. ForSectionIIquestions,selectasampleofstudentwork(withanyidentifyinginformationobscured),andworkthroughtheanswertogetherasaclass.

Checkstudentnotesandreturntests[5minutes]

Attheendofclass,checkstudentnotes,andreturnthetestsinhardcopyformifapplicable.

AccommodationandDifferentiationThecurriculumdoesnotofficiallycoverthechartypesinceitisnotincludedintheAPsubset.However,ifyourclassisprogressingquickly,feelfreeintointroducecharintoallfutureexamples,worksheets,andtests.

InELLclassrooms,youshouldgivemoreexamplesforeachtype,andspendmoretimedrillingduringtheintroductionandnote-takingsegments.

ForumdiscussionLesson2.00TestReviewandReteach(TEALSDiscourseaccountrequired)

Lesson2.00:TestReview&Reteach

120

Page 121: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson2.01—BasicDataConcepts

Overview

Objectives—Studentswillbeableto…

IdentifyandcategorizedatatypesIdentifyoperatorsandoperands.Correctlyapplyrulesofprecedence

Assessments—Studentswill…

Writecodethatyieldsagivenanswer,usingrulesofprecedenceCreateexpressionsandpredictoutputusingoperator/operandexpressionsets

Homework—Studentswill…

Completeself-checkquestions1-3(4 edition:1,3,4)ReadBJP2.2upto“StringConcatenation”

Materials&PrepProjectorandcomputerWhitepaperandmarkersClassroomsetsofoperator/operandexpressioncardscreatedfromWS2.1Pairorsmallgroupstudentassignments

Operator/OperandExpressionsetscanbeprintedandcutfromregularprinterpaper,oryoucanwritethemoutonconstructionpaper,creatingcolor-codedsets(recommendedtopreventcheatingandreinforcememorycues).

PacingGuide

th

Lesson2.01:BasicDataConcepts

121

Page 122: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Introductiontodatatypes 10min

Think-pair-shareactivity 5min

Introductiontooperatorsandprecedence 10min

EvaluatingExpressionsactivity 20min

Checkstudentstudylists 5min

ProcedureHookyourclasstodaybyexplainingthatthey’regoingtobeabletocreateacalculatorbytheendofthisweek.

Bell-workandAttendance[5minutes]

IntroductiontoDataTypes[10minutes]

Beginwithabrieflectureaboutdatatypes.

Towriteamorecomplicatedprogramlikeacalculator,weneedtofamiliarizeourselveswiththedifferenttypesofdatathatJavacanworkwith.

Type(ordatatype):anameforacategoryofdatavaluesthatareallrelated

Typeintdescribesallwholenumbers,orintegers(havestudentsnamesomeexamples)

Typedoubledescribesallnumberswithdecimalpoints(havestudentsgivesomeexamples)

Youcanrememberifsomethingisadoublebecausetherearenumbersonbothsidesofadecimalpoint(like2numbers,doublenumbers)

Typebooleandescribeslogicalvalues—thismeanstrueorfalse.Therearenoothervaluesintypeboolean.

Anexpressionisasimplevalue,orasetofoperations(anequation)thatproducesavalue.

Onesimpleexampleofanexpressionisvalue,like3.14or439.

Lesson2.01:BasicDataConcepts

122

Page 123: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Anotherexampleofanexpressionis2+5.9,becauseitisanoperationthatproducesavalue.(Askstudentstopointouttheint,double,andexpressioninthisexample.)

Intheexpression2+5.9,theplussigniscalledanoperatorbecausethesymbolindicatesanoperationtobeperformedononeormorevalues.

Werefertothevaluesasoperands—bothintanddoubleareoperands.

Think-Pair-ShareActivity[5minutes]

1. Whilestudentsarefinishingwritingdowndefinitionsintheirnotes,writeanassortmentofdatatypeexamplesontheboard.

2. HavestudentscategorizealloftheprimitivetypesontheboardduringaThink-Pair-Shareexercise.Remindstudentstodoscratchworkintheirnotebooks,sinceitwillcounttowardstheirclassworkgrade(thisencourageseveryonetoworkduringthe“think”stageoftheactivity).

3. Bringtheclassbacktowholegroup,andcallonstudentstoshareacategoryforeachdatatype.

IntroductiontoOperatorsandPrecedence[10minutes]

1. Doaquickreviewofarithmeticoperators.Studentsshouldbeabletovolunteermostofthese,butyoumayhavetospendsomereviewonmod,especiallyifyourclassisnotongradelevelformathematics.

2. Askstudentsfortheoperatorsthatrepresentadditionandsubtraction.

3. Introducethespecialsymbolsweusefortheoperatorsmultiplicationanddivision.

Divisionhasslightlydifferentrulesifyou’reworkingintypeint:

12/5evaluatesto2,becauseeventhoughthecalculatorshowsus2.4,intdoesn’tletushaveadecimalpoint(whattypedoes?)

It’sveryimportanttorememberthatintalwaysdropsthepartafterthedecimalpoint.Soevenifyouevaluated39/10,youranswerwouldbe3,not4.

4. Introducethemod%operator,andhavestudentsworkthroughafewexampleswithyoutopractice.

Inelementaryschoolwecalledita“remainder”

Lesson2.01:BasicDataConcepts

123

Page 124: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

1079%34evaluatesto25,becauseyouget31R25(34goesinto107934times,with25leftover)

Ifyoutrytogettheanswerwithyourcalculator,youwon’tget25—you’llneedtodolongdivisiontogettherightanswer(or,youcangetJavatodoit!)

5. Ifwedon’tuseparenthesesinourexpressions,Javausesprecedencetodecidewhichoperationsgofirst(studentswillprobablymentionPEMDAS),andevaluatesleft-to-right:

13*2+239/10%5–2*2Startlefttoright,13*2evaluatesto26239/10evaluatesto23(havestudentsdothisonetoseeiftheycatchtheint)Stillmovingleft-to-right,now23*5evaluatesto3,and2*2evaluatesto426+3–4evaluatesto25

EvaluatingExpressionsActivity[20minutes]

1. Dependingonyourclasssize,havestudentsformpairsorsmallgroups

2. GiveeachpairorsmallgroupaZiplocbagwithasetofoperand/operatorcards.

3. Studentsshouldwriteouttheexpressionstheycreate,alongwiththevaluetheyevaluateto,intheirnotebooks.

4. Oncestudentshavefinishedaset,havethemrepackagethesetandtradewithanothergroup(ortradeintheirsetwithyou).

5. Encouragegroupstocheckeachothers’answersandhelpeachotheriftheygetstuck.

CheckStudentStudyLists[5minutes]

Attheendofclass,gooverstudentnotebooks.

AccommodationandDifferentiationThecurriculumdoesnotofficiallycoverthechartypesinceitisnotincludedintheAPsubset.However,ifyourclassisprogressingquickly,feelfreeintointroducecharintoallfutureexamples,worksheets,andtests.

InELLclassrooms,youshouldgivemoreexamplesforeachtype,andspendmoretimedrillingduringtheintroductionandnote-takingsegments.

TeacherPriorCSKnowledge

Lesson2.01:BasicDataConcepts

124

Page 125: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

TheAPCSAexamcoversasubsetoftheJavaprimitivedatatypes.ForamorethoughunderstandingoftheJavadatatypes(byte,short,int,long,float,double,char,andboolean)seehttp://www.learnjavaonline.org/en/Hello%2C_World%21.

StringisnotaprimitivedatatypeinJavabutisaclass.Stringsinmanybehaveslikeaprimitivedatatype,forexampleyoucanaddtwoStringstogetherwiththe+sign.ThisisasourceofconfusionformanybeginnerJavaprogrammersasthelanguageisinconsistentwithitstreatmentofString.

VideoBJP2–1,Expressionshttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c2-1

CSE142,BasicDataConcepts(40:42–49:59)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=b5df64f2-e42f-4943-bab6-29eca0ab8f00&start=2442

ForumdiscussionLesson2.01BasicDataConcepts(TEALSDiscourseaccountrequired)

Lesson2.01:BasicDataConcepts

125

Page 126: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson2.02—Declaring&AssigningVariables

Overview

Objectives—Studentswillbeableto…

Identify,declare,andassignvariables.

Assessments—Studentswill…

WriteaprogramthatconvertstemperaturefromFahrenheittoCelsius.

Homework—Studentswill…

ReadtherestofBJP2.2Completeself-checkquestions5,6,9,12-15(4 edition:6,7,10,14-17)

Materials&PrepProjectorandcomputer(ifyouareableto/opttouseEclipsewithyourstudents)WhitepaperandmarkersClassroomcopiesofWS2.2PairorsmallgroupstudentassignmentsSampleonlinetemperatureconverter(http://www.onlineconversion.com/temperature.htm)

Sincemostoftoday’slessonfollowsWS2.2,youshouldhavereadthroughtheworksheet.Youmayprefertodeletethenotesfromtheworksheet(soitisonlyasheetofexercises)ifyouareworkingondevelopingnote-takingskillsinyourclassroom.WerecommendleavingthesesectionsinforELLclassrooms,soyourstudentscanfocusonsyntaxrulesinsteadoftranslatingwhattheyarehearingtovocabularytheyneedtothenwriteintheirnotebooks.

PacingGuide

th

Lesson2.02:Declaring&AssigningVariables

126

Page 127: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Introductionandworksheetexercises 25min

Practice-Itexercises 20min

Turninworksheets,wrapup 5min

ProcedureSincemuchofthisclassinvolveslearningsyntax,therewillbealotofdrillingduringtheclass.Trytospiceupthelessonbyallowingstudentstoworkinpairs,orplayingsoftmusicinthebackgroundtoputstudentsintherightheadspacetosettledownforwork.

Hookyourclasstodaybyaskingwhichofthemaretakingorhavetakenphysicsorchemistry.AskstudentsaboutworkingwithFarenheitandCelsiustemperatures—dotheyhavetoconverttemperaturesinclass?Whichmeasurementaretheymorefamiliarwith?Whichdotheyusemoreoften?Showstudentstheonlinecalculatorandaskiftheyeverusesuchonlinetools,andtellstudentsthatthey’regoingtolearnhowthisprogramisbuilttoday.

Bell-workandAttendance[5minutes]

IntroductionandWorksheetExercises[25minutes]

1. UsingWS2.2,walkstudentsthroughtheproperwaytodeclareavariable.

Besuretospot-checkforunderstandingbyhavingstudentsgiveyouthedefinitionsoftype,syntax,declaration,andvariable(allboldedinthetext).

Encouragestudentstousetheirnotesifneeded.

2. GuidestudentsthroughthesyntaxrulesforvariabledeclarationsbyworkingthroughthefirstfewexamplesofExercise1inpairs.

3. GivestudentsafewminutestocompleteExercise1ontheirown;encouragestudentstotackleExercise2aswell,thencheckallanswerstogetherasawholegroup.

4. UsingthefigureonExercise3ofWS2.2,walkstudentsthroughthepropersyntaxtoassignavariable.

Spot-checkforunderstandingbyaskingstudentstodefinetheitalicizedwords.

Askstudentsforafewsampleanswers,correctthemifneeded,thengivestudentsafewminutestocompleteExercise3inpairs.

Lesson2.02:Declaring&AssigningVariables

127

Page 128: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

5. Asawholegroup,walkstudentsthroughExercise4and5.Complete5atogetherasagroup,thenletstudentsworkon5binpairs.

Atthispoint,yourclassmayberaringtogetstartedontherestoftheassignmentwithoutyourhelp.Iftheyare,great!PostthePractice-itquestionsontheboardsotheycancontinuetothatassignmentoncetheyhavecompletedtheworksheet.Ifyouclasswantsyoutowalkthemthroughstringconcatenation,gothroughtheexamplesasabove.

Practice-ItExercises[20minutes]

1. HavestudentslogintoPractice-IttocompletethefollowingPractice-Itself-checkquestions:

a.studentVariables

b.valuesofA,B,C

2. HavestudentscompletePractice-Itexercise“displacement.”

3. Studentsshouldworkontheirown,butiftheexerciseistoochallenging,youmightopttohavestudentscollaborateonanswers.Besuretoremindstudentsthateachstudentshouldturnintheirownsetofwork.

Studentsturninworksheets,wrapup[5minutes]

Attheendofclass,collectWS2.2andPractice-Itsubmissions.

AccommodationandDifferentiationIfyouhavestudentswhoarespeedingthroughthislesson,youshouldencouragethemto:

CompletePractice-Itself-checkproblem“timesOperator.”

ChallengethemtobuildtheirownprogramthatconvertsFarenheittoCelsius(thisversionwon’ttakeuserinput—yet!)

Havethestudentcreateaclassroomposterdiagramingthepartsofvariabledeclaration&assignment.

Ifyourclassisstrugglingwithlearningsyntax,youcansplitthelessoninto2lessons,and/ortakeoffsomeofthehomeworkquestions.Ifsplittingthelessonintwo,werecommendstoppingtoday’slessonbeforestringconcatenation.

Lesson2.02:Declaring&AssigningVariables

128

Page 129: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

CommonMistakesVariablescommonmistakes:http://interactivepython.org/runestone/static/JavaReview/VariableBasics/commonMistakes.html

MisconceptionsStudentswilldrawontheirmathknowledgewhenlearningvariables.Thisleadstoconfusiononthedifferencesinaprogramminglanguage.

Theequalsign=isassignmentinJava,notequality.Whenreadingoutcode,explicitlysaying“assignment”willhelpreinforcetheconceptthat=isnotequality:x=1isreadas“xisassignedthevalue1”.

Avariableisacontainerforvaluethatcanchange,itdoesnotdenoteafixedvalue.FromWS2.2,considerthefollowingstatements:

intage=17;

age=age+1;

Studentsmayviewthesecondlineofcodeasamathequationandmissthepointthatageisavariableandcontainsavalue.Theage=age+1changesthevalueofage.WhenlearningJavathereisthecodewhichisstatic,therunningofthecode,andthestateofthevariableduringruntimewhichisfundamentallydifferentfromanequationinmaththatcanbesubstitutedandmanipulatedtosolveforsomeunknown.

Studentsready=x+2;andthinktheequationisstorediny,notavalue.

x=1;

y=x+2;

x=3;

System.out.println(y);//whatisdisplayedfory?

Forstudentswiththemisconceptionthattheequationisstored,theywillincorrectlycompute6aswhatisdisplayedfory.

Javaisnotaspreadsheetthatstorestheequation.Explicitlyteachingthatxandyareindependentvariablesinaprogramminglanguageandholdvaluesisanimportantdistinction.Thisdiffersinmathwherey=x+2isarelationship.Showingthestateof

Lesson2.02:Declaring&AssigningVariables

129

Page 130: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

thevariablescanbeachievedusingthewhiteboard,thedebuggerbysteppingthroughonelineofcodeatatime,andexaminingvariables,orusingavisualizationtoollikehttp://cscircles.cemc.uwaterloo.ca/java_visualize/.

VideoBJP2–2,VariablesandAssignmenthttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c2-2

CSE142,Variables(5:12–12:48)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=ca84c6fe-878e-4bcf-92d4-a18edd3fef21&start=310

CSHomeworkBytes,VariableandAssignment,withElizabethhttps://www.youtube.com/watch?v=fPqGiexXi_Y

ForumdiscussionLesson2.02DeclaringandAssigningVariables(TEALSDiscourseaccountrequired)

Lesson2.02:Declaring&AssigningVariables

130

Page 131: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson2.03—StringConcatenation&IncrementDecrementOperators

Overview

Objectives—Studentswillbeableto…

Applytherulesofstringconcatenation.Correctlyinterpretincrementinganddecrementingstatements.

Assessments—Studentswill…

Evaluatestatementsandpredictoutputduringagameofgrudgeball

Homework—Studentswill…

ReadremainderofBJP2.2Completeself-checkquestion4(4 edition:5)

Materials&PrepProjectorandcomputer(optional)WhitepaperandmarkersRulesforgrudgeball(seewebsitefordetails:http://toengagethemall.blogspot.com/2013/02/grudgeball-review-game-where-kids-attack.html)Teamassignmentsthatdivideyourclassinto5or6teamsNerfhoop&ball(orwastepaperandtrashcan)Taped2-and3-pointlines

Takethetimetofamiliarizeyourselfwiththerulesofgrudgeball,andtestoutyour2and3pointlinesbeforeclassbegins(youmayneedtoreadjustthem).Ifyoucangetpermissionfromyourschooltoleavetapeonthefloor,itishelpfultohavethoselinesdownfortherestoftheyear.Infutureclasses,ifyourstudentsarehavingahardtimesettlingdownduringareviewsession,orcan’tstandaworksheet,youcanalwaysconverttheworksheetorreviewsessionintoaquickgameofgrudgeball.

th

Lesson2.03:StringConcatenation&IncrementDecrementOperators

131

Page 132: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Introductionandnote-taking 15min

Grudgeball 35min

ProcedureBecausetoday’slessoncombinesseveralmarginally-related(butimportant)conceptswithnomaintheme,thedrilling/activityportionoftheclasswillservetotiethelessontogetherintheformofaclasscompetition.Ifspaceandwhiteboardsetupallow,setupthegrudgeball“court”andscoreboardbeforeclassbeginssoastomystifythestudents.Beforeyoubeginlecture,announcetostudentsthattheyshouldpaycloseattention,sincethelecturecontentwillbetestedduringthegame.

Bell-workandAttendance[5minutes]

VocabularyandHistoryofBugs[10minutes]

1. Beginwithalectureaboutthetopicstobecovered.

Stringconcatenation:letsyouputtogetherseveralstringsintoonestring,thewaywecombinenumbersinanexpression!

Whenyouseea+betweenstrings(lookforthosequotationmarks!),thatmeansthatyou“add”thestringstogether:

System.out.println("Spongebobthinks"+"thebesttimetowear"+"asweate

r"+"isallthetime!");

Carefullywriteout(orpointout,ifusingaPowerpoint)thespaceswithintheStrings.Writeouthowthestringconcatenates,askingstudentstopredictthelatterportionofthestringcombo.

Offerupasecondexample,askingthestudentstopredicthowtheexpressionwillevaluate,discussingtheplacementofquotationmarksfirst:

Lesson2.03:StringConcatenation&IncrementDecrementOperators

132

Page 133: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

System.out.println("Herewecombine"+1+"integer"+"withthestrings!")

;

Givethestudentsalittleextraguidedpracticebywalkingthemthroughthistrickyexample:

42+"istheanswerto"+"everything!"+1+1

Stepwise,showstudentshowthisevaluatesto“42istheanswertoeverything!11”

Askstudentsiftheycancomeupwithawaytomaketheanswerevaluateto“42istheanswertoeverything!2”

2. Switchgearsandtellstudentsthesecondusefultoolyou’regoingtoteachthemtodayishowtoincrease(ordecrease)avariablebyaparticularamountwithoutwritingawholeseparateequation.

BrieflyexplainthatinJava,theequationsbelowmean“add7tothecurrentvalueofx,”“dividethecurrentvalueofyby3,”insteadofthetraditionalmathematicaluseof“equals.”Immediatelyshowstudentshowtowritetheabbreviatedversionsofthesestatements:

x=x+7;ORx+=7;y=y/3;ORy/=3;

Oncestudentshavewrappedtheirheadsaroundthisnon-algebraicreading(andgivenyousomecorrectexamples),explainthespecialcaseofincrementingordecrementingby1:

x++;OR++x;x--;OR--x;

Grudgeball[35minutes][Optional]

Ifyoufeellikeyourclassunderstandsincrementandstringconcatenation,considerskippingthisgameandfocusingonon-the-boardexamples(youcanusethequestionsfromGrudgeballbelow)ormovingonto2.4.

1. Dividestudentsintotheirassignedteams.

2. Reviewtherulesforgrudgeball,andhavethestudentsrepeattherulesbacktoyou.

3. Usingtheproblemslistedbelow(andanyyoumayadd,dependingonyourclass’needs),playgrudgeballuntilateamwins,oruntiltheclassperiodends.

Lesson2.03:StringConcatenation&IncrementDecrementOperators

133

Page 134: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

a.Ifaclassgetstheanswerwrong,BRIEFLYpausethegametohavestudentsoffercorrectionsbeforemovingtothenextteam’squestion.

b.Ifcorrectionseemstobedraggingon,jumpinandquicklyre-teachusingtheincorrectanswerasyourexample.Itisimportanttokeepthepacegoingtomaintainstudentinterestinthegame!

Gudgeballproblems&answershavebeengroupedassumingthatyouhave6teams.Ifyouhavefewerteams,each“round”willbeshiftedaccordingly,soyoumayhaveroundswheredifferentteamsarepracticingdifferentconcepts.Judgeeachteam’sknowledgegaps,andadjustwhichquestionsyouaskeachgroupaccordingly.

GRUDGEBALLPROBLEMSANDANSWERS

Whatdotheseevaluateto?

1)"Patrick"+"why"+"areyou"+"here?"→Patrickwhyareyouhere?

2)2+"words:"+"Na.Chos."→2words:Na.Chos.

3)"Friendship"+1+"$"+"magic!"→Friendship1$magic!

4)"Watchout"+"for"+"\"\""+""+"escapesequences!"→Watchoutfor""escapesequences!

5)"Pikachu,pikapika"+"peeeeeeeeka"+"ch"+0+0+"!"→Pikachu,pikapikapeeeekach00!

6)"PEMDAS"+"doesn't"+(2+3)*4+"matter"+"right?"+1→PEMDASdoesn’t20matterright?1

Writeastatementthat:

7)Increasesthecurrentvalueofxby150.→x=x+150;orx+=150;

8)Decreasesthecurrentvalueofyby9.→y=y-9;ory-=9;

9)Multipliesthecurrentvalueofzby5.→z=z*5;orz*=5;

10)Dividesthecurrentvalueofqby14.→q=q/14;orq/=14;

11)Incrementsxby1.→x++;,++x;,x=x+1;,orx+=1;

12)Decrementsxby1.→x--;,--x;,x=x–1;,orx-=1;

Predicttheoutput:

Lesson2.03:StringConcatenation&IncrementDecrementOperators

134

Page 135: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

13)

intx=1;

x+=3;

System.out.println("Thevalueofxis"+x);

→Output:Thevalueofxis4

14)1+1+1+"1"+1+1+1→Output:31111

15)

inty=2;

y/=2;

System.out.println("1+"+y+"ishowmuchagain?");

→Output:1+1ishowmuchagain?

16)110–10+"flipit"+0+0+1→Output:100flipit001

17)"100–10"+"flipit"+0+"0+1"→Output:100–10flipit00+1

18)

intnumber=5;

number++;

System.out.println("Mynewvalue"+"isthe"+"number"+number);

→Output:Mynewvalueisthenumber6

AccommodationandDifferentiationIfyourclassisstrugglingwithlearningstringconcatenationand/orincrementingdecrementing,thebeststrategyhereistorepeat,repeat,repeat.Addmoresimpleproblemsbeforeyouadvancetothemixedtypeconcatenation,andworkthroughmoreoftheproblemsasawholegroup.

InELLclassrooms,youshouldreadeachquestionaloudinadditiontoshowingitontheboardorprojector.

CommonMistakes

Lesson2.03:StringConcatenation&IncrementDecrementOperators

135

Page 136: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Commonmistakeswithstrings:http://interactivepython.org/runestone/static/JavaReview/Strings/sMistakes.html

VideosCSE142(12:48–18:29)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=ca84c6fe-878e-4bcf-92d4-a18edd3fef21&start=769

CSHomeworkBytes,MathematicalOperatorsandPrecedence,withVinniehttps://www.youtube.com/watch?v=RTmRwEy-yFA

ForumdiscussionLesson2.03StringConcatenation&IncrementDecrementOperators(TEALSDiscourseaccountrequired)

Lesson2.03:StringConcatenation&IncrementDecrementOperators

136

Page 137: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson2.04—MixingTypes&Casting

Overview

Objectives—Studentswillbeableto…

DescribewhichtypesautomaticallyconvertintootherswhenappearingtogetherPredicthowanexpressionwithmixedtypeswillevaluateConverttypesbycasting

Assessments—Studentswill…

Use“zombierules”ofprecedencetocorrectlywritecodethatyieldsagivenanswerCreatetheirownexpressionsPredictoutputbycompletingandtradingworksheets

Homework—Studentswill…

ReadBJP2.3upto“NestedforLoops”Completeself-checkquestion18Finishtheworksheetifnotcompletedinclass

Materials&PrepProjectorandcomputer(ifyouareableto/opttouseEclipsewithyourstudents)WhitepaperandmarkersClassroomcopiesofWS2.4,Poster2.4Zombie/werewolfvideo(https://www.youtube.com/watch?v=ZL-58z3HxUI&feature=youtu.be&t=2m41s)

Probablywanttoplayonmute!Unicornimage(http://1.bp.blogspot.com/_WOWQJUlRtKQ/TRD5BW8v5GI/AAAAAAAABAY/llLQ4VSCskc/s1600/moon-wallpaper9.jpg)

PacingGuide

Lesson2.04:MixingTypes&Casting

137

Page 138: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

IntroductiontoMixingTypes 10min

Activity1 15min

IntroductiontoCasting 5min

Activity2 15min

Turninworksheets,wrapup 5min

ProcedureToday’sclassusestheconceptofinfectionandcureasmetaphorsfortypeconversionandtypecasting.HavetheYouTubevideoofthewerewolvesandzombiesplayingasstudentsarrive.Oncestudentshavecompletedbellwork,hookyourclasswithadiscussionofthezombie/werewolffighthappeningonthevideo.

Bell-workandAttendance[5minutes]

IntroductiontoMixingTypes[10minutes]

1. Herearesomequestionstoguidethisopeningconversation:

Whohasseenmoviesaboutwerewolvesorzombies?Cananyonetellmehowyoubecomeawerewolf?Howdoyoubecomeazombie?Whatdoyouthinkwouldhappenifazombiebitawerewolf?

2. Introducethefollowingmetaphor:

Ifahumangetsbittenbyawerewolf,theybecomeawerewolf.Ifawerewolforhumangetsbittenbyazombie,itbecomesazombie.

So:zombie>werewolf>humanThesamesortofthinghappensifweputtogetherdifferenttypesinanexpression(aka“mixingtypes”):

Ifanintisplacedinanexpressionwithadouble,Javaconvertsittoadouble.(Itgetsinfectedandbecomesadouble.)

IfadoubleorintisplacedinanexpressionwithaString,JavaconvertsittoaString.(ThewerewolfdoublegetsbittenbythezombieString,andisnowalsoazombieString.)

Lesson2.04:MixingTypes&Casting

138

Page 139: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

So:String>double>int

InJavawecallthis“promoting”becausethedoubleholdsmoreinformationthanint,andStringholdsmoreinformationthandouble!(We’lllearnmoreaboutwhatinformationisstoredinaString,butfornowjustrememberitstrue.)

Spot-checkyourstudentsbyaskingthemtonamethefantasy-equivalentforeachtypeinanexampleontheboard:

2+2.3(evaluatesto4.3becausehuman/int2ispromoted/infectedtowerewolf/double2.0)

Activity1[15minutes]

1. HavestudentsbeginWS2.4aloneorquietlyinpairs(thisstrategyisrecommendedforELLclasses).Directstudentstoonlyworkthroughwerewolfandzombiequestions(stopattheunicorns).

2. StudentsWILLtripuponthemixedtypeStringquestions.

a.Youshoulddefinitelycoveranexampleortwooftheseontheboard,andyoumayfindthatyouhavetoswitchtowholegroupinstructionforthemajorityofthese.

b.Yourpriorityshouldbetothoroughlycompleteseveralexamples,andtoseethatstudentscancompletethesequestionscorrectlywithoutyouraid.Ifyouneedtoslowdownyourpace,goforit!

3. Ifstudentsarecompletingthequestionson-pace,bringtheclasstogetherforanotherroundofwhole-groupinstruction.

IntroductiontoCasting[5minutes]

1. Introducetheconceptofcastingbyaskingstudentswhattodoiftheyreallywanttopreservethehumanrace(inttype)?

2. Review/repeattheearlierconceptsbyaskingstudents:Howdoweconvertwerewolf-doublestohuman-ints?

3. Introducecasting(Hamthisup:“Asweallknow,youcancureanythingwithunicornmagic!”)

Unicornmagic=“casting”(rememberthatUnicornsCASTamagicalspelltoprotecthumansorwerewolvesfrominfection/conversion)

Tocureawerewolf-double,sohebecomesahuman-int,youcanCASTitbyputtingthenameofthetypeyouwantinfrontofthevalueyouwanttoconvert(cast):

Lesson2.04:MixingTypes&Casting

139

Page 140: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

(int)42.9⇒42

IMPORTANT:Javajustcutsoffthatextrapartafterthedecimal—italwaysroundstowardzero.

BUTunicornmagiccan’tturnzombiesbackintoanythingbecausemagiccan’tbringyoubackfromthedead.(Onceyou’reazombie,you’realwaysazombie!)Socasting(int)stror(double)stronaStringstrdoesn’twork.

Activity2[15minutes]

1. HavestudentsreturntoWS2.4,startingontheunicorn/castingsegmentoftheexercise.

2. Workthrough1or2problemsasawholegroupbeforeyouleavestudentstotheirowndevices.

3. Ifstudentfrustrationlevelsarehigh,bringtheclassbacktowhole-groupandworkthroughafewmoreexamplesslowlyandthoroughly.Ifyouneedtorevisittheanalogyorhavestudentsflipthroughtheirbooksagain,youshoulddosoatthispoint.

TurninWorksheets,WrapUp[5]

Attheendofclass,collectthecompletedworksheets.

AccommodationandDifferentiationIfyouhavestudentswhoarespeedingthroughthislesson,youshouldencouragethemtodrawordesignapostershowingtherelationshipbetweenmixedtypes.Thepostershouldcontainlargeimagesofhumans,werewolves,zombiesandunicornssothatstudentscanseetherelationshipsfromallaroundtheroom.

Evenifyoudonothaveastudentdothisforyou,weHIGHLYrecommendmakingaposterofthissort.Studentsdonotforgetit!Ifallelsefails,youcanusetheimagesavedasPoster2.4.

VideoCSE142,Casting(18:39–31:29)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=ca84c6fe-878e-4bcf-92d4-a18edd3fef21&start=1119

Lesson2.04:MixingTypes&Casting

140

Page 141: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

CSHomeworkBytes,TypeConversations,withKristinhttps://www.youtube.com/watch?v=y-4vMMeBcAc

ForumdiscussionLesson2.04MixingTypes&Casting(TEALSDiscourseaccountrequired)

Lesson2.04:MixingTypes&Casting

141

Page 142: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson2.05—forLoops

Overview

Objectives—Studentswillbeableto…

Traceloopstopredictprogrambehavior.Constructloopstoexecutesimpletasks.

Assessments—Studentswill…

TraceandconstructloopsinPractice-Itproblems

Homework—Studentswill…

ReadBJP2.3“NestedforLoops”Completeself-checkquestions19-21(4 edition:22-24)

Materials&PrepProjectorandcomputerWhitepaperandmarkersClassroomcopiesofWS2.5

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Introductiontoforloops 15min

Practice-Itactivity 35min

Procedure

th

Lesson2.05:forLoops

142

Page 143: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Forloopsareveryconfusinginthebeginning,sowe’vepreparedastudenthandoutthatdiagramsthepartsofaloop.Encouragestudentstotakesupplementalnotesintheirnotebookandonthehandout.

Hookyourstudentsbybettingthem$100thatyoucanwriteaprogramthatoutputsthefirst1,000integersinfewerthan10linesofcode(adjustthesenumbersaccordingtothegullibility/jadednessofyourclassroom).

Bell-workandAttendance[5minutes]

IntroductiontoforLoops[15minutes]

1. Ifyouhaven’talready,distributethehandoutwithloopdiagramstoyourstudents.Followingalongwiththehandout:

Startbuildingyourforloop,narratingthepartsasyougo.Askstudentsforhelpwiththedifferentcomponentsoftheprogram(startingwiththepublicclass):

publicclassCount1000{

publicstaticvoidmain(String[]args){

for…

(Breaktoworkthroughthefirstpageofthehandout.)

2. Callonstudentstoreadtheparts1–4.Havestudentsplacetheirfingersonthepartofthediagramthatcorrespondstotheexplanatorytext.

3. PointoutthateventhoughJavaisreadingacrosstheforloopatthetop,Javajumpsdowntocheckoutthebodyofthelooptocheckifthetestistrue.Ifit’strue,itupdatestheloopandexecuteswhatwasinthebody.

Tracethisflowofcontrolontheboard,andhavestudentsphysicallytraceitontheirsheetsasyounarratethestepsagain.

Thislaststepisvery,veryimportant:don’tskipit!(humanshavehadcommunicationbytouchandsightlongbeforeweevolvedlanguage—thelearningcentersofourbrainarebetterabletopickupnewinformationifweinvolvemovement,touch,orphysicalmanipulation).

4. AskstudentstodoaquickThink-Pair-Shareastowhattheoutputwillbeforthesamplecodeonthehandout.Getthemstartedbywritingoutthefirstandsecondlineofoutputwhileyoutracetheloopasawholeclass.

Lesson2.05:forLoops

143

Page 144: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Ifthisgoeswell,moveonthefinalexampleandtheactivityfortheday.Ifitdoesn’t,re-teachtheconceptsusingtheflowchartonthebackofthehandout.

Again,havestudentstracethediagramwiththeirhands.Havethemturnthesheetbackovertothecodediagram,andnarratetheflowofcontrolastheymovetheirhandstowhereJavaisreadingtheprogram.

5. Returntotheprogramthatwilloutputthefirst1,000positiveintegersinfewerthan10linesofcode.Encouragestudentstoguesshowmanylinesitwilltaketowritethewholeprogram:

publicclassCount1000{

publicstaticvoidmain(String[]args){

for(inti=1;i<1000;i++){

System.out.println(i);

}

}

}

Tweakdifferentpartsofthecodeandaskstudentstopredicthowitwillchangeyouroutput.

Changethecontinuationtesttoi<=1000.Changethevariableitox.Changetheupdatetoi+=2(orx+=2,dependingonwhichcodeyouhaveupthere).Ifanyoftheseexamplesstumpyourclass(andtheywill),takethemthroughtheloop,onestepatatime,writingdownsampleoutputtofindthenewpattern.

Practice-ItActivity[35minutes]

1. Dependingonthemoodandfrustrationlevelsintheclass,youmaychoosetohavestudentsworkinpairs.

a.Ifstudentsarereallyhavingaroughtime,workthroughthefirstPractice-Itquestiontogetherasawholegroup.

b.Putsoft,soothing(butupbeat)musiconinthebackgroundtoeasetension!

2. HavestudentslogintoPractice-IttocompletethefollowingPractice-Itself-checkquestions:

a.Count2b.fingerTrapc.howManyLines

Lesson2.05:forLoops

144

Page 145: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

3. Ifmore25%ormoreoftheclassisstruggling,returntowholegroupwiththestipulationthatstudentswhogetitmaycontinueworkingindependently.

AccommodationandDifferentiationIfyouhavestudentswhoarespeedingthroughthislesson,youshouldencouragethemtocompletePractice-Itself-checkproblems“numberTotal”and“blastoff”.

TeacherPriorCSKnowledgeThetextbookBJPintroducesreducingredundancyandgeneralizationearlyinthecurriculum.Becauseoftheearlyintroduction,studenthavenotbeenexposedtothelogicaloperatorsandhaveonlybeenintroducedtothenotionofbooleantypes.Youcanletstudentsknowthattheclasswillgooverthemiddlepartoftheforstatement,the“continuationtest”,willbecoveredindetailinafuturelesson.

Misconceptions

CommonSyntaxErrors

Usingcommasasthedelimiterintheforstatementisacommonerror.Thiscouldstemfromthedifferenceinpatternbetweenmethodcallsthatusecommaandforstatementsthatusethesemi-colon.

Specifyingthateachofthe3partsoftheforstatementisaJavastatementthatendsinasemi-colonmayhelpstudentsrememberthedelimiterisasemi-colon.

Unbalancedparenthesesand/orcurlybracketsstarts.

ManyclassesuseIDEsintheclassroom.Whenparenthesesorcurlybracketsareoff,theeditorstartsindentingthecodeinnon-standardways.Thisisthefirstindicationtothestudentthatthereissomethingwrongwiththesyntax.LettingstudentsknowthattheIDEhelpsformat,butifthereisasyntaxerrorintheircodewhiletyping,theeditorwillnotformatcorrectly.Thestudentmaywanttotakeacloserlookattheircode,specificallymatchingparenthesesandcurlybrackets.

Incorrectendingforstatementwithsemi-colon.

ConceptualErrors

Lesson2.05:forLoops

145

Page 146: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Variablescopeforthecountingvariableisrestrictedtotheforblock.

Orderofexecutionoftheinitialization,continuationtest,conditionalstatements,andupdatestatement.

Whenwalkingthroughexamplesofaforloop,itistemptingtouseboxestorepresenttheloopvariable.However,astheloopvariablechanges,thevalueisrepeatederasedtoindicatethenewvalue.Ifatableisusedandthevalueoftheloopvariablecrossedout,thestudentscanseetheprogressionofthevariablethroughtheiterations.

VideoBJP2–3,forLoopshttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c2-3

CSE142,TheforLoop(31:30–42:03)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=ca84c6fe-878e-4bcf-92d4-a18edd3fef21&start=1890

ForumdiscussionLesson2.05forLoops(TEALSDiscourseaccountrequired)

Lesson2.05:forLoops

146

Page 147: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson2.06—nestedforLoops

Overview

Objectives—Studentswillbeableto…

Tracenestedloopstopredictprogrambehavior.Constructloopstoexecutesimpletasks.

Assessments—Studentswill…

TraceandconstructnestedloopsinPractice-Itproblems.

Homework—Studentswill…

ReadBJP2.4“Scope”and“Pseudocode”Completeself-checkquestions26,27(4 edition29,30)andexercise4

Materials&PrepProjectorandcomputerWhiteboardandmarker

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Introductiontonestedforloops 15min

Practice-ItActivity 30min

LoopChallenge 5min

Procedure

th

Lesson2.06:nestedforLoops

147

Page 148: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Todayyourhookisanotherwager,onlythistimethestudentshavetocreatethecodetogetthereward(TEALSswag,ticketstotheraffle,bonuspoints,etc.).Ifyouplantouseabadgesystem,thisprojectisagoodonetostartwith(a‘loop’badge,perhaps?).

Bell-workandAttendance[5minutes]

IntroductiontoNestedforLoops[15minutes]

1. Remindstudentsofyesterday’sbet,thentellyourstudentsthatyou’llawardthem[prize]iftheycanrewritetheprogramfromyesterdayin11lines.Thecatchisthatstudentcan’tusealoopthatexecutesmorethan10times!Explainthatyou’regoingtogivethemanewprogrammingtooltoday,andthenthey’llhavesometimeattheendofclasstoseeiftheycanmeetyourchallengeforthepoints.

2. Reviewtheconceptof“controlstructure,”andhavestudentsexplaintoyouthattheloopcontrolsthestatementsintheloopbody.Askstudentstowalkyouthroughtheexampleontheboard,narratingwhatJavaisdoingasyouadvanceyourhandalongtheloop:

for(inti=1;i<=3;i++){

System.out.println("Calacasycalaveras!");

}

Youmightconsiderdeliberatelyleavinginanerrorortwoasyouwritethecodeontheboard—studentsLOVEtocatchyouinanerror!Ingeneral,leavinginerrorsisagoodwaytoconditionerror-checkingbehaviorinyourstudentswithoutthemfeelingforced.Ifstudentsdon’tcatchtheerrorbeforeyou’rereadytomoveon,pointtoitandaskstudentsifthecodeiscorrect.Occasionallypointtocorrectcodeandaskstudentstoexplainwhyitisapropercodingchoice,orwhatotheroptionswouldbe.

IfyourclassdoesnotcelebrateDíadelosMuertos,changethestringaboveto“TrickorTreat,”“AllSaintsDay,”“KolSanaWentaTayeb”orwhateverismostrelevant.

Ifyourclassneedsmorephysicalengagement,haveavolunteercometotheboardtobeconsoleoutput,andpointtothem,directingthemtowriteoutputontheboardeverytimetheloopisexecuted.Youcanalsohaveanotherstudentwalkthroughtheflowoftheloopinyourplace.

3. Asyouinsertanotherlooptocreateanestedloop,explainthatthegreatthingaboutcontrolstructuresisthattheycancontrolothercontrolstructures!

Lesson2.06:nestedforLoops

148

Page 149: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

(Engagementoption:ifyourclassisfamiliarwithXzibit/PimpmyRide,thisisagreatopportunityforayo-dawgmeme,butatthispoint,thisisprobablyonlyareferencethatcollege-ageandabovewillget.)

for(inti=0;i<3;i++){

for(intj=1;j<=3;j++){

System.out.println("Calacasycalaveras!");

}

}

Pointoutthatwealwaysuseadifferentcontrolvariable(jinsteadofi)sothatJavaknowswe’rewritinganewloop.

Asyouwritetheinnerloop,askstudentshowmanytimesitexecutes,andbrieflydiscussthedifferencebetweeninitializingat0and1,andhowthatrelatesto<or<=inthetest.

AskstudentshowmanylinesJavawilloutput(9),andwalkthroughtheloopshowingflowofcontrolanddirectingastudenttoproducetheoutput.

publicclassCount1000{

publicstaticvoidmain(String[]args){

for(inti=1;i<1000;i++){

System.out.println(i);

}

}

}

4. Tweakdifferentpartsofthecodeandaskstudentstopredicthowitwillchangeyouroutput.

Changethecontinuationtesttoi<=1000.Changethevariableitox.Changetheupdatetoi+=2(orx+=2,dependingonwhichcodeyouhaveupthere).Ifanyoftheseexamplesstumpyourclass(andtheywill),takethemthroughtheloop,onestepatatime,writingdownsampleoutputtofindthenewpattern.

Practice-ItActivity[30minutes]

Dependingonthemoodandfrustrationlevelsintheclass,youmaychoosetohavestudentsworkinpairs.

Lesson2.06:nestedforLoops

149

Page 150: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Ifstudentsarereallyhavingaroughtime,workthroughthefirstPractice-Itquestiontogetherasawholegroup.

Putsoft,soothing(butupbeat)musiconinthebackgroundtoeasetension!

HavestudentslogintoPractice-IttocompletethefollowingPractice-Itself-checkquestions:

a.starExclamation1b.starExclamation2c.starExclamation3

HavestudentscompletethePractice-ItExercise“starTriangle.”

a.Youshouldemphasizetheimportanceofconstructingastructurediagrambeforetheystartcoding.

b.Althoughwehaven’ttalkedaboutpseudocodeyet,suggestthatstudentswriteoutinEnglish(orwhatevertheirpreferredlanguageis)thestepsthattheywillneedtodotosolvetheproblem.Encouragestudentstoworkonthisinpairsifneeded.

Ifmore25%ormoreoftheclassisstruggling,returntowholegroupwiththestipulationthatstudentswhogetitmaycontinueworkingindependently.

LoopChallenge[30minutes]

1. Ontheboardortheprojector,bringupthechallengeyouintroducedinthebeginningofclass.

StudentsmaybeginonthechallengeoncetheyhavefinishedtheirPractice-Itexercises.

Inordertoencourageallstudentstotrythechallenge,allowslowerstudentstosubmittheirchallengeanswerelectronicallybytheendoftheday.(Thiscompromisegivesthemtimetoworkonthecodeatlunchorafterschool,butdissuadesstudentsfromdirectlycopyingothers’answers.)

LOOPCHALLENGE

Writeaprogramthatoutputsthefirst1,000integersin11linesofcode.Youmaynotusealoopthatexecutesmorethan10times.

Lesson2.06:nestedforLoops

150

Page 151: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

publicclassCount1000{

publicstaticvoidmain(String[]args){

for(inti=0;i<10;i++){

for(intj=0;j<10;j++){

for(intq=0;q<10;q++){

System.out.println(i);

}

}

}

}

}

AccommodationandDifferentiationIfyouhavestudentswhoarespeedingthroughthislesson,youshouldencouragethemto:

CompletePractice-Itself-checkExercises“fibonacci”and“numberTriangle.”

Developanalgorithmfortacklingcomplexcodingproblems.(Whatgeneralizablestepsdidtheytaketocorrectlybuildthenestedloopprograms?)

Havethestudentturntheseideasintoamnemonic,poster,orchecklisttosharewiththeclass.

MisconceptionsDeterminingthepurposeofthetwovariablescountersinnestedloopsisconfusingtostudents.Mostintroductionstonestedloopsuse“i"and“j”astheloopvariables.Startingwith“i"isacarryoverfromtheFortranprogramminglanguagewherevariablesstartingwiththelettersItoNwereintegersandloopvariablesareintegers.However,Javadoesnothavethisrestriction,integervariablescanstartwithanyletter.

Inordertohelpstudentsgraspthetwoloopvariables,useloopvariablesincontextwherestudentsmaybemorefamiliarwith:row/column,x/y.Thisaffordsusingagraphicalrepresentationthatstudentscanplotwhiletracingthroughthenestedloops.

Confusionoftheorderofexecutionofthe3partsoftheforloopfromasingleforloopgetscompoundedwithnestedforloops.Theorderofexecutionforthenestedloopis:

outerloopinitializevariableouterlooptestconditioninnerloopinitializevariableinnerlooptestcondition

Lesson2.06:nestedforLoops

151

Page 152: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

bodyofinnerloopinnerloopupdatevariablerepeatinnerloopouterloopupdatevariablerepeatouterloop

Attemptingtousetheinnerloopvariableintheoutsideloopblock.Itisnotobvioustobeginnersthateventhoughtheinnerblockvariableisdeclaredinsidetheouterblock,theinnerblock’sscopeisrestrictedtotheinnerblock.

VideoBJP2–4,NestedforLoopshttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c2-4

CSE142,NestedforLoops(16:18–37:50)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=ca84c6fe-878e-4bcf-92d4-a18edd3fef21&start=2524

ForumdiscussionLesson2.06NestedforLoops(TEALSDiscourseaccountrequired)

Lesson2.06:nestedforLoops

152

Page 153: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson2.07—Scope&Pseudocode

Overview

Objectives—Studentswillbeableto…

Identifythescopeofavariable.Identifycommonscopeerrors

Assessments—Studentswill…

Completeaworksheet

Homework—Studentswill…

ReadBJP2.4“Pseudocode”Completeself-checkquestions31-33(4 edition34-36)Checkclassnotesforcompletion,addingdailysummariesifneeded

Studentsmayusethebooktosupplementtheirnotesifneeded.

Materials&PrepProjectorandcomputerWhiteboardandmarkersClassroomcopiesofWS2.7

Sincemostoftoday’slessonfollowsWS2.7,youshouldhavereadthroughtheworksheet.Youmayprefertodeletethenotesfromtheworksheet(soitisonlyasheetofexercises)ifyouareworkingondevelopingnote-takingskillsinyourclassroom.WerecommendleavingthesesectionsinforELLclassrooms,soyourstudentscanfocusonsyntaxrulesinsteadoftranslatingwhattheyarehearingtovocabularytheyneedtothenwriteintheirnotebooks.

PacingGuide

th

Lesson2.07:Scope&Pseudocode

153

Page 154: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Introductiontoscope 10min

Worksheetactivity 15min

Introductiontopseudocode 5min

ProgrammingProject1 20min

ProcedureScopeisanotherchallengingtopic,sowe’vepreparedastudenthandoutthatdiagramsscope.Encouragestudentstotakesupplementalnotesintheirnotebookandonthehandout.

Bell-workandAttendance[5minutes]

IntroductiontoScope[10minutes]

1. UsingWS2.7,walkstudentsthroughthesampleillustrationofscopeandscope-relatederror.

Beforeyouexplainthatbracketsdefinescope,askstudentstotellyouwhytheythinktheerrorintheexample.Theymaybeabletospotthescopefromtheirreadinglastnight.

2. Havestudentscopytherulesforscopeofftheworksheetandintotheirnotebooks.Studentsshouldheadthepage“The4CommandmentsofScope,”andillustrate,circle,highlight,star,orotherwiseemphasizetheserulessotheyareeasytofindinthenotebookthroughouttheyear.

Transcribingthesenotesisnotbusywork—intheELLclassroom,thisslowsdownthepaceandallowsstudentsadditionaltimetoprocessthelanguageandstudytheconceptsconveyed.Thisisagoodstrategyforallclasses(ELLornot)!

Atthispoint,yourclassmayberaringtogetstartedontherestoftheassignmentwithoutyourhelp.Iftheyare,great!

Iftheyarestillseeminguncertainabouthowtoapplyrulesofscope,walkthroughExercise1aandasktheclasstoexplaintoyouhow/whyyouknowthatscopeabeginsandendswhereitdoes.

Lesson2.07:Scope&Pseudocode

154

Page 155: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

WorksheetActivity[15minutes]

1. HavestudentsworkindependentlyorinpairsonWS2.7.

a.Remindstudentstorefertotheir4Commandmentswhensearchingforerrors.

b.Playmusicquietlyinthebackgroundtoencouragefocusanddiscouragechatting.

c.Ifstudentsarestrugglingwiththeexercise,allowthemtopairup.Encouragestudentstotradepapersandlookforerrors.

2. Ifmore25%ormoreoftheclassisstruggling,returntowholegroupwiththestipulationthatstudentswhogetitmaycontinueworkingindependently.

3. Reviewanswersasawholegroup.MakesuretocallthevariablesboxedinExercise1“localvariables,”andaskstudentstoexplainwhatmakesthemlocalized.

Introductiontopseudocode[5minutes]

Usinganexamplethatwaspopularduringthelastweekofclass,showstudentshowtoplanaprogramusingpseudocode.

ProgrammingProject1[20minutes]

Asaclass,beginplanningaprogramtoanswerProgrammingProject1.

Thechallengingtaskofwritingthepseudocodeand/orstructurediagram(youshouldalwaysrequireone,both,oracombinationofthetwo)isthemostimportantpartofthisexercise,soavoidthetemptationofgivingstudentstoomuchguidance.

AccommodationandDifferentiationItislikelythatstudentswillnotfinishtheprogrammingprojectduringclass.Youcanreducestudentstressbysettingtheexpectationthattheysubmitcompletepseudocodebytheendofclass;notacompletedprogram.Youmayextendtheprogramforadvancedstudents,andaskthattheysubmitanentireprogram(completewithclassheader).

VideoBJP2–5,DrawingComplexFigureswithforLoopshttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c2-5

Lesson2.07:Scope&Pseudocode

155

Page 156: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

CSE142,ManagingComplexity:ProblemDecompositionandPseudocode(1:58–16:17)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=3431711f-29f8-43a5-9855-4d09894ae29d&start=118

CSE142,ManagingComplexity:NestedLoops(16:17–37:50)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=3431711f-29f8-43a5-9855-4d09894ae29d&start=977

CSE142,ManagingComplexity:ClassConstant(Optional)(37:51–49:17)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=3431711f-29f8-43a5-9855-4d09894ae29d&start=977

CSE142,ManagingComplexity:Review(Optional)(0:58–21:04)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=26cacdb4-6e47-405f-a788-912a9a158b41&start=58

ForumdiscussionLesson2.07Scope&Pseudocode(TEALSDiscourseaccountrequired)

Lesson2.07:Scope&Pseudocode

156

Page 157: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson2.08—ProgrammingProject

Overview

Objectives—Studentswillbeableto…

Planandconstructastructuredprogramcontainingnestedloops.

Assessments—Studentswill…

Submitacomplete,functionalprogrambytheendofnextclass

Homework—Studentswill…

OutlineChapter2,omittingBJP2.5

Materials&PrepProjectorandcomputer(ifyouareableto/opttouseEclipsewithyourstudents)Studentself-helpsystem(suchasC2B4orstudentpairing)

Makesureyouaresetuptogradestudentnotebookstoday.Ifpossible,youshouldonlycollect3–5notebooksatatimesostudentshavetheirnotebooksavailabletoreferenceduringprogrammingtime.

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Introduction&classroomprocedures 10min

Programmingproject 30min

Studentstradework,check,&submit 10min

Procedure

Lesson2.08:ProgrammingProject

157

Page 158: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Topreparestudentsfortheupcomingunitexam,thenextfewclassperiodswillbedevotedtoreinforcingconceptsandapplyingthetools,procedures,andcodethatwereintroducedthisunit.

Bell-workandAttendance[5minutes]

IntroductionandClassroomProcedures[10minutes]

1. Ifyourcomputertimerequiresyoutomovetoanotherroomortochangeseating,youshouldteachand/orreviewthoseproceduresbeforeintroducingthelabmaterial.It’sbeenafewweekssincethelastlongformprogrammingassignments,somakesuretoaskstudentswhattheproceduresareifthey:

havegottenstuck(checkpseudocodeandstructurediagram),finishedearly(moveontochallengequestions),orcan’trememberacodingruleorprocedure(checkyournotes,worksheets,andtextbook,C2B4)

Unlessyouhavehadstudentssubmittingworkelectronicallyregularly,youshouldmodelandreviewthoseproceduresbeforestudentsbeginwork.

2. Introducetheprogrammingproject,takingamomenttotalkstrategywithyourclass.

PROGRAMMINGPROJECT:Writeaprogramthatproducesthefollowingfigureasitsoutputusingnestedforloops.

|"""""""""|

\:::::::/

\:::::/

\:::/

\:/

/:\

/:::\

/:::::\

/:::::::\

|"""""""""|

TIPS:StartwithastructurediagramorwritingoutstepsinEnglishaspseudocode.Trytoisolaterepeatedtasksintomethods.Includecommentsinwithyourcodesootherscaneasilyunderstandwhatthecodeissupposedtodo.

3. Askyourclassforsuggestionsastohowtotacklethisprogrammingproblem.Studentsshouldsuggestdrawingastructuraldiagram,buildingtheprogramonemethodatatime(iterativedevelopment),andfollowingthecorrectionstepsontheirpersonalalgorithms(debugging).

Lesson2.08:ProgrammingProject

158

Page 159: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Proceduraldecompositionishard!Asagroup,askstudentstodiscusswhatcomponentsgointodrawingeachline.

Whatcharacteristicsstaythesameforeachline?(Slashes,colons,spaces)Whatcharacteristicscouldweusealoopfor?Whatmightwewanttomakeitsownmethodthatwecancallmorethanonce?

ProgrammingProject[30minutes]

GetstudentsstartedontheASCIIartprogrammingproject.Offerstudentshelpaftertheyhavetriedtoanswerthequestionsthemselves:

a.Havethecheckedthebookforexamples?

b.Havetheyaskedafriend(ortwo)forhelp?

Ifstudentsseemtobegettingstuckonthesamesegmentofcode,offerahintortipontheboard(silently,withoutdisruptingstudentflow).

Iftheentireclassisstuck,returntowholegroupandworkthroughtheprogrammingchallengetogetherasaclass,havingstudentsofferanincreasingproportionoftheanswersasyoumovealong.

Studentstradework,check,andturnin[5minutes]

Attheendofclass,havestudentslookovereachother’sprojectsbeforesubmitting.

AccommodationandDifferentiationIfyouhavestudentswhoarespeedingthroughthisproject,youshouldencouragethemto:

Finishtheprogrammingprojectstartedinclassyesterday.ActasstudentTAsandhelpstrugglingclassmates(NOTE:youshouldspecificallydirectstudentsNOTtogiveanswers,buttohelpstudentsthinkofideasontheirown.)

Ifyouhavestudentsthatarestrugglingduringthisclass(andyouwill),resisttheurgetohelpstudentstoomuchatthisstage.Askleadingquestions,directstudentstotheirnotes,oranexamplethatdemonstratesasimilarsolution,butdon’tgivestudentstheanswerhere.Resilience/gritisanimportantemotionaltoolforsolvingcomplexprogrammingproblems:theemotionaljourneystudentstakeduringthesedifficultprogrammingproblemsisasimportantastheactualcodingchallenge.

Ifstudentsarehavingtroubleduetolanguage,pairstudentsupsothosewithmoreadvancedEnglishcanhelpthosethatareemergentlanguagelearners.

Lesson2.08:ProgrammingProject

159

Page 160: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ForumdiscussionLesson2.08ProgrammingProject(TEALSDiscourseaccountrequired)

Lesson2.08:ProgrammingProject

160

Page 161: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson2.09—ProgrammingProject

Overview

Objectives—Studentswillbeableto…

Planandconstructastructuredprogramcontainingnestedloops.

Assessments—Studentswill…

Submitacomplete,functionalprogrambytheendofclass.

Homework—Studentswill…

Completepracticequestionswithclassconstants

Materials&PrepProjectorandcomputer(ifyouareableto/opttouseEclipsewithyourstudents)Studentself-helpsystem(suchasC2B4orstudentpairing)

Todayisday2oftheprogrammingproject;besuretoremindstudentsthattheyonlyhavethefirst30minutesofclasstofinishandsubmittheirprogram.Bepreparedtoreviewthecorrectcodeandofferanupgradeusingclassconstantsforthesecondhalfofclass.

Ifyouhavenotfinishedgradingnotebooks,makesureyouaresetuptogradestudentnotebookstoday.Ifpossible,youshouldonlycollect3–5notebooksatatimesostudentshavetheirnotebooksavailabletoreferenceduringprogrammingtime.

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Programmingproject 30min

Introductiontoclassconstants 10min

Studentsupdatetheircode 10min

Lesson2.09:ProgrammingProject

161

Page 162: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ProcedureToday’slessonwillbeacombinationofdrillingthepartsofabasicprogram,andconditioningstudentstocheckforcommonerrors.Tohookyourclass,havepicturesofpunchcardsandpunchcardreadersupwhenstudentsenter.Ifpossible,havephysicalpunchcardsavailabletopassaroundtheroomfortactilelearnersasyouexplaintheoriginsofthephrase“bug”and“debugging.”

Bell-workandAttendance[5minutes]

ProgrammingProject[30minutes]

Havestudentscontinuetheprogrammingproject,aimingtofinishwithabouttenminutesleftinclass.

IntroductiontoClassConstants[10minutes]

1. PresentonaboardorprojectoracompleteJavaclassthatsolvestheprogrammingproject.Ideally,thiswouldbeastudentsolution.Walktheclassthroughthesolution,havingstudentshelpyoutracetheflowofcontrolandpredictingoutputtoconfirmthattheprogramworks.

AskstudentswhattheywouldneedtochangeinordertomakethehourglassXunitslarger.Onlychangethevaluesthatstudentsspecifyinordertodrivehometheideathatmanyvaluesintheforloopterminationmustbeupdated.

Suggestthattheremightbeaneasierwaytoupdateallofthesevaluesatonce,andintroduceclassconstants.

2. Traceorruntheprogramwiththeupdatedclassconstantstodemonstratethatthisdoesindeedwork.

3. IfyouarerunningtheprograminEclipse,showthatyoucaneasilychangetheconstants.Changethevaluesseveraltimes,runningtheprogrameachtimetodrivethishome.

StudentsUpdateTheirCode[10minutes]

Givestudentstimetoupdatetheirprojectcode,nowincludingclassconstants.

AccommodationandDifferentiation

Lesson2.09:ProgrammingProject

162

Page 163: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Ifyouhavestudentswhoarespeedingthroughthisproject,youshouldencouragethemtoactasstudentTAsandhelpstrugglingclassmates(NOTE:youshouldspecificallydirectstudentsNOTtogiveanswers,buttohelpstudentsthinkofideasontheirown.)

Ifyouhavestudentsthatarestrugglingduringthisclass(andyouwill),resisttheurgetohelpstudentstoomuchatthisstage.Askleadingquestions,directstudentstotheirnotes,oranexamplethatdemonstratesasimilarsolution,butdon’tgivestudentstheanswerhere.Resilience/gritisanimportantemotionaltoolforsolvingcomplexprogrammingproblems:theemotionaljourneystudentstakeduringthesedifficultprogrammingproblemsisasimportantastheactualcodingchallenge.

Ifstudentsarehavingtroubleduetolanguage,pairstudentsupsothosewithmoreadvancedEnglishcanhelpthosethatareemergentlanguagelearners.

ForumdiscussionLesson2.09ProgrammingProject(TEALSDiscourseaccountrequired)

Lesson2.09:ProgrammingProject

163

Page 164: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson2.10—Finding&FixingErrors

Overview

Objectives—Studentswillbeableto…

Finderrorsintheirreturnedhomeworkassignments.Correcttheircode

Assessments—Studentswill…

Re-submitallhomeworkassignmentswithcorrectedanswers.

Homework—Studentswill…

Studyforthetestby:ReviewingallthebluepagesattheendofChapter2Re-readingsectionsasneeded

Submit5questionsforreviewinclasstomorrowusingelectronicsurvey

Materials&PrepAnystudenthomeworkassignmentsthatyouhavenotyetreturnedStudentself-helpsystem(suchasC2B4orstudentpairing)Electronicsurveyforstudentreviewrequests

Whenyougradehomeworkassignments,itwillbemostusefultotheselessonsifyouonlymarkananswerincorrectorcorrect.ELLclassroomsaretheexceptiontothisrule—studentswillbehavingahardenoughtimejustreadingthematerial;youcanspeedalongtheirprocessingbycorrectingoneexample,thenhavingthemlookforsimilarerrorswiththatexample.

Thehomeworktonightasksstudentstosubmit5questionsforreview.Createanelectronicsurveyforstudentstocompletewith6textfields,oneforname,and5forquestionstheyhaveaboutCh.2content.Setatime-deadline(e.g.10pm)bywhichtimestudentsmusthavesubmitted5questionsfromCh.2thattheywouldliketoseereviewedintomorrow’sclass.Ifstudentsdonothavequestions,stipulatethattheystillhavetosubmitsomethingtoreceivecredit,evenifitisonlyquestionstheythinkotherstudentsmayhave.

Lesson2.10:Finding&FixingErrors

164

Page 165: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Introductionandhomeworkdistribution 5min

Studentwork 35min

Studentstradework,check,andsubmit 10min

ProcedureTodaywecontinuereinforcingconceptsandapplyingthetools,procedures,andcodethatwereintroducedlastweek.Studentswillhavetheopportunitytocorrectanyincorrecthomeworkassignments.Ifstudentsdidnothavetimetofinishtheprogrammingprojectsfromyesterday,youmayallowthemtimetoworkonthoseprojectstoday.

Thisisagooddaytoloosenupthevibeintheclassroomabit.Tryplayingmusicsoftlyinthebackgroundtoencouragestudentstorelaxandfocusonspottingerrors.Trytoavoidloud,rhythmicmusic,andavoidthepitfallofallowingstudentstoselectthestation!

Bell-workandAttendance[5minutes]

IntroductionandHomeworkDistribution[5minutes]

1. Returnstudenthomeworkpackets,orhavestudentsplacetheirreturnedhomeworksinapileontheirdesk.

2. Explaintostudentsthattheyhavetheopportunitytogetfullcreditontheirhomeworkgradesbycorrectingthemnow,inclass.Askstudentsforsuggestions/ideasonhowtomakesuretheydon’tmissanyerrors.

a.Bynowstudentsshouldbeusedtorelyingontheirerrorchecklist/algorithm.

b.Hopefully,studentssuggestusingthe4CommandmentsofScope,creatingpseudocodeand/orstructurediagramstoclarifythinkingonprogramstructure,andcheckingtheirnotesandthetextbook.

StudentWork[35minutes]

Havestudentsworkindividuallytocorrecttheirhomeworkgrades.

Lesson2.10:Finding&FixingErrors

165

Page 166: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Offertimechecksforstudentssotheystayontask.

Ifstudentshavenotfinishedtheirprogrammingprojectfromyesterday’sclass,allowthemtodosotoday.

Studentstradework,check,andturnin[10minutes]

Attheendofclass,havestudentstradetheirhomeworkassignmentstoevaluateeachother’scorrectionsbeforesubmission.

AccommodationandDifferentiationIfyouhavestudentswhoarespeedingthroughthislesson,youshouldencouragethemtotackleprogrammingproject2&3inthetextbook.

Ifyouwereunabletofinishgradingstudentnotebooksyesterday,finishthemtodaywhilestudentsareworking.Returnnotebooksbytheendofclasssostudentsmayusethemtostudyfortheexam.

ForumdiscussionLesson2.10Finding&FixingErrors(TEALSDiscourseaccountrequired)

Lesson2.10:Finding&FixingErrors

166

Page 167: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson2.11—Review

Overview

Objectives—Studentswillbeableto…

IdentifyweaknessesintheirUnit2knowledge.

Assessments—Studentswill…

Createapersonalizedlistofreviewtopicstoguidetonight’sstudysession.

Homework—Studentswill…

Studyfortomorrow’stest!

Materials&PrepProjectorandcomputerWhiteboardandmarkerResultsfromelectronicsurveyofreviewtopicsClassroomcopiesofthepracticetestWS2.11

Oncestudentshavesubmittedtheirreviewrequests,assemblethosetopicsintocategoriesandpreparetore-teachthetopicsasneeded.

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Introductionandtestformatorientation 15min

Testreview 30min

Checkstudentstudylists 5min

Lesson2.11:Review

167

Page 168: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ProcedureEngagetheclassinthereviewsessionbypointingoutthatyourreviewtopicshavebeenhandselectedbytheclass.Explainthatyouwillreviewtest-takingstrategiesinadditiontoreviewingsubjectmatter.

Bell-workandAttendance[5minutes]

IntroductionandTestFormatOrientation[15minutes]

1. Clearlyindicatethatyouexpectallstudentstohavealistofreviewtopicstostudythisevening.Periodicallyremindstudentsthatthislistwillbecheckedattheendofclass.

2. Studentsshouldalreadybefamiliarwiththesectionsofthetest,butitdoesn’thurttohavestudentsre-readthedirections.

3. Workthroughthesampleproblemsonthetestasawayofreviewingtopics,andansweranyquestionsthatstudentsbringupasyougo.

TestReview[30minutes]

1. Usingtheresultsfromtheelectronicsurvey,addressthevariousreviewtopics,prioritizingquestionsthatpoppedupthemost.

a.Somequestionsyoumayalreadyhaveaddressedwhileworkingthroughthesampletest.

b.Bereadyforadditionalquestionstopopupasyougo.Saveyourselftheworkanduseoldhomeworkquestionsandstudent-generatedtestquestionsasexamplestoworkthrough.

c.Jotdownnotesaboutwhichtopicsyoucoveredinreviewsoyoucanadjusttheexamtoreflectthetopicsyourstudentshavelearned.

2. Useacombinationofgroup-solvingquestionsonthewhiteboard,think-pair-share,andtimed-responseasreviewstrategies.

3. Afteryou’vecompletedreviewinganidea,remindtheclassthattheyshouldwritedownthattopiciftheyfeeltheystillhavetoreviewittonight.(Yes,thiswillbearemindereveryfewminutes,butitwillpayofflaterwhenstudentsstartcreatingreviewlistswithoutpromptinglaterintheyear!)

Checkstudentstudylists[5minutes]

Lesson2.11:Review

168

Page 169: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Spendthelast5minutesofclasscheckingeachstudent’sreviewtopiclist.

AccommodationandDifferentiationInELLclasses,youmaywanttochangecode-writingquestionstoParsonsProblems.EducationalresearchshowsahighcorrelationbetweenParsonsscoresandcodewritingscores,andalowcorrelationbetweencodewritingandtracingandbetweenParsonsandtracing.(Inotherwords,ParsonsProblemsaccuratelyassessastudents’abilitytocreatecode.)FormoreinformationonParsonsProblems,checkoutthispaper(https://cseweb.ucsd.edu/classes/fa08/cse599/denny.pdf).

Eveninanon-ELLclass,youmaywanttochangesomeSectionIIquestionstoParsonsproblemsbecause(1)gradingthequestionsiseasier,sincelogicandsyntaxerrorsareeasytodiscern,and(2)studentschallengedbylanguageprocessingareabletomorequicklycompletetheproblem.

Ifyourstudentsareeasilycompletingtheprogrammingprojectsintheweekleadingtothetest,youmaywanttoeditthetestbydeletingthe“fillintheblanks”andleavingemptyspace.

ForumdiscussionLesson2.11Unit2Review(TEALSDiscourseaccountrequired)

Lesson2.11:Review

169

Page 170: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson3.00—TestReview&Reteach

Overview

Objectives—Studentswillbeableto…

Re-learnorstrengthencontentknowledgeandskillsfromUnit2.

Assessments—Studentswill…

Re-submittestanswerswithupdatedcorrectionsforpartialorfullcreditCreditdependsoninstructorpreference

Homework—Studentswill…

ReadBJP3.1upto“LimitationsofParameters”Correctanyincorrecttestanswersbyre-answeringonaseparatesheetofpaper

Togetbackcredit,theymustjustifytheirnewanswersStaplenewanswersheettooldtestandturnintomorrow

Materials&PrepProjectorandcomputerWhiteboardandmarkersCorrectedstudenttestsStudentgrades(postedonline,emailedtostudents,orhandedbackonpaperinclass)Digitalcopyoftestquestionsforprojector

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Classdiscussion(ifneeded) 10min

Testreviewandreteach 35min

Checkstudentnotesandreturntests 5min

Lesson3.00:TestReview&Reteach

170

Page 171: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ProcedureReturnstudentgradesbeforeclassbeginsorwhilestudentsarecompletingthebellwork.

Donotreturnstudents’testsbeforethereviewsession,sinceyouwanttomotivatestudentstopayattentiontotheentirereview,takingsupplementalnotestheentiretime.

Bell-workandAttendance[5minutes]

ClassDiscussion(ifneeded)[10minutes]

1. Ifgradesarelow,invitetheclasstoadiscussionofwhatcanbeimproved.Beginwithstudentcomplaintsandsuggestionstobuildstudentbuy-in.Askstudents:

howtheyfelttheyweregoingtodobeforethetestwhatsurprisedthemoncetheyweretakingthetestwhattheyfeltworkedinthefirstunit(lessons,reviewstrategies,assignments)whatdotheythinktheywanttochangeforthesecondunit

2. Onceyoufeelthatadialoguehasbeenestablished,validatestudents’feelings,thenchallengethem(e.g.APcoursesarestressful,butthisisgoodpracticeforcollege,wherethepaceisfasterandprofessorsdon’tgivepersonalizedinstruction).Inanon-judgmental,supportivetone,remindstudentsthattobesuccessfulinthecourse:

ReadingismandatoryHomeworkismandatory(Andvaluable!Youwillneverassign“busy”work.)Tobettermanagetheirtime,studentsshouldplanfor1hourofhomeworkaweeknight,withupto2hoursofhomeworkeachweekend.Ifthisseemsimpossible,theyshouldmeetwithyouortheirguidancecounselortoassesswhethertheycanfitinanAPclassatthistime.ItisVERYimportanttokeepyourtonesympatheticatthispoint—anoverworked,overstressed,underperformingstudentwillslowyourentireclassdown,andcolorthatstudentagainstCSforthefuture!

TestReviewandReteach[30minutes]

1. Walkthestudentsthrougheachquestiononthetest,glossingoverquestionsthateveryoneansweredcorrectly.

a.Youcanaskforstudentstovolunteeranswers,orcallonstudentsrandomly.Makesurethatstudentsexplaintheirlogicwhentheyanswer.Ifastudentgivesanincorrectanswer,theexplanationwilltellyouwhatyouneedtore-teachorclarify.

Lesson3.00:TestReview&Reteach

171

Page 172: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

b.Donotskipquestionsthateveryoneansweredcorrectly,butdonotspendmorethanthetimeittakestoreadthequestion,andcongratulatestudents’correctanswers.

2. Projectacopyofeachquestionasyoureview—thiswillhelpstudentsrecallthequestion/processtheinformation.

3. Makesurethatstudentsaretakingnotesduringthere-teach,remindingstudentsthatforhomework,theywillhaveanopportunitytowinbacksomeofthepointsontheirexam.

4. ForSectionIIquestions,selectasampleofstudentwork(withanyidentifyinginformationobscured),andworkthroughtheanswertogetherasaclass.

Checkstudentnotesandreturntests[5minutes]

Attheendofclass,checkstudentnotes,andreturnthetestsinhardcopyformifapplicable.

AccommodationandDifferentiationIfstudents’gradesaresufferingbecausethereadingassignmentsaretakingthemtoolong,youhaveafewoptions(somemoredrasticthanothers):

Setasideclassroomtimetoreadthroughtheassignmentbeforestudentsleave.

Givestudentsthelinesofcodeneededtocompleteassignments,butinjumbledorder.Havestudentsrearrangethelinesofcodeintotheproperprogram(thisiscalledaParsonsProblem).

Flipyourclassroom:recordyourlectures,andhavestudentswatchthemandtakenotesforhomework.Anyclassworkdrillsorworksheetscanbedistributedfor“homework,”andthemorecomplicatedassignmentsthatwouldnormallybedoneathome,canbecompletedwithyourhelpwhentheycometoclass.

Ifstudentsdon’thaveacomputertoworkonPractice-Itproblemsathome,createprinted-outsheetsinsteadthatstudentscanwritecodeonto.Classtimeshouldthenbefilledwithreadingassignments,andmorecomplicatedcodingpracticesothatyouareavailabletotutorasneeded.

Encourageadvancedstudentstotakeonadditionalprogrammingchallenges.OneeasywaytodothisistoassignProgrammingProjectsfromthebluepagesattheendofeachChapter.Amoreopen-ended(andmoreinteresting)challengewouldbetohave

Lesson3.00:TestReview&Reteach

172

Page 173: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

studentsflesh-outadditionalsectionsofalarger,year-roundPokémon-esquegame.Foreachconceptyoulearn,askyouradvancedstudentstothinkofafeatureorsequencefromthegamethatcanbeprogrammedusingthetoolsthey’veacquired.

Encouragestudentstocarefullynametheirfiles,andleavelotsofcommentssotheycanusethecodelaterintheyeartoputthegametogether.

ForumdiscussionLesson3.00TestReview&Reteach(TEALSDiscourseaccountrequired)

Lesson3.00:TestReview&Reteach

173

Page 174: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson3.01—Parameters

Overview

Objectives—Studentswillbeableto…

Correctlyconstructformalandactualparameters(arguments).Predictoutputofprogramsthatuseparameters

Assessments—Studentswill…

Teachamini-lessonexplainingtherelationshipbetweenparametersandvaluesSubmitPractice-Itquestions

Homework—Studentswill…

ReadBJP3.1“LimitationsofParameters”and“MultipleParameters”Completeself-checkquestions4-7

Materials&PrepProjectorandcomputerWhiteboardandmarkersAssignmentsfor5studentgroupsGIFofsoftwaredevelopmentgoneawry(https://g.redditmedia.com/tPgaGgDXL0yZyLe_4pjr1ZO2_qpIOk8t5eopSErOwVk.gif?w=320&s=c5345cd1b395f874f92f51e2509e97ae)

PacingGuide

Lesson3.01:Parameters

174

Page 175: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Instruction 15min

Studentmini-lessonpreparation 10min

Studentmini-lessondelivery 10min

Practice-ItActivity 10min

ProcedureYourhookfortodayisanexampleofwhathappenswhenwedon’tstayflexiblewithourprogramming.Havethegifupandlooping,andexplainthatthisimageisanillustrationofwhatcanhappentoourprogramsifwedon’tmakethemadaptable.

Bell-workandAttendance[5minutes]

Instruction[15minutes]

1. Beginclasswithalecture/discussionthatintroducesparameters

Partofthereasonsthathumansaresogoodatsolvingnewproblemsisthattheygeneralizethesolutiontowholecategoriesofproblems.

Thebookgivesanexampleofwalkingasageneralizabletask—walking20stepsandwalking10stepscanbedescribedasthetaskof“walkingforward,”andthepartthatvaries(wecallthisaparameter)isthenumberofsteps.

Inprogramming,whenwemakecodeflexibleby“parameterizing”partsofthetaskthatarelikelytochange,weendupwithprogramsthatareshorter,easiertounderstandforothercoders,betterorganized,andreusable.

Imaginehowdifficultlifewouldbeifyouhadtoseparatelylearnallthemovementsrequiredtowalk10stepsdownthatrunwayinadditiontotheprocedureforwalking20stepsittakestogettothestage?Instead,yourbraincomputesageneralrulesomethinglike“walkonlythenumberofstepstothenextobstacle,”then(ideally)youreyesandearsinputhowmanystepsthatshouldbe.

Javaisthesameway—ittakeslessmemoryandcomputingpowertoexecuteaprogramifyouwritecodethatisflexible/reusablewithdifferentparameters.(Infact,inthischapterwe’regoingtolearnhowtouseuser

Lesson3.01:Parameters

175

Page 176: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

input—liketheinformationwegetfromoureyesandears—toinfluencethebehavioroftheprogramswewrite!)

Whataresomeotherbehaviorsthatwe“parameterize”everyday?(Ifstudentsneedhelpgettingstarted,suggest:

Braidinghair:differentheadsrequireadifferentnumberofbraids,butthebraidingisalwaysthesameprocedure.

TurningonthestereoorTV:themethodstoturnontheTV,radio,orstereoarealwaysthesame,butyouadjustthevolumetodifferentlevelsdependingonthetimeofday.Whatwouldtheparametersbeinthisexample?(Time,volume)

2. Ifyourstudentshadaproblemfromthelastcoupleofweeksthatdrovethemcrazy,usethatexampleinstead,sincethey’llalreadyhaveaclearmemoryofit.Otherwise,reviewthisprogrammingexamplefromthebook:

Inthelastchapter,weinsertedspacesintoadrawingbycallingamethod:

writeSpaces();

IfwewantedtotellmethodwriteSpacestooutput10spaces,wemightdecidetodeclareavariable:

intnumber=10;//Cananyoneexplainwhythiswon'twork?

writeSpaces();

→Thiswon’tworkbecausenumber’sscopeisoutsidethewriteSpacesmethod.

Insteadweparameterizethenumberofspacesbychangingthemethodheaderashighlightedbelow(thisusedtobeemptyparentheses,remember?)

publicstaticvoidwriteSpaces(intnumber){

for(inti=1;i<=number;i++){

System.out.print("");

}

}

Nowwhenwecallthemethod,wecan(andmust!)includetheparameterizedvalue:

Lesson3.01:Parameters

176

Page 177: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

writeSpaces(10);

writeSpaces();//ERROR:Noparameterspecified

writeSpaces(24901);

writeSpaces(9/3-2);

OntheboardorinEclipse,pointoutthedifferencebetweenanactualparameter(argument)andaformalparameter(orjust“parameter”).Pointtoafewdifferentexamplesofeachonsamplecode,askingstudentswhichoneiswhich,andhowtheyknow.

StudentMini-LessonPreparation[10minutes]

1. Studentsaregoingtogetachancetoteachthesecondhalfofclass—themechanicsofparameters.Assigneachgrouponesectionofthesamplecodeinsection3.1“MechanicsofParameters.”

Studentgroupsshouldtake10minutestoreviewtheprogram,readtheexampleonthepagesfollowingtheexample,thenfigureouthowtheywanttoexplaintoclasswhatvaluesarebeingstoredinthecomputer’smemory.

2. Ontheboardoroverhead,givestudentsafewthingstheyshouldconsiderinplanningtheirminilesson:

a.Whoisgoingtospeakwhen?

b.Howareyougoingtoillustratetheflowofcontrol?

c.Whatdoyouneedtohaveupontheboardtoillustrateyourmini-lesson,andwhoisinchargeofwritingitout?

d.Whereandhowwillyoufeaturetheoutputproducedbyyourcodesegment?

StudentMini-LessonDelivery[10minutes]

Havestudentgroupssequentiallyteachthroughtheexampleinthebook,demonstratingthechangestothestoredvalue,predictingoutput,andtracingtheflowofcontrol.

Practice-ItActivity(ifneeded)[10minutes]

Ifthemajorityofstudentsareunderstandingthecontent,allowstudentstoworkindividuallyonPractice-Itself-checkproblems:

a.methodHeaderSyntaxb.MysteryNumsc.Oops3-errors

Lesson3.01:Parameters

177

Page 178: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

AccommodationandDifferentiationIfstudentsarestrugglingwithcontent,youmightopttoworkonPractice-Itinawholegroupsetting.Insomeclasses,theteachingexercisemighttakeanentireclassperiod.

Tokeepfromlosingtoomuchinstructionaltime,remindstudentsoftheirpresentationtimelimitwhiletheyareplanning,andduringtheirpresentation.

Checkstudentsastheyarecoordinatingtheirmini-lesson;offerfeedbackonthetimingoftheirlesson.

Useatimerduringstudentlessons,andholdupa“1minute”warningsigntokeepstudentsonpace.Thiscanbecomeafun/sillychallengeifthatsuitsyourteachingstyle.Useabuzzerorgongtokeepthelessonsonscheduleinanonstressfulway.

Ifstudentsarespeedingthroughthecontent,encouragethemtocompleteoneofthefollowingprojects(dependingonhowmuchtimeisavailable):

Createaposterfortheclassroomthatdiagrams/illustrateshowtocorrectlyparameterizeamethod.

TackleCh.3ProgrammingProject#1forextracredit.(Thismightbecompletedoverthecourseofseveraldays.)

MisconceptionsWhenpassingparameterstomethods,studentsmayincludethetypewhentheparameterisavariable:whiteSpace(intx);.Thestudentmaybepatternmatchingmethoddeclarationwithmethodinvocation.

VideoBJP3–1,MechanicsofParametershttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c3-1

CSE142,SingleParameters(21:05-33:05)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=26cacdb4-6e47-405f-a788-912a9a158b41&start=1265

CSE142,MultipleParameters(33:06-50:0)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=26cacdb4-6e47-405f-a788-912a9a158b41&start=1985

Lesson3.01:Parameters

178

Page 179: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

CSHomeworkBytes,FunctionsandParameters,withKomalhttps://www.youtube.com/watch?v=UuZCQWErV-A

ForumdiscussionLesson3.01Parameters(TEALSDiscourseaccountrequired)

Lesson3.01:Parameters

179

Page 180: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson3.02—LimitationsofParameters&MultipleParameters

Overview

Objectives—Studentswillbeableto…

Modifyprogramsusingparametersandclassconstantstocreateoriginalartworks.

Assessments—Studentswill…

Completeanartprojectand“artiststatement”justifyingtheirprogrammingchoices

Homework—Studentswill…

ReadBJP3.1“ParametersversusConstants”and“OverloadingMethods”Jazzupartprojectsandprograms

Materials&PrepProjectorandcomputerWhiteboardandmarkersSampleoffinalproject(picture,artiststatement,code)Picturesfrompreviousyear’s“galleryopening”Ballforpassingflowofcontrol

Aroundthistimeofyear,manyschoolshaveopenhousesand/orparent-teacherconferences.Ifyouhavethetimeandresources,thisprogrammingprojectisaexcellentopportunityforstudentstoshowcasetheirworkforparents,principals,superintendents,etc.Forinstructionsonusingthislessonasanopportunitytosharestudentwork,refertoAccommodation&Differentiationattheendofthislessonplan.

Ifthisisyourfirstyearteachingthislesson,youobviouslywon’thavepicturesfrompreviousyearsevents.Makesuretodocumentthislessonforfutureyearssoyoucanhookstudentswiththeglamorandexcitementofanartgalleryopening.

PacingGuide

Lesson3.02:LimitationsofParameters&MultipleParameters

180

Page 181: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Reviewandintrotomultipleparameters 15min

Studentpractice 30min

ProcedureHookyourstudentsbyshowinganexampleofacompletedartproject,statement,andcodesample.Ifyoudon’thavepreviousworktosharewithstudents,showthemsomesamplesofASCIIartandaskstudentstopredicthowmanylinesofcodethey’dneedtodesigntheimages.

Bell-workandAttendance[5minutes]

ReviewandIntroductiontoMultipleParameters[15minutes]

1. Ifyouwillbeholdingareceptionforstudentart(seeendoflessonfordetails),announcethatnow.Segueintotoday’slessonbyexplainingthatyou’regoingtogivestudentsafewadditionaltoolstouseintheirartproject.Givethemaquickrecap/reviewbeforeteachingmultipleparameters:

Callstudentsuptotheboard—sometohelpyoudemonstrateflowofcontrol,anothertoproduceconsoleoutputonthewhiteboard.

Usingtheexamplebelow,reviewtheflowofcontrolbyhavingthestudents(mainandparameter)passinformationtoyou(themethod).Havetheclassdirectyourotherstudentwhatoutputtowriteontheboard.Askstudentswhatvariablexisthroughouttheexampletodrivehometheideathatparametersdon’tchangevaluewhenthemethodchangesalocalvalue.

Lesson3.02:LimitationsofParameters&MultipleParameters

181

Page 182: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

publicclassParameterExample{

publicstaticvoidmain(String[]args){

intx=17;

doubleNumber(x);

System.out.println("x="+x);

System.out.println();

intnumber=42;

doubleNumber(number);

System.out.println("number="+number);

}

publicstaticvoiddoubleNumber(intnumber){

System.out.println("Initialvalue="+number);

number=number*2;

System.out.println("Finalvalue="+number);

}

}

Itispossibletodeclaremultipleparameters!Thetrickistoalwaysmakesureyourmethodacceptstheparametersinthesameorder.Whencallingthemethod,passtheparametersinthesameorderinwhichtheyweredeclared.

publicstatic<type><name>(<type><name>,<type><name>…<type><name>){

<statement>;

<statement>;

<statement>;

}

2. Usingthediagrambelow,walkstudentsthroughthiscodingexample.Youshouldhavestudentsdraw,circle,andexplainthepartsofthecodeintheirownnotebookssotheyhaveachancetothinkthisthrough.

Lesson3.02:LimitationsofParameters&MultipleParameters

182

Page 183: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

publicstaticvoidmain(String[]args){

writeChars('=',20);//-----------------Writesalineof20='s

System.out.println();//-----------------Returnstothenextline

for(inti=1;i<=10;i++){//-------For10linesofpicture(height)

writeChars('>',i);//-------Increasethenumberof'>'sineach

line

writeChars('',20-2*i);//-------Decreasethenumberofspacesinea

chline

writeChars('<',i);//-------Increasethenumberof'<'sineach

line

System.out.println();//-------Gotothenextlinebeforestarting

thebody

}//oftheloopagain.

}

publicstaticvoidwriteChars(charch,intnumber){

for(inti=1;i<=number;i++){

System.out.print(ch);

}

}

Havestudentspredicthowtheoutputwillchangeifyouchange1or2thingsinthecode,thenallowthemtostarttheiropen-endedactivity.

StudentPractice[30minutes]

1. Encouragestudentstospendafewminutesfiddlingwiththecodewereviewedinclasstoseehowitchangestheoutputtedimage.It’sreallyimportantthatstudentshavetimeandspacetofiddlewithcodetounderstandhowthedifferentpartsrelate.Encouragestudentstostartwiththiscodeandbuildfromit/changeittomakewhateverimagestheywanttomakefortheirfinalproject.

2. Instructstudentsthattheywillneedtocreateadesignthatusesparameters,loops,and/ornestedloops.Extrapointswillbeawardedforparticularlycomplex/creativeimages.

3. Theyshoulduse(andkeepcopiesof)astructurediagramand/orpseudocodefortheirownrecords,sincetheywillbeexpectedtowriteashortparagraphexplaininginplainEnglish(ortheirnativetongue).

4. Theyareallowedtocontinueworkingonthisprojectoutsideofclass:youhavegraciouslydecidednottoassignproblemsforhomeworktonightsothattheywillhavetimetoworkonthecode.

Lesson3.02:LimitationsofParameters&MultipleParameters

183

Page 184: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Ifyoufindthatstudentsarehighlyengagedintheproject,youmightopttoextendthislessontoa2periodcodingsession.Themoreopportunitystudentshavetomanipulatecodeandcheckoutput,themoreintuitiontheywillhavedowntheroadastheyinternalizewhatindividualpiecesofcodemean.

AccommodationandDifferentiationIfyoufeelthatstudentsneedtheextrareview,askstudentstohelpyoubuildtheexampleprogramyouuseduringtheintroductionofclass.Dothisasawholegrouptokeepclassonpace,andwriteonlytheinformationthatstudentsgiveyou(i.e.letmistakeshappen,thenguidetheclasstoerror-checktheirownwork).

Ifstudentsarehavingahardtimewiththecodingproject,youmayencouragethemtoworkinpairsinsteadofasindividuals.Ifsomeofyourclasspartnersup,makesurethattheclassunderstandsthatteamswillbeexpectedtowritemorecompleximagesthanthosecreatedbystudentsworkingalone.

EncouragestudentstothinkabouttheirlearningandcodingprocessesbyhavingstudentsarticulateHOWthey’velearnedwhattheylearned.Thiscanbedonebyhavingstudentsexplaintheircodingdecisionstopeersandlaypeoplewithnocodingexperience.Agreatwaytodothisinalow-pressuresettingistohavestudentssharetheirworkwithparentsandothersatanopenhouse;hamitupalittleforfun!

Displaystudentworkaroundtheroom,andhavestudentsexplainortalkabouttheirworkduringan“artgalleryopening”heldatlunch,afterschool,orintheeveningduringparentteacherconferencesoropenhouseevents.

Inviteyourprincipal,superintendent,andschoolstafftoattend—thisisagreatwaytoincreasecommunitybuy-inforyourclass.

Provide(orhavestudentsbringin)cubedcheese,fruit,crackers,whitegrapejuice,andcrackers.Createafancyreceptiontablewithatablecloth,plasticwineglasses,andcocktailnapkins.

Playjazz,stringquartet,ortriphopsoftlyinthebackgroundtocreateatrendyreceptionvibe,andhavestudents“dresslikeartists”andstandneartheirwork.Makesureyoudressup/downtofitthescene!

Ifpossible,handvisitors“questioncards”togivethemideasofhowtheycanlearnmoreaboutstudentworkastheycirclethe“gallery.”Cardsshouldincludepromptslike:

Tellmeaboutyourpicture;howdidyoucomeupwiththisidea?Canyouexplaintomeabitabouthowyougetthecomputertodrawthisimage?

Lesson3.02:LimitationsofParameters&MultipleParameters

184

Page 185: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Howdidyougoabouttheprocessofwritingthiscode?Howdidyoustartthisproject?IfIwantedtochangethispicture,howwouldIgoaboutdoingit?

Aneventlikethismaintains/raisesstudentmoraleasstudents:

takeownershipoftheirwork,receivepraisefortheirhard-earnedaccomplishmentsthusfar,andrealizehowmuchthey’velearnedwhentheyexplaincodetoanon-coder.

ForumdiscussionLesson3.02LimitationsofParameters&MultipleParameters(TEALSDiscourseaccountrequired)

Lesson3.02:LimitationsofParameters&MultipleParameters

185

Page 186: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson3.03—ReturnValues

Overview

Objectives—Studentswillbeableto…

Writeaprogramthatreturnsvalues.

Assessments—Studentswill…

CompletePractice-ItquestionsWriteaprogramtomeetaPokémonChallenge

Homework—Studentswill…

Completechapter3self-checkquestion17andexercise#1

Materials&PrepProjectorandcomputer(ifyouareableto/opttouseEclipsewithyourstudents)WhiteboardandmarkersPosterorimageof

Blastoise(http://tinyurl.com/ndy3v69)andRaichu(http://tinyurl.com/n2u5vn2)

ThislessonusesPokémoncode;youshouldreadthroughtheexampleandlearnhowstatsworkat(http://bulbapedia.bulbagarden.net/wiki/Stats).Thewikioffersagreatamountofdetail,andcanbeusedtoofferadditionalprogrammingchallengestoadvancedstudents.Youmaywanttobookmarkthispageforfuturereference,sincePokémonstatsareusedinfutureexamples.

PacingGuide

Lesson3.03:ReturnValues

186

Page 187: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Reviewandintrotoreturningvalues 15min

Practice-It 15min

PokémonChallenge 15min

ProcedureThislessonintroducesmethodsthatreturnvalues,andfamiliarizesstudentswiththeMathclass.YoushouldhookstudentsbyintroducingthePokemonchallenge(tobecompletedattheendoftheclass);studentswillcreatemorecodetobeusedintheirlargerPokemonprogram.

Bell-workandAttendance[5minutes]

ReviewandIntroductiontoReturningValues[15minutes]

1. Beginwithalecture/discussionaboutthePokémonchallengeandreturningvalues.

Whenyou’replayingavideogamelikePokemon,partofthefunisthegraphicimagesthathelpcommunicatethestoryofyourbattles,training,ortravels.However,alloftheoutcomesofyourgamearedeterminedbymaththathappensinthebackground.

ThePokemonwithbetterstatswinsabattle;someadditionalrandomnumbersarethrownintorepresenttheunpredictablenatureoftherealworld.

Todaywe’regoingtolearnhowtowritemethodsthatreturnavalue—wealreadyknowhowtogetJavatocomputesimpleequationsforus;nowwe’regoingtolearnhowtogetJavatogiveusbackthosenumberssowecanusethemelsewhereinourprogram.

Whileprogrammerscanmanipulatetheparameterspassedintoafunction,theircodeisoperatedonacopyofthevalue,andnotthevalueitself.

Ifintxispassedasanargumentintoanexpressionastheparameterintnum,thefunctionmaymanipulatethevaluestoredinnum.Whenthefunctionreturns,xwillbeunchanged.

Lesson3.03:ReturnValues

187

Page 188: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

StudentsmayfindthefollowinganalogyfromStackOverflowhelpful:“Theproceduredefinesaparameter,andthecallingcodepassesanargumenttothatparameter.Youcanthinkoftheparameterasaparkingspace,andtheargumentasanautomobile.”

We’realsogoingtolearnhowtouseacollectionofequationsthatJavaalreadyhaswrittenforuscalledtheMathClass.Thesepre-mademethodsmakedoingcomplexequationsmucheasier!

2. Here’sthesyntaxtowritingamethodthatreturnsthesumofnumbers1–n;firsttheheader:

publicstaticdoublesum(doublen){

We’reusedtohaving“void”inthisspot—butvoidactuallymeansthatwe’rewritingamethodthatwedon’texpecttoreturnanything.Inthishighlightedexample,wewriteourmethodtoreturnavalueofthedoubletype.

publicstaticdoublesum(doublen){

Highlightedisourmethodname,itgoesinthesameplaceintheheaderasitalwaysdid.

publicstaticdoublesum(doublen){

Weusedtojustleavethehighlightedsectionasemptyparentheses,nowwehavetotellJavawhattypeoftypeofdatawe’regoingtoputintothemethod(theformalparameter).

3. Askstudentstochangethemethodheadersoitsumsdatafrominputintdataandreturnsdataofthetypeintaswell.

4. AskstudentstochangethemethodheadersothisnewmethodiscalleddoubleSum.

5. Ifstudentsareadjustingthesepartsofthemethodheaderwithease,moveontothemethodbody:

publicstaticintsum(intn){

return(n+1)*n/2;

Withoutthespecialreturnstatement,thiswouldn’treturnavaluetothemainmethod!Itwouldbasicallybeavoidmethod,liketheoneswewrotebefore.ItisanerrorinJavaforflowofcontroltoreachtheendofanon-voidmethodwithoutareturn!

Thismethodonlymakessenseifwehaveamainmethodthatcanpickupthevaluethatwe’reaskingJavatoreturn,sohavestudentswriteamainmethod:

Lesson3.03:ReturnValues

188

Page 189: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

publicstaticvoidmain(string[]args){//a.Whyisthemainmethodvoi

d?

intanswer=sum(100);//b.Whatisthislinedoing?

System.out.println("Thesumof1to100is"+""+answer);

i. Themethodmainisvoidbecauseitreturnsnovalue.ii. Thislineisdeclaring&assigningavaluetothevariableanswer.

6. Askstudentstotellyouwheretoplacethebrackets,andbrieflyreviewscope.

Iftheywanttodofanciermath,theycanusetheformulasthatJavahasalreadystoredintheMathclass.Asstudentsreadlastnight,thereisalistofthemost-usedformulasintable3.2ofthebook.

ThereisspecialnotationneededforthemethodsintheMathclass,becauseyouhavetotellJavatogoandusethemethodinanotherclass.Wecallthis“dotnotation.”

IfyouwantedtogeneratearandomnumbertouseinaformulaforyourPokemongame(toaddalittlechancetoabattle,letssay),youwouldcreateamethod:

publicstaticdoublepokemonRandom(){

returnMath.random()*100;

}

Themathclass’methodrandomgivesarandomnumberbetween0.0and1.0;wemultiplyitby100becausePokemonrandomnumbersarevaluesbetween0and100.Thismethodnowgivesusarandomnumberbetween0and100.WecanuseournewpokemonRandommethodwheneverweneedarandomnumberfromthatrange.

Ifstudentsaregettingthematerial,havethemworkindependentlyonthePractice-Itproblems,otherwise,workthroughtheproblemstogetherasawholeclass.

Practice-It[15minutes]

HavestudentsworkindividuallyorinpairstocompletethefollowingPractice-Itselfcheckquestions:

1. parameterMysteryReturn2. mathExpressions23. min

PokémonChallenge[15minutes]

Lesson3.03:ReturnValues

189

Page 190: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Oncestudentshavecompletedtheseexercises,invitethemtocompletethefollowingPokémonchallenge:

POKEMONCHALLENGE:

APokémon’sbasestatvalueswillmostoftenhavethegreatestinfluenceovertheirspecificstatsatanylevel.Ifweleaveoutindividualvalues,effortvalues,andnature,alevel100Pokémon’sstatsinAttack,Defense,Speed,SpecialAttack,andSpecialDefensewillbeexactly5morethandoubleitsbasestatvaluesineach,whiletheHitPoints(HP)statwillbe110plusdoublethebasestatvalue(exceptinthecaseofShedinja,whoseHPisalways1).

WriteaprogramthatreturnsaPokémon’sstatsforAttackandHPatlevel100.Youshoulduseparametersandmethodsthatreturnvaluesforthisprogram.YoumaychoosetousethebasestatsforBlastoiseORRaichugivenhere:

Blastoise Raichu

HP:79 HP:60

Attack:83 Attack:90

Defense:100 Defense:55

SpecialAttack:85 SpecialAttack:90

SpecialDefense:105 SpecialDefense:80

Speed:78 Speed:110

AccommodationandDifferentiationForstudentswhocompletethePokemonchallengeearly,askthemtofleshouttheirprogramby:

AddingmethodsthatreturnstatsforSpeed,SpecialAttack,SpecialDefense,andDefense.

WritingamethodthatwillcomparestatsbetweenBlastioseandRaichu,thenreturnthemaximumvalue.(Thisprogramdoesn’tneedtoacceptuserinput–yet!)

IfstudentsarestrugglingwiththePokemonChallenge,urgethemtobeginwiththeirstructurediagramofpseudocode.Oncetheyhavethiscode,helpthemwritethemethodtocalculatestatsbyassistingwiththealgebra,ifneeded.

Lesson3.03:ReturnValues

190

Page 191: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

MisconceptionsOutputtotheconsoleissomehowsynonymouswiththereturnvalueofamethod:overloadingtheuseofthewordoutput.

VideoBJP3-2,ParametersandReturnValueshttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c3-2

CSE142,MethodsthatReturnValues(1:25-8:45)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=dc713b99-c294-403f-82ee-52fc3323a19b&start=85

CSE142:Returnvalueworkedexample(8:46-38:32)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=dc713b99-c294-403f-82ee-52fc3323a19b&start=85

ForumdiscussionLesson3.03ReturnValues(TEALSDiscourseaccountrequired)

Lesson3.03:ReturnValues

191

Page 192: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson3.04—ProgrammingProject

Overview

Objectives—Studentswillbeableto…

Writeaprogramthatusesparameters,themathclass,andreturnsvalues.

Assessments—Studentswill…

SubmitanEquestriaprogrambytheendofclass.

Homework—Studentswill…

ReadBJP3.3upto“InteractiveProgramsandScannerObjects”CompleteCh.3self-checkquestions18&19

Materials&PrepProjectorandcomputer(ifyouareableto/opttouseEclipsewithyourstudents)WhitepaperandmarkersClassroomcopiesofWS3.4,EquestriaClassroomcopiesofAlgorithmforSolvingProblemsPosterorimageofEquestriamapwithCartesiancoordinates(Poster3.4)

Thehandout“AlgorithmforSolvingProblems”shouldbeused/drilledeverytimethestudentsareaskedtosolvealarger,APTestSectionII–typeproblem.Youmayfinditusefultomakealarge-formatpostertohanginyourroomsostudentsalwaysseethestepstheyshouldusetotacklealargeprogrammingproblem.

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Introductiontoprogrammingproject 5min

Studentprogrammingtime 45min

Lesson3.04:ProgrammingProject

192

Page 193: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ProcedureOverthenextfewweeks,we’llbeintroducingstudentstolargerprogrammingprojectstomeettheAPComputerScienceAlabrequirements.Itisinyourandyourstudents’bestinterestifyouencouragethemtohelpthemselvesandeachotherbeforeseeingyou.Dependingonthelengthofyourclassperiods,thislabmaytake2classperiodstocomplete.

Bell-workandAttendance[5minutes]

IntroductiontoProgrammingProject[10minutes]

Beginwithanintroductiontotoday’sprogrammingproject.

Studentsshouldcompletethisprogrammingprojectindividually.Asawholegroup,reviewtheAlgorithmforSolvingProblemssheet.Readthesheetoutloud,andbrieflymodelthestepsasyoureviewtheprogrammingassignment.Readtheprogrammingassignmenttotheclass,takingtimetopausebetweeneachofthethreerequirementsoutlinedinthequestion.

Askstudentswhattheirveryfirststepsshouldbeaccordingtotheproblem-solvingalgorithm.

Requirethatpseudocode/commentdocumentationbesubmitted.Includetheseaspartofthelabgrade.

Remindstudentstotackleonepartoftheproblematatime.ItisOKiftheyleavepseudocodeinwhiletheysolveadifferentpartoftheproblem,andtheydon’thavetosolveallofpartsoftheprograminanyparticularorder.

Theyshouldrefertotheirnotes,textbooks,andposters/workaroundtheroomtohelpthemcomeupwithideas/solutionstoprogrammingproblems.

Sometimesit’sagoodideatostepawayfromaproblemforafewminutesifthey’restuck—workonadifferentmethodandreturntowheretheywerestucklater.

StudentProgrammingTime[45minutes]Inanemail,ontheprojector,orasahandout(WS3.4),givestudentsthefollowingquestionstoworkonindividually,orinpairs.

Lesson3.04:ProgrammingProject

193

Page 194: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

PROGRAMMINGPROJECT

Exercise1

PrincessLunaandCelestiaaregoingonatourofthekingdomtogreettheothercitizensofEquestria.Theirtourtakesthemonacircularpath(shownonmap).WriteamethodcalledroadTripthat(1)acceptsasaparameterthediameterofthecircularpath,and(2)returnsthelengthofthetrip.

Theequationforcircumferenceis:C=dπ

JavahasamathconstantcalledMath.PI.

Exercise2

Writeamethodcalleddistancethat(1)acceptsfourintegercoordinates:x1,y1,x2,y2asparameters,(2)computesthedistancebetweenpoints(x1,y1)and(x2,y2)onthemap,and(3)returnsthatdistance.

Theequationforthedistanceis:sqrt((x2-x1) +(y2-y1) ).

Testoutyourprogrambywritingamainmethodthatcallsthedistancemethodforeachofthefollowingpairsofcities.Yourmainmethodshouldoutputthevaluereturnedbythedistancemethod.

1. DistancefromBaltimaretoManehattan=

2. DistancefromLosPegasustoNeighagraFalls=

3. DistancefromtheBadlandstoPonyville=

Exercise3

WriteaprogramthathelpsPrincessLunaplana3-stoptourofEquestria.Chooseany3locationsinEquestria,asdefinedbytheirxandycoordinatesonthemap.Youprogramshouldoutputthedistancebetweenthethreedestinations.

YoushouldusethedistancemethodsyouwroteforExercise2.

Exercise4

WriteamethodcalledtotalTripthatacceptsparametersfor3locations(eachcontainingcoordinates)andreturnsthetotaldistancetraveledbyvisitingall3locationsandreturningtothestartinglocation.YoushouldusethedistancemethodsyouwroteinExercise2andyoucanchooseany3locationsinEquestria.

Extracredit:makethisprogramcompute4locationsinstead!

2 2

Lesson3.04:ProgrammingProject

194

Page 195: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

AccommodationandDifferentiationForstudentswhocompletethelabearly,askthemtofleshouttheirprogrambyaddingamethodthatwillcalculatethesumofthedistancestravelledbetweenthreecitiesinExercise2.

Ifyoususpectthatstudentswillstrugglewithproceduraldecomposition,havethemworkingroupstofigureoutacourseofactionbeforebeginning.Proceduraldecompositionisoneofthehardestskillsforstudentstoacquire,soitiscriticalthatyouallowstudentstofightthroughtheprocess.

Ifadditionalscaffoldingisneeded,youmightlistallofthepartsoftheprogram,orhavestudentscomeupwiththeparts(“figureouthowtowritetheequationinJavausingthemathclass,”“createsomeparameterstopasstoareturnmethod,”“writetheframeworkforamethodtoreturnthedistancevalue”)outoforder,thengivethestudentssometimetoorganizethestepsthemselves.Asawholegroup,youcanthencometoconsensusonwhatstepsneedtobeapproached,andwhatordercomponentsshouldappearinthefinalprogram.

ForumdiscussionLesson3.04ProgrammingProject(TEALSDiscourseaccountrequired)

Lesson3.04:ProgrammingProject

195

Page 196: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson3.05—UsingObjects&StringProcessing

Overview

Objectives—Studentswillbeableto…

Differentiatebetweenprimitiveandobjecttypes.Apply0-indexingandstringprocessingtechniquestopredicttheoutputofaprogram.

Assessments—Studentswill…

CompleteWS3.5

Homework—Studentswill…

ReadBJP3.3“InteractiveProgramming”and“SampleInteractiveProgram”Completeself-checkquestions19-21

Materials&PrepProjectorandcomputer(ifyouareableto/opttouseEclipsewithyourstudents)WhiteboardandmarkersClassroomcopiesofWS3.5

Thehandoutsforthislessonincludenotesaswellasexercises.Ifyouareworkingondevelopingnote-takingskillsinyourclassroom,youmayprefertodeletethenotesfromtheworksheet(soitisonlyasheetofexercisesand/orimages).

IfyouteachinanELLorSpEdclassroom,leavingtheworksheetas-iswillallowstudentstofocusoncontentinsteadoftranslatingnotesintotheirnotebooks.

PacingGuide

Lesson3.05:UsingObjects&StringProcessing

196

Page 197: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Intro/Reviewofobjects&stringprocessing 5–15min

RoundRobin 35–45min

Paperselection&gradeannouncement 3min

ProcedureThereareseveralwaysyoucanteachtoday’sclass.Youshouldfirstcheckinwithyourstudentstoseehowpreparedtheyarefortoday’slesson.Ifstudentsunderstoodmostofwhattheyreadforhomeworklastnight,youcanaskstudentsforspecificquestions,coveronlythosetopics,thenmoveontotheRound-Robinactivity.Ifyourclassismostlyconfused,youcanre-teachallofthecontent,followingalongtheworksheet,andbreakingtheexercisesinto4parts(aslistedontheoriginalworksheet).

Bell-workandAttendance[5minutes]

Introduction/ReviewofObjectsandStringProcessing[10minutes]

1. Beginwithanintroductiontotheconceptsofobjectsandstringprocessing.

UsingWS3.5,walkstudentsthroughthedifferencebetweenprimitivesandobjects.

Askstudentstoexpandontheatom/moleculemetaphor;what“atoms”makeuptheString“molecule?”(Charsareatoms.)

Makesuretoemphasizethatanobjecttypescontainsdataandbehavior(methods),whileprimitivesjustcontaindata.

Itmighthelpstudentsorganizetheirthoughtsifyougraphicallyorganizetypeswiththefollowinghierarchy:

Lesson3.05:UsingObjects&StringProcessing

197

Page 198: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Types

.''.

.''.

.''.

.''.

PrimitivesObjects

.'|'.'.

.'|'.'.

.'|'.'.

intdoublebooleanString

2. Whenexplainingtheconceptofclass,thecaranalogymightnotresonatewithyourstudents(especiallyiftheydonotusecars,orliveinanareawherecarsarenotcommon).Sincewe’renotdelvingintotheconceptofclasstoodeeplyatthispoint,don’tspendtoomuchtimeonthisconcept.Additionalanalogiesthathaveworked:

Class:Home,Object(instancesofclasshome)eachstudent’shome.

Class:Desk,Objecteachstudent’sdesk(canintroducestatesofdesk:messy,neat,crooked,without-a-chair,etc.)

3. Whenreviewingobjectmethods,remindstudentsthattheyneedtodosomethingwiththereturnvalue,suchasSystem.out.print.

ReviewdotnotationasdiagramedModelcountingtheindexpositionswhenyoudemonstratethecharAtmethod.HavestudentspredicttheoutputofcharAtwithdifferentindexes.

4. BreakforthefirstboutofRoundRobin(or,ifonlyconductingaquickreview,finishreviewingalltopicsandallowstudentstodoallRoundRobinexercisesattheendoftheintroduction.)

Inreviewingsubstring,indexOf,toUpperCase,toLowerCase,andequalsmethods,workthroughsomeadditionalexamplesontheboardifneeded.Ifprovidingthestudentsthecompleteworksheet(withnotes),encouragethemtohighlight,circle,ortranscribethedefinitionsorsyntaxexamplesintotheirnotebook.

Afun“tricky”waytoassessstudentunderstandingistoaskwhyJavareturns-1whenthesearchtextisn’tfound.(Answer:-1isneveravalidindexintoaString.)

RoundRobin[35-45minutes]

1. Round-robinisadrillinganderror-checkingexerciseusedwithworksheets.Atminimum,thereshouldbe1questionforeachstudent(e.g.aclassof15studentswouldneedaworksheetwith15ormorequestions).Studentswritetheirnameontheworksheet,completethefirstproblem,thenpassthepapertothestudentontheright

Lesson3.05:UsingObjects&StringProcessing

198

Page 199: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

(orwhateverdirectionyouchoose).Thenextstudentfirstchecksthepreviousanswer,correctingitifneedbe,thencompletesthesecondquestion.Eachstudentthenpassesonthepaperagain.Bytheendoftheexercise,eachstudenthascheckedandcompletedeachquestionontheworksheet.

2. ThehookisthatyouchooseonlyONEworksheetfromthepiletograde.Allstudentsgetagradefromthatoneworksheet.Thiskeepsstudentsinvestedthroughouttheexercise.Advancedstudentswillcheckquestionsthroughoutthewholeworksheet,andallstudentswilltrytheirbesttocatchtheirown(andothers’)mistakes,sincethewholeclasssharestherandomly-selected-paper’sgrade.

3. Youshouldtimeeachquestion/checkinginterval,andcall“SWITCH!”whenitistimeforstudentstopassalongpapers.

a.Exercise1questions(thefirst4questions)shouldtake~2minuteseach.

b.Exercise2questions(thesecond4questions)shouldtake~2minuteseach.

c.Exercise3questions(asetof5questions)shouldtake~2-3minuteseach.

d.Exercise4questions(thelastsetof4questions)shouldtake~1minuteeach.

Adjustthetimingonthesequestionsasneeded,buttrytokeepabriskpace.Partoftheengagementfactoristhesenseofurgency.

Paperselectionandgradeannouncement[3minutes]

Iftimeallows,randomlyselecttheworksheetandannouncetheclassgradewithabitoffanfare,congratulatingtheclassonajobwelldone.

AccommodationandDifferentiationTooptimizethisexercise,youmightconsiderrearrangingstudents(orcreatingapassing-path)thatmixesstudentsofdifferentcodingabilities.Theadvancedstudentscanusetheextratimetocorrectmistakesmadebyothers;iftheyaresittinginproximitytothestudentthatmadetheerror,theywillhaveabetterchanceofexplainingthecorrectanswertothem.

Duetothebriskpaceoftheround-robinrotation,thereshouldn’tbetoomuchdowntimeforanyonestudent.Ifyoudofindastudentthatislookingbored,makeeyecontactwiththemasyouremindtheentireclassthateveryoneshouldbecheckingtheproblemshandedtothemoncetheyaredonewithsolvingtheirassignedproblem.

Lesson3.05:UsingObjects&StringProcessing

199

Page 200: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ELLclassroomsmayneedtoallow2classperiodstocompletetheround-robinexercise.Therearemanytopicscoveredduringthelesson,anditmaybebesttointroducevocabularyataslowerrate.

MisconceptionsUptothispoint,studentshavebeenusingquotedstringsasaprimitivetype,butStringisaclassinJava.Worksheet3.5introducestheString.equals()method.Studentswillneedtostartthinkingofstringsasanobjectandwhencomparingtwostrings,usethe.equals()method.Javaisinconsistentinitstreatmentofstrings.

VideosBJP3-3,WorkingwithStringsValueshttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c3-3

CSE142,Strings(18:40–33:05)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=6ca465e0-abac-4b46-b488-d4ba5c6c5aa6&start=1322

UWAPCSPrep,JavaStringProcessinghttps://www.youtube.com/playlist?list=PL_bszZLe8OFfnueQ6fn7wNqu87k3X2Nin

ForumdiscussionLesson3.05UsingObjects&StringProcessing(TEALSDiscourseaccountrequired)

Lesson3.05:UsingObjects&StringProcessing

200

Page 201: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson3.06—InteractivePrograms&ScannerObjects

Overview

Objectives—Studentswillbeableto…

Writeprogramsthatacceptuserinputusingascannerobject.

Assessments—Studentswill…

CompletePractice-Itproblems

Homework—Studentswill…

OutlineChapter3,exceptforBJP3.4

Materials&PrepProjectorandcomputerWhiteboardandmarkers

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Introductiontointeractiveprogramming 15min

Studentpractice 35min

Procedure

Bell-workandAttendance[5minutes]

Lesson3.06:InteractivePrograms&ScannerObjects

201

Page 202: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

IntroductiontoInteractiveProgramming[10minutes]

1. HookthestudentswithabriefdiscussionaboutPokemon.Besurethatthefollowingpointscomeupduringdiscussion(eitheryoubringthemup,oryouguidethestudentstobringthesepointsupthemselves):

EV(experiencevalues)aregainedthroughcombat.WhenonePokemonwinsagainstanother,theywinEVpointstoraiseyourstats.

Thesestatsareprivate,thetrainer(user)cannotseethem.

IfyouwanttoknowwhatyourEVvalueis(soyoucandeterminestrategyandgainthemostpoints),youneedtocomputeityourselfgiventhevaluesthatyoucansee.

TheformulaforcalculatingHPisonBulbepedia,andifwedosomealgebrawecancalculateEV.Let’swriteaprogramthatwillhelpuscalculateEVforanyPokemonstatsatrainerenters.

2. Haveastudent(orsequentialstudents)cometotheboardtowritetheconsoleoutputasyouworkthroughtheexamplebelow.Youshouldhavestudentswriteandlabelthissampleprogramasyouwriteit.Whilediscussingthedifferentpartsoftheprogram,circletheroom,checkingtomakesurestudentsarekeepingupwiththenotes.

WriteamethodthatreadsuserinputforknownPokemonstatstodetermineEV(effortvalue).

importjava.util.*;

Anytimeyou’regettinguserinput,startwiththisimportdeclaration:

publicclassGetEV{

publicstaticvoidmain(String[]args){

ScanneruserInput=newScanner(System.in);

Sofar,theheaderslookfamiliar.Whenconstructingthescanner:

YoualwayscapitalizeScannerNamethescannersomethinguseful(scanner,console,userInput)Constructwiththenewkeyword,andSystem.in.

System.out.println("ThisprogramcalculatesuserEV.");

System.out.println("InputyourPokemon'sstatsbelow:");

Thisoutputstotheconsoleamessageexplainingtheprogramtotheuser:

Lesson3.06:InteractivePrograms&ScannerObjects

202

Page 203: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

System.out.print("Hitpoints:");

inthp=userInput.nextInt();

Thispairsauserpromptwithavariablehpthatholdstheinformationtheuserinputted.

System.out.print("Level:");

intlevel=userInput.nextInt();

Again,wepairthepromptfortheuserinputwiththescannerthatacceptsandstoresthatdataasavariableforlateruse.

System.out.print("IV:");//Thisisforinitialvalueoftheh

itpointstat.

intiv=userInput.nextInt();

System.out.print("BaseHP:");

intbase=userInput.nextInt();

NextweneedtowritetheformulathatwillcalculateEVfromtheuserinput,thenreturnavalue(otherwisethescannerhasnofunction!)Youshouldhavethestudentsbuildasmuchofthisformulaaspossible:

EV=(((HP–10)100)/Level–2Base–IV–100)*4

intev=(((hp–10)*100)/level–2*base–iv–100)*4;

System.out.println("Youhave"+ev+"effortvaluepointsforyour

HPstat.");

}

}

Ifstudentsneedanotherexample,workthroughthebookexampleformortgagepayments,havingstudentswritemoreofthecodethaninthepreviousexample.

StudentPractice[35minutes]

1. HavestudentscompletethefollowingPractice-Itself-checkquestions:

i. promptMultiplyBy2ii. SumNumbersiii. RobertPaulson

2. HavestudentscompletethefollowingPractice-Itexamplequestions:

i. scientific

Lesson3.06:InteractivePrograms&ScannerObjects

203

Page 204: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ii. cylinderSurfaceAreaiii. sphereVolume

AccommodationandDifferentiationInELLclassrooms,youshoulddistributeahandoutdiagrammingthepartsofaprogramwithallvocabularywordsincludedonthesamplecodeorscreenshot.Turningthepicturesontheworksheetintoclassroomposterswillbehelpfulinhelpingstudentsremembersyntax.

VideoBJP3–4,ProgrammingwithParametershttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c3-4

CSE142,Scanner(0:21-23:06)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=0c247411-e890-4835-8a79-bee6e74066c2&start=21

ForumdiscussionLesson3.06InteractivePrograms&ScannerObjects(TEALSDiscourseaccountrequired)

Lesson3.06:InteractivePrograms&ScannerObjects

204

Page 205: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson3.07—PokémonBattleProgrammingProject

Overview

Objectives—Studentswillbeableto…

Writeaprogramthatrequestsuserinputandreturnsdata.

Assessments—Studentswill…

WriteaprogramthatcalculatesdamagedonetoPokémoninabattle.

Homework—Studentswill…

SummarizetheirclassnotessincethelastexamIftheyaremissingnotes,getthemfromanotherstudentorsupplementthemfromthetextbook

Materials&PrepProjectorandcomputer(ifyouareableto/opttouseEclipsewithyourstudents)WhiteboardandmarkersClassroomcopiesofWS3.7LPBattleVideoofsamplebattle(http://youtu.be/k7K5LEE9xxw?t=48s)Advanceddamagecalculator(https://pokemonshowdown.com/damagecalc/)

The8-minutevideodemonstratesatypicalbattlesequencefromoneofthemorerecentPokémonversions.Ifyourclassdoesnotplaythevideogame,youcouldshowbattlefootageoftheanimeseries,thecardgame,orthecoingame.Astheinstructor,youshouldfamiliarizeyourselfwiththesequenceofaPokémonbattle,soyoucanhelpstudentswithproceduraldecompositionandgradedifferentstudentsolutions.

PacingGuide

Lesson3.07:PokémonBattleProgrammingProject

205

Page 206: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Introductiontolab&viewingofbattle 10min

Studentprogrammingpractice 40min

ProcedureTheprogrammingprojecttodayhasstudentsprogramminga“starter”Pokémonbattlesequence.Thisisasomewhatopen-endedassignment,sincestudentscansubmitabasicprogramthatruns1or2interactions,oracompletebattlesequence,dependingontheirlevelofunderstanding.

StudentprogramsforthisassignmentwillbealobotomizedversionofaPokémonbattlesincestudentshavenotyetlearnedconditionalstatements.Thisisadeliberatemove:studentscanfocusonbuildingsegmentsofcodethatacceptbasicuserinput,usethemathclasstogeneraterandomnumberstodeterminebattleoutcomes(orroll-of-the-diceorspinforthecard-gameandcoingameversions),andreturngametext.Capitalizeonstudentfrustrationby(ormotivatestudentswiththeprospectof)hintingatamoreinteractiveprogramafterthenextfewlessonsonCh.4andCh.5.

Bell-workandAttendance[5minutes]

IntroductiontoLabandViewingofBattle[10minutes]

Atthebeginningofclass,introducethelabandwatchthesamplebattlevideo.

StudentProgrammingPractice[40minutes]

1. Havestudentscompletethisprogrammingprojectindividually.Beforeyoubreakouttheclassforlabtime,readthequestionoutloudtotheclass,takingtimetopausebetweeneachoftherequirementsoutlinedinthelabassignment.

2. Askstudentswhattheirveryfirststepsshouldbe.

Theyshouldoutlinetheirapproachinpseudocodeorwithastructurediagram.Remindthemthatthisdocumentationshouldbesubmittedinordertogetfullcreditfortheirlab,andreferthemtotheAlgorithmforSolvingProblemssheet.

Lesson3.07:PokémonBattleProgrammingProject

206

Page 207: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Remindstudentstotackleonepartoftheproblematatime.RemindstudentsthatitisOKiftheyleavepseudocodeinwhiletheysolveadifferentpartoftheproblem,andpartialcreditshouldbegiventocorrectpseudocode.

3. Toencouragegrit,havestudentsreviewthestepstheyshouldtakebeforeraisingtheirhandforaquestion:

Refertonotes,textbooks,andposters/displayedworkaroundtheroom.Workonadifferentpartoftheproblemiftheygetstuck,thenreturntoitlater.Askanotherstudentforahint,tip,orforerror-spotting.

4. Inanemail,ontheprojector,orasahandoutWS3.7,givestudentthefollowingquestionstoworkonindividually(or,ifscaffoldingrequiresit,inpairs).

PROGRAMMINGPROJECT

Completethisprogrammingprojectusingyournotes,thetextbook,andanyonlineorin-classsourcesyoulike.Yourworkmustbeyourown;youmayaskafriendtolookoveryourwork,ordiscussproceduraldecompositionwithyou,butyoumustwriteallcodeonyourown.Toreceivefullcreditonthislab,youmustsubmitastructurediagramorpseudocode-planforeachquestion.

RecallhowtouseScannertogetuserinput:

Scannerconsole=newScanner(System.in);

System.out.print("Hello,whatisyourname?");

Stringname=console.nextLine();

System.out.print("Whatisyourage?");

intage=console.nextInt();

Exercise1

WriteamethodcalledbattleStart()thatintroducesthebattle,promptstheusertochoosetheirfirstPokémontobattle,andoutputsthepairing.battleStart()shouldalsoreturnthenameofthePokemonchosen.Youroutputshouldlooksomethinglikethis:

Lesson3.07:PokémonBattleProgrammingProject

207

Page 208: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Anothertrainerisissuingachallenge!

Zebstrikaappeared.

WhichPokémondoyouchoose?Arcanine

YouchoseArcanine!

It’saPokémonbattlebetweenArcanineandZebstrika!Go!

CallbattleStart()fromyourmain()methodandstorethenameofthePokemoninavariable.

Exercise2

Writeamethodcalleddamage()thattakesaPokemon’snameasaparameterandreturnstheaboutofHPafterdamagehasbeendone.damage()shouldprompttheuserfortheirbasestatsinordertocalculatedamage.Usethefollowingequationsforcalculatingdamage:

Modifier=SameTypeAttackBonus(STAB)\*Random

Damage=Modifier*((2*Level+10)/250+(Attack/Defense)*Base+2)

Hint:ThePokémongamealwaysselectsarandomnumberbetween0.85and1.0.

Youroutputshouldlooklikethis:

ZebstrikausedThunderbolt!

Trainer,whatareyourArcanine’sstats?

Level:

Attack:

Defense:

Base:

STAB:

HP:

Arcaninesustained10pointsdamage.

HP,afterdamage,arenow70.

Calldamage()fromyourmain()methodwiththePokemon’snamefromExercise1andstorethereturnvalue(HP)inavariable.

Exercise3

WriteamethodcalledstatsTable()thatacceptstheuser’sPokemonname,statsandlearnedmovesasparameters,andoutputssomethingsimilartothisimage:

Lesson3.07:PokémonBattleProgrammingProject

208

Page 209: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Youarenotrequiredtoalignthecolumnsofthetablesinanyfancyway,butifyoudo,useescapesequencestoaligndata.Foryourdrawing,youmayusecodeyou’vegrabbedfromtheinternet,orrecycleanimageyoucreatedearlierintheyear.

Sampleoutput:

NameAlakazam

Level40

------------------------------

HP96

ATTACK52

DEFENSE51

SP.ATK121

SP.DEF81

SPEED107

-------------------------------

MovesLearned:ThunderWave,HiddenPower,PsychoCut,Recover

CallstatsTable()fromyourmain()methodwiththePokemon’snamefromExercise1andtheHPfromExercise2andanyothervaluesyou’dlikefortheotherparameters.

Conclusion

Inyourcompletedprojectshouldincludethefollowingmethods:

battleStart()damage()statsTable()

Thesemethodsshouldallbecalledinmain()sothattheplayercanexperiencetheentirebattleinonesitting.

ProperJavasyntaxandthoroughcommentsarerequired.

Lesson3.07:PokémonBattleProgrammingProject

209

Page 210: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

AccommodationandDifferentiationIfyouhavestudentsfinishthelabquickly,invitethemtocheckouttheadvanceddamagecalculatoronline.Theycanaddinputfieldstotheirowndamagecalculator,thusimprovingtheirPokémonsimulation.

Alternatively,ifstudentsseeminterestedinincreasingtheinteractivityoftheirbattlesequence,youcanallowthemtoreadaheadinthebook.StudentsmayreaduponBulbapedia(thewikiforPokémon)thatThunderbolthasa10%chanceofparalyzingits’target.InvitestudentstothinkhowtoaddthatfactorintotheirbattlesimulationastheyreadthroughCh.4andCh.5materials.

IfstudentsarestrugglingwithcreatingthegraphicinExercise3,helpstudentsbywritinghelperlinesofcodeontheboard,orcreatingapseudocodeoutlineasawholegroup.

ForumdiscussionLesson3.07PokémonBattleProgrammingProject(TEALSDiscourseaccountrequired)

Lesson3.07:PokémonBattleProgrammingProject

210

Page 211: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson3.08—Finding&FixingErrors

Overview

Objectives—Studentswillbeableto…

Finderrorsintheirreturnedhomeworkassignments.Correcttheirpreviouslysubmittedhomeworkandclasswork

Assessments—Studentswill…

Re-submitallhomeworkassignmentswithcorrectedanswers.

Homework—Studentswill…

ReadBJP4.1upto“NestedifelseStatements”CompleteChapter4self-checkproblems1–6

Materials&PrepAnystudenthomeworkassignmentsthatyouhavenotyetreturnedStudentself-helpsystem(suchasC2B4orstudentpairing)Bookmarksonstudents’computerstowebmaker.org

IfyouarenotyetfamiliarwithX-rayGoggles,Thimble,orPopcornMaker,youshouldtakesometimetoexplorewebmaker.orgbeforeclass.Thesiteisrichwithenrichmenttoolsandhooksforyourclassroom!

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Introductionandhomeworkdistribution 5min

Studentwork 35min

Studentstradework,check,andsubmit 10min

Lesson3.08:Finding&FixingErrors

211

Page 212: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ProcedureTodaywecontinuereinforcingconceptsandapplyingthetools,procedures,andcodethatwereintroducedlastweek.Studentswillhavetheopportunitytocorrectanyincorrecthomeworkassignments.Ifstudentsdidnothavetimetofinishtheprogrammingprojectsfromyesterday,youmayallowthemtimetoworkonthoseprojectstoday.

Rewardstudentsthatdidtheirworkcorrectlywithquietfreetime.Alternatively,givethemafunprogrammingassignmenttodo,suchasgeneratingameme,animations,gigposters,orcomicstriponMozilla’sWebmaker.org.TheseactivitiesteachHTMLandCSS,soyoumightavoidthemifyouthinkexploringdifferentsyntaxwillconfuseyourstudents.

Bell-workandAttendance[5minutes]

IntroductionandHomeworkDistribution[5minutes]

1. Returnstudenthomeworkpackets,orhavestudentsplacetheirreturnedhomeworkinapileontheirdesk.

2. Explaintostudentsthattheyhavetheopportunitytogetfullcreditontheirhomeworkgradesbycorrectingthemnow,inclass.Askstudentsforsuggestions/ideasonhowtomakesuretheydon’tmissanyerrors.(Bynowstudentsshouldbeusedtorelyingontheirerrorchecklist/algorithm.)

StudentWork[35minutes]

Havestudentsworkindividuallytocorrecttheirhomeworkgrades.

Offertimechecksforstudentssotheystayontask.Ifstudentshavenotfinishedtheirprogrammingprojectfromyesterday’sclass,allowthemtodosotoday.

Studentstradework,check,andturnin[10minutes]

Attheendofclass,havestudentstradetheirhomeworkassignmentstoevaluateeachother’scorrectionsbeforesubmission.

AccommodationandDifferentiation

Lesson3.08:Finding&FixingErrors

212

Page 213: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Studentsthatdon’thavecorrectionstomakeshouldberewardedfortheirhardworkwithsilentfreetime.Encouragethemtodoworkforanotherclass,readthenextchapter,ordoafunprogrammingprojectonline.

Ifyouhaveastudentthatappreciatespublicrecognition,havethemserveasyour“TA”thisclass,goingaroundtohelpstudentscorrecttheirpapers.Remindthemtoguidestudentsthroughtheprocessinsteadofjustgivingthemtheanswers.

ForumdiscussionLesson3.08Finding&FixingErrors(TEALSDiscourseaccountrequired)

Lesson3.08:Finding&FixingErrors

213

Page 214: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson3.09—RelationalOperators&if/else

Overview

Objectives—Studentswillbeableto…

EvaluaterelationalexpressionsPredictandtracetheflowofanifstatement.

Assessments—Studentswill…

Evaluaterelationalexpressionsandpracticecorrectifstatementsyntaxduringagameofgrudgeball.

Homework—Studentswill…

ReadBJP4.1“Nestedif/else”and“ObjectEquality”Completeself-checkquestions7–9andexercises1&2

Materials&PrepProjectorandcomputer(optional)WhiteboardandmarkersClassroomcopiesofOperatorPrecedenceRulesforgrudgeball(seewebsitefordetails:http://toengagethemall.blogspot.com/2013/02/grudgeball-review-game-where-kids-attack.html)

Takethetimetofamiliarizeyourselfwiththerulesofgrudgeball,andtestoutyour2and3pointlinesbeforeclassbegins(youmayneedtoreadjustthem).Ifyoucangetpermissionfromyourschooltoleavetapeonthefloor,itishelpfultohavethoselinesdownfortherestoftheyear.Infutureclasses,ifyourstudentsarehavingahardtimesettlingdownduringareviewsession,orcan’tstandaworksheet,youcanalwaysconverttheworksheetorreviewsessionintoaquickgameofgrudgeball.

Lesson3.09:RelationalOperators&if/else

214

Page 215: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Introduction&note-taking 15min

Activity:Grudgeball 35min

ProcedureRatherthandrillnewruleswithworksheets,thedrilling/activityportionoftheclasswillservetotiethelessontogetherintheformofaclasscompetition.Ifspaceandwhiteboardsetupallow,setupthegrudgeball“court”andscoreboardbeforeclassbeginssoastomystifythestudents.

Bell-workandAttendance[5minutes]

Introduction&Note-Taking[15minutes]

Beforeyoubeginlecture,announcetostudentsthattheyshouldpaycloseattention,sincethelecturecontentwillbetestedduringthegame.

Ifyouwanttowritecodethatexecutessomeofthetime,butnotallthetime,youcanwriteanifstatement(askstudentswhatsituationsmightuseanifstatement—iftheyarestuck,askthemtothinkabouttheirlastfewprogrammingprojects!)

if(test){//BooleanExpression

<statement>;//ControlStatement

<statement>;//ControlStatement

}

Havestudentscomeuptothefrontoftheroomtodemonstratetheflowofcontroloftheifcontrolstructure.

Put2alternativestogetherbyusinganif/elsestatement:

Lesson3.09:RelationalOperators&if/else

215

Page 216: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

if(test){

<statement>;

<statement>;

}else{

<statement>;

<statement>;

}

Sowhatshouldstudentsputinthe“test”sectiontoevaluateastrueorfalse?

3*3==3*1*3

//<expression><relationaloperator><expression>

Evaluatebothexpressions,thenseeiftherelationaloperatorholdstrueornot.

Operatorsstudentsneedtoknow:

==:equalto!=:notequalto<:lessthan>:greaterthan<=:lessthanorequalto>=:greaterthanorequalto|

Asfarasprecedencegoes:

relationaloperatorshavealowerprecedencethanarithmeticoperatorsrelationaloperatorshavehigherthanequalityoperatorsinequalityoperators(<,>,<=,>=)havehigherprecedencethantheequalityoperators(==,!=)

3+2*2==9evaluatesto:false,since7isnotequalto9.

Havestudentsdirectyouhowtosolvethis.

Ifyou’dliketorefertoavisualaidforthissegmentoftheintroduction,poster3.16.2illustratesJavarulesofprecedenceforalloperators.

Youcanonlyusearelationaloperatoronprimitivedatatypes!(Askstudentswhichtypesareincluded,whichonesareexcluded.)

Activity:Grudgeball[35minutes][Optional]

Ifyoufeellikeyourclasshasagrasponthesyntaxandrelationalexpressions,considerskippingthisgameandfocusingonon-the-boardexamples(youcanusethequestionsfromGrudgeballbelow)ormovingonto3.10.

Lesson3.09:RelationalOperators&if/else

216

Page 217: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

1. Dividestudentsintotheirassignedteams.

2. Reviewtherulesforgrudgeball,andhavethestudentsrepeattherulesbacktoyou.

3. Usingtheproblemslistedbelow(andanyyoumayadd,dependingonyourclass’needs),playgrudgeballuntilateamwins,oruntiltheclassperiodends.

i. Ifaclassgetstheanswerwrong,BRIEFLYpausethegametohavestudentsoffercorrectionsbeforemovingtothenextteam’squestion.

ii. Ifcorrectionseemstobedraggingon,jumpinandquicklyre-teachusingtheincorrectanswerasyourexample.Itisimportanttokeepthepacegoingtomaintainstudentinterestinthegame!

4. Grudgeballproblems&answershavebeengroupedassumingthatyouhave6teams.Ifyouhavefewerteams,each“round”willbeshiftedaccordingly,soyoumayhaveroundswheredifferentteamsarepracticingdifferentconcepts.Judgeeachteam’sknowledgegaps,andadjustwhichquestionsyouaskeachgroupaccordingly.

GRUDGEBALLPROBLEMS

Translatethesestatementsintologicalteststhatcouldbeusedinanif/elsestatement.Writetheappropriateifstatementwithyourlogicaltest.

a)zisodd.b)zisnotgreaterthany’ssqureroot.c)yispositive.d)Eitherxoryiseven,andtheotherisodd.e)yisamultipleofz.f)yisanon-negativeonedigitnumber.

Giventhevariabledeclarations

intx=4;

inty=-3;

intz=4;

whataretheresultsofthefollowingrelationalexpressions?(TrueorFalse?)

g)x==4h)x==yi)x==z

Lesson3.09:RelationalOperators&if/else

217

Page 218: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

j)x+y>0k)y*y<=zl)x*(y+2)>y–(y+z)*2

Correctthefollowingstatementsyntaxerrors:

m)ifx=10then{n)if[x=10]{o)if(xequals42){p)if(x==y){q)If(x>8){r)IF(x<=7){

Identifyandcorrectoneofthe(7)errorsinthefollowingcode:

publicclassOops4{

publicstaticvoidmain(String[]args){

inta=7,b=42;

minimum(a,b);

if{smaller=a}{

System.out.println("aisthesmallest!");

}

}

//Returnstheminimumoftheparametersaandb.

publicstaticvoidminimum(inta,intb){

if(a<b){

intsmaller=a;

}else(a=b){

intsmaller=b;

}

returnintsmaller;

}

}

AccommodationandDifferentiationInELLclassrooms,youshouldreadeachquestionaloudinadditiontoshowingitontheboardorprojector.

Ifthisreviewsessionistooeasy,givestudentstimetostartonthehomeworkonceyouhavefinishedGrudgeball.

Lesson3.09:RelationalOperators&if/else

218

Page 219: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

TeacherPriorCSKnowledgeTheunarynotoperator!(commonlyreadas“bang”)iscommonlyusedinlogicalexpressionstonegateabooleanvalue.Theuseofnotisuniqueamongthelogicaloperatorsasittakesonlyoneoperand.Notisanalogoustothenegativesign(-)whereaminusbeforeanumericvalueorexpressionrepresentsthenegativeofthevaluewhereasanot(!)beforeabooleanvaluerepresentstheoppositetruthvalue:truebecomesfalseandfalsebecomestrue.

Programminglanguageshaveadefaultorderofevaluatingexpressionscommonlyreferredtoasoperatorprecedence.Weusuallyteachstudentstobeexplicitintheirlogicalexpressionsforclarityandtoavoidmistakes.However,aknowledgeofthelanguagesprecedencerulesisvaluablewhenbothreadinganddebuggingcode.SeethefollowingforJava’sprecedencerules:https://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html.Inordertogradecorrectly,itisessentialtoknowJava’sorderofoperations.

CommonMistakesConditionalscommonmistakes:http://interactivepython.org/runestone/static/JavaReview/Conditionals/cMistakes.html

MisconceptionsConfusingtheassignmentoperator(=)withthecomparisonoperator(==)isoneofthemostcommonmistakesdonebybeginningprogrammers.Unfortunately,semanticallyasingleequalsignisusedtodenoteequalityinmathematicsandformoststudentstheyhavebeendoingmathmuchlongerthancomputerscience.

Itisimportantfortheteacherwhenreadingcodealoudtodifferentiatesingleequalsasassignmentanddoubleequalsascomparison.Thefollowingwouldbereadas:

x=5;//“xisassigned5”

if(y==4)//“ifyisequalto4”

ManystudentsthinkallstatementsinJavaendinasemi-colon(;).However,thisisnotalwaysthecaseastheif-blockendsincurlybraceswhenusedwithablockofcode.Studentsinthehabitofaddingsemi-colonstotheendofeachstatementinevitablyaddsemi-colonsattheendoftheconditional,likeso:

Lesson3.09:RelationalOperators&if/else

219

Page 220: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

if(a>1);//allstatementsendinsemi-colonmisconception

WhenteachingstudentsaboutJavastatements,itisimportanttodistinguishbetweenstatementsthatendinasemi-colonandthosethatsignifyscopewiththecurly-braces.SingleJavastatementssuchasdeclaringvariables,assignment,etc.endinsemi-colonswhileJavastatementsthatdenotescopelikeclassdefinitionsandmethodshavecurlybraces.If-statementscandoboth.

LogicaloperatorsANDandORarecoveredinafuturelesson.However,studentswillcombinelogicaloperatorssimilartomathsyntax:

if(9<=grade<=12)//relationaloperatormisconception

Forstudentsthataskaboutcompoundconditionals,youwillneedtodeferandstatetheywillbecoveredshortlyinafuturelesson.ForstudentswithpriorprogrammingexperienceinevitablysearchingforthecorrectsyntaxsincetheEnglishwords“and”and“or”donotworkinJava.

Onecommonerrorismismatchedtheparentheses:

if(a==10//mismatchedparentheses

ormismatchedcurlybraces:

if(b==12)

dozen=true;

}

EventhoughmanyIDEswillhelpstudentsbyprovidingmatchingparentheses,agoodhabitforstudentstolearnwhenwritingcodebyhandistoaddtheclosingparenthesesrightaftertheywritetheopenparentheses.Thesameistrueforopenandclosecurlybraces.StudentswillneedtolearntowritecodebyhandfortheAPexam,sopracticehandwrittenJavaisimportanttostudents’success.

Inaddition,goodcodingstylewithproperindentinghelpswithstudentrecognitionofmismatchedclosingparenthesesandcurlybracesbecauseofthevisualpattern.Goodprogrammingstylemakesiteasiertoidentifyerrorsinthepattern.Thiscanbeusedduringlabforstudentswithmismatchedparenthesesand/orcurlybraces.Insteadoffindtheerror,askingthestudenttocleanuptheirindentingwillhelpthemfinderrorsontheirown.

Lesson3.09:RelationalOperators&if/else

220

Page 221: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Whenconstructingif-statements,studentsinserttheconditionoftheif-statementwithinthebracketsinsteadoftheparentheses:

if{a>1}//conditionalvsblockmisconception

Seeabove“mismatchedtheparentheses”forgoodprogrammingpractice.

VideoBJP4–2,Nestedif/elseStatements(note:titleofvideoismislabeled,shouldbe“if/elseStatements”)http://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c4-2

CSE142,if/elseStatements(38:41-50:15)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=0c247411-e890-4835-8a79-bee6e74066c2&start=2321

CSE142,MethodswithConditionalExecution(4:08-18:39)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=fc356a4a-92a2-4038-9b89-90ea0ffa4533&start=248

CSHomeworkBytes,RelationalandConditionalOperators,withElizabethhttps://www.youtube.com/watch?v=M-mYpnPygY0

CSHomeworkBytes,If-Statements,withJimhttps://www.youtube.com/watch?v=SxWFYfA4i0M

ForumdiscussionLesson3.09RelationalOperators&if/else(TEALSDiscourseaccountrequired)

Lesson3.09:RelationalOperators&if/else

221

Page 222: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson3.10—Nestedif/elseStatements

Overview

Objectives—Studentswillbeableto…

ChoosewhichifstatementstousefordifferentproblemsUsecorrectsyntaxforthedifferentifstatements

Assessments—Studentswill…

Teachamini-lessononsequentialornestedifstatementsSubmitseveralPractice-Itquestions

Homework—Studentswill…

ReadBJP4.1“Factoringif/elseStatements”and“TestingMultipleConditions”Completeexercises4and5

Materials&PrepProjectorandcomputer(optional)WhiteboardandmarkersGroupcopiesofWS3.10Posterpaper,constructionpaper,whitepaper,andlinedpaperMarkers,tape,andgluesticksClassroomcopiesoftextbooksStudentgroupassignments(3-6groups)

Haveallmaterialsoutonstudentdesks,orconvenientlylaidoutforstudentstohelpthemselvestosotheycanstartrightaway,withminimalinstructionfromyou.Don’tforgettocirclewhichif/elsestatementsstudentsshouldbepresentingon.

PacingGuide

Lesson3.10:Nestedif/elseStatements

222

Page 223: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Studentpractice 20min

Studentmini-lessons 15–25min

Practice-Itexercises 15min

ProcedureYourhookfortoday’slessonistoturnthereinsovertostudentsimmediately.Haveinstructionsprintedoutandsittingatteamworkstations(oronstudentdesks).Makestudentsanswertheirownquestionsusingtheinstructionsheetandtextbook.

StudentPractice[20minutes]

Givestudents20minutestopreparetheirpresentation.Useatimerandperiodicallyannouncehowmuchtimeisleftinclasssostudentscanpacethemselves.

StudentMini-Lessons[15minutes]

1. Givestudents5minutesperteamtopresenttheirtopic.

2. Encouragestudentstoaskquestions,andbesuretoaskaquestionortwoofeachteam(dependingonhowmanyteamsyouhave).

Worksheet[15minutes]

Leaveabout10–15minutesattheendofclassforstudentstoindividuallycompletePractice-Itquestions:

1. ifElseMystery12. ifElseMystery23. season

AccommodationandDifferentiationCirclearoundtheroomtohelpstudentsthroughreadingthetextinthetextbook.Makesurethateachofyourworkingteamsareproperlystratified(ratherthanusingtieredgrouping).

Ifstudentsarespeedingalong,encouragestudentstowritedownquestionstoposetoothergroupsduringmini-lessons.

Lesson3.10:Nestedif/elseStatements

223

Page 224: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ForumdiscussionLesson3.10Nestedif/elseStatements(TEALSDiscourseaccountrequired)

Lesson3.10:Nestedif/elseStatements

224

Page 225: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson3.11—ReducingRedundancy

Overview

Objectives—Studentswillbeableto…

Simplifycodeandreduceredundancybyfactoringif/elsestatementsandtestingmultipleconditionssimultaneously.

Assessments—Studentswill…

Completeaclasscompetition

Homework—Studentswill…

ReadBJP4.2FinishoutliningChapter4,excludingsections4.3,4.4,and4.5

Materials&PrepProjectorandcomputer(optional)WhiteboardandmarkersRostersforclassteams

Theteamsfortoday’scompetitionshouldbetiered.Dependingonthesizeofyourclass,youshouldaimfor4teamsorteamsof4people.

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Reviewingproceduresandforminggroups 5min

Competitionquestion1 15min

Competitionquestion2 15min

StudentsbeginoutliningChapter4 15min

Lesson3.11:ReducingRedundancy

225

Page 226: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ProcedureAsyourhook,grandlyannounceaclasscompetitionbetweenteamsandannouncetheprizeforthewinningteam(thismightbeTEALSswag,bonusclassroomparticipationpoints,oradditionalraffleentriesintheyear-endTEALSgiveaway).Usethisclasscompetitionasanassessmenttodeterminehowmuchre-teachingyouneedtodo.

Bell-workandAttendance[5minutes]

ReviewingProceduresandFormingGroups[5minutes]

Announceclassteamsandrearrangestudentsasneeded.

CompetitionQuestion1[15minutes]

Givestudents5minutestocompletethechallenge,andtakenoteofwhichteamfinishesfirst.

Ifstudentsarestruggling,youmayextendthetime,orofferuniversallyhelpfultips(e.g.“Ifyouseeparenthesesthataren’tbeingusedtoestablishprecedence,ortocast,itmeansyou’recallinganothermethod.”)

Theteamthathasthecorrectanswerfirstwinstheprize.

Reviewstudentanswerstogetherasawholegroup,revisitingconceptstaughtearlierintheweekasmistakescomeup.Wheneverpossible,havestudentsvolunteerthecorrectprocedure,approach,orcode.Encouragestudentstotakenotesduringthisprocesssotheycanreviewtopicsoutsideofclass.

COMPETITIONQUESTION1

Factoroutredundantcodefromthefollowingexamplebymovingitoutoftheif/elsestatement,preservingthesameoutput.

if(x<30){

a=2;

x++;

System.out.println("SpongebobSquarepants!"+x);

}else{

a=2;

System.out.println("SpongebobSquarepants!"+x);

}

Lesson3.11:ReducingRedundancy

226

Page 227: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

CompetitionQuestion2[15minutes]

Onceyou’vecompletedthisexercise,offerupthesecondchallengequestion,asbefore.Thisquestionmaytakeupto10minutesforstudentstocomplete.

COMPETITIONQUESTION2

Rewritethepoorly-structuredcodegivenhere,soitavoidsredundancy.Forthecaseofthiscompetition,youcanassumethattheuseralwaysinputs1or2.

intsum=1000;

Scannerconsole=newScanner(System.in);

System.out.print("Isyourmoneymultiplied1or2times?");

inttimes=console.nextInt();

if(times==1){

System.out.print("Andhowmuchareyoucontributing?");

intdonation=console.nextInt();

sum=sum+donation;

count1++;

total=total+donation;

}

if(times==2){

System.out.print("Andhowmuchareyoucontributing?");

intdonation=console.nextInt();

sum=sum+2*donation;

count2++;

total=total+donation;

}

StudentsBeginOutliningChapter4[15minutes]

Onceyouhavecompletedthecompetitionandreview,havestudentsbeginoutliningChapter4.Whatevertheydonotfinishoutliningtheyshouldcompletetonightforhomework.

AccommodationandDifferentiationCirclearoundtheroomtohelpstudentsthroughreadingthetextinthetextbook.Makesurethateachofyourworkingteamsareproperlystratified(ratherthanusingtieredgrouping).IfyouteachinanELLclassroom,youmayopttochangetheassignmentsothatallthelinesofcodearepresent,butshuffledoutoforder(asaParsons-typeProblem).

Ifstudentsarespeedingalong,encouragestudentstowritedownquestionstoposetoothergroupsduringmini-lessons.

Lesson3.11:ReducingRedundancy

227

Page 228: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

VideoBJP4-3:Factoringif/elsehttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c4-3

CSE142:Factoringif/elseStatementsandReasoningaboutPaths(18:40-34:05)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=fc356a4a-92a2-4038-9b89-90ea0ffa4533&start=248

ForumdiscussionLesson3.11ReducingRedundancy(TEALSDiscourseaccountrequired)

Lesson3.11:ReducingRedundancy

228

Page 229: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson3.12—CumulativeAlgorithms

Overview

Objectives—Studentswillbeableto…

Findandcorrectsyntaxerrorsinconditionalcumulativealgorithms.

Assessments—Studentswill…

Write,modify,andcorrectprogramswrittenbyothers.

Homework—Studentswill…

ReadBJP5.1(skip“do/whileLoops”)CompleteChapter4ProgrammingProject#2

Materials&PrepProjectorandcomputer(optional)WhiteboardandmarkersClassroomcopiesofWS3.12Plasticbindersleeves(1perstudent)

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Introductiontocumulativealgorithmsandmin/maxloops 15min

ProgrammingActivity–Programmer1input 10min

ProgrammingActivity–Programmer2input 15min

ProgrammingActivity–EditsandReflection 10min

Procedure

Lesson3.12:CumulativeAlgorithms

229

Page 230: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Bell-workandAttendance[5minutes]

IntroductiontoCumulativeAlgorithmsandMin/MaxLoops[15minutes]

1. Asyourhook,conductanexperimentwithyourstudents:

Announcethatyou’regoingtoreadalistofsixnumbersbetween1and100,andthefirstpersonwhoisdonecalculatingthesumcorrectlywins[classroomrewardofyourchoice].

Studentsshouldindicatetheyaredonecalculatingbyraisingtheirhand.Explainthatyouwillkeeptrackofraisedhands,andthatyou’llcalloneachpersonuntilyouencounterthecorrectanswer.

Readoffthenumbers,andkeeptrackofwhofinshesearly,andwhofinisheslate.Askstudentshowtheycomputedtheiranswers.

You’relookingforananswerfromthe“quick”studentsthattheykeptarunningtally,andthatthe“late”studentsthattheyaddedallthenumbersattheend.

2. Nowproposethatyouwanttotallysixteennumbers.Askstudentshowstudentswhatmethodyoushoulduse,andaskthemtodescribethealgorithmforsolvingtheproblemusingpseudocode.

Translatethepseudocodeintoaloopusingthefollowingexample:useaforloopwithacodeforaddingusingkeywordsum:

intsum=0;

Wealwaysinitializeat0,becausesumneedsaninitialvaluetostartwith.

for(allnumberstosum){obtain“next”withScannersum+=next

Thisispseudocode!Inreallife,we’dbeginwithbuildingascannerinthemainmethod.Let’slookatsomerealcodehere.Sinceweknowwewantuserinput,whatisthefirstthingwedobeforecreatingourclass?

importjava.util.\*;

3. Nowwecreateourclassandmainmethod(havestudentstellyouwhattodo):

Lesson3.12:CumulativeAlgorithms

230

Page 231: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

publicclassExamineNumbers1{

publicstaticvoidmain(String[]args){

System.out.println("Thisprogramaddsyournumbers.");

System.out.println();

4. AddourScanner(havestudentsgiveyouthecode):

Scannerscanner=newScanner(System.in);

System.out.print("Howmanynumbersdoyouwanttoadd?");

inttotalNumber=scanner.nextInt();

5. Andfinallyourloopwiththesumkeyword:

doublesum=0.0;//ByusingtotalNumberinste

ad

for(intj=1;j<=totalNumber;j++){//ofanactualnumber,wegi

ve

System.out.print("#"+j+"?");//ourprogramflexibility.

doublenext=scanner.nextDouble();

sum+=next;

}

Besuretobrieflydiscusstheuseofdoublevs.int(wherewouldyouhavetochangecodeifyouwantedint?),thevariableivs.j(youcanmakeitanythingaslongasyou’reconsistent),andvariablesnextandsum.

6. Finallywehavetoaddthecodethatreturnsthesumsothattheusercanseetheresult:

System.out.println();

System.out.println("Yournumbersaddto"+sum);

}

}

7. Invite3studentsuptotheboard(nowthatthecompleteprogramiswritten)

OnestudentactsasJavatotraceflowofcontrol(thisstudentnarrateswhatishappeningoneachline)

Anotherstudentactsasconsoleoutput,writingoutputasJavacreatesit

Trytohaveconsoleoutputwrittenonthesameareaoftheboardeachtimeyoudothistypeofexercise.

Theotherstudentactsasthevaluesbeingstoredinsumandnext

Lesson3.12:CumulativeAlgorithms

231

Page 232: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Thisstudentshouldbewritingtheirvaluesinalocationontheboardthatyouneveruseforwritingconsoleoutput.Reservingaphysicalspacefor“internalworkingswedon’tsee”willhelpstudentskeepexecutionvs.outputseparate.

Seatedstudentsshouldhelpthestudentfigureoutwhatthevaluesinsumandnextarebeingupdatedtowitheachexecutionoftheloop.

Getsampleuserinputfromtheclass.

Ifthatexamplewentwell,moveontomin/maxloops;otherwise,workthroughtheexamplewithnewuserinput.Toscaffoldthisactivity,usewholenumbersandkeeptheloopshort.

Asstudentscontinuetoworkontheirsamplegame,theymaywanttotrackminimumormaximumscores.Askforstudentexamplesofwhenthismightbethecase(e.g.successinthefewestnumberofsteps,maximumscore)

8. Inthiscasewestickwiththeforloopcontrolstructure,butmodifyittokeeptrackofwhetherthenewestvalueislargerthan(orsmallerthan)thevaluestheuserhasinputtoJavasofar:

//Initializemaxtolowestpossiblevalueortofirstvalue.for(allnumberstocompare){obtain"next"withscannerif(next>max)//or:if(next<min){max=next//min=next

Let’sbuildarealprogramwiththis:

intmin=value;

intmax=value;

for(inti=1;i<length;i++){

Scannergetsnextnumber

if(value>max){

max=value;

}elseif(value<min){

min=value;

}

}

9. Askstudentstodiscusswhatthisprogramdoes.Ifamoreconcreteexampleisneeded,workthroughthefirstprogrammingquestiontogetherasawholeclass.Encouragestudentstotellyouwhatcodetowritedownforeachstep,asmuchaspossible.

ProgrammingActivity–Programmer1Input[10minutes]

Lesson3.12:CumulativeAlgorithms

232

Page 233: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

1. HandoutWS3.12

2. Readtheinstructionsonthesheetaloud,thenaskstudentstoexplainthembacktoyou.

Askstudentswhypseudocodeissoimportanttoincludeinthisexercise.

Explicitlypointoutthespaceforastructurediagramorprogramoutline.Askstudentswhythisissuchanimportantstructuretoinclude.

Makesurethatstudentsareprogramminginpen,notinpencil,sothatalleditingstepsarevisible.

3. Givestudents10minutestobuildthefirstpartoftheprogram.

Ifstudentsarestruggling,youmayextendthetime,orofferuniversalhelpfultips.

ProgrammingActivity–Programmer2Input[15minutes]

Havestudentstradepaperswiththeirassignedprogrammingpartner.

1. Remindstudentstoaddtheirnametothepaperas“programmer2.”2. Givestudentsanother15minutestobuildontheprogramandmakeedits.

ProgrammingActivity–EditsandReflection[10minutes]

Havestudentsreturneachothers’papers,andhavethefirststudentmakeeditsandfillinthecommentsection.

AccommodationandDifferentiationAsa“runningactivity,”haveyourstudentscreateanewblanksheettitled“TrickyCodeCheatSheet,”andgivethemaplasticsleevetoprotectthisreferencesheetintheirbinder.Encouragestudentstostartwritingdownhints,tips,andusefulsnippetsofcodethattheycanrefertoduringhomework,classwork,programmingprojects,andeventests.

Everytimeyouencounterausefulsnippetofcode,recommendthatstudentsincludeitontheir“CheatSheet,”sostudentscandrilltheusefulcodethroughouttheyear.SometricksthatshowupontheAPinclude:

Using%2==0toidentifyevennumbers,use%2==1toidentifyoddnumbers.

Tofindthelastdigitofalargenumber,use%10.

Tipsfromtoday’sclasswouldinclude:

Lesson3.12:CumulativeAlgorithms

233

Page 234: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Tokeeparunningtotal,usesuminaforloop(initializeto0,puttherangeofnumbersintheloopheader).

Toaccesstheminormaxvalue,useanif/elsestatement(initializetofirstorhighest/lowestnumber,putdatarangeinforloopheader).

AskstudentswhatatipforScannerwouldlooklike,oratipforwhentoimportjava.util.*

VideoBJP4-4,Programmingwithif/elseandCumulativeSumshttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c4-4

CSE142,CumulativeSum(23:07-38:40)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=0c247411-e890-4835-8a79-bee6e74066c2&start=1387

ForumdiscussionLesson3.12CumulativeAlgorithms(TEALSDiscourseaccountrequired)

Lesson3.12:CumulativeAlgorithms

234

Page 235: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson3.13—whileLoops

Overview

Objectives—Studentswillbeableto…

Tracewhileloopstopredict:ThenumberoftimesthebodyexecutesTheoutputofthecode

Differentiatebetweenwhileloops,ifstatements,andforloops

Assessments—Studentswill…

CompletePractice-Itquestions

Homework—Studentswill…

ReadBJP5.1“RandomNumbers”Completeself-checkquestions#1-4andexercise2

Materials&PrepProjectorandcomputerWhiteboardandmarkersClassroomcopiesofWS3.13

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Introduction&think-pair-share 15min

StudentPractice-Itactivity 35min

Procedure

Lesson3.13:whileLoops

235

Page 236: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Bell-workandAttendance[5minutes]

Introduction&Think-Pair-Share[15minutes]

1. AskstudentstoofferpseudocodethatexplainshowtheymighttrackdamagetoaPokemon.

(Studentanswersshouldincludesomeofthesesteps:StartwithinitialHP,andwhileHPisgreaterthan0,askhowmuchdamage,subtractit,andendprintwith“Pokemonfainted!”)Pointoutthatthisprocesshasnopredeterminedlength(indefinitelooping),soyouneedtouseanewtypeofloopcalledawhileloop.

Ifstudentsneedadditionalexamplesofindefinitelooping,useasimplerexample,askingstudentshowtheywoulddoubleanumberuntilitwasbiggerthanN.

2. EngagestudentsintheintroductiontodaybyhavingstudentscompletethegraphicorganizeronWS3.13asyoureviewthestructure,flow,andsyntaxofthewhileloop.

3. Compareandcontrastthewhileandforloops(seecodesnippetsbelow):botharecontrolstructuresthatsendtheflowofcontrolthroughaloop,butscopediffers,sotheloopsexecuteindifferentways.

Havestudentspointoutwhereiisdeclared.

Introducetheconceptofdefinitevs.indefiniteloopsandaskstudentswhentheymightwanttouseanindefiniteloop(theywillprobablyhavewantedtousethisstructureintheirearlierprogrammingprojects—promptthemwiththisifnoonevolunteersanexample).

Call2studentsuptotheboard;onetotracetheflowofcontrolandtheotherwritetheoutput.

//whileloop://forloop:

inti=0;for(inti=0;i<10;i++){

while(i<10){System.out.println(i);

System.out.println(i);}

i++;

}

4. InvitestudentstoThink-pair-shareonthefollowingexample:

Lesson3.13:whileLoops

236

Page 237: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

intn=91;

intfactor=2;

while(n%factor!=0){

factor++;

}

System.out.println("Firstfactoris"+factor);

Howmanytimesdoesthisloopexecute?Whatistheoutput?

Inthesamepairs,havestudentsrewritethewhileloopasaforloop.

StudentPractice-ItActivity[35minutes]

1. HavestudentscompletethefollowingPractice-Itproblems:

i. whileLoopsii. forToWhileiii. whileLoopMystery1iv. whileLoopMystery2

2. Ifstudentscompletetheseproblemswithtimetospare,havethemcompletePractice-Itexercise“gcd.”

AccommodationandDifferentiationIfstudentsarehavingdifficultytracingwhileloops,usingpropersyntax,orpredictingtheoutputoftheloop,youcanchangethePractice-Itexercisetoareciprocalteachingexercise,where¼oftheclassdoeseachproblem,andtheycometothefrontoftheroomtoexplaintheirsolutionandprocesstotherestoftheclass.

Ifyouhavestudentsthatfinishedtheclassworkaheadoftime,encouragethemtoexploredo/whileloops(whichareNOTpartoftheAPsubset).

CommonMistakesLoopscommonmistakes:http://interactivepython.org/runestone/static/JavaReview/LoopBasics/lMistakes.html

VideoCSE142,WhileLoop(11:21-15:55)

Lesson3.13:whileLoops

237

Page 238: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=f9874ea5-8d4d-4bf1-8924-ded454847a58&start=681

ForumdiscussionLesson3.13whileLoops(TEALSDiscourseaccountrequired)

Lesson3.13:whileLoops

238

Page 239: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson3.14—RandomNumbersN.B.THISLESSONISOPTIONAL(WhileMath.randommightbeincludedontheAPexam,theRandomclassisnotpartoftheAPsubset.)

Overview

Objectives—Studentswillbeableto…

Writeexpressionsthatgeneratearandomintegerbetweenanytwovalues.

Assessments—Studentswill…

CompletePractice-Itquestions

Homework—Studentswill…

ReadBJP5.2Completeprogrammingproject1

Materials&PrepProjectorandcomputerWhiteboardandmarkers

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Introductionandthink-pair-share 15min

StudentPractice-Itactivity 35min

Procedure

Lesson3.14:RandomNumbers

239

Page 240: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Hookyourclassbytalkingaboutrandomizedtasksthatariseingamestheymayplay.Forexample:

Createanenemythatspawnsaftersomerandomamountoftime,butbetween7and23seconds.

Pickarandomitemfromalistof100wordstheuserneedstoguessinHangman

Createanewusernamebetween6and10characterspickingrandomlywhateachcharacteris,fromlower/capitallettersandnumbers.

Makeaballbounce,butnotprecisely,byaddingrandomanglestothebounce.

Bell-workandAttendance[5minutes]

IntroductionandThink-Pair-Share[15minutes]

1. Oncestudentshaveallhadachancetoexplorethedice,showthemhowtogeneraterandomnumbersthattheycanuseintheirgameprogram,computersimulations,orsecurityprograms(movingforward).

Constructarandomobject(seeifanyonecantellyouhowtodothisfromtheirreadinglastnight):

Randomr=newRandom();

CallthenextIntmethod,passingtheupperlimitoftherangeofyourrandomnumber(inthecaseofa6sideddice,thiswouldbe6).

result=r.nextInt(6);//Givesyouarandomnumberbetween0-5.

Doesthiscodeaccuratelysimulateasixsideddice?(Havestudentswiththesix-sideddiceansweryourquestion.)Toshiftthatresultbetween1and6,youneedtoadd1toyourcode:

result=r.nextInt(6)+1;//Givesarandomnumberbetween1-6.

Outputtheresult:

System.out.println("Yourolleda"+result);

2. GivestudentsafewminutestodoaThink-Pair-Shareforthefollowingquestions:

Lesson3.14:RandomNumbers

240

Page 241: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Writeanexpressionthatsimulatesarollofa20–sideddice.Writeanexpressionthatyieldsarandomnumberbetween0.0and1.0.

3. ReviewTable5.2fromthebookasyoudiscusstheanswersinawholegroup.

nextInt()=randomintegerbetween-2^31and(2^31–1)nextInt(max)=randomintegerbetween0and(max–1)nextDouble()=randomrealnumberbetween0.0and1.0nextBoolean()=randomlogicalvalueoftrueorfalsePrimingtheloop:remindstudentsthattheymustinitializevariablesbeforetheloop(thismakessurethatJavaknowshowtoenter/starttheloop).

StudentPractice-ItActivity[35minutes]

1. HavestudentscompletethefollowingPractice-Itself-checkproblems:

a.randomRangeABCDEb.randomInteger0to1c.randomOddInteger50to99

2. Ifstudentscompletetheseproblemswithtimetospare,havethemcompletePractice-Itexercises:

a.randomXb.randomLines

AccommodationandDifferentiationIfstudentsarehavingdifficultytracingwhileloops,usingpropersyntax,orpredictingtheoutputoftheloop,youcanchangethePractice-Itexercisetoareciprocalteachingexercise,where1/5oftheclassdoeseachproblem,andtheycometothefrontoftheroomtoexplaintheirsolutionandprocesstotherestoftheclass.

Ifyouhavestudentsthatfinishedtheclassworkaheadoftime,encouragethemtocompletePractice-ItExercisethreeHeads.

VideoBJP5–1,RandomNumbershttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c5-1

CSHomeworkBytes,RandomNumbers,withElizabethhttps://www.youtube.com/watch?v=R0MqnEofFvs

Lesson3.14:RandomNumbers

241

Page 242: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

CSE142,RandomNumbers(11:12–17:17)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=fe3ea547-6068-4e56-ab0b-e8f8605dd836&start=672

CSE142,GuessingGame(17:18–37:13)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=fe3ea547-6068-4e56-ab0b-e8f8605dd836&start=1038

ForumdiscussionLesson3.14RandomNumbers(TEALSDiscourseaccountrequired)

Lesson3.14:RandomNumbers

242

Page 243: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson3.15—Fencepost&SentinelLoops

Overview

Objectives—Studentswillbeableto…

Describewhentousefencepostandsentinelloops.Usepropersyntaxtoconstructthesecontrolstructures.

Assessments—Studentswill…

Teachamini-lessonexplainingtherelationshipbetweenparametersandvaluesstoredinmemory

Homework—Studentswill…

ReadBJP5.3Completeexercises#6&8Summarizeallofyourdailynotesifnotalreadydone

Materials&PrepProjectorandcomputerWhiteboardandmarkersGroupcopiesofWS3.153ormoreclassroomcopiesofthetextbook

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Mini-lessonplanning&prep 15min

Studentpresentations&practice 30min

Lesson3.15:Fencepost&SentinelLoops

243

Page 244: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ProcedureToday3studentteamswillteachalessononfencepostalgorithms,sentinelloops,orsentinelloopswithifstatements.Yourhookwillbetoturntheclassovertostudentsassoonastheyenter.Studentgroupsareexpectedtogeneratesamplequestions;letstudentsknowthatyouwillcollectthosequestionstouseonquizzesorasbellwork.

Bell-workandAttendance[5minutes]

Ontheboard,ontheprojector,orinagrouphandout,letstudentsknowthattheyneedtopreparea5minutelessonanda2-5minuteclassactivitytoteachtheirtopic.Usethegradingrubricasoutlinedhere:

3pts. 2pts. 1pts. 0pts.

Presentationincludesdefinitionsandanexamplewithpropersyntax.

Presentationincludesdefinitionsoranexamplewithpropersyntax.

Presentationincludesdefinitionsoranexamplewithpropersyntaxwithonemistake.

Presentationincludesdefinitionsoranexamplewithpropersyntaxwithmanymistakes.

Presentationincludesanon-exampleashelpfulcontrast.

Presentationincludesanon-examplethatismarginallyhelpful.

Presentationincludesanon-examplethatdoesnotaddtocomprehension.

Presentationincludesanon-examplethataddsconfusion,orpresentationdoesnotincludeanon-example.

Presentationincludesahelpfultipthatisclearlyexplainedandconciselystated.

Presentationincludesahelpfultipthatisclearlyexplainedorconciselystated.

Presentationincludesahelpfultipthatisnotclearlyexplainedandmayincludeasmallerror.

Presentationdoesnotincludeahelpfultiporhint.

Mini-LessonPlanning&Prep[15minutes]

1. Assigneachgroupasubsectionofsection5.2“FencepostAlgorithms,”andmakesurethatyoucirclethatassignmentoneachgroups’copyofWWS3.15.Studentgroupsshouldtake15minutestoreviewtheirsection,re-readtheexampleonthepagesfollowingtheexample,thenfigureouthowtheywanttoexplainthealgorithmtotheclass.

2. Ontheboardoroverhead,givestudentsafewthingstheyshouldconsiderinplanningtheirminilesson:

a.Whoisgoingtospeakwhen?

Lesson3.15:Fencepost&SentinelLoops

244

Page 245: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

b.Howareyougoingtoillustratetheflowofcontrol?

c.Whatdoyouneedtohaveupontheboardtoillustrateyourmini-lesson,andwhoisinchargeofwritingitout?

d.Whereandhowwillyoufeaturetheoutputproducedbyyourcodesegment?

e.Whatisyourmini-activitygoingtolooklike?(Youmightwanttoassign1–2peopletoworkonthissectionwhiletherestofthegroupworksonthelesson.)

3. Havestudentgroupssequentiallyteachthroughfencepostalgorithms,sentinelloops,andfencepostswithifstatements.

4. EncouragestudentstoaddthesestrategiestotheirTrickyCodeCheatSheet.

StudentPresentations&Practice[30minutes]

AccommodationandDifferentiationIfyourclasslearnsbetterthroughtactileorvisio-spatiallearning,youcanchangethisassignmenttoamake-a-posterlesson,havingstudentsworkinpairsortripletstocreateaninformativeposterononeofthetopics.Ifyou’refortunateenoughtohaveatheatricalormusicalclass,invitethemtocreateasong,poem,ornarrateddance/playthatteachestheirtopic.Forpoemsorsongs,encouragestudentstowritethemoutorrecordthemsoyoucandisplaythemaroundyourroom.

CommonStudentQuestionsSinceyourstudent-instructorswon’tbeabletoanswerin-depthquestionsontheirtopic,youshouldbereadytoassistduringtheQ&Asectionoftheirlesson.Somestudentquestionsthathavepoppedupinthepast,withtheiranswers,arelistedbelow:

1. Thesentinelloopexampleinthebooksaysthatthesentinelvaluewillbereadandaddedtothesumunlesswedoafencepostalgorithmorifstatement.Whyisthat?Doesn’tthetestevaluatetofalseandterminatetheloop?

Writeanexampleontheboardinpseudocodeoractualcode,andtracetheflowofcontrolwithyourmarker.Inthiscase,thepseudocodeinthebookisabitmisleadingbecauseitlookslikethetestwillterminateintheheader.Thepromptforthesentinelisalreadyintheloopbody,sothesentinelwillbeevaluatedbeforelooptermination.

Lesson3.15:Fencepost&SentinelLoops

245

Page 246: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Ifyouthinkyourclasswillbecomfortable,instructyourteachinggrouptodothisillustration,andjusthelpalong.

2. Whatdoyoudoifyoudon’tknowthefirstvaluetoputinyourfencepostalgorithm?Whatifyou’regettingallofyourdatafromuserinput?

3. Whendoweknowtoreversetheorderofloopconstruction?Theexamplefromthebookhasusswitchingaroundalotofstuffforthesentinelloopwithifstatements.

Putanexampleupontheboard(orhavethestudentinstructorsdoso),andtracetheflowofcontrolbeforeandafterrearrangingtheloopbody.

VideoBJP5-3,SentinelLoopshttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c5-3

CSE142,Fencepost(0:28-11:20)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=f9874ea5-8d4d-4bf1-8924-ded454847a58&start=28

CSE142,SentinelLoops(15:56)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=f9874ea5-8d4d-4bf1-8924-ded454847a58&start=681

ForumdiscussionLesson3.15Fencepost&SentinelLoops(TEALSDiscourseaccountrequired)

Lesson3.15:Fencepost&SentinelLoops

246

Page 247: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson3.16—BooleanLogic

Overview

Objectives—Studentswillbeableto…

WriteagamethatplaysRock-Paper-Scissors.

Assessments—Studentswill…

Submitaprogramattheendof2or3classperiods.

Homework—Studentswill…

OutlineChapter5(uptoandincludingBJP5.3)

Materials&PrepProjectorandcomputerWhiteboardandmarkersClassroomcopiesofWS3.16(RPS,Pig),DeMorgan’sLaw,Poster3.16.1,Poster3.16.2Linktorock-paper-scissorgame(http://tinyurl.com/bubyvtu)Poster3.16.1Poster3.16.2

Truthtablesareanimportanttool,especiallyforsomeAPtestquestions.Ifyouarenotfamiliarwithtruthtables,watchthis5minutetutorialonline(http://tinyurl.com/mw8ohof).Werecommendinstructorsdrawoutthe&&,||,and!truthtables,andmaybedoanintermediateexampleofatwo-operatorexpression,beforegettingintotheDeMorgan’slawexamplelaterinclass.

PacingGuide:Day1

Lesson3.16:BooleanLogic(2Days)

247

Page 248: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Attendance&studentplay 5min

IntroductiontoBooleanLogicAdd5–10minutesifusingtruthtables 10min

Studentprogrammingactivity 40min

PacingGuide:Day2

Section TotalTime

Attendance&outlinecollection 5min

Whole-grouptroubleshootinganddiscussion 10min

Studentprogrammingactivity 40min

ProcedureInplaceofbell-work,invitestudentstowarmupforclassbyvisitingtheonlineRockPaperScissorgameatthelinkabove.AfteraquickreviewofBooleanlogicandvariables,studentswillbeaskedtobuildtheirownRockPaperScissorgame.Thisprogrammingprojectshouldtakebetween2and355-minuteclassperiodstocomplete

Attendance&StudentPlay[5minutes]

IntroductiontoBooleanLogic[10minutes]

1. Studentsshouldhavealreadyreviewedthismaterialaspartoflastnights’homeworkassignment.Beforemovingontopurelymathematicalexamples,startwithareal-lifeexampleofhowweapplylogic.BesuretochangePandQtostatementsthatarerelevanttoyourstudents.

P:Itisaholiday.Q:Myfamilyishavingdinnertogether.

!(p||q)⇒Itisnotthecasethat(itisaholidayORmyfamilyishavingdinnertogether)

!p&&!q⇒ItisnotaholidayANDmyfamilyisnothavingdinnertogether.

Review&&,||,and!,includingnon-examples:

Lesson3.16:BooleanLogic(2Days)

248

Page 249: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

┌──────────┬───────────────────────┬────────────────────┐

│Operator│Expression│Result│

┝━━━━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━

━━━━━━━━━━┥

│AND│(4==4)&&(2>1)│Evaluatesto:True│

│OR│(1<2)││(2<1)│Evaluatesto:True│

│NOT│!(2<1)│Evaluatesto:True│

└──────────┴───────────────────────┴────────────────────┘

if(q==1||2||4){//ERROR:YoumustusefullBooleanexpressions.

statement;

statement;

}

if(q==1||q==2||q==4){//Correct

statement;

statement;

}

2. AsaspecialnoteonnegatingBooleanexpressions,reviewDeMorgan’slaw(poster3.16.1).HavestudentswriteDeMorgan’slawontheirTrickyCodeCheatSheet.

Ifyoufeelconfidentworkingwithtruthtables,workthroughthefollowingillustrationofDeMorgan’slaws.Ontheboardorprojector,onlywritetableheadersasyougo(puttingthemallupatoncemayleadtopanic/distractionforsomestudents).

pqp││q!(p││q)!p!q!p

&&!q

┌───────────┬───────────┬───────────┬───────────┬───────────┬───────────┬────

───────┐

│F│F│││││

│F│T│││││

│T│F│││││

│T│T│││││

└───────────┴───────────┴───────────┴───────────┴───────────┴───────────┴────

───────┘

HavestudentshelpyoufillouteverypossiblecombinationofBooleanvaluesforpandq.

Askstudentstoevaluatethelogicalexpressionforeachvalueofpandq.

Lesson3.16:BooleanLogic(2Days)

249

Page 250: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

pqp││q!(p││q)!p!q!p

&&!q

┌───────────┬───────────┬───────────┬───────────┬───────────┬───────────┬────

───────┐

│F│F│F││││

│F│T│T││││

│T│F│T││││

│T│T│T││││

└───────────┴───────────┴───────────┴───────────┴───────────┴───────────┴────

───────┘

Nowhavestudentsnegateallofthevaluesfromthepreviouscolumn.

pqp││q!(p││q)!p!q!p

&&!q

┌───────────┬───────────┬───────────┬───────────┬───────────┬───────────┬────

───────┐

│││F│T│││

│││T│F│││

│││T│F│││

│││T│F│││

└───────────┴───────────┴───────────┴───────────┴───────────┴───────────┴────

───────┘

Askstudentstocompletethevaluesfor!pand!q,referringtothevaluesfromthefirstcolumn.

Lesson3.16:BooleanLogic(2Days)

250

Page 251: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

pqp││q!(p││q)!p!q!p

&&!q

┌───────────┬───────────┬───────────┬───────────┬───────────┬───────────┬────

───────┐

│F│F│││T│T│

│F│T│││T│F│

│T│F│││F│T│

│T│T│││F│F│

└───────────┴───────────┴───────────┴───────────┴───────────┴───────────┴────

───────┘

Nowhavestudentsapplythe&&operatorto!pand!q.

pqp││q!(p││q)!p!q!p

&&!q

┌───────────┬───────────┬───────────┬───────────┬───────────┬───────────┬────

───────┐

│││││T│T│

T│

│││││T│F│

F│

│││││F│T│

F│

│││││F│F│

F│

└───────────┴───────────┴───────────┴───────────┴───────────┴───────────┴────

───────┘

Pointouttoyourstudentsthatthesetwocolumnsarethesame.Whenevertwocolumnsofatruthtablearethesame,wesaythattheexpressions(columnheadings)areequivalent,orinterchangeable.

Lesson3.16:BooleanLogic(2Days)

251

Page 252: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

pqp││q!(p││q)!p!q!p

&&!q

┌───────────┬───────────┬───────────┬───────────┬───────────┬───────────┬────

───────┐

││││T│││

T│

││││F│││

F│

││││F│││

F│

││││F│││

F│

└───────────┴───────────┴───────────┴───────────┴───────────┴───────────┴────

───────┘

Intheillustrationabove,weshowedthat!(p&&q)isequivalentto!p&&!q.Invitestudentstoshowtheequivalenceof!(p&&q)and!p||!q.

3. Reviewoperatorprecedenceonyourclassroomposter3.16.2(orprojectedoverhead,ifyou’rehavingastudentmaketheposterforyouduringclass).

4. CheckforstudentunderstandingbyhavingstudentscompletePractice-Itself-checkquestionsassertions1andassertions3.

StudentProgrammingActivity[40minutes]

Ontheprojector,boardorasahandout(WS3.16),givestudentsthefollowingprogrammingprompt.AlinktotheNYTimesarticleaboutrockpaperscissorsisincludedintheMaterialssectionofthislessonplan.

PROGRAMMINGACTIVITY

Exercise1

WriteagamethatplaysmanyroundsofRockPaperScissors.Theuserandcomputerwilleachchoosebetweenthreeitems:rock(defeatsscissors,butlosestopaper),paper(defeatsrock,butlosestoscissors),andscissors(defeatspaper,butlosestorock).Iftheplayerandcomputerchoosethesameitem,thegameisatie.

Agoodprogramwillpromptforuserinput,compareinputtoacomputercounter-move,thenoutputaverdict(userloses,wins,orties),promptforanotherroundorexit.

Lesson3.16:BooleanLogic(2Days)

252

Page 253: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Anexcellentprogramwilldoallthatasatisfactoryprogramdoes,butwillusedifferentalgorithmicstrategiesforchoosingthebestitem.Teacher’snote:thereisnosuperiorstrategy—thefocushereistogetstudentstotrydifferentapproachesandconcludethatontheirown.

Exercise2

Youandyourpartnershouldtestoutthegamebyplayingitatleast3timeseach.Keeprecordofhowmanymovesittookbeforeyouwonorlostthegame.

Exercise3

Writeaprogramthatcompares2players.Yourprogramshouldpromptforeachplayer(1)thenumberoftimestheyplayedthegame,(2)thenumberoftimestheywonthegame,(3)thenumberofmovesforeachgame.Havetheprogramreportwhichplayerperformsbetteronthebasisoftheirreportedstatistics.Testyourprogrambyinputtingyourandyourpartner’sresultsfromExercise2.

Exercise4

WriteaprogramthatplaysthedicegamePig.Pigisa2-playergamewheretheplayerstaketurnsrepeatedlyrollingasingle6-sideddie.Aplayerrepeatedlyrollsthedieuntiloneofthetwoeventsoccurs:(1)eithertheplayerchoosestostoprolling,inwhichcasethesumofthatplayer’srollsareaddedtohis/hertotalpoints,or(2)iftheplayerrollsa1atanytime,allpointsfromthatturnarelotsandtheturnendsimmediately.Thefirstplayertoreachascoreofatleast100pointswins.

Togetfullcreditonthisassignment,youmustincludeastructurediagramand/orpseudocodeexplainingyourstrategy.

Beforeyoubegin,takeamomenttodecidehowyourcomputerwillpickrock,paper,orscissor.Shouldthecomputerpickrandomly?Shoulditpickthesameitemalways?Shoulditrepeatthesameitemforatime,thenswitchstrategies?ReadthroughtheNewYorkTimesarticleonRockPaperScissor,andanyotheronlinesourcesyouchoosetohelpyoudraftaplanforyourprogram.

Allowstudentstoworkinpairs,andencouragepairstotestouteachothers’programs,lookateachotherscode(tocheckforerrors),etc.Ifstudentsappeartobeworkingtooclosely,remindthemthateachteamisresponsibleforwritingtheirowncode.

Startgradingstudentnote-booksinsmallbatches(sostudentsarenotwithouttheirnotebooksfortoolong!)

Lesson3.16:BooleanLogic(2Days)

253

Page 254: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

AccommodationandDifferentiationInviteyourartisticstudentstocreateposters3.16.1and3.16.2foryourclassroom.Ifneeded,workthroughthe2Practice-Itquestionsasawholeclass.

Foryourmoreadvancedstudents,youmightencouragethemtocreatemorecomplexalgorithms,ormoreadvancedinteractionwiththeuser.IftheyareinterestedinAIandmachinelearning,invitethemtoresearchthetopicandexperimentwithdifferenttechniquesontheirRockPaperScissorprogram.

MisconceptionsStudentsoftenhavethemisconceptionthatlogicalOR(||)isexclusiveOR.Inastudent’sdailylife,theycanhaveeitherbrownieorthecupcake.Thisimpliestheycanhaveoneortheother,notboth.However,inbooleanlogic,“aorb”isalsotrueifbotharetrue.

Studentsaskwhythesymbol&&forANDan||forOR?Andwhydouble&&vssingle&.

JavawasderivedfromtheCprogramminglanguage.ThedesignersKernighanandRichiemadedesigndecisionsbasedonpriorprogramminglanguagesoftheirtime.ThehistoryofCcanbefoundhere:https://www.bell-labs.com/usr/dmr/www/chist.html.Java’suseof&and|ishistoricallybasedonC.

Acommonsyntaxerrorbybeginnerandexperiencedprogrammersalikeistypingasingleampersand&orverticalbar|.Single&and|arebitwiseoperators,andarenotthesameasdouble&&and||whicharelogicalANDandOR,respectively.

LogicaloperatorsANDandORdonotfollowEnglishlanguagesyntax.Forexample,testingwhetheradicerolliseither7or11couldbetranslatedincorrectlyto:

if(roll==7||11)//INCORRECT:Logicaloperatormisconception

if(roll==7||roll==11)//CORRECT

VideoBJP5-4,TheBooleanTypehttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c5-4

Lesson3.16:BooleanLogic(2Days)

254

Page 255: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ForumdiscussionLesson3.16BooleanLogic(TEALSDiscourseaccountrequired)

Lesson3.16:BooleanLogic(2Days)

255

Page 256: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson3.17—Finding&FixingErrors

Overview

Objectives—Studentswillbeableto…

Finderrorsintheirreturnedhomeworkassignments.Correcttheircode

Assessments—Studentswill…

Re-submitallhomeworkassignmentswithcorrectedanswers.

Homework—Studentswill…

Studyforthetestby:ReviewingallthebluepagesattheendofChapters3,4,and5Re-readingsectionsasneeded

Submit5questionsforreviewinclasstomorrowusingelectronicsurvey

Materials&PrepAnystudenthomeworkassignmentsthatyouhavenotyetreturnedStudentself-helpsystem(suchasC2B4orstudentpairing)Electronicsurveyforstudentreviewrequests

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Introductionandhomeworkdistribution 5min

Studentwork 35min

Studentstradework,check,andsubmit 10min

Lesson3.17:Finding&FixingErrors

256

Page 257: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ProcedureToday,studentswillhavetheopportunitytocorrectanyincorrecthomeworkassignments.Ifstudentsdidnothavetimetofinishtheprogrammingprojectsfromyesterday,youmayallowthemtimetoworkonthoseprojectstoday.

Bell-workandAttendance[5minutes]

IntroductionandHomeworkDistribution[5minutes]

1. Returnstudenthomeworkpackets,orhavestudentsplacetheirreturnedhomeworksinapileontheirdesk.

2. Explaintostudentsthattheyhavetheopportunitytogetfullcreditontheirhomeworkgradesbycorrectingthemnow,inclass.Askstudentsforsuggestions/ideasonhowtomakesuretheydon’tmissanyerrors.(Bynowstudentsshouldbeusedtorelyingontheirerrorchecklist/algorithm.)

StudentWork[35minutes]

Havestudentsworkindividuallytocorrecttheirhomeworkgrades.

Offertimechecksforstudentssotheystayontask.Ifstudentshavenotfinishedtheirprogrammingprojectfromyesterday’sclass,allowthemtodosotoday.

Studentstradework,check,andturnin[10minutes]

Attheendofclass,havestudentstradetheirhomeworkassignmentstoevaluateeachother’scorrectionsbeforesubmission.

AccommodationandDifferentiationIfyouhavestudentswhoarespeedingthroughthislesson,youshouldencouragethemtotackleprogrammingproject1inChapter5.

Ifyouwereunabletofinishgradingstudentnotebooksyesterday,finishthemtodaywhilestudentsareworking.Returnnotebooksbytheendofclasssostudentsmayusethemtostudyfortheexam.

Lesson3.17:Finding&FixingErrors

257

Page 258: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ForumdiscussionLesson3.17Finding&FixingErrors(TEALSDiscourseaccountrequired)

Lesson3.17:Finding&FixingErrors

258

Page 259: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson3.18—Review

Overview

Objectives—Studentswillbeableto…

IdentifyweaknessesintheirUnit1knowledge.

Assessments—Studentswill…

Createapersonalizedlistofreviewtopicstoguidetonight’sstudysession.

Homework—Studentswill…

Studyfortomorrow’stestusingyourtargetedreviewlist

Materials&PrepProjectorandcomputerWhiteboardandmarkerResultsfromelectronicsurveyofreviewtopicsClassroomcopiesofthepracticetestWS3.18

Oncestudentshavesubmittedtheirreviewrequests,assemblethosetopicsintocategoriesandpreparetore-teachthetopicsasneeded.

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Introductionandtestformatorientation 15min

Testreview 30min

Checkstudentstudylists 5min

Lesson3.18:Review

259

Page 260: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Procedure

Bell-workandAttendance[5minutes]

IntroductionandTestFormatOrientation[15minutes]

1. Clearlyindicatethatyouexpectallstudentstohavealistofreviewtopicstostudythisevening.Periodicallyremindstudentsthatthislistwillbecheckedattheendofclass.

2. Studentsshouldalreadybefamiliarwiththesectionsofthetest,butitdoesn’thurttohavestudentsre-readthedirections.

3. Workthroughthesampleproblemsonthetestasawayofreviewingtopics,andansweranyquestionsthatstudentsbringupasyougo.

TestReview[30minutes]

1. Workthroughthevariousreviewtopics,prioritizingquestionsthatpoppedupthemost.

a.Somequestionsyoumayalreadyhaveaddressedwhileworkingthroughthesampletest.

b.Bereadyforadditionalquestionstopopupasyougo.Saveyourselftheworkanduseoldhomeworkquestionsandstudent-generatedtestquestionsasexamplestoworkthrough.

2. Useacombinationofgroup-solvingquestionsonthewhiteboard,think-pair-share,andtimed-responseasreviewstrategies.

3. Afteryou’vecompletedreviewinganidea,remindtheclassthattheyshouldwritedownthattopiciftheyfeeltheystillhavetoreviewittonight.(Yes,thiswillbearemindereveryfewminutes,butitwillpayofflaterwhenstudentsstartcreatingreviewlistswithoutpromptinglaterintheyear!)

Checkstudentstudylists[5minutes]

Spendthelast5minutesofclasscheckingeachstudent’sreviewtopiclist.

AccommodationandDifferentiation

Lesson3.18:Review

260

Page 261: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Thefirstpracticeproblemcallsamethodinsideanexpressioninsideaparametertoansweranothermethodcall(thissoundscrazy,buttakealookatthequestionbeforeyouwriteitoff!)Logically,thequestionmakessense,butitmaythrowsomeofyourstudents.Usethequestionasanopportunitytomodelpropertest-takingstrategies:

Readcodeline-by-line.

Ifstumpedonamultiple-choicequestion,trypluggingintheanswerstoseeiftheyevaluatecorrectly.

Writenotesandcrossoutanswersonyourpapercopyofthetest.

IfyouhavebeenusingParsonsProblems,onyourstudents’testsyoumaywanttothrowina“fullchallenge”blanksection2questionduringthisunitorthenexttoscaffoldyourstudentsuptothechallengeofarealAPtest.

Aswritten,theexamsincreaseinlengthandcomplexitywitheachunit.Ifyourstudentsareallacingthetest,challengeyourstudentsbymodifyingthesection2questions,andaddingextrasection1questions.

ForumdiscussionLesson3.18Review(TEALSDiscourseaccountrequired)

Lesson3.18:Review

261

Page 262: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Test2GuideAswritten,thetestforthisunitisprobablytoolongforstudentstocompleteinoneclassperiod.Extraquestionshavebeenincludedsoyoucan:

1. Pickandchoosewhichquestionswillappropriatelyassessyourstudents.2. Createdifferentversionsofthetest(ifyou’venoticedthatcheatingisaproblem).3. SimulateanauthenticAPtestexperience.

Whenmodifyingthetesttosuityourstudents,don’tforgetto:

1. ChangetheheadingsonSectionI&IItoreflecttheactualnumberofquestions.2. ChangetheheadingsonSectionI&IItoreflectthecorrectpercentagesoftheirtotal

testscore.TheAPexamweightsSectionI&IIat50%oftheoverallscore,each.3. Adjustthetestpacingforyourclassperiod’stimespan.Theultimategoalistowork

yourstudentsuptoapaceof2minutesperSectionIquestion,and26minutesperSectionIIquestion(includingtimeforchecking).

ForumdiscussionTest2Guide(TEALSDiscourseaccountrequired)

Test2Guide

262

Page 263: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson4.00—TestReview&Reteach

Overview

Objectives—Studentswillbeableto…

Re-learnorstrengthencontentknowledgeandskillsfromUnit3.

Assessments—Studentswill…

Re-submittestanswerswithupdatedcorrectionsforpartialorfullcreditCreditdependsoninstructorpreference

Homework—Studentswill…

ReadBJP6.1Correctanyincorrecttestanswersbyre-answeringonaseparatesheetofpaper

Togetbackcredit,theymustjustifytheirnewanswersStaplenewanswersheettooldtestandturnintomorrow

Materials&PrepProjectorandcomputerWhiteboardandmarkersCorrectedstudenttestsStudentgrades(postedonline,emailedtostudents,orhandedbackonpaperinclass)Digitalcopyoftestquestionsforprojector

Ifyourclassisacingtheexams,andyoudonotfeelthatyouneedtore-teachanymaterial,youshouldskipthislessonandmoveondirectlytoLP4.1.Besuretoupdatestudenthomeworksostudentshaveread§6.1.intimeforthelesson.

PacingGuide

Lesson4.00:TestReview&Reteach

263

Page 264: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Classdiscussion(ifneeded) 10min

Testreviewandreteach 35min

Checkstudentnotesandreturntests 5min

ProcedureReturnstudentgradesbeforeclassbeginsorwhilestudentsarecompletingthebellwork.

Donotreturnstudents’testsbeforethereviewsession,sinceyouwanttomotivatestudentstopayattentiontotheentirereview,takingsupplementalnotestheentiretime.

Bell-workandAttendance[5minutes]

ClassDiscussion(ifneeded)[10minutes]

1. Ifgradesarelow,invitetheclasstoadiscussionofwhatcanbeimproved.Beginwithstudentcomplaintsandsuggestionstobuildstudentbuy-in.Askstudents:

HowtheyfelttheyweregoingtodobeforethetestWhatsurprisedthemoncetheyweretakingthetestWhattheyfeltworkedinthefirstunit(lessons,reviewstrategies,assignments)Whatdotheythinktheywanttochangeforthesecondunit

2. Onceyoufeelthatadialoguehasbeenestablished,validatestudents’feelings,thenchallengethem(e.g.APcoursesarestressful,butthisisgoodpracticeforcollege,wherethepaceisfasterandprofessorsdon’tgivepersonalizedinstruction).Inanon-judgmental,supportivetone,remindstudentsthattobesuccessfulinthecourse:

Readingismandatory

Homeworkismandatory(Andvaluable!Youwillneverassign“busy”work.)

Tobettermanagetheirtime,studentsshouldplanfor1hourofhomeworkaweeknight,withupto2hoursofhomeworkeachweekend.Ifthisseemsimpossible,theyshouldmeetwithyouortheirguidancecounselortoassesswhethertheycanfitinanAPclassatthistime.

ItisVERYimportanttokeepyourtonesympatheticatthispoint—anoverworked,overstressed,underperformingstudentwillslowyourentireclassdown,andcolorthatstudentagainstCSforthefuture!

Lesson4.00:TestReview&Reteach

264

Page 265: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

TestReviewandReteach[30minutes]

1. Walkthestudentsthrougheachquestiononthetest,glossingoverquestionsthateveryoneansweredcorrectly.

a.Youcanaskforstudentstovolunteeranswers,orcallonstudentsrandomly.Makesurethatstudentsexplaintheirlogicwhentheyanswer.Ifastudentgivesanincorrectanswer,theexplanationwilltellyouwhatyouneedtore-teachorclarify.

b.Donotskipquestionsthateveryoneansweredcorrectly,butdonotspendmorethanthetimeittakestoreadthequestion,andcongratulatestudents’correctanswers.

2. Projectacopyofeachquestionasyoureview—thiswillhelpstudentsrecallthequestion/processtheinformation.

3. Makesurethatstudentsaretakingnotesduringthere-teach,remindingstudentsthatforhomework,theywillhaveanopportunitytowinbacksomeofthepointsontheirexam.

4. ForSectionIIquestions,selectasampleofstudentwork(withanyidentifyinginformationobscured),andworkthroughtheanswertogetherasaclass.

Checkstudentnotesandreturntests[5minutes]

Attheendofclass,checkstudentnotes,andreturnthetestsinhardcopyformifapplicable.

AccommodationandDifferentiationIfstudents’gradesaresufferingbecausethereadingassignmentsaretakingthemtoolong,youhaveafewoptions(somemoredrasticthanothers):

Setasideclassroomtimetoreadthroughtheassignmentbeforestudentsleave.

Givestudentsthelinesofcodeneededtocompleteassignments,butinjumbledorder.Havestudentsrearrangethelinesofcodeintotheproperprogram(thisiscalledaParsonsProblem).

Flipyourclassroom:recordyourlectures,andhavestudentswatchthemandtakenotesforhomework.Anyclassworkdrillsorworksheetscanbedistributedfor“homework,”andthemorecomplicatedassignmentsthatwouldnormallybedoneathome,canbecompletedwithyourhelpwhentheycometoclass.

Lesson4.00:TestReview&Reteach

265

Page 266: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Ifstudentsdon’thaveacomputertoworkonPractice-Itproblemsathome,createprinted-outsheetsthatstudentscanwritecodeonto.Classtimeshouldthenbefilledwithreadingassignments,andmorecomplicatedcodingpracticesoyouareavailabletotutorasneeded.

Encourageadvancedstudentstotakeonadditionalprogrammingchallenges.OneeasywaytodothisistoassignProgrammingProjectsfromthebluepagesattheendofeachChapter.Unit4introducestheMagpielab,alongformprogramminglabwithplentyofenrichmentopportunities;encouragestudentstoworkonthisprojectiftheyareeverleftwithafewminutesaftercompletingaclassassignment.

ForumdiscussionLesson4.00TestReview&Reteach(TEALSDiscourseaccountrequired)

Lesson4.00:TestReview&Reteach

266

Page 267: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson4.01—ArrayBasics

Overview

Objectives—Studentswillbeableto…

Define,populate,andaccessarrays.

Assessments—Studentswill…

CompleteexerciseswithmanipulativesonWS4.1.

Homework—Studentswill…

ReadBJP7.1“For-EachLoop”and“TheArraysClass”Completeself-checkquestions#1,7,9

Materials&PrepProjectorandcomputerWhiteboardandmarkersClassroomcopiesofWS4.1,Poster4.2Arraywhiteboards(seenotesatendoflesson)anddry-erasemarkersStudentsmall-groupassignments(~3-4studentspergroup)Largemanipulativeforteacherdemo(optional)

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Introductiontoarrays 20min

Studentarrayactivity 25min

Paperselection&gradeannouncement 5min

Lesson4.01:ArrayBasics

267

Page 268: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ProcedureDivideyourclassintosmallgroupstoday,andhavethemanipulatives(seebelow)outateachgroupstation,desk,orworkspace.Offerajust-in-timeintrotoarraysasoutlinedbelow,butdon’tbelaborinstruction;studentsmayhavebettersuccessphysicallyworkingthroughtheactivity.Circulatearoundtheroomtocheckforunderstanding,butletstudentshelpandchallengeeachother.

Bell-workandAttendance[5minutes]

IntroductiontoArrays[20minutes]

1. Openupwiththeexampleofdailytemperatureontheslides.

Asktheclasstobuildtheprogram,theyshouldreachthepointwheretheycalculatetheaverage,butareunabletocalculatethedaysaboveaverageastheymustaccessthedataasecondtime.

Inorderthesuccessfullymaketheprogram,wewouldneedtostorethetemperatureforeveryday.

Anarrayisanindexedstructurethatholdsmultiplevaluesofthesametype.Askstudentsifthey’veseenanythinginJavathatmightbeanarray.(AStringcanbethoughtofasanarrayofcharacters!)

Thevaluesstoredinanarrayarecalledelements.Individualelementsareaccessedusinganintegerindex(theposition).Askstudentswhatelementisstoredatindex2,4,and7inthisstring/array.

Sinceanarrayisanobject,youhavetoconstructit(youcan’tjustdeclareitasavariable).

int[]numbers=newint[10];

Nothingisinthehighlightedbracketsbecauseyou’redescribingwhattypeisgoingtobecontainedinthearray.

int[]numbers=newint[10];

Here’sthenameofyourarray—inthiscasewe’remakinganarrayofnumbers.

int[]numbers=newint[10];

Lesson4.01:ArrayBasics

268

Page 269: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Weusethenewkeywordsincewe’reconstructinganobject,thenwetellJavahowmanyelementswewanttostoreinourarray.Inthiscasewewanttostore10numbersinthearray.

Checkforstudentunderstandingbyaskingstudentstotellyouhowtoconstructanarraythatholds9integers.

int[]numbers=newint[9];

Alternatively,youcaninitializeanarraybywritingoutthefullarray.

int[]numbers={0,1,2,3,4,5};

2. Bothofthesesamplearraysareonly½donerightnow—they’rearraysfilledwith0sbecauseJavaauto-initializesarraystoadefaultvalueof0(forchar,double,andint)orfalse(forboolean).Soournumberarraylookssomethinglikethis:

.------------------.---.---.---.---.

|array`numbers`:|0|0|0|0|

+------------------+---+---+---+---+

|index|0|1|2|3|

`------------------'---'---'---'---'

Tofillinthisarray,weneedtofillinthevaluesforeachlocation:

numbers[0]=27;

numbers[3]=-6;

Nowthearraylookslikethis:

.------------------.---.---.---.---.

|array`numbers`:|27|0|0|-6|

+------------------+---+---+---+---+

|index|0|1|2|3|

`------------------'---'---'---'---'

3. Brieflytouchonothertypesofarraysandcommonerrors.

Youcanhavearraysofalmostanything:String,double,boolean,etc.Examplesofaninstantiateddoubleandbooleanarrayareontheslides.Asktheclasswhattheymustchangetocreatethesearrays.

Lesson4.01:ArrayBasics

269

Page 270: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Coverthecommonindex-out-of-boundsexception.Iftheprogramcallsillegalindexesorindexesoutside0andthearray’slength–1,Javawillthrowyouanexception.(It’salwaysnicetogooverreasonsforexceptionssoyoudon’tneedtocorrectthemalllater!)

4. Ifyouhaveareallybigarray,youcanuseaScannertograbvaluesfromuserinput,oryoucanautofillthemwithaloop:

for(inti=0;i<age.length;i++){

age[i]=input.nextInt();

}

Asyoumoveacrossthearray(inthiscasetofilleachelementwithauser-inputtedvalue),wecallthis“arraytraversal.”You’llneedtodothisalotinthefuture,soyoushouldputageneralformulainyourTrickyCodeCheatSheet:

for(inti=0;i<age.length;i++){

//dosomethingwithage[i];

}

StudentArrayActivity[25minutes]

1. Distributewhiteboardsandmarkerstogroupworkstationsbeforestudentsgetseated.

2. Ifyoufeelthatyourstudentsneedtheadditionalstructure,assigngroupstoworktogetheronProblem2.

3. Walkaroundtheroom,spot-checkingforstudentunderstandingandansweringanystudentquestions.

PaperSelection&GradeAnnouncement[5minutes]

Attheendofclass,considerchoosingonegroup’swhiteboardtoevaluateasademonstrationfortheclass.

AccommodationandDifferentiationRatherthanassigninggroupsrandomlyorbyability,usetieredgroupingasadifferentiationstrategy.Concepts/skillswillbecoveredatdifferentlevelsofcomplexityinresponsetodiagnosedneedsofeachlearner.Yourtieredgroupassignmentswillprobablyendupchangingfromoneexercisetoanother,sincestudents’needsandstrengthsvarywithinstructionalobjectivesandtasktypes.

Lesson4.01:ArrayBasics

270

Page 271: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Youcanreducepaperwasteandincreasestudentengagementbycreatinganinexpensiveclassroomsetof“arraywhiteboards”followingtheseinstructions:

1. Purchasepanelboardfromyourlocalhardwarestore(http://tinyurl.com/zgtlbhr)

2. Havetheassistantcuttheboardintolongstripsthatyoucanuseas1dimensionalarrays.

i. Ifyouliketouseindividualwhiteboardstocheckforstudentunderstanding,youcanhavewhiteboardscuttoindividualstudentsquares,thenhavestudentslineupthelittlewhiteboardsintoaone-dimensionalarrayforthisexercise.

ii. Ifyouplanonusingtheseasarrayboards,youcaneithersubdividetheboardsintoelement-blockswithblackelectricaltape,oryoucanhaveyourstudentsdrawtheblocksinwiththeirdryerasemarkers.(Thelatteroptionencouragesstudentstoconstructarraysofdifferentsizes.)

iii. Yourtotalnumberofarraywhiteboardsshouldbe:

(#smallgroupsinyourclassroom)*2+1instructorarrayboard

3. Usethesearray-whiteboardstodemonstratetherelationshipbetween1(andlater2)dimensionalarraysduringthisunit.

Inmathematics,amanipulativeisanobjectwhichisdesignedsothatalearnercanperceivesomemathematicalconceptbymanipulatingit,henceitsname.Theuseofmanipulativesprovidesawayforchildrentolearnconceptsinadevelopmentallyappropriate,hands-onandexperientialway.

[TEST:helloworld]

TeacherPriorCSKnowledgeArraysinJava(andotherobjectorientedprogramminglanguages)areclasses.Thisbringsthewholeobjectorientedparadigmintoplay.Whendeclaringanarrayvariable,thevariableisnowareferencetoanarrayobject.Inordertocreateanobjectfromaclasstheprogrammerusesthenewkeyword.Thereisadistinctionbetweenthearrayreferenceandthearrayobject.Thisprogrammingconstructallowsformultiplereferencetopointtothesameobject.

CommonMistakes

Lesson4.01:ArrayBasics

271

Page 272: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Arrayscommonmistakes:http://interactivepython.org/runestone/static/JavaReview/ArrayBasics/aMistakes.html

MisconceptionsStudentsunderstandingofthedifferencebetweentheindexiandthecontentofthei elementstoredina[i].

Loopbounds:

0-basedindexarrays,wherearraysend,versusarraylength,andwhataretherangeofindicestoexpressaparticulararrayrange.

VideoBJP7–1,ArraySimulationhttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c7-1

CSE142,Arrays(1:35–26:06)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=14058dec-efd5-4db3-b841-9d836e92bfb4&start=95

CSHomeworkBytes,Arrays,withArielhttps://www.youtube.com/watch?v=PFohS2HvCgs

ForumdiscussionLesson4.01ArrayBasics(TEALSDiscourseaccountrequired)

th

Lesson4.01:ArrayBasics

272

Page 273: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson4.02—For-EachLoop&ArraysClass

Overview

Objectives—Studentswillbeableto…

Populateandaccessarraysusingafor-eachloop

Assessments—Studentswill…

CompletemanipulativesexercisesonWS4.2

Homework—Studentswill…

ReadBJP7.2upto“ReversinganArray”Completeself-checkquestions#12-14

Materials&PrepProjectorandcomputerWhiteboardandmarkersClassroomcopiesofWS4.2Poster4.2Arraywhiteboards(seenotesatendofLP4.2)anddryerasemarkersStudentsmall-groupassignments(≈3-4studentspergroup)Largemanipulativeforteacherdemo(optional)

PacingGuide

Lesson4.02:For-EachLoop&ArraysClass

273

Page 274: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

IntroductiontoArrays 10min

StudentArrayActivity 35min

Paperselection&gradeannouncement 5min

ProcedureAswithyesterday’sclass,divideyourclassintosmallgroups,andhavethemanipulativesoutateachgroupstation,desk,orworkspace.Offerajust-in-timeintrotofor-eachloops,butdonotgetboggeddownintheintroductorylesson.Manystudentswilllearnfromphysicallypracticingthefor-eachcontrolstructureusingthearraywhiteboards.Circulatearoundtheroomtocheckforunderstanding,butletstudentshelpandchallengeeachother.

Bell-workandAttendance[5minutes]

IntroductiontoArrays[10minutes]

1. Brieflyintroducethefor-eachloop,arrayinitialization,andtheArraysclassbeforedismissingtheclasstoworkontheirgroupactivity:

Ifyouwanttoaccesseachelementinthearraywithoutchangingthevalues(tosummarizeorcountthem),youcanaccessthemusingafor-eachloop:

for(<type><name>:<array>){

<statement>;

<statement>;

}

2. Placeanarrayontheboard,demonstratingthequickwaytodeclareanarray,andthenillustratehowafor-eachloopcouldbeusedtoaccessthearray:

int[]fallTemperatures={55,50,59,69,48,30,48};

ThisinitializesanarraycalledfallTemperatureswith7integervalues.Askstudentswhentheymightseethesetemperaturesintheirregion,andhowthevaluesinthearraywoulddifferduringanotherseasonorinadifferentlocation.Itmaymake

Lesson4.02:For-EachLoop&ArraysClass

274

Page 275: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

senseinyourregiontochangethearraynametowinterTemperaturesornightTimeTemperatures,etc.

for(inti=0;i<fallTemperatures.length;i++){

if(fallTemperatures[i]>32){

above++;

}

}

Thisisourtraditionalloop,whichtraversesthearrayandsumsupallthetemperaturesthatareabovefreezing(weassumethereisamethodcalled“above”thatkeepsarunningcountofhowmanydayswereabove32degrees).Wecanexpressthissameprocesswithafor-eachloop:

for(inti:fallTemperatures){

if(i>32){

above++;

}

}

withthegeneralformof:

for(<type><name>:<array>){

<statement>;

<statement>;

}

Makeapointofhavingyourstudentswriteanotetoremindthemselvesthatfor-eachloopscannotmodifyvalueswithinanarray,onlyexamineeachvalueinsequence.

StudentArrayActivity[35minutes]

1. Distributewhiteboardsandmarkersorpaperprintoutstogroupworkstationsbeforestudentsgetseated.

2. Ifyoufeelthatyourstudentsneedtheadditionalstructure,assigngroupstoworktogether.

3. Ifyouthinkstudentswillneedtheextraguidance,helpstudentstogetherinawhole-groupsetting.Tohelpstudentswithoutgivingthemtheansweroutright,pointoutthat:

a.numbers[7]evaluatesto0.

Lesson4.02:For-EachLoop&ArraysClass

275

Page 276: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

b.numbers[numbers[7]]→numbers[0]doesNOTevaluateto0.

c.Instead,thememorylocationnumbers[0](theindex0ofthenumbersarray)receivesavalue.

4. Walkaroundtheroom,spot-checkingforstudentunderstandingandansweringanystudentquestions.

PaperSelection&GradeAnnouncement[5minutes]

Attheendofclass,considerchoosingonegroup’swhiteboardtoevaluateasademonstrationfortheclass.

AccommodationandDifferentiationIfyouhaveastudentthatwouldbenefitfromadditionaltactileorvisiospatiallearningexercises,invitehimorhertocreateaclassroomposterthatcontainsthesameinformationasPoster4.2.

Ratherthanassigninggroupsrandomlyorbyability,usetieredgroupingasadifferentiationstrategy.Concepts/skillswillbecoveredatdifferentlevelsofcomplexityinresponsetodiagnosedneedsofeachlearner.Yourtieredgroupassignmentswillprobablyendupchangingfromoneexercisetoanother,sincestudents’needsandstrengthsvarywithinstructionalobjectivesandtasktypes.

VideoCSE142,ArrayTraversal(26:06–33:26)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=14058dec-efd5-4db3-b841-9d836e92bfb4&start=1570

CSE142,For-EachLoop(19:40–22:40)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=14058dec-efd5-4db3-b841-9d836e92bfb4&start=1570

ForumdiscussionLesson4.02For-EachLoop&ArraysClass(TEALSDiscourseaccountrequired)

Lesson4.02:For-EachLoop&ArraysClass

276

Page 277: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson4.02:For-EachLoop&ArraysClass

277

Page 278: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson4.03—Printing,Searching,&TestingforEquality

Overview

Objectives—Studentswillbeableto…

Manipulatesingle-dimensionarraysusingavarietyofarraytransversalalgorithms.

Assessments—Studentswill…

Teachamini-lessononprinting,searching/replacing,testingforequality,reversinganarray,orstringtraversal.CompleteaquizattheendofDay2

Homework—Studentswill…

Day1:Completeself-checkquestions#15-17andexercise3Day2:ReadBJP7.3andcompleteself-checkquestions#19-21

Materials&PrepGroupcopiesofWS4.3Assignmentsfor5studentgroups5classroomcopiesofthetextbook(orhavestudentsbringtheircopiestoclass)Copiesofthegradingrubric(ontheoverheadorprintedout;optional)

Youwillneedtocirclestudentassignmentsonpoint2ofWS4.3,soeachgroupknowswhattopictheyareexpectedtoteach.

PacingGuide:Day1

Lesson4.03:Printing,Searching,&TestingforEquality(2Days)

278

Page 279: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Introductiontoassignment 10min

Studentpreparationoflesson&quizquestions 40min

PacingGuide:Day2

Section TotalTime

Groupset-up,attendance 5min

Grouppresentations(~8minutespergroup) 40min

Quiz 10min

ProcedureYourhookfortoday’slessonistoturnthereignsovertostudentsimmediately.Haveinstructionsprintedoutandsittingatteamworkstations(oronstudentdesks).Encouragestudentstoanswertheirownquestionsusingtheinstructionsheetandtextbook.FrequentlyaskedquestionsandsuggestionsforstudentgroupsareincludedinAccommodationsandDifferentiation.

Bell-workandAttendance[5minutes]

IntroductiontoAssignment[10minutes]

1. ReviewtheassignmentasoutlinedonWS4.3,andaskstudentstoexplainbacktoyouwhattheirgrouppresentationsneedtoincludeforfullcredit.Ifyouneedto,reviewproceduresforgroupwork,thensplittheclassintogroups.

Ifyoufeelitwillbenefityourclass,reviewingordistributingthegradingrubricbeforetheassignmentshouldbedoneatthispoint.

StudentPreparationofLessonandQuizQuestions[40minutes]

Givestudentstheclassperiodtopreparetheirpresentationandgeneratequizquestionsfortomorrow’sclass.

Lesson4.03:Printing,Searching,&TestingforEquality(2Days)

279

Page 280: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Useatimerandperiodicallyannouncehowmuchtimeisleftinclasssostudentscanpacethemselves.

Emphasizetostudentsthattheyshouldprimarilydrawupontheirtextbookstohelpthemplantheirlesson.

Answerstocommonlyaskedquestions,andtipsforthedifferentgroupsmaybefoundbelow:

FAQ:PRINTINGANARRAY

Guidanceforstudentteachers

1. Ifstudentsarelackingdirection,encouragestudentstorefertothetextbookandtracetheloopandpredicttheoutputofthecodethatprintsthearray“list”vertically.

2. Agood“TrickyCodeCheatSheet”tipcanbefoundonthesamepage;anytimeyouseealistofvaluesseparatedbycommas,studentsshouldremembertouseafencepostalgorithm.

CommonQuestions/Answers

1. Whenwouldweencounteranemptyarray?

Ifyousetarrayvaluestonull,they’reactuallyempty(notjustequalto0orfalse).Anotherwayyoucouldgetanemptyarrayisifyouinitializedanarrayofsize0;thentherewouldbenoelementsatall!

2. Whydowehavetoincludeextracodetoaccountforanemptyarray?

Weputin“contingencycode”todealwithanemptyarraytobethorough.Ifwedon’thandlespecialcasescorrectly,Javawillthrowanexception,sowetrytocoverourbasesandpreventthatfromhappening.

FAQ:SEARCHINGANDREPLACING

Guidanceforstudentteachers

1. Ifstudentsarehavingtroubleoutliningtheirlesson,encouragethemtoteachcounting,thenlocatingvaluesinalist.Oncethey’vecoveredthosemethods,theycanfinishupbytracingthesamplemethodreplaceAllandexplainingtheoutput.

2. Agood“TrickyCodeCheatSheet”tipwouldbetheconventionofreturning-1ifavalueisnotfoundinthelist.

Lesson4.03:Printing,Searching,&TestingforEquality(2Days)

280

Page 281: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

CommonQuestions/Answers

1. Whydoweuseafor-eachloopforcountingoccurrences,butnotforfindingvaluesinalist?

Neitheronerequiresyoutochangethecontentsofthearray!**Ifwe’refindinganiteminalistandreturningitsindex,thenweneedtotrackindexesaswesearch.That’sdonenaturallywitharegularforloop;withafor-eachloop,we’dhavetomanuallysimulateaforlooptocomputetheindex.

2. Whyisthemethod“count”initializedtozero?

Thisissettingupthelooptoworkcorrectly—review“primingthepump”analogyifneeded.

FAQ:TESTINGFOREQUALITY

Guidanceforstudentteachers

1. Remindstudentstoincludethedefinitionforwhatmakesarraysequivalent(theyhavethesamelengthandstorethesamesequenceofvalues).

2. Ifstudentsarestrugglingwiththesequenceoftheirlesson,youmightsuggestthattheybeingbyteachingthesamplemethod“equals,”thencirclingbacktoexplainwhytestingforinequalityiseasierthantestingforequality.

3. AgoodgeneraltipfortheTrickyCodeCheatSheetwouldbethecommonpatternformethodslike“equals;”Testallforthewaysthatthetwoobjectsmightnotbeequal,returningfalseifthereareanydifferences,ortrueattheveryendifalltestsarepassed.

CommonQuestions/Answers

1. Can’twejustuseArrays.equalstoseeiftwoarraysareequal?

Yes,youcan(andshould)usethismethodfromtheArraysclass.Inteachingyourunit,yourpurposeistofamiliarizestudentswiththewaytowritecodethattestsequalsingeneral.Whileyoumightnotneeditinthisparticularsituation,youmaywanttotweakthemethoddowntheroad,andyoucannotedittheArrays.equalsmethodbecauseitsnotinaclassyoucanedit.

FAQ:REVERSINGANARRAY

Guidanceforstudentteachers

Lesson4.03:Printing,Searching,&TestingforEquality(2Days)

281

Page 282: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

1. Ifstudentsneedguidanceonstructuringtheirlesson,encouragethemtoworkthroughthefinal(correct)method“swap,”tracetheflowofcontrolandoutput,thencoverwhyotherversionsdon’twork.(Theymaynotpresentinthisorder,butcoveringthecorrectanswershouldhelpthemorganizetheirthoughts.)

2. AgoodtipfortheTrickyCodeCheatSheetistosummarizethestepsneededtoswaptwovalues.ThiscomesupoftenontheAPexam.

CommonQuestions/Answers

1. Whycan’twejustswapvaluesbyassigningthemtoeachother?

Ifyouassignonevaluetotheother,youcopyoverthevalues,so½waythroughtheprocess,you’vegot2copiesofthesamevalue.Thesecondhalfoftheswapdoesn’twork!

2. Whydowehavetostoptheswaploop½waythroughthelist.length?Won’tthatjustswap½ofthelist?

Usingalineof4–6objects(pens,paperclips,whateveryouhavearoundtheclassroom),startbyswappingthefirst&lastitems,thenthenext-inner-two,andsoon.Counteachmoveasyoumakeit,thenpauseatthehalfwaypoint,pointingoutyou’veconductedlength/2swaps.Proceedwiththefinalswaps,returningobjectsbacktotheiroriginalplace.

FAQ:STRINGTRAVERSALALGORITHMS

Guidanceforstudentteachers

1. Encouragethegrouptospendsometimeduringtheirlessononwhyyouuseparenthesesformostarrays,butnotwithstrings.

2. Ifstudentsareatalossforhowtoteachtheirsegment,suggestcoveringanexampleandanon-exampleforcontrast.Agoodnon-examplewouldbetraversinganarraythatisn’tastring.

CommonQuestions/Answers

None.

1. Collectquizquestionsbeforetheendofclass.CheckandcompileintoaquizfortheendofDay2.

2. OnDay2,giveeachgroup5minutestopresenttheirtopicand3minutesforquestions.

Lesson4.03:Printing,Searching,&TestingforEquality(2Days)

282

Page 283: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Encouragestudentstoaskquestions,andbesuretoaskaquestionortwoofeachteam(dependingonhowmanyteamsyouhave).

3. Usethegradingrubricasoutlinedhere:

3pts. 2pts. 1pts. 0pts.

Presentationincludesdefinitionsandanexamplewithpropersyntax.

Presentationincludesdefinitionsoranexamplewithpropersyntax.

Presentationincludesdefinitionsoranexamplewithpropersyntaxwithfewmistakes.

Presentationincludesdefinitionsoranexamplewithpropersyntaxwithmanymistakes.

Presentationincludesanon-exampleashelpfulcontrast.

Presentationincludesanon-examplethatismarginallyhelpful.

Presentationincludesanon-examplethatdoesnotaddtocomprehension.

Presentationincludesanon-examplethataddsconfusion,orpresentationdoesnotincludeanon-example.

Presentationincludesahelpfultipthatisclearlyexplainedandconciselystated.

Presentationincludesahelpfultipthatisclearlyexplainedorconciselystated.

Presentationincludesahelpfultipthatisnotclearlyexplainedandmayincludeasmallerror.

Presentationdoesnotincludeahelpfultiporhint.

1. Administerthestudent-generatedquiztoassessstudentunderstanding.

AccommodationandDifferentiationCirclearoundtheroomtohelpstudentsthroughreadingthetextinthetextbook.Makesurethateachofyourworkingteamsareproperlystratified(ratherthanusingtieredgrouping).

Ifstudentsarespeedingalong,encouragestudentstowritedownquestionstoposetoothergroupsduringmini-lessons.Ifeveryonefinishescreatingtheirlessonsearly,starttheclassroompresentationsonDay1insteadofwaitingforDay2.Ifonly1or2groupshavefinishedearly,encouragegroupstorehearselessondelivery.

VideoBJP7-2,ArrayTraversalAlgorithmshttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c7-2

Lesson4.03:Printing,Searching,&TestingforEquality(2Days)

283

Page 284: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

CSE142,RandomAccesstoArray(33:26-42:00)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=14058dec-efd5-4db3-b841-9d836e92bfb4&start=2006

ForumdiscussionLesson4.03Printing,Searching,&TestingforEquality(TEALSDiscourseaccountrequired)

Lesson4.03:Printing,Searching,&TestingforEquality(2Days)

284

Page 285: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson4.04—ReferenceSemantics

Overview

Objectives—Studentswillbeableto…

Compareandcontrasthowprimitivesandarraysaretreatedwhenpassedasparameters.

Assessments—Studentswill…

CompletegraphicorganizersandaworksheetExtracredit:completeaPokémonChallenge

Homework—Studentswill…

ReadBJP7.4upto“Command-LineArguments”Completeexercises#9,10

Materials&PrepProjectorandcomputerwiththispage:http://www.legendarypokemon.net/javacalc.htmlWhiteboardandmarkersClassroomcopiesofWS4.4InstructorcopyofWS4.4Answer

The“worksheet”fortodayisa5-pageworkpacket,soifyourschoolhaslonglines/productiontimeforthecopymachine,planahead!

PacingGuide

Lesson4.04:ReferenceSemantics

285

Page 286: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Studentactivity 25–30min

Studenttrade&check 5min

Wholegroupreview&papersubmission 15min

ProcedureHookyourclasstodaywiththeconceptofa“backwards”classstructure.Usingonlytheinformationgleanedfromlastnight’sreading(andperhapssomehelpfromafriend),studentsshouldworkthroughasmuchoftheworksheetastheycaninthetimeallotted(~30minutes).Finishtheclasswithwhole-classnotetakingonthetopicsthatwerechallenginginthesheet.

Bell-workandAttendance[5minutes]

StudentActivity[25-30minutes]

HavestudentsstartworkingonWS4.4inpairsoralone.Useatimertohelpstudentspacethemselves.

StudentsTrade&Check[5minutes]

After25–30minutesgivestudentsafewminutestocheckeachothers’work.

WholeGroupReview&PaperSubmission

1. Asawholegroup,askstudentsforquestionstheyhadontheworksheet.Usetheanswerkeyincludedonthistoguideinstruction.

2. Collectworksheetsattheendofclass.

AccommodationandDifferentiationIfyouhavebeenusingParsonProblemsthroughouttheyear,yourstudentswillbefamiliarwiththeformatofQuestion8ontheworksheet.Forotherclasses,thismaybethefirsttimethey’vebeenaskedtorearrangeprovidedcode.Readthroughtheproblemoutloudwiththe

Lesson4.04:ReferenceSemantics

286

Page 287: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

class,thenreadthroughthelinesofcodeinthebottomhalfofthequestion.Eachlineofcode(eventhelonebracket)canbeshuffledandre-arrangedtoprovidethecorrectcodesequence.

Studentsuccessinthislessonreliesheavilyonstudents’havingbeenabletoreadandcomprehendthepriornights’reading.InELLclassrooms,encouragestudentstoopentheirbooksandworkwiththetextinfrontofthem,andpairstudentsofdifferinglanguageabilities.

Ifyouknowyourstudents’readingabilitieswillnotallowforalessonlikethis,conductthelessonasawhole-group,teachingasegmentofthechapterandpausingtoletstudentsworkonaquestionbeforemovingforward.

Theworksheetmatchesupsequentiallywithsection7.3,soyoucanhavestudentsreadalongwithyourinthebookasyouworkthroughthesheet,and/oryoucanallowadvancedstudentstoworkontheirownasyouhelptherestofclass.

Therewillprobablybealotofvariationinhowlongittakesstudentstocompletetoday’sassignment.

Askstudentswhofinishearlytodesignahands-ondemonstrationthatusesthearraywhiteboards(andanyothermaterialsaroundtheroom)toexplaintheproperanswerstothequestionsontheworksheet.Iftheycomeupwithanycooldemos,usethemduringstudentreviewattheendoftheclass.

BereadywithaPokemonChallengeforthestudentsthatspeedthroughtheassignment:

POKEMONCHALLENGE

Thisjavabasedcalculator(http://www.legendarypokemon.net/javacalc.html)usesmedianIVs(initialvalues)andinputEVs(effortvalues)tocalculateaPokemon’sstatsonagivenlevel.

WriteamethodcalledmedianIVthatacceptsanarrayofintegerIVsasitsparameterandreturnsthemedianofthenumbersinthearray.

Themediannumberisthenumberthatappearsinthemiddleofthelistifyouarrangetheelementsinorder.Youcanassumethatthearrayisofoddsize(sothatoneelementisfoundinthemiddle),andthatthenumbersinthearrayarebetween0and99,inclusive.Forexample,themedianof[5,9,4,10,11]is9,andthemedianof[0,8,1,89,48,27,30]is27.

Hint:CheckouttheTallyprograminchapter7forsomeideasonwhatcodetouse.

Lesson4.04:ReferenceSemantics

287

Page 288: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

VideoCSE142,ArrayInitializer(3:26–5:43)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=acae034a-2b95-4eb3-b3f0-17a77a7b5ff3&start=206

CSE142,Passingarrayasparameter(5:44–9:05)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=acae034a-2b95-4eb3-b3f0-17a77a7b5ff3&start=344

CSE142,Arrays.toString()(21:19–25:27)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=acae034a-2b95-4eb3-b3f0-17a77a7b5ff3&start=1278

CSE142,Valuesvsreference(25:28–39:18)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=acae034a-2b95-4eb3-b3f0-17a77a7b5ff3&start=1528

CSE142,modifyingarraywhenpassedasparameter(39:19–43:41)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=acae034a-2b95-4eb3-b3f0-17a77a7b5ff3&start=2359

ForumdiscussionLesson4.04ReferenceSemantics(TEALSDiscourseaccountrequired)

Lesson4.04:ReferenceSemantics

288

Page 289: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson4.05—ShiftingValues&ArraysofObjects

Overview

Objectives—Studentswillbeableto…

ShiftelementswithinanarrayConstructarraysofobjects

Assessments—Studentswill…

CompletePractice-ItquestionsModelmemorymanipulationusingarraywhiteboards

Homework—Studentswill…

ReadBJP7.4“NestedArrays”andBJP7.5“RectangularTwo-DimensionalArrays”Completeself-checkquestions#27-29andexercise#4

Materials&PrepProjectorandcomputerwiththispage:http://www.legendarypokemon.net/javacalc.htmlClassroomwhiteboard&markersArraywhiteboard&markersSmallgroupassignments&seatingarrangements(ifpossible)

Ifyourclassroomstructureallowsit,arrangearraywhiteboardsandmarkersatstationswherestudentscangatheraroundthemtomodeltheconceptsyouteachduringyourintro.Ideally,studentswillbestandinghuddledaroundthearrays,activelymovingandrearrangingitems.

PacingGuide

Lesson4.05:ShiftingValues&ArraysofObjects

289

Page 290: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Introduction&small-grouppractice 20–25min

Practice-ItQuestions 25–30min

Error-checkingalgorithm(seebelow) 10min

ProcedureHookyourclasstodaybyhavingtheminsmallgroupswiththearraywhiteboardsduringyourIntroduction.Asyouwriteoutthecodesamplesonthewhiteboard,pauseatdifferentstagestomodelwhatishappeningtotheelementsstoredinmemory.Astheintroductionprogresses,askstudentstomodelthechangesforthewholeclass,withyouandtheothergroupsreplicatingtheirmanipulations.Thekeytothisintroductionistohavestudentsworkingthroughtheexamplesinphysicalspace,somakesurethatallgroupsareworkingalongwiththeirarraywhiteboards.

Bell-workandAttendance[5minutes]

Introduction&Small-GroupPractice[10minutes]

1. IntroduceyourexamplearraycalledmetroCardRides(ordailyDrive,milesWalked,whateverrepresentsyourstudents’commutetoschool),andholdupanarrayofints:

2. Brieflyaskyourstudentstodirectyouinconstructingandinitializingthisarrayobject,thenaskstudentsforsomeideasastohowtomovethe5fromthefirstelementofthearraytothelastelement,sothatweendupwith[4][3][2][1][5].

Givestudentsaminutetotrymovingnumbersaroundtheirwhiteboards.Mostnumberscanbemovedbyshiftingdownthelinewithaforloop,butthefirstelementwillneedtoberemovedtoallow“space”fortheshift.

3. Askstudentshowtostorethatfirstelement(value5)intoalocalvariable,thenwritethatcodeonyourmainwhiteboard.

intfirst=metroCardRides[0];

Lesson4.05:ShiftingValues&ArraysofObjects

290

Page 291: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Redirectstudentstothetaskofshiftingtherestofyourvaluesonyourarray.Asaclass,discusswhatyouneedthecodetodo,thenaskthegroupstodraftsomecodeandtestthatcodeontheirarraybytracingthecodeandcheckingforerrors.

4. Thecorrectloopforthislooplookslikethis:

for(intj=0;j<metroCardRides.length–1;j++){

metroCardRides[j]=metroCardRides[j+1];

}

IfstudentsusemetroCardRides.lengthinsteadofmetroCardRides.length–1,walkthroughthelooponyourarraywhiteboard,demonstratingthatmetroCardRides.lengthcausesJavatorunofftheendoftheloopsincethereisnoelementatindex5.Alternatively,remindstudentsaboutzeroindexing,andseeiftheycatchtheirownmistake.

5. Askstudentstoremindyou(inpseudocode)whatallthestepsarethatareneededtosuccessfullyshiftthenumbersinthearray.

Modelonyourarraywhiteboardwhatstepshavealreadybeensuccessfullywritten,andaskstudentswhatislefttodonowthatyourarraylookslikethis:

Selectagrouptogiveyouthelaststepthatre-insertsthefirstelementatindex4,andasktheclasstofinishupthecompletemethod,soyourfinalmethodlookslikethis:

publicstaticvoidfirstToLast(int[]metroCardRides){

intfirst=metroCardRides[0];

for(intj=0;j<metroCardRides.length–1;j++){

metroCardRides[j]=metroCardRides[j+1];

}

metroCardRides[metroCardRides.length–1]=first;

}

6. Ifallstudentsunderstandthismethod,movethelastelementtothefirstposition,shiftingtheotherelementsonepositiontotheright.

Directstudentstostartworkingonthischallengebyre-settingtheirwhiteboardsandmodelingthedifferentstepsthatneedtooccur.

Lesson4.05:ShiftingValues&ArraysofObjects

291

Page 292: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Walkaroundtheroom,checkingthatstudentsareontherightpath.Studentsshouldrecognizethattheyneedtotemporarilystorethelastelementasavariablenowthatthey’reshiftingarrayelementsintheotherdirection.

7. Oncestudentshavewrittenthecodetheythinkiscorrect,havethemtracetheirowncodeandmanipulatethearraysintheirwhiteboard.

Encouragestudentstodivideupthistasksoonestudentreadsthecodeandanotherstudentmovestheelementsonthewhiteboard.Allmembersshouldbeengagedinerrorchecking.

8. Thecorrectfinalcodelookslikethis:

publicstaticvoidfirstToLastRight(int[]metroCardRides){

intlast=metroCardRides[metroCardRides.length–1];

for(intj=metroCardRides.length–1;j>=1;j--){

metroCardRides[j]=metroCardRides[j–1];

}

metroCardRides[0]=last;

}

9. Spotcheckstudentcodeforanoff-by-oneerror;startingtheloopat0asksJavatolookforavalueatindex-1,whichdoesn’texist.(Ifstudentsaremodelingtheircodeexecutionwiththearraywhiteboards,theyshouldcatchthis.)

Ifstudents“correct”thiserrorbystartingtheloopat1,askthemtomodelthecodeexecutionwiththeirarraywhiteboardsforyou.Theloopoverwritesthevalueatj–1withthevalueatj,sothearraywillstartfillinginwithall5sasthelooprepeatsitself:

Thesolutiontothisistricky!Itmightbeworthdiscussing/workingasaclassifgroupsaregettingstuckonthis.Theloopneedstoshiftvaluesrightbystartingattheleftandrunningbackwards.Seeifyoucangetstudentstobrainstormthissolutionbymanipulatingthevaluesontheirwhiteboardsfirst.

Lesson4.05:ShiftingValues&ArraysofObjects

292

Page 293: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Nowaddbackinthetemporarily-storedvalue1atindex0.

10. Collectthearraywhiteboards(orhavestudentssetthemaside)andbrieflyintroducearraysofobjects.

Thisisanoptionalextension.Sincewehaven’tstudiedobjectsyet,youmightwanttoleavethisoutifitistoofarbeyondyourstudents’zoneofproximateknowledge.

Arraysofobjectsstorereferencetoobjectsinsteadofaprimitivetypevalue.Drawingsomethinglikethismighthelpstudentcomprehension:

Lesson4.05:ShiftingValues&ArraysofObjects

293

Page 294: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Askstudentsleadingquestions,gettingthemtotellyouthatbecausethearrayandthearraycontentsarebothobjects,bothneedtobeconstructed.

Workthroughanexampletogetherasaclass;askstudentstohelpyouconstructanarrayofpoints.Yourcodeshouldlooksomethinglikethis:

Point[]points={

newPoint(3,7),

newPoint(4,5),

newPoint(8,2),

newPoint(7,5),

newPoint(2,8)

};

Practice-ItQuestions[25-30minutes]

1. Dependingonthemoodandfrustrationlevelsintheclass,youmaychoosetohavestudentsworkinpairs.

a.Ifstudentsarereallyhavingaroughtime,workthroughthefirstPractice-Itquestiontogetherasawholegroup.

b.Putsoft,soothing(butupbeat)musiconinthebackgroundtoencouragework

2. HavestudentslogintoPractice-IttocompletethefollowingPractice-Itself-checkquestions:

a.arrayCodeTracing3b.arrayCodeTracing4c.arrayMystery2d.arrayMystery3e.isPalindrome

3. HavestudentscompletePractice-ItExerciseappend.

Lesson4.05:ShiftingValues&ArraysofObjects

294

Page 295: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

4. Ifmore25%ormoreoftheclassisstruggling,returntowholegroupwiththestipulationthatstudentswhounderstandthetaskmaycontinueworkingindependently.Otherwise,encouragepeertutoring,orusingthetextbookornotebooksforhelp.

Error-CheckingAlgorithm[10minutes]

Attheendofclass,iftimepermits,havestudentsdraftanalgorithmforerror-checking(seebelowfordetails).

AccommodationandDifferentiationIfyourclassneedsadditionalchallenges,makethearraysinyourexamplesabitmoresophisticated.Changethevaluesoradd“tricks”tothecode,andincludesomemistakesinyourdelivery(writtenorconceptual)toletthestudents“catch”you.Iftheydon’tcatchyou(andyou’reagoodactor),fumbleyourwayintorevealingthemistakeinlogicorcode,andletthemcatchyousoyoucanmodelapositiveattitudetowardserrorchecking.

Ifstudentsfinishthislessonearly,havethemdraftanalgorithmorchecklistthatwillhelpstudentschecktheirloopcodewhenshiftingvaluesinanarray(whatarecommonerrorstolookfor?).

Ifthechecklististhorough,brief,andcomplete,havestudentscreateahandoutorposterthatyoucanhanguporsharewiththeclass.

Toadjustforreading/comprehensionchallengesintheELLclassroom,considerhavingstudentsworkinsmallgroupswiththearraywhiteboardsinsteadofansweringquestionswithinPracticeIt.Giveeachgroup/studentaprintoutwiththequestions,andhavethemturnintheworksheetsattheendofclass.

VideoBJP7-3–1:Arrayshiftingalgorithmhttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c7-3-1

CSE142:Mysterycodewalkthrough(9:06–21:18)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=acae034a-2b95-4eb3-b3f0-17a77a7b5ff3&start=560

CSE142:Reversinganarray(43:42–49:30)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=acae034a-2b95-4eb3-b3f0-17a77a7b5ff3&start=2622

Lesson4.05:ShiftingValues&ArraysofObjects

295

Page 296: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

CSE142:Absolutevaluesanarray(1:42–5:11)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=acae034a-2b95-4eb3-b3f0-17a77a7b5ff3&start=2622

ForumdiscussionLesson4.05ShiftingValues&ArraysofObjects(TEALSDiscourseaccountrequired)

Lesson4.05:ShiftingValues&ArraysofObjects

296

Page 297: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson4.06—NestedLoopAlgorithms&RectangularArrays

Overview

Objectives—Studentswillbeableto…

Correctlyadjustnestedloopheadersforusewitharrays.Correctlyconstructtwo-dimensionalarrays.

Assessments—Studentswill…

CompleteWS4.6

Homework—Studentswill…

ReadBJP10.1upto“AddingtoandRemovingfromanArrayList”Completeself-checkproblems#1-6

Materials&PrepProjectorandcomputerWhiteboardandmarkersClassroomcopiesofWS4.6Arraywhiteboards

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Introduction/Reviewofobjects&stringprocessing ≈10min

RoundRobin ≈35min

Paperselection&gradeannouncement 3min

Lesson4.06:NestedLoopAlgorithms&RectangularArrays

297

Page 298: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Iftheinstructiontakeslongerthanexpected,assigntheworksheettosmallgroupssostudentscanworktogethercollaboratively.Thisshouldallowyoutocompletethelessoninoneclassperiod.Alternatively,youcanassignstudentstofinishtheworksheetathomeforhomework,ormaketheworksheetshorter.

ProcedureThereareseveralwaysyoucanteachtoday’sclass.Youshouldfirstcheckinwithyourstudentstoseehowpreparedtheyarefortoday’slesson.Ifstudentsunderstoodmostofwhattheyreadforhomeworklastnight,youcanaskstudentsforspecificquestions,coveronlythosetopics,thenmoveontotheRound-Robinactivity.Ifyourclassismostlyconfused,youcanre-teachallofthecontent,workingthroughseveralexampleswithThinkPairSharesbeforebreakingintotheRoundRobinActivity.AnoptionalProgrammingChallengeisincludedattheendofthelessonifyourlessonfinishesearly.

Bell-workandAttendance[5minutes]

Introduction/ReviewofObjects&StringProcessing[10minutes]

1. Twodimensionalarrayscomeinhandywhentrackingcertaintypesofdata;adjusttheexplanationsoit’srelevanttoyourstudents(agrocerystore,aStarbucks,afarmer’smarket).

Previously,wemighthaveusedanarraytokeeptrackofsandwichordersinlineatabodega:

Supposewehaveseveralworkersatthebodegamakingsandwiches,andwewanttokeeptrackoftheorderseachoneisworkingon.Wecouldusemultiplearrays,oranarrayofarrays.

Totraversemultidimensionalarrays,weneedanewtooltohelpusfillthem.

2. Demonstrateabasicnestedloopusedtoswitchnumbersinanarray.Beginbyusingthearraywhiteboardtodemonstratewhatyouwantthecodetodo:

Lesson4.06:NestedLoopAlgorithms&RectangularArrays

298

Page 299: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Challengethestudentstocomeupwithpseudocode(oractualcode,ifthey’rereadyforit)thatprintsoutalloftheinversionsinthisarray.Aninversionisapairofnumbersinwhichthefirstnumberinthelistisgreaterthanthesecondnumber.Besuretoemphasizethatnoelementsarebeingmovedorshifted.Theoutputforthearrayabovewouldbe:

(4,3)

(4,2)

(4,1)

(3,2)

(3,1)

(2,1)

Anarray

wouldoutput:

(3,1)

(3,2)

(4,2)

3. Asyourstudentsareworkingonthisproblem,encouragethemtousethewhiteboardarraystoorganizetheirthoughtsandvisualizetheproblem.Theirpseudocodeshouldlooksomethinglikethis:

for(everypossiblefirstvalue){

for(everypossiblesecondvalue){

if(firstvalue>secondvalue){

print(first,second).

}

}

}

Asawholegroup,orinindividualgroups(dependingonfamiliaritywiththematerial),constructthefinalcode:

Lesson4.06:NestedLoopAlgorithms&RectangularArrays

299

Page 300: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

for(inti=0;i<data.length-1;i++){

for(intj=i+1;j<data.length;j++){

if(data[i]>data[j]){

System.out.println("("+data[i]+","+data[j]+")");

}

}

}

Asa“TrickyCodeCheatSheet”tip,youmightdiscussthegeneralreminderthatforaninversion,thesecondvaluehastoappearafterthefirstvalueinthelist.Thismeansthatyouonlywanttocomparevaluesthatcomeafterthefirstvalue,sotheinnerloopinitializesatj=i+1.

Ifstudentsaskwhytheouterloopendsatdata.length–1,havethemtracethecodeandpredictoutputusingtheirwhiteboards.Theyshouldnoticethatsinceonlypairsofnumbersarebeingcompared,thelastelementofthearraywillneverbeapossiblefirstvalue.

4. Askavolunteerstudenttohelpyoubuildaphysicalrepresentationofamultidimensionalarray(anarrayofarrays).Demonstratethecodeusedtocreatearraysofmultipledimensions,andhavestudentsgatherarraywhiteboardsfromaroundtheroomtoshowwhatthearrayswouldlooklikeinmemory:

double:onedoublevalue

double[]:a1dimensionalarrayofdoubles

double[][]:a2dimensionalarray(grid)ofdoubles

double[][][]:a3dimensionalarray(cube)ofdoubles

Lesson4.06:NestedLoopAlgorithms&RectangularArrays

300

Page 301: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Anarrayconstructedwiththecodebelowhas2rowsand3columns:

double[][]ages=newdouble[2][3];

Havestudentsindexthearrayforyou:

Youmightopttogivestudentsthisgeneralformulaforthesyntaxofdeclaringandconstructingamultidimensionalarray:

5. Runthroughsomeexampleswithyourstudents:

Toaccessthe1 elementofthe2 row:ages[1][0]

Toaccessallelementsofthe1 row:ages[0]

Toaccessallelementsofthe2 row:ages[1]

6. Multidimensionalarrayscanalsobepassedasparameters.Havestudentstracetheflowofcontrolandpredicttheoutputofthecodebelow:

publicstaticvoidprint(double[][]grid){

for(inti=0;i<grid.length;i++){

for(intj=0;j<grid[i].length;j++){

System.out.print(grid[i][j]+"");

}

System.out.println();

}

}

Askstudentswhyyoureferencedgrid.lengthintheouterloop(thenumberofrows),andwhatgrid[i].lengthrefersto(thenumberofcolumns).

Asafinaltip,letstudentsknowthatformultidimensionalarrays,Arrays.toStringwon’tworkcorrectly,andtheyshoulduseArrays.deepToStringinstead.

RoundRobin[45minutes]

1. Round-robinisadrillinganderror-checkingexerciseusedwithworksheets.Atminimum,thereshouldbe1questionforeachstudent(e.g.aclassof15studentswouldneedaworksheetwith15ormorequestions).Studentswritetheirnameonthe

st nd

st

nd

Lesson4.06:NestedLoopAlgorithms&RectangularArrays

301

Page 302: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

worksheet,completethefirstproblem,thenpassthepapertothestudentontheright(orwhateverdirectionyouchoose).Thenextstudentfirstchecksthepreviousanswer,correctingitifneedbe,thencompletesthesecondquestion.Eachstudentthenpassesonthepaperagain.Bytheendoftheexercise,eachstudenthascheckedandcompletedeachquestionontheworksheet.

2. ThehookisthatyouchooseonlyONEworksheetfromthepiletograde.Allstudentsgetagradefromthatoneworksheet.Thiskeepsstudentsinvestedthroughouttheexercise.Advancedstudentswillcheckquestionsthroughoutthewholeworksheet,andallstudentswilltrytheirbesttocatchtheirown(andothers’)mistakes,sincethewholeclasssharestherandomly-selected-paper’sgrade.

3. Youshouldtimeeachquestion/checkinginterval,andcall“TIME!”whenitistimeforstudentstopassalongpapers.

a.Questions1–4shouldtake≈1minuteeach.b.Questions5–9shouldtake≈2minuteseach.c.Questions10–12shouldtake≈3minuteseach.d.Questions13–14shouldtake≈4minuteseach.e.Questions15–16[Bonus]shouldtake≈5minuteseach.

Adjustthetimingonthesequestionsasneeded,buttrytokeepabriskpace.Partoftheengagementfactoristhesenseofurgency.

PaperSelection&GradeAnnouncement[3minutes]

Iftimeallows,randomlyselecttheworksheetandannouncetheclassgradewithabitoffanfare,congratulatingtheclassonajobwelldone.Ifthereareanyincorrectanswers,usethetimeattheendofclasstoreviewthecorrectsolutionsortakequestions.

AccommodationandDifferentiationTooptimizethisexercise,youmightconsiderrearrangingstudents(orcreatingapassing-path)thatmixesstudentsofdifferentcodingabilities.Theadvancedstudentscanusetheextratimetocorrectmistakesmadebyothers;iftheyaresittinginproximitytothestudentthatmadetheerror,theywillhaveabetterchanceofexplainingthecorrectanswertothem.

Duetothebriskpaceoftheround-robinrotation,thereshouldn’tbetoomuchdowntimeforanyonestudent.Ifyourstudentsarefinishingfasterthanthetimeintervalsindicated,reducetheamountoftimeallottedtomaintainasenseofurgency/keepstudentsontask.Iffinishedearly,offeraProgrammingChallengewhileyougradethesampleworksheet.

Lesson4.06:NestedLoopAlgorithms&RectangularArrays

302

Page 303: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

CommonMistakesTwodimensionalarrayscommonmistakes:http://interactivepython.org/runestone/static/JavaReview/Array2dBasics/a2dMistakes.html

VideosBJP7-3-2,TallyingwithanArrayhttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c7-3-2

ForumdiscussionLesson4.06NestedLoopAlgorithms&RectangularArrays(TEALSDiscourseaccountrequired)

Lesson4.06:NestedLoopAlgorithms&RectangularArrays

303

Page 304: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson4.07—ArrayList

Overview

Objectives—Studentswillbeableto…

ConstructcodeusingArrayList.Predicttheoutputofmethodsthattakearraysasparametersand/orreturnarrays.

Assessments—Studentswill…

Evaluatestatementsandpredictoutputduringagameofgrudgeball

Homework—Studentswill…

OutlineChapter7andBJP10.1“ArrayList”Completeself-checkquestions#3-6andexercise#3

Materials&PrepProjectorandcomputer(optional)WhitepaperandmarkersClassroomcopiesofPoster4.7Rulesforgrudgeball(seewebsitefordetails:http://toengagethemall.blogspot.com/2013/02/grudgeball-review-game-where-kids-attack.html)Teamassignmentsthatdivideyourclassinto5or6teamsNerfhoop&ball(orwastepaperandtrashcan)Taped2-and3-pointlines

BrieflyreviewtherulesofGrudgeballifyouhaveforgottenthem.Ifyouhaveremovedyour2and3pointlinesfromlasttimeyouplayed,testoutyour2and3pointlinesbeforeclassbegins.

PacingGuide

Lesson4.07:ArrayList

304

Page 305: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Introductionandnote-taking 15min

Grudgeball 35min

ProcedureTohookyourclassfortoday’smaterial,andifspaceandwhiteboardsetupallow,setupthegrudgeball“court”andscoreboardbeforeclassbegins.Remindstudentsthatlecturecontentwillbetestedduringthegame.

Bell-workandAttendance[5minutes]

Introductionandnote-taking[10minutes]

1. Askstudentstonamesomelimitationsofarrays:shiftingvaluesisanordeal,addingelementsrequiresforminganew,largerarrayandcopyingvaluesover,deletingelementsleavesempty,unusedindexes.

2. IntroducethemoreflexibleArrayList(besuretoremindstudentsthattheyneedtoimportjava.util.ArrayList):

Usesarraystostorevalues(fastrandomaccess)

TheArrayListclasscontainsmethodstomakeadd,remove,andshiftvalueseasily.

ArrayListtakesatypeparametertodeterminewhatkindofvaluesitwilluseaselements:

ArrayList<String>storesalistofStrings.ArrayList<Point>storesalistofPoints.

Ifyouforgettopassaparameterwiththetypeyouwantthearraytocontain,thecodewon’texecute.

3. ConstructanArrayListofStringstodemonstratesyntax:

ArrayList<String>spongebob=newArrayList<String>();

Eventhoughthenotationlooksabitdifferent,thesyntaxisfairlysimilartowhatwe’veusedinthepast.ArrayList<type>ishowweindicatethetype—justlikeyou’duseintwhendeclaringaonedimensionalortwodimensionalarray.

ArrayList<String>spongebob=newArrayList<String>();

Lesson4.07:ArrayList

305

Page 306: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ThisisthenameofyourArrayList.Itcanbeanynon-keywordthatyouwanttouse.

ArrayList<String>spongebob=newArrayList<String>();

Askstudentsiftheycantellyouwhatthenewkeywordisfor(weusethenewkeywordwhenconstructinganobject).

ArrayList<String>spongebob=newArrayList<String>();

Wheneveryouseeemptyparentheses,itmeansthatyou’renotusingparameters.

4. UsingPoster4.7,reviewsomeofthemethodsyoucanusetomanipulateArrayLists.AddsomespongebobelementstoyourArrayList:

spongebob.add("PatrickStar");

spongebob.add("SquidwardTentacles");

spongebob.add("Mr.Krabs");

spongebob.add("Pikachu");

spongebob.add("SandyCheeks");

AskstudentsforsuggestionsonhowtoprintoutthisArrayList,andaskthemtopredicttheoutput:

System.out.println("SomeofthecharactersonSpongebobare"+spongebob);

StudentswillprobablynoticethatPikachuisnotacharacterintheSpongebobcartoon;askthemtorefertoPoster4.7tosuggestsomecodetoremovePikachufromthelist:

spongebob.remove(3);//Pikachuisstoredatindex3

Nowaskstudentstoaddanothercharacterfromtheshowtothemiddleofthelist,atindex3:

spongebob.add(3,"Plankton");

Thefirstparameter3indicatesthetargetlocation,andthesecondparameter"Plankton"indicatestheStringtobestoredthere.

["PatrickStar","SquidwardTentacles","Mr.Krabs","SandyCheeks"]

becomes

Lesson4.07:ArrayList

306

Page 307: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

["PatrickStar","SquidwardTentacles","Mr.Krabs","Plankton"]

5. BrieflyreviewafewotherusefulArrayListmethods.Studentswillhaveanopportunitytopractice(andyouwillhaveanopportunitytoreteachifneeded)duringGrudgeball,sothiscanbeaquickoverview:

ARRAYLISTMETHODSOVERVIEW

TogetanelementfromtheArrayListandprintit

System.out.println(spongebob.get(3));

TogetthenumberofelementsintheArrayListandprintit

System.out.println(spongebob.size());

ToaddalltheelementsintheArrayList

intsum=0;

for(int=0;i<spongebob.size();i++){

Strings=spongebob.get(i);

sum+=s.length();

}

System.out.println("Totaloflengths="+sum);

Havestudentsjustifyyourcodechoices,andaskastudent(orstudents)totracethecodeandnarratethestepsfortheclass.

Toreplaceanarrayelement(noshifting)

spongebob.set(3,"Plankton");

ThiswouldreplacePikachuwithPlanktondirectly,withoutrequiringtheshiftingofthearray.

Toclearanarray

spongebob.clear();

Lesson4.07:ArrayList

307

Page 308: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Thisremovesallelementsfromthelistandleavesnullvaluesateachindex(it’sanemptyarraynow).

Grudgeball[35minutes]

1. Dividestudentsintotheirassignedteams.

2. Reviewtherulesforgrudgeball,andhavethestudentsrepeattherulesbacktoyou.

3. Usingtheproblemslistedbelow(andanyyoumayadd,dependingonyourclass’needs),playgrudgeballuntilateamwins,oruntiltheclassperiodends.

a.Ifaclassgetstheanswerwrong,BRIEFLYpausethegametohavestudentsoffercorrectionsbeforemovingtothenextteam’squestion.

b.Ifcorrectionseemstobedraggingon,jumpinandquicklyre-teachusingtheincorrectanswerasyourexample.Itisimportanttokeepthepacegoingtomaintainstudentinterestinthegame!

Gudgeballproblems&answershavebeengroupedassumingthatyouhave6teams.Ifyouhavefewerteams,each“round”willbeshiftedaccordingly,soyoumayhaveroundswheredifferentteamsarepracticingdifferentconcepts.Judgeeachteam’sknowledgegaps,andadjustwhichquestionsyouaskeachgroupaccordingly.

GRUDGEBALLPROBLEMSANDANSWERS

UseatypeparametertodeclareanArrayListthat:

a.StoresalistofStrings→ArrayList<String>b.Storesalistofintegers→ArrayList<Integer>(Wrapperclass)c.StoresalistofPoints→ArrayList<Point>d.Storesalistofdoubles→ArrayList<Double>(Wrapperclass)e.Storesalistofsoccerteams→ArrayList<String>f.Storesalistoftemperatures→ArrayList<Double>(Wrapperclass)

ConstructanArrayList:

g.Calledzthatstoresalistofints→ArrayList<int>z=newArrayList<Integer>();

h.CalledlistthatstoresalistofStrings→ArrayList<String>list=newArrayList<String>();

i.CalledjosethatstoresalistofPoints→ArrayList<Point>jose=newArrayList<Point>();

Lesson4.07:ArrayList

308

Page 309: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

j.CalledpokemonthatstoresalistofPokémon→ArrayList<String>pokemon=newArrayList<String>();

k.CalledmetroCardthatstoresthenumberofmetrocardrideseachstudenthasleftontheircardtoday→ArrayList<Integer>metroCard=newArrayList<Integer>();

AccommodationandDifferentiationInELLclassrooms,readthequestionsaloudinadditiontoshowingthequestionontheboardorprojector.Considerdistributingaworksheetwiththequestionsonitsostudentscanwritedownanswersduringthegame.

CommonMistakesArraysListcommonmistakes:http://interactivepython.org/runestone/static/JavaReview/ListBasics/listMistakes.html

MisconceptionsJavauses3differentsyntaxforgettinglengthswhichisasourceofstudentconfusion:

String.length()

array.length

ArrayList.size()

VideosBJP10–1,RemovingfromanArrayLiasthttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c10-1

BJP10–2,AddingtoanArrayListofIntegershttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c10-2

CSE142,ArrayList(6:40–25:29)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=efa0eeba-81bc-497c-a1ae-46cda247c563&start=400

Lesson4.07:ArrayList

309

Page 310: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

CSE142,WrapperClass(41:53–44:54)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=efa0eeba-81bc-497c-a1ae-46cda247c563&start=2510

ForumdiscussionLesson4.07ArrayList(TEALSDiscourseaccountrequired)

Lesson4.07:ArrayList

310

Page 311: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson4.08—Finding&FixingErrors

Overview

Objectives—Studentswillbeableto…

Finderrorsintheirreturnedhomeworkassignments.Correcttheircode

Assessments—Studentswill…

Re-submitallhomeworkassignmentswithcorrectedanswers.

Homework—Studentswill…

ReviewmaterialsfortheMagpielabby:ReviewingallthebluepagesattheendofChapter7andChapter10(onlythematerialforsection10.1ofChapter10)

Submit5questionsforreviewinclasstomorrowusingelectronicsurveyUpdateallsummariesinnotebookfortheupcomingnotebookcheck

Materials&PrepAnystudenthomeworkassignmentsthatyouhavenotyetreturnedStudentself-helpsystem(suchasC2B4orstudentpairing)Electronicsurveyforstudentreviewrequests

Thehomeworktonightasksstudentstosubmit5questionsforreview.Createanelectronicsurveyforstudentstocompletewith6textfields,oneforname,and5forquestionstheyhaveaboutCh.7andCh.10.1content.Setadeadlinebywhichtimestudentsmusthavesubmitted5questionsfromthechaptersthattheywouldliketoseereviewedaftercompletionoftheMagpielab.Ifstudentsdonothavequestions,stipulatethattheystillhavetosubmitsomethingtoreceivecredit,evenifitisonlyquestionstheythinkotherstudentsmayhave.

YoushouldscorehomeworkfromLP4.7whilestudentsareworkingsoyoucanturnbackthoseassignmentsduringthisclassperiod.

Lesson4.08:Finding&FixingErrors

311

Page 312: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Introductionandhomeworkdistribution 5min

Studentwork 35min

Studentstradework,check,andsubmit 10min

ProcedureTodaywecontinuereinforcingconceptsandapplyingthetools,procedures,andcodethatwereintroducedlastweek.Studentswillhavetheopportunitytocorrectanyincorrecthomeworkorclassworkassignments.Ifstudentsdidnothavetimetofinishthehomeworkfromyesterday,youmayallowthemtimetoworkonthattoday.

Bell-workandAttendance[5minutes]

IntroductionandHomeworkDistribution[5minutes]

1. Returnstudenthomeworkpackets,orhavestudentsplacetheirreturnedhomeworkinapileontheirdesk.

2. Explaintostudentsthattheyhavetheopportunitytogetfullcreditontheirhomeworkgradesbycorrectingthemnow,inclass.Askstudentsforsuggestions/ideasonhowtomakesuretheydon’tmissanyerrors.

a.Bynowstudentsshouldbeusedtorelyingontheirerrorchecklist/algorithm.

StudentWork[35minutes]

Havestudentsworkindividuallytocorrecttheirhomeworkgrades.

Offertimechecksforstudentssotheystayontask.

Ifstudentshavenotfinishedhomeworkassignments,allowthemtimetodaytocompletetheseassignmentstoturninforpartialcredit.

Studentstradework,check,andturnin[10minutes]

Lesson4.08:Finding&FixingErrors

312

Page 313: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Attheendofclass,havestudentstradetheirhomeworkassignmentstoevaluateeachother’scorrectionsbeforesubmission.

AccommodationandDifferentiationInELLclassrooms,pairstudentsandallowthemtoworktogethertocorrecttheirwork.

Forthosestudentswhohavenothingtocorrect(orfinishveryearly),rewardthemwithsilentfreetime,orallowthemtoworkonafree-choiceprogrammingproject.

ForumdiscussionLesson4.08Finding&FixingErrors(TEALSDiscourseaccountrequired)

Lesson4.08:Finding&FixingErrors

313

Page 314: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson4.09—MagpieLab

Overview

Objectives—Studentswillbeableto…

Completealong-formlab,usingifstatements,algorithms,theStingclass,arrays,andArrayLists.

Assessments—Studentswill…

CompleteCollegeBoard’sAPCSAMagpieChatbotLabAnswerassessmentquestionsonthefourthclassexam

Homework—Studentswill…

CompletehomeworkassignmentsasoutlinedinthePacingGuidebelow

Materials&PrepProjectorandcomputerMagpieChatbotLabTeacher’sGuideClassroomcopiesoftheMagpieChatbotLabStudentGuideAssociatedMagpieChatbotFiles

ReadthroughtheTeacherandStudentguidesaheadoftimetofamiliarizeyourselfwiththepartsofthislong-formlab.Usingtheguides,completethelabonyourowntospotpossiblechallengesforyourstudents.Uploadallstudentfilesontoeachcomputerdesktopforstudentaccess.

PacingGuide:Day1

Lesson4.09:MagpieLab(5Days)

314

Page 315: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

StudentActivity1&2 Fullclass-students

Notebookchecks Fullclass-teacher

Homework:ReadCh.6intheBarronReviewBook TONIGHT

PacingGuide:Day2

Section TotalTime

StudentActivity2,continued Fullclass-students

Notebookchecks Fullclass-teacher

Homework:Completepracticequestions#1-18inBarron TONIGHT

PacingGuide:Day3

Section TotalTime

StudentActivity3 Fullclass-students

Notebookchecks(ifnotcompleted) Fullclass-teacher

Homework:Completepracticequestions#19-37inBarron TONIGHT

PacingGuide:Day4

Section TotalTime

StudentActivity4 Fullclass-students

Notebookchecks(ifnotcompleted) Fullclass-teacher

Homework:CheckandcorrectanswersinBarron TONIGHT

PacingGuide:Day5

Lesson4.09:MagpieLab(5Days)

315

Page 316: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

StudentActivity5 Fullclass-students

Checkforstudentreviewquestions Fullclass-teacher

Homework:CheckBarronReviewBookforhighlighting,notetaking,andpracticetestcompletion/correction

TONIGHT

ProcedureAllguides,samplecode,answercode,andexamplecodemaybefoundinthefolder“Milestone1—MagpieChatbotLab.”AssessmentquestionsincludedontheTeacher’sguidehavebeenmovedtotheUnit4exam.

AboutBarron’s

Barron’sisanAPCSAreviewbookthatsomeschoolsprovidestudents.Ifyourschooldoesn’tprovideBarron’stherearemanyalternativehomeworkassignmentsthatcanbefoundatcodingbat.com/javaorpractice-it.

Alternatively,youcansavetimespentonthelabbycheckingactivitiesashomework.

GeneralProjectNotes

Tohelpstudentsstartthelabsmoothly,startActivity2asawholegroup.OpenEclipseandguidestudentsthroughopeningtheMagpieandMagpieRunnerfiles.

EncouragestudentstousetheirTrickyCodeCheatSheets,4CommandmentsofScope,notebooks,textbooks,classroomposters,andhomeworkassignments.

Offeroccasionaltime-checkstohelpkeepstudentsonpace.

Gradenotebooksandreviewbooksinbetweenhelpingstudentssostudentscankeepnotebooksforhomeworkandstudyingintheevenings.

AccommodationandDifferentiationInELLclassrooms,readalldirectionsaloudbeforebreakingintoindividualpractice,andallowuptotwicetheamountoftimeforcompletionofthelab.Asneeded,allowstudentstopairuptohelpeachotherwithreadingcomprehension(butremindstudentsthattheyeach

Lesson4.09:MagpieLab(5Days)

316

Page 317: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

mustsubmittheirowncode).Eachdaythatyoubeginthelab,startwithaquicksurveyofstudentconcernsandquestions.

Differentiationofthelabassignmentcanbefoundonpage14oftheTeacher’sguide.

ForumdiscussionLesson4.09MagpieLab(TEALSDiscourseaccountrequired)

Lesson4.09:MagpieLab(5Days)

317

Page 318: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson4.10—Review

Overview

Objectives—Studentswillbeableto…

IdentifyweaknessesintheirUnit4knowledge.

Assessments—Studentswill…

Createapersonalizedlistofreviewtopicstoguidetonight’sstudysession.

Homework—Studentswill…

Studyfortomorrow’stestusingtargetedreviewlist

Materials&PrepProjectorandcomputerWhiteboardandmarkerResultsfromelectronicsurveyofreviewtopicsClassroomcopiesofthepracticetestWS4.10

Oncestudentshavesubmittedtheirreviewrequests,assemblethosetopicsintocategoriesandpreparetore-teachthetopicsasneeded.Ifyouarecrunchedfortime,holdthereviewsessionduringthesecondhalfofDay5oftheMagpieChatbotLab.

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Reviewofstudentquestions 30min

Sampletestreview 15min

Checkstudentstudylists 5min

Lesson4.10:Review

318

Page 319: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Procedure

Bell-workandAttendance[5minutes]

ReviewofStudentQuestions[30minutes]

1. Clearlyindicatethatyouexpectallstudentstohavealistofreviewtopicstostudythisevening.Periodicallyremindstudentsthatthislistwillbecheckedattheendofclass.

2. Beginwithareviewofstudent-submittedquestionsbeforereviewingthepracticequestions.

SampleTestReview[15minutes]

1. BeginreviewwithpracticetestWS4.10.HavestudentsworkthroughsectionIquestions,thenreviewtheanswersasaclass.

2. GivestudentstimetocompletesectionIIquestions,thenreviewtheanswersasaclass.

3. Finally,workthroughthevariousreviewtopics,prioritizingquestionsthatpoppedupthemost.

Somequestionsyoumayaddresswhileworkingthroughthesampletest.

Bereadyforadditionalquestionstopopupasyougo.Saveyourselftheworkanduseoldhomeworkquestionsandstudent-generatedtestquestionsasexamplestoworkthrough.

4. Useacombinationofgroup-solvingquestionsonthewhiteboard,think-pair-share,andtimed-responseasreviewstrategies.

5. Afteryou’vecompletedreviewinganidea,remindtheclassthattheyshouldwritedownthattopiciftheyfeeltheystillhavetoreviewittonight.

CheckStudentStudyLists[5minutes]

Spendthelast5minutesofclasscheckingeachstudent’sreviewtopiclist.

ForumdiscussionLesson4.10Unit4Review(TEALSDiscourseaccountrequired)

Lesson4.10:Review

319

Page 320: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson4.10:Review

320

Page 321: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson5.00—TestReview&Reteach

Overview

Objectives—Studentswillbeableto…

Re-learnorstrengthencontentknowledgeandskillsfromUnit4.

Assessments—Studentswill…

Re-submittestanswerswithupdatedcorrectionsforpartialorfullcreditCreditdependsoninstructorpreference

Homework—Studentswill…

ReadBJP8.1Correctanyincorrecttestanswersbyre-answeringonaseparatesheetofpaper

Togetbackcredit,theymustjustifytheirnewanswersStaplenewanswersheettooldtestandturnintomorrow

Materials&PrepProjectorandcomputerWhiteboardandmarkersCorrectedstudenttestsStudentgrades(postedonline,emailedtostudents,orhandedbackonpaperinclass)Digitalcopyoftestquestionsforprojector

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Classdiscussion(ifneeded) 10min

Testreviewandreteach 35min

Checkstudentnotesandreturntests 5min

Lesson5.00:TestReview&Reteach

321

Page 322: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ProcedureReturnstudentgradesbeforeclassbeginsorwhilestudentsarecompletingthebellwork.

Donotreturnstudents’testsbeforethereviewsession,sinceyouwanttomotivatestudentstopayattentiontotheentirereview,takingsupplementalnotestheentiretime.

Bell-workandAttendance[5minutes]

ClassDiscussion(ifneeded)[10minutes]

1. Ifgradesarelow,invitetheclasstoadiscussionofwhatcanbeimproved.Beginwithstudentcomplaintsandsuggestionstobuildstudentbuy-in.Askstudents:

howtheyfelttheyweregoingtodobeforethetestwhatsurprisedthemoncetheyweretakingthetestwhattheyfeltworkedinthefirstunit(lessons,reviewstrategies,assignments)whatdotheythinktheywanttochangeforthesecondunit

2. Onceyoufeelthatadialoguehasbeenestablished,validatestudents’feelings,thenchallengethem(e.g.APcoursesarestressful,butthisisgoodpracticeforcollege,wherethepaceisfasterandprofessorsdon’tgivepersonalizedinstruction).

TestReviewandReteach[30minutes]

1. Walkthestudentsthrougheachquestiononthetest,glossingoverquestionsthateveryoneansweredcorrectly.

a.Youcanaskforstudentstovolunteeranswers,orcallonstudentsrandomly.Makesurethatstudentsexplaintheirlogicwhentheyanswer.Ifastudentgivesanincorrectanswer,theexplanationwilltellyouwhatyouneedtore-teachorclarify.

b.Donotskipquestionsthateveryoneansweredcorrectly,butdonotspendmorethanthetimeittakestoreadthequestion,andcongratulatestudents’correctanswers.

2. Projectacopyofeachquestionasyoureview—thiswillhelpstudentsrecallthequestion/processtheinformation.

3. Makesurethatstudentsaretakingnotesduringthere-teach,remindingstudentsthatforhomework,theywillhaveanopportunitytowinbacksomeofthepointsontheirexam.

4. ForSectionIIquestions,selectasampleofstudentwork(withanyidentifyinginformationobscured),andworkthroughtheanswertogetherasaclass.

Lesson5.00:TestReview&Reteach

322

Page 323: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Checkstudentnotesandreturntests[5minutes]

Attheendofclass,checkstudentnotes,andreturnthetestsinhardcopyformifapplicable.

AccommodationandDifferentiationEncourageadvancedstudentstotakeonadditionalprogrammingchallenges.OneeasywaytodothisistoassignProgrammingProjectsfromthebluepagesattheendofeachChapter.

Ifyouhaveafewstudentsthatarestrugglingwiththeclass,choosethesestudentstocreateyourclassroompostersafterschoolorforextracredit.

ForumdiscussionLesson5.00TestReview&Reteach(TEALSDiscourseaccountrequired)

Lesson5.00:TestReview&Reteach

323

Page 324: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson5.01—ObjectOrientedProgramming

Overview

Objectives—Studentswillbeableto…

Describetherelationshipbetweenclasses,objects,andclientcode.Predicttheoutputofthecodethatusesobjects.

Assessments—Studentswill…

CompletePractice-Itquestions

Homework—Studentswill…

ReadBJP8.2upto“MutatorsandAccessors”

Materials&PrepProjectorandcomputerWhiteboardandmarkersClassroomcopiesofWS5.1.1Classroomcopiesofthetextbook(orjustsection8.1)Bookmarksonstudentcomputers(oremailedlinks)toBulbapedia

IfyoudecidetoemailorlinktothePokemonwikipage,thecompleteaddressis:http://bulbapedia.bulbagarden.net/wiki/Main_Page.Studentscanalsoeasilysearchforthepagebytypingin“bulbapedia”or“pokemonwiki.”

PacingGuide

Lesson5.01:ObjectOrientedProgramming

324

Page 325: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Introduction:Discussion 10–30min

Introduction:SyntaxNotes 10–20min

Activity1:Practice-It 15min

Activity2:Researchingforacustomclass 15min

ReadthroughalloftheInstructor’snotesbeforeyouplanthislesson.Insomeclassrooms,itmightbebestifyouextendthisintoatwo-daylesson.Itisworthittospendplentyoftimediscussingconceptsofdesignanddebatingchoicestodrivehometheideathatobjectandclassconstructionarecompletelycustomizable.Ifyouareexpandingthislessonplantoatwo-daylesson,usegraphicorganizerWS5.1tohelpstudentsorganizetheirthoughtsfromtheclassdiscussionduringDay1.AsuggestedstoppingpointforDay1syntax/notesisindicatedbyadottedline.

OnDay2,startwiththesyntaxnotesbelowthedottedline,theninvitestudentstocompleteActivity1and2.

ProcedureIfyouhavetheoptiontorearrangeseating,setupstudentseatsinacircleforclassdiscussion.Asstudentsfilterin,startsmalldiscussionswiththefollowingtalkingpoints:Towritepersonalizedprogramsthathandlereal-lifedata,they’llneedtoknowhowtodesignandcreatetheirownmodelsofreal-lifeevents,phenomena,orprocesses.Ratherthanlearningnewstructuralcode,they’regoingtostartfocusingonmakingdesigndecisions.

Upuntilnowwehaveusedpre-madeobjectsandclassesthataregiventousbyimportingjavaclasses(bonuspointsifstudentscannamesomeexamples).Movingforward,they’llbeusingcustomizedclassesthatthey’vebuiltthemselves.

Bell-workandAttendance[5minutes]

Introduction:Discussion[10-30minutes]

1. Givestudentspermissiontoputdowntheirpencilstoparticipateinadiscussion(youcanreviewimportantdefinitionsaspartofarecapbeforeclasspractice).It’simportanttogetstudentsusedtocritiquinganddebatingdesigndecisionsbeforegettingintothenuts-and-boltsofobjects.

Lesson5.01:ObjectOrientedProgramming

325

Page 326: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Whatdowemeanby“modelsofreal-lifeevents,phenomena,orprocesses?”Inprogramming,objectsaremodelsofsomethingelse:

Theobjectforecastisamodelofafutureweatherevent.Theobjectstudent1isamodelofanactualstudentthatgoestothisschool.TheobjectmyDogisamodelofyourpetdog.

Whatdowemeanbymaking“designdecisions?”Tomodelaforecast,student,ordog,youneedtomakecertaindecisionsaboutwhatdataandactionsareimportanttoyourmodel.Askstudentstooffersomedesigndecisionsforaforecastobject:

i. Whattypesofdataareimportantforalocalforecast?

ii. WhatsortsofdatamightbeimportantforastudentwritingtheforecastobjectinAlaska?Arizona?Oklahoma?

iii. Whatbehavior(methods)mightwewantourforecastobjecttohave?

Discussionpointstobringup/guidestudentsto:

Ifyou’reinterestedinforecastingatornado,youmightchoosetomodeltheweatherwithfinergranularitythanyoumightoptforifpredictingrainfallorcloudcover.

Differentmodelcomponentswillbeappropriateindifferentsituations.

DoesaforecastwrittenbyastudentinArizonaneedthesameinputsandmethodsasaforecastinOklahoma?Whatmightbedifferent?Thesame?

2. Workthroughanotherdesigndiscussionaboutthestudent1ormyDogobject.Howmightyoudesignthestudent1objectinamusicschool?Amartialartsschool?Ahighschoolorcollege?Whatbehaviors(methods)anddata(states)mighttheyhaveincommon?Whichwouldbedifferent?(Boththemusicschoolandmartialartsschoolmightincludefieldsforbillinginformation,butonlythemartialartsschoolwouldhavefieldswithemergencymedicalinformation.)

Ifstudentsaresuggestingoverly-complexmodelsofstudent1ormyDog,useitasanopportunitytodiscusscomplexity.Isitalwaysagoodideatoaddstatesandbehaviors(dataandmethods)?Whenisitappropriatetomakeamodelmorecomplex?Whendoyouwanttokeepitsimple?

Theruleofthumbistoonlyincludethecomplexityyouneed.Ifthislanguageworksforyourclass,tellthemtoalwaysdesignaroundprinciplesofcompleteness,robustness,andsimplicity.

Completeness:DoesthismodeldoeverythingIneedittodo?DoesitcontainallthedataIneedittocontain?

Lesson5.01:ObjectOrientedProgramming

326

Page 327: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Robustness:IsthismodelsufficientlyflexibleforeverythingIneedittodo?CanIuseitindifferentcontexts(thisisn’timportantinthisunit,butwillbecomeimportantlater.)

Simplicity:Canmymodelbesimpler?Extracomplexitycanleadtocodingmistakesorerrorsdowntheroad.Iwantmycodetobeeasyforotherprogrammerstoread/interpret.

Introduction:SyntaxNotes[10-20minutes]

1. DistributegraphicorganizersWS5.1tothestudentsthatneedextrastructurefortheirnotes.Startbyshowingstudentsthedifferencebetweenaprogramthatisasetofactions(commands),andaprogramthatcontainsdataandbehavior(dataandmethods).

Thisobjectdigitsisa(verysimple,andsomewhatboring)modelofacollectionofintegers.Thismodelcontainsstate(data)andactions(methods):

int[]digits={1,2,3,4,5,6,7,8,9,10};//Thedataisstoredinthe

array.

System.out.println(Arrays.toString(digits));//Themethoddictatesactions

//tobedonewiththedata.

Dependingonyourclass’cultureandlevelofunderstanding,youmightconsiderabriefside-discussiononotherwayswecouldgettheprogramtoprintoutthearray.Askforstudentstovolunteersomeothercode,andaskstudentstoargue/debatewhetheritiseasiertowritethecodefromscratchoraskthearraytoformatitself(asabove).

2. AnobjectisacombinationofdataANDmethods.Thebookreferstotheseasstate(content,ordata)andbehavior(methods,orwhatistobedonewiththedata).

Thebehaviorcanmodifyorreportthedatacontainedbytheobject.

Thebookreferstothedataasthe“state”oftheobject

Askstudentstodescribehowweusetheword“state”indailylife,andaskthemtocomparetohowyouuse“state”incomputerscience.

Askstudentstoexplainhowtheword“behavior”appliestoanobject.

Bycontrast,thisisaprogramthatisnotanobject/model:

Lesson5.01:ObjectOrientedProgramming

327

Page 328: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

while(guess!=number){

System.out.println("Incorrect.");

System.out.println("Yourguess?");

guess=console.nextInt();

numGuesses++;

}

Askstudentswhythisisn’tanobject/modelofsomething.(Thisprogramonlycontainsactions,nobehavior.)

3. Thecodethatusestheobjectsiscalledclientcode.You’dnevercreateamodelofsomething(createanobject)ifyouweren’tgoingtouseitwithotherprograms(clientcode).

Topullfromourearlierexample,whatsortofprogram/clientcodemightmakeuseofstudent1?(Anattendanceprogram,agraderecordsprogram)

Whatprogram(clientcode)mightneedtoaccessthedataandmethods(stateandbehavior)storedinthemyDogobject?(Aveterinarian’sdigitalmedicalcharts,adogshow’sregistrationprogram)

4. Usingwhicheverexampleismostengagingtoyourstudents,havethemwrite3objectswithpropersyntaxasaThink-Pair-Share.Beforeyoulisttheobjects,haveabriefdesignconversationasawholegroup,sostudentscandecidewhatdataandmethodsshouldbeincludedineachobject.Somesuggestedobjects:

myDog,teachersDog,sistersDogstudent1,student2,student3forecastNY,forecastAZ,forecastOK

Askstudentsiftheywrotethesamecodeoverandoveragain,howlongittookthem,iftheycanthinkofanotherwaytomakethetaskeasier(someofthemmighthavereadaboutclassesthenightbefore).

5. Aclassisablueprint(oroutline)thattellsJavahowtomakeaparticularsetofobjects.WecouldsaveourselvesalotoftimebywritingaclassStudent,whichwillmakesurethateverystudentobjecthas<whateverfieldsyourstudentsdecidedstudentshouldhave>.

Eachobjectiscalledaninstanceofthatclass.

TheobjectmyDogisaninstanceoftheDogclass.SoistheobjectteachersDogandsistersDog.WhatisanotherinstanceoftheDogclass?(Anyindividualdogiscorrect—categoriesofdog,suchasseeingEyeDogarenotobjects,butprobablyclassesinahierarchy—moreonthatlater!)

AskstudentstogiveinstancesoftheStudentandForecastclasses.

Lesson5.01:ObjectOrientedProgramming

328

Page 329: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Finally,askforstudentstoprovideexamplesoftheirownclassesandinstances.Someexamples:

Class:ClassroomChairInstances:Student1’sSeat,Student2’sseat,etc.

Class:PensInstances:Mypen,yourpen,thepenonthedesk

Ifyouusetheseexamples,walkaroundtheclassroom,physicallytouchingorpickinguptheinstancesofeachclass.

Asyouworkthroughtheseexamples,becarefulnottogenerateanexamplethatillustratesasuperclasswithclasses.Thiswillbecomingupinthenextunit,soit’simportantnottoconfusestudents.

Ifastudentgivesanexamplethatisoverlygeneral,youcanredirectthemtowardsamorespecificexample:

IncorrectStudentExample:Class=Car,Instances=Jetta,Prius,ModelTCorrection:Class=Car,Instances=myCar,yourCar,thatCarOverThere

Aclasscontainsseveralkeycomponents:

Fields—whichoutlinewhatdata(state)theobjectwillhold

Methods—whichdeterminethebehaviorofeachobject

Constructors—codethatinitializeseachobjectasitsbeingconstructedwiththenewkeyword

Aclassusesencapsulationtoprotecttheobject’sdatafromoutsideaccess(bytheclientcode).Youdothisbymakingeachfieldprivate.

Ifyouneedadditionalexamples,workthroughthebookexampleofthePointClass,drivinghometheideathataclasscancontainwhatevertheywant/need.Ifyourstudentsareeasilygraspingtheseconcepts,havethestudentshelpyoucreateaboutique/bespokeclassPokémon.Theideahereistogivethemadesignproblemthattheycanworkthrough,makingchoicesaboutcontentandbehaviorthatresultinamodelofthePokémongame.

Activity1:Practice-It[15minutes]

1. Studentswillbeworkingingroupsformuchoftheweek,sohavethemworkindependentlytoday.Ifstudentsarereallyhavingaroughtime,workthroughthefirstPractice-Itquestiontogetherasawholegroup.

Lesson5.01:ObjectOrientedProgramming

329

Page 330: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

2. HavestudentsreadthroughthePointClassexamplebeforemovingontothePracticeItquestions.

3. HavestudentslogintoPracticeIttocompletethefollowingself-checkquestions:

a.whatIsOOPb.whatIsAnObjectc.StringObjectd.ReferenceMystery3e.CalculatorObject

4. Ifmore25%ormoreoftheclassisstruggling,returntowholegroupwiththestipulationthatstudentswhogetitmaycontinueworkingindependently.

Activity2:ResearchingForaCustomClass[5minutes]

1. AskstudentstotakeafewminutestoresearchthePokémongameinearnest.AnongoingdesignchallengewillbeforthemtoconstructamodelofthePokémongamethatresemblestheonetheyplayathome.Iftheyarealreadyfamiliarwiththegame,theyshouldvisitBulbapediatolearnhowsomeofthestatsarecalculated.Iftheyarenotfamiliarwiththegame,theyshouldwatchgameexamplesonYouTube,readtherulesandstepsonNintendo’swebsite,ornavigatethroughtheintropagesonBulbapedia.Thiscanbeextendedasahomeworkassignment.

Ifyourstudentshavetroublereading,directthemtothefollowingwebpagesinsteadofhavingthemsearchattheirowndiscretion:

i. http://www.pokemon.com/us/parents-guide/(Basicoverviewofthegame)

ii. https://youtu.be/DlEbXH8eUTk?t=1m26s(thisisa30minuteYouTubevideoofgameplay—studentsshouldeitherwatchitathomeoronlywatchthefirst5-10minutesinclass)

iii. http://www.pokemon.com/us/pokedex/(typesofPokemon)

iv. http://tinyurl.com/no4mzic(Pokemonwithstats)

v. http://en.wikipedia.org/wiki/Gameplay_of_Pokémon(Wikipediaentry)

2. Asstudentsresearch,havethemjotdownideasforwhattypeofdataandbehaviorstheywouldwanttoincludeinaPokémonclass.Whatdesignfeaturesdotheyfeelaremostimportanttotheirmodel?Encouragestudentstojustifytheiranswerstoeachother,you,andtheclassatlarge.

Lesson5.01:ObjectOrientedProgramming

330

Page 331: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

3. Ifstudentsshowinterest,letthemreadaheadinthetextbooktofigureoutexactlywhatfields,methods,andconstructorstheymightuseinthenextclass.Askstudentstoreflectontheircurrentmodelandthinkofwaystheycouldimprove/changeit.

AccommodationandDifferentiationIfyouhavestudentswhoarespeedingthroughthislesson,invitethemtocreateamindmapoftheconceptsintroducedtodayusingkeyvocabularywords.Ifthemindmapisthorough,givethestudentmaterialstoturnthemapintoalarge-formatposterfortheclassroom.

Forstudentsstrugglingwiththevocabulary,askthemtobringinphysicalobjectsthatcanallbeclassifiedasthesametype.(Perhapstheybringindrinkbottles,ortypesofsnacks,ordifferentwritingimplements.)Usingthoseobjects,youshouldhavethemcreateanin-classdisplaythatmodelstherelationshipbetweenclassesandinstancesoftheclass.Havestudentslabelthephysicalobjectswith:

ClassnameObjectInstanceof[nameofclass]Samplecodeorpseudocode(onindexcardsorpiecesofpaper)for:

FieldsConstructorsMethods

Ifstudentsneedadditionalanchoringforthe“object”concept,askthemiftheycanguesswhatobjectthey’veworkedwithbefore.(Stringobjects,Scannerobjects,etc.)Haveabriefdiscussionwhereyou:

AskstudentstoprovideexamplesofdatastoredinStringobjects(Dataincludesthecharactersandtheirlocations,informationaboutthelengthofthestring.)

Askstudenttoprovideexamplesofbehavior(methods)associatedwithStrings.(Methodsincludeanythingusedinthe.dotnotation,suchass.length().)

Ifyouneedadditionaldiscussion,askstudentstodiscussthebehaviorandstateofarrayobjects.

TeacherPriorCSKnowledgeUptothispoint,studentshavebeenconsumersofobjects.TheyhaveusedtheString,Scanner,andArrayListclasses.Aswemoveintoobjectorientedprogrammingconcepts,studentswillbeabletocreateclassesandobjects.Thisislikebeingabletoreadalanguage

Lesson5.01:ObjectOrientedProgramming

331

Page 332: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

tobeingabletowritealanguage.Bothrequiresomeknowledgeandskillinadditiontolotsofpractice.Theknowledgeandskillarerelatedforreadingandwriting,butnotnecessarilythesame.

MisconceptionsStudentsthinkclassisacollectionofobjects,ratherthanatemplateforcreatingobjects.

VideosBJP8-1,DefiningaClasshttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c8-1

CSE142,IntroObjectOrientedProgramming(11:26–19:53)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=2071ef1c-2912-4b41-8052-d327180ea215&start=686

CSE142,ClassvsObject(26:36–31:43)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=2071ef1c-2912-4b41-8052-d327180ea215&start=686

ForumdiscussionLesson5.01ObjectOrientedProgramming(TEALSDiscourseaccountrequired)

Lesson5.01:ObjectOrientedProgramming

332

Page 333: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson5.02—ObjectState&Behavior

Overview

Objectives—Studentswillbeableto…

Describeclasses,objects,andclientcode.Predicttheoutputofthecodethatusesobjects.

Assessments—Studentswill…

CompleteWS5.2individuallyorinpairs.

Homework—Studentswill…

ReadBJP8.3upto“TheKeywordthis”Completeself-checkquestions#9-11,13-16

Materials&PrepProjectorandcomputerWhiteboardandmarkersClassroomcopiesofWS5.2

YoushouldreadtheintroductionontheBulbepediawebsitesoyouunderstandthemainideasbehindthePokémongame.IfyousearchYouTube,youcanfindrecordedgamestoseehowaPokémonbattlestarts,progresses,andends.

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Introduction 15-30min

Studentpractice:WS5.2 25min

Studentstradework,check,andturnin 10min

Lesson5.02:ObjectState&Behavior

333

Page 334: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ProcedureYesterdayyouaskedstudentstodosomeresearchonwhatfields,constructors,andmethodswouldbeappropriateforbuildingacustom-madePokémonclass.Solicitstudents’inputbeforeyouworkthroughaPokémonclassexample.

AskstudentswhattheythinkaPokémonclassshouldinclude,andwhy.EncouragestudentstoarguefororagainstcertaindesignfeaturesinthePokémonclass.ShouldtheclassincludeallPokémonstats?Arethereanybehaviors(methods)youthinkallinstanceobjectsshouldhave?WhataresomeexamplesofinstancesofthePokémonclass?(AnyindividualPokémonisaninstanceofthePokémonclass,forexamplePikachu,Bulbasaur.)

Bell-workandAttendance[5minutes]

Introduction[15-30minutes]

1. Askstudentstoreviewtheirnotesfromthedaybefore,remindingyouwhatthemaincomponentsofaclassare.(Fields,methods,constructors,andencapsulation.)

Thesyntaxfordeclaringafieldisthesameasthesyntaxfordeclaringnormalvariables(typefollowedbysemicolon).Ifyourstudentsarefeelingconfident,inviteavolunteeruptodeclareafieldonthewhiteboardforyourPokémonclass.

RemindstudentsthatfieldssignifythatEVERYinstanceobjectoftheclassshouldhavethatvariableinsideit,soastheirexample,theyshoulddeclareatraitthateveryinstanceofPokémonwillhave.

Yourexampleshouldlooksomethinglikethis:

publicclassPokemon{

privateinthp;//Pokémonstatsincludehitpoints,or"HP"

privateintattack;

Studentswillprobablystartvolunteeringadditionalexamplesoncetheyrealizethatstatsmakeforgoodfields.Someotherfieldsinclude:

privateintdefense;

privateintspecialAttack;

privateintspecialDefense;

privateintspeed;

Lesson5.02:ObjectState&Behavior

334

Page 335: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Forthesakeofsimplicity,trytokeepstudentsto2or3fieldsfornow.Don’tjustarbitrarilydeclarethis;encouragestudentstothinkabouthowweuseclassesandobjectsasmodels.Askthemtocriticizeyourcurrentmodel.

Doesitneedtobecomplexyet?

Ifweoptforsimplicity,whatareweyieldinginsufficiency/robustness?

Ifstudentsagreetokeepitsimplefornow,remindthemthattheycanmakeadesignchoicetoincreasecomplexitylater.Mostprogrammersstartwithasimplermodelandbuildupastheyfleshouttheirprogram.

Ifstudentsneedadditionalexamplesforappropriatefields,leadstudentsthroughthefollowingexamples(havingthemaddasmuchofthecodeaspossible).Makesurethatstudentscanjustifytheirchoicesinfieldsandexplainwhytheywouldincludesomedataandnotothers.Ateveryopportunity,repeatthefactthattheyareusingdatatomodeltherealworld:

publicclassStudent{

privateStringname;

privateintgradeLevel;

privatedoublegpa;

publicclassDog{

privateStringbreed;

privatedoubleweightInKg;

publicclassForecast{

privatedoublewindSpeed;

privateStringwindDirection;

privatebooleantornadoWarning;

2. Remindstudentsthatinthepreviousclasstheylearnedthatobjectscombinebothstate(data)andbehavior(methods).Sofarwe’vecreatedfieldsinourclassesthatstatewhatdatawillbestoredinallinstanceobjects.

WhatwouldbeagoodmethodtoincludeinallinstancesoftheStudentclass?WhatwouldbeagoodmethodforallinstancesoftheDogclasstohave?Whatmethodshouldallforecastshave,nomatterwhatareayou’reforecastingfor?

3. Let’saddamethodinsidetheobjectthatwillreportinformationaboutthedatastoredinourPokémonobjects.Becausethismethodisbeingwrittenwithintheobject,werefertoitasaninstancemethod(itisnotinclientcode).

Pokémongetaneffortribboniftheircombinedstatsexceedacertainvalue.WhatwouldthemethodsumStatslooklike?

Lesson5.02:ObjectState&Behavior

335

Page 336: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

publicintsumStats(){

returnhp+attack+defense+specialAttack+specialDefense+speed;

}

SincethismethodgetsinformationaboutyourPokémoninstance,butdoesn’tchangeanyofthevalues,whatdoyoucallthistypeofmethod?(Accessor)

Isthisclientcode?(No,itispartofthePokémonclass,whichiswhywecallitaninstancemethod.)

4. Let’swriteanotherinstancemethodthatwillletuschangethestate(datavalues)storedinourPokémoninstanceobjects.Inthegame,whatcanyoudotocauseyourstatstochange?(Winbattles,consumevitamins)

Pokémoncanusevitaminstoboosttheirstats.Herearesomeexamplevitaminsforyoutouseattheboard:

hpUp:+pointstoHPprotein:+pointstoattackiron:+pointstodefensezinc:+pointstospecialDefense

Inkeepingwithourearlierexample,amethodtoupdatestatswithvitaminswouldlooksomethinglikethis:

publicvoidconsumeVitamin(inthpUp,intprotein){

hp+=hpUp;

attack+=protein;

}

Studentsmaywanttoaddothervitamins.

5. Askstudentsiftheycandeducethesyntaxrulesforinstancemethodsbasedonthetwomethodswe’vewrittensofar:

public<type><name>(<type<name>,<type><name>…){

<statement>

<statement>

}

6. SinceweknowthatallinstancesofourPokémonclasswillhaveinitialvaluestotheirstats,wecouldcreateaconstructortoinitializeallofourvalues.

Lesson5.02:ObjectState&Behavior

336

Page 337: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Itoftendoesn’tmakesensetohaveJavaautoinitializeourstatsto0,sowebuildourownconstructorthatrequiresustopassinitialparameters.

Havestudentspointouttoyoutheclass,fields,andconstructor:

publicclassPokemon{

privateinthp;

privateintattack;

publicPokemon(inthitpoints,inta){//Inacompleteversio

nyou

hp=hitpoints;//wouldincludeallst

ats.

attack=a;

}

}

7. Nowthatyouusedtheconstructor,it’sveryeasytocreateobjects!WhatwouldaninstanceoftheclassPokémonbe?(AnyPokémontype;Pikachu,Bulbasaur,Squirtle,etc.)

Pokemonpikachu=newPokemon(70,120);

Ifstudentsaregettingexcitedaboutthisexample,askthemtolookuptypesandtheirtypicalinitialvalues(IVs)forhitpointsandattack.LetthempracticeconstructingnewinstancesofthePokémonclass.

AskstudentshowyouwouldaddthePokémontype(electric,ground,rock,etc.)totheconstructor.

PointoutthatitisincorrecttoconstructaPokémonobjectwithoutpassinginitialhitPointsandattackparameters.Sinceyouwroteacustom-madeconstructorforyourclass,Javawon’tletyoucallnewPokémon()anymore.Instead,yourcodejustwon’tcompile.

StudentPractice:WS5.2[25minutes]

1. Remindstudentstousetheirtextbooks,notes,classroomresources,andonlineaidstohelpthemanswerthequestionsonWS5.2.

2. Encouragestudentstoworkindependentlyuntilthelast10minutesofclass.

Studentstradework,check,andturnin[10minutes]

Lesson5.02:ObjectState&Behavior

337

Page 338: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Havestudentstradeanderror-checkeachother’spapers.Error-checkingpartnersshouldwritetheirnameonthesheetstosharecreditforthework.

AccommodationandDifferentiationInclasseswherereadingcomprehensionisanissue,havestudentsworkinpairstoday.Ifyouhavealreadycreatedthesmallgroupassignmentsforthenextclass(seeLP5.3),youcanassignpairsthatwillbeinthesamegrouptomorrow.

Ifyouhavestudentswhoarespeedingthroughthislesson,invitethemtocreateadiagramshowingthedifferentpartsofaclassandinstanceobjectthatweintroducedtoday.Ifthediagramiscorrectandthorough,givethestudentmaterialstoturnthediagramintoalarge-formatposterfortheclassroom.

TeacherPriorCSKnowledgeInNoviceJavaProgrammers’ConceptionsofObjectandClass,andVariationTheorybyEckerdalandThuné,novicestudentsviewobjectsatthreelevels:

Objects:

ObjectisexperiencedasapieceofcodeAsabove,andinadditionobjectisexperiencedassomethingthatisactiveintheprogramAsabove,andinadditionobjectisexperiencedasamodelofsomerealworldphenomenon

Class:

Classisexperiencedasanentityintheprogram,contributingtothestructureofthecodeAsabove,andinadditionclassisexperiencedasadescriptionofpropertiesandbehavioroftheobjectAsabove,andinadditionclassisexperiencedasadescriptionofpropertiesandbehavioroftheobject,asamodelofsomerealworldphenomenon

Softwaredevelopersareadeptatseeingobjectsandclassesasmodelsforbothrealandabstractconstructs.

ForthepurposesoftheAPtest,allfieldsareprivate.Thisensuresgoodprogrammingpracticeforbeginningstudentsbecauseitforcestheuseofaccessorsmethods:accessorsandmutators.Thedefaultaccessforfieldswhennoaccessmodifieris

Lesson5.02:ObjectState&Behavior

338

Page 339: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

specifiedispackageprivate.Thismeansallclassesinthesamepackagewherethevariableisdefinedcanaccessthefield.

MisconceptionsStudentsaddstatictoclassmethoddefinitions.NowthatClasseshavebeenintroduced,staticmethodsthataretiedtotheclassareoftenconfusedwithnonstaticmethods.Studentscancallstaticmethodswithoutcreatinganobject,however,anobjectmustbecreatedfirstandthenon-staticmethodcanbecalled.

VideosBJP8-2:DefiningaClasshttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c8-2

CSE142,ObjectOrientedProgrammingState(19:54–26:25)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=2071ef1c-2912-4b41-8052-d327180ea215&start=686

CSE142,ObjectOrientedProgrammingBehavior(31:44–42:44)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=2071ef1c-2912-4b41-8052-d327180ea215&start=1905

CSE142,Objectmethods(45:32–49:41)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=2071ef1c-2912-4b41-8052-d327180ea215&start=2732

ForumdiscussionLesson5.02ObjectState&Behavior(TEALSDiscourseaccountrequired)

Lesson5.02:ObjectState&Behavior

339

Page 340: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson5.03—ObjectInitialization:Constructors

Overview

Objectives—Studentswillbeableto…

Describeandcreateclasses,objects,andclientcode.Predicttheoutputofthecodethatusesobjects.

Assessments—Studentswill…

CompletePractice-Itquestions

Homework—Studentswill…

ReadBJP8.4Takenotes,sinceyouwillhavetoteachamini-lessonlaterinthisunit

Materials&PrepProjectorandcomputer(ifyouareableto/opttouseEclipsewithyourstudents)WhiteboardandmarkersClassroomcopiesofWS5.3.1,WS5.3.2Studentsmall-groupassignments(3-4pergroup)2dialoguebubbles(indexcardsorstickynotes)foreachgroupRolloftape/gluestickforeachgroup1large,1medium,and2smallstickynotesforeachgroup1blanksheetofpaperforeachgroup

Mostteacherswilleitheralreadyhavethesematerialsonhand,orbeabletoborrowthemfromanotherteacherorthemainoffice.Youshouldtrytogiveyourclassroomteacheratleast1weeknoticetogetthesesuppliestogether.

Template5.3.1shouldbere-sizedtoledgerorlegalsizedpaper,ifitisavailableinyourschool.Ifyouhaveaccesstotheselargerpiecesofpaper,encouragestudentstowritetheircodelargelysostudentscaneasilyreadtheexampleswhentheyarepostedaroundthe

Lesson5.03:ObjectInitialization:Constructors

340

Page 341: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

room.

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Introduction 10min

Studentwork 30min

Studentviewing&exitticket 10min

ProcedureThislessonincludestwohooks:First,assemblethepacketsofmaterialsforeachgroupbeforeclass,andlaythesuppliesoutforstudentstosee/wonderabout.Secondly,introducetoday’slessonwithahipsterflair(ifyoucanpullitoff)byemphasizingtheartisanal,custom-made,hand-crafted,boutique(etc.)natureoftheclassesandobjectstheywillbecreatingtoday.Theskyisthelimit!Theycanchooseanyclassofobjectstheyareinterestedinfortheirgroupwork.

Ifyoufeeladditionalmotivationisneeded,youcanofferaprize(TEALSswag,etc.)tothemostcreative,complete,andcorrectcodesample.Offersomejust-in-timeinstruction,thenletthestudentsworktogetherwiththeguidanceofWS5.3.1

Bell-workandAttendance[5minutes]

Introduction[10minutes]

1. Weknowthatobjectsuseconstructors—youmightrememberthemfromearlierintheyearwhenweusedthenewkeywordnewtoconstructanewarray.

Startyourconstructorwiththekeywordpublic

Followwiththeclassnameandwhateverparametersyouthinkyoushouldinclude

Thisisadesignquestion—whichparametersdoyouthinkshouldbeauto-initialized?Whendoesitmakesensetoproscribeaninitialstate?

2. Workthroughtheexampleswe’vereviewedinpreviousclasses.WhatconstructorlooklikefortheStudentclass?TheDogclass?AForecastclass?

Lesson5.03:ObjectInitialization:Constructors

341

Page 342: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Givethefirstexample,butwitheachexamplehavestudentsofferincreasingamountsofthecodethemselves.

Askstudentsiftheycanthinkofsomesituationswheretheymightwanttoleaveoutsomeofthefieldsfromtheconstructor.

publicclassStudent{

publicStringname;

publicintgradeLevel;

publicdoublegpa;

publicStudent(Stringn,intgl,doubleg){//It'sagoodideatou

seasingle

name=n;//letterfromthefield

syouare

gradeLevel=gl;//initializinginthec

onstructor.

gpa=g;//Itkeepsthingssimpl

e!

}

publicclassDog{

publicStringbreed;

publicdoubleweightInKg;

publicDog(Stringb,doublew){//Studentsmayaskwhywehavetoc

reate

breed=b;//theseadditionalparameternames.

This

weightInKg=w;//plumbingmayfeelclumsy,butit'

sjust

}//astepwehavetoacceptinJava.

publicclassForecast{

publicdoublewindSpeed;

publicStringwindDirection;

publicbooleantornadoWarning;

publicForecast(doublews,Stringwd){//Maybeitdoesn'tmakesens

etohave

windSpeed=ws;//atornadowarninginthef

orecast.

windDirection=wd;//Thisisadesignchoice!

}

Lesson5.03:ObjectInitialization:Constructors

342

Page 343: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Becauseyouhavebuiltacustomclasswithobjectsthatyoudesigned,youcan’trelyonJavatoauto-initializeyourobjectstozerovalueslikeitdoesfortheArrayclass.Thearrayclasshasitsownconstructorthatsays“setallinitialvaluestozero-equivalents.”Youwillalwaysneedtowriteyourownconstructortoinitializeyournewobjects.

StudentWork[30minutes]

1. Ifyouhaveasample(thatyoudidyourself,orthatyousavedfrompreviousstudents’work),holditupasanexamplefortheclass,butdonotletstudentslooktooclosely.Theideahereisforstudentstoseethattherearedifferentsheetsofpaperandstepstotheproject;youdon’twantthemlookingatdetailsofthecode.

2. Beforeyoubreakstudentsintogroups,remindtheclassthattheyshouldreadthroughalloftheinstructionsfirstsotheygetagoodideaofwhattheir“boutique”classisrequiredtodo/contain.

a.Theyshouldspendatleast5minutesdiscussingtheirapproachtoprogramdesign,potentialstrengths,andweaknessesofthatdesign,thencometoconsensus.

b.Warnstudentsthatyouwillaskallgroupmemberstojustifytheirdesignchoices.(Followthroughwiththis,walkingaroundtheroomtospot-checkstudents!)

3. Askstudentswhattheyshoulddoiftheyhaveaquestionorgethunguponpartoftheexercise.(Checktheirnotes,checkthebook,discussitasagroup,andifallthatdoesn’twork,raisetheirhandsforhelp.)

4. Breakstudentsintotheirassignedteamsanddistributethematerials(worksheets5.3.1and5.3.2)toeachgroup.Invitethemtostartonreadinganddesigndebate.

5. Ifstudentsarestrugglingwithaquestion,youcanreferthemtothefollowingsectionsintheirbook:

a.Steps1–2—Thefirsthalfofsection8.2b.Steps4–11—Thesecondhalfofsection8.2c.Step3—Thefirsthalfofsection8.3d.Step12—Section8.1

StudentViewing&ExitTicket[10minutes]

1. Havestudentsputouttheircodeondesks,orpinnedtothewall,andhavetheentireclassvisiteachArtisanalClass/Objectset.

2. Asatickettoleave,havestudentswritedowntheirname,thenameofanothergroup’sclass,andhowtheywoulddeclareanobjectaccordingtothatgroups’constructor.

Lesson5.03:ObjectInitialization:Constructors

343

Page 344: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

AccommodationandDifferentiationForELLclasses,youmaywanttoletstudentsinvestigatethesamplefinishedproductmorecloselytogivethemcuesoninstructionssotheycanfocusonthecodinginstead.Ifthetaskisstillslowingtheclassdowntoogreatly,readthedirectionsaloudtotheclass,anddemonstratethesteprequired(e.g.selectingthestickynoteandstickingittothetemplate).

Moreadvancedclasseswillwhizthroughthisactivityin15minutesorless.Ifthishappensinyourclassroom,encouragestudentsto:

addmoremethods,includingcomments,andlabelingimplicitparameters

addmoreclientcode,includingcommentsonthecodetoexplainwhatitdoes

addotherclassesandobjects(onadditionaltemplates)andcreateamodelthatshowshowalltheobjects,classes,andclientcodemightlinktogetherinalargerprogram

reservesometimetocompletetoday’shomeworkandmoveontoLesson5.4.

TeacherPriorCSKnowledgeConstructorsyntax.HereisthestatementforcreatinganobjectfromclassPhone:

PhonemyPhone=newPhone();

Here’stheconstructorforclassPhone:

publicclassPhone{

publicPhone(){

//Phoneconstructorcodegoeshere

}

}

IfyoubreakdownthecreationofaPhoneobject:newPhone()therighthandsidePhone()issimplyamethodcall.Themethodthatiscalledistheconstructor.IfwenowlookattheconstructordefinitionpublicPhone(),itmatchestherighthandsideofthecreationofaPhoneobject.Theonlydifferencebetweencallingaconstructorwhencreatinganobjectandastaticornon-staticmethodisthereturntypeisimplied.Aconstructorbydefinitionreturnsareferencetoanobjectinthisexample,areferencetoaPhone.Sincetheconstructorbydefinitioncanonlyreturnonetype,itwasremovedfromthesyntaxwhendefiningaconstructor.

Lesson5.03:ObjectInitialization:Constructors

344

Page 345: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

MisconceptionsStudentsaddingvoidreturntypetoconstructordefinition.Studentsareinthehabitofspecifyingareturntypeformethods.Theonecasewherethereturntypeisnotneediswhendefiningtheclass’constructor.Ifareturntypeisspecified,themethodistreatedasamethodoftheclassandnotasaconstructor.Thecodewillcompilebuttheconstructorwillneverbecalled.

VideosBJP8-3,DefiningaClasshttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c8-3

CSE142,Usingvsbuildingobjects(1:41–7:36)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=0ef2111f-c799-4da9-b64a-2d876da98fb0&start=101

CSE142,toString()(optional)(7:37–23:33)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=0ef2111f-c799-4da9-b64a-2d876da98fb0&start=457

CSE142,Constructors(23:34–30:13)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=0ef2111f-c799-4da9-b64a-2d876da98fb0&start=1414

CSE142,MultipleConstructors(optional)(30:14–35:37)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=0ef2111f-c799-4da9-b64a-2d876da98fb0&start=1814

ForumdiscussionLesson5.03ObjectInitialization:Constructors(TEALSDiscourseaccountrequired)

Lesson5.03:ObjectInitialization:Constructors

345

Page 346: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson5.04—Encapsulation

Overview

Objectives—Studentswillbeableto…

Explainwhatencapsulation/abstractionare,andwhytheyareimportantprogrammingstrategies.

Assessments—Studentswill…

Teachamini-lessononencapsulation/abstraction,usingprivatefields,usingclassinvariants,andchanginginternalimplementations

Homework—Studentswill…

CompleteaquizattheendofDay2Completechapter8self-checkquestions17-21

Materials&PrepGroupcopiesofWS5.4Assignmentsfor4studentgroups4classroomcopiesofthetextbook(orhavestudentsbringbookstoclass)Copiesofthegradingrubricontheoverheadorprintedout(optional)

Youwillneedtocirclestudentassignmentsonpoint2ofWS5.4,soeachgroupknowswhattopictheyareexpectedtoteach.

PacingGuide:Day1

Lesson5.04:Encapsulation

346

Page 347: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Introduction;reviewingtheassignment 10min

Studentpreparationoflesson 30min

Studentpractice 10min

PacingGuide:Day2

Section TotalTime

Bell-workandattendance 5min

Studentmini-lessons 35min

Quizusingstudent-generatedquestions 15min

ProcedureYourhookfortoday’slessonistoturnthereinsovertostudentsimmediately.Haveinstructionsprintedoutandsittingatteamworkstations(oronstudentdesks).Encouragestudentstoanswertheirownquestionsusingtheinstructionsheetandtextbook.FrequentlyaskedquestionsandsuggestionsforstudentgroupsareincludedinAccommodationsandDifferentiation.

Bell-workandAttendance[5minutes]

Introduction&ReviewingtheAssignment[10minutes]

1. Preparestudentsbytellingthemthatthe4topicscoveredtodayarethe4subsectionsof8.4,thereadingthatwasduetoday.

2. Givestudents15minutestopreparetheirpresentationandgeneratequizquestionsfortomorrow’sclass.

a.Useatimerandannouncetimeat10-and5-minutesremainingsostudentscanpacethemselves.

b.Answerstocommonlyaskedquestions,andtipsforthedifferentgroupsmaybefoundbelow:

Lesson5.04:Encapsulation

347

Page 348: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ASSIGNMENTFAQ

Encapsulation&Abstraction

Guidanceforstudentteachers

1. Ifstudentsarelackingdirection,encouragestudentstorefertothetextbook.Agoodexampleofwhyit’simportanttoencapsulatecodecanbefoundinthe“Didyouknow”blueboxinsection8.4.

2. Agood“TrickyCodeCheatSheet”tipwouldbeforstudentstoformaruletheirpeerscanmemorizeforwhenits’appropriatetoencapsulatecode.

CommonQuestions/Answers

1. Whycan’twejustignorecode,orpromisenottomodifyitinsteadofencapsulatingit?

Mostlargeprogramsareauthoredbymanypeopleoverthecourseofmonthsoryears!Sometimesyoudon’tneed(orwant)toknowthedetailsofanotherprogrammingsegment—ifitain’tbroke,don’tfixit.Tokeepfromaccidentallychangingcode,it’sbestpracticeto“protect”itbyencapsulation.

PrivateFields

Guidanceforstudentteachers

1. Ifstudentsarehavingtroubleoutliningtheirlesson,suggestthattheystartwiththefourthcompleteversionofcodeinthetextbook.Iftheyusethetextbookexample,makesuretheypointoutwhichprogramistheclientcode.

2. Agood“TrickyCodeCheatSheet”tipwouldbetheconventionoffieldsatthetopoftheclass,followedbyconstructors,followedbymethods.

CommonQuestions/Answers

1. Whatisthescopeofprivatefields?

PrivatefieldsarevisibletoallofthecodeinsidethePointclass,includingtheinstancesoftheclass.Clientcodecannotdirectlyrefertoanobject’sfieldsifyou’veencapsulatedthem(markedthemasprivate).

2. Butwhatifwestillwantclientcodetohavetoreadsomeofthefields?

Writeanaccessormethod(a“get”method).Itreturnsacopyofthefield’svaluestotheclient,sotheclientcanseethevalues,butcan’tmodifythem.

Lesson5.04:Encapsulation

348

Page 349: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ClassInvariants

Guidanceforstudentteachers

1. Remindstudentstoincludethedefinitionofaclassinvariantforstudentstorecordintheirnotebooks.

2. Sincewedidnotcoverthethiskeyword,youshouldpointouttothegroupthatthethiskeywordintheexampleallowsthecodetodirectlyrefertotheimplicitparameter.Sincethismightbeconfusing,youshouldgivethisgroupextraassistance,orassignyourmostadvancedgroupthislesson.

3. Usingdivision/modulus60toconvertsecondstominutesorminutestohoursasoutlinedinthebookisausefultipforthe“TrickyCodeCheatSheet.”

CommonQuestions/Answers

1. Howisenforcingaclassinvariantdifferentfromusingaclassconstant?

Aclassconstantwillalwaysstaythesamevalue;itdoesnoteverchange.Aclassinvariantisafactaboutsomedatathatyouastheprogrammerassertwillalwaysbetrue.Forinstance,inPokemon,eachstatmustbelessthan255—thatisthemaxvalueyoucanhaveforanyonestat.ThevalueitselfmaygoupordowndependingonwhathappenstoyourPokemoninthegame,butitwillalwaysbelessthan255.

2. Canyouuseamutatormethodtochangetheclassinvariants?

No,sopickandchooseyourinvariantswithcaution!

3. Skiptheexceptionsexample—exceptionsarenotontheAPexamandwillnotbetested!

ChangingInternalImplementations

Guidanceforstudentteachers

1. Ifstudentsneedguidanceonstructuringtheirlesson,encouragethemtocoordinatewiththegroupteachingclassinvariants,sincetheywillbemodifyingthecodetaughtbythatgroup.Theymightalsowanttorefertothe“DidYouKnow”blueboxinthesection.

2. AgoodtipfortheTrickyCodeCheatSheetcouldbethesimplertimespancode.

CommonQuestions/Answers

1. Howcomechangingtheinternaldesigndoesaffectclientcode?

Lesson5.04:Encapsulation

349

Page 350: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Sinceyouencapsulatedyourclass,theclientcodewon’tknowthatyouchangedtheinternalstate.Theonlywayyourchangingtheclasscodecanmesswithaclientprogramisifyouchangetheconstructorsormethodheaders.

StudentPreparationofLesson[30minutes]

1. Giveeachgroup7minutestopresenttheirtopicand2minutesforquestions.

2. Encouragestudentstoaskquestions,andbesuretoaskaquestionortwoofeachteam(dependingonhowmanyteamsyouhave).

3. Usethegradingrubricasoutlinedhere:

3pts. 2pts. 1pts. 0pts.

Presentationincludesdefinitionsandanexamplewithpropersyntax.

Presentationincludesdefinitionsoranexamplewithpropersyntax.

Presentationincludesdefinitionsoranexamplewithpropersyntaxwithfewmistakes.

Presentationincludesdefinitionsoranexamplewithpropersyntaxwithmanymistakes.

Presentationincludesanon-exampleashelpfulcontrast.

Presentationincludesanon-examplethatismarginallyhelpful.

Presentationincludesanon-examplethatdoesnotaddtocomprehension.

Presentationincludesanon-examplethataddsconfusion,orpresentationdoesnotincludeanon-example.

Presentationincludesahelpfultipthatisclearlyexplainedandconciselystated.

Presentationincludesahelpfultipthatisclearlyexplainedorconciselystated.

Presentationincludesahelpfultipthatisnotclearlyexplainedandmayincludeasmallerror.

Presentationdoesnotincludeahelpfultiporhint.

AccommodationandDifferentiationCirclearoundtheroomtohelpstudentsthroughreadingthetextinthetextbook.Makesurethateachofyourworkingteamsisproperlystratified(ratherthanusingtieredgrouping).

Ifstudentsarespeedingalong,encouragestudentstowritedownquestionstoposetoothergroupsduringmini-lessons.Ifagroupfinishesearly,encouragethemtorehearselessondelivery.

TeacherPriorCSKnowledge

Lesson5.04:Encapsulation

350

Page 351: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Javaisinconsistentwithitsuseofencapsulationwhichcouldcauseconfusionwithbeginningstudents.WhengettingthelengthofaStringa,theaccessmethod.length()isused.However,whengettingthelengthofanarray,thepublic,thoughfinal,instancevariable.lengthisused.

MisconceptionsStudentsgetthenotionthatbecauseofdataencapsulation,classescannotbefieldsofanotherclass.Eventhoughthedataintheclassisprotectedfrombeingmodifieddirectlybyotherclasses,theclassitselfcanbeusedasfieldsinotherclasses.

VideosBJP8-4,Encapsulationhttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c8-4

CSE142,Encapsulation(35:38–45:58)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=0ef2111f-c799-4da9-b64a-2d876da98fb0&start=2138

CSE142,“this”notation(optional)(45:59–49:46)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=0ef2111f-c799-4da9-b64a-2d876da98fb0&start=2759

ForumdiscussionLesson5.04Encapsulation(TEALSDiscourseaccountrequired)

Lesson5.04:Encapsulation

351

Page 352: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson5.05—Finding&FixingErrors

Overview

Objectives—Studentswillbeableto…

Finderrorsintheirreturnedhomeworkassignments.Correcttheircode

Assessments—Studentswill…

Re-submitallhomeworkassignmentswithcorrectedanswers.

Homework—Studentswill…

ReviewmaterialsforthePicturelabby:ReviewingallthebluepagesattheendofChapter8

Submit5questionsforreviewinclasstomorrowusingelectronicsurveyUpdateallsummariesinnotebookfortheupcomingnotebookcheck

Materials&PrepAnystudenthomeworkassignmentsthatyouhavenotyetreturnedStudentself-helpsystem(suchasC2B4orstudentpairing)Electronicsurveyforstudentreviewrequests

Thehomeworktonightasksstudentstosubmit5questionsforreview.Createanelectronicsurveyforstudentstocompletewith6textfields,oneforname,and5forquestionstheyhaveaboutCh.8content.Setadeadlinebywhichtimestudentsmusthavesubmitted5questionsfromCh.8thattheywouldliketoseereviewedaftercompletionofthePictureslab.Ifstudentsdonothavequestions,stipulatethattheystillhavetosubmitsomethingtoreceivecredit,evenifitisonlyquestionstheythinkotherstudentsmayhave.

PacingGuide

Lesson5.05:Finding&FixingErrors

352

Page 353: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Introductionandhomeworkdistribution 5min

Studentwork 35min

Studentstradework,check,andsubmit 10min

ProcedureTodaywecontinuereinforcingconceptsandapplyingthetools,procedures,andcodethatwereintroducedlastweek.Studentswillhavetheopportunitytocorrectanyincorrecthomeworkorclassworkassignments.Ifstudentsdidnothavetimetofinishthehomeworkfromyesterday,youmayallowthemtimetoworkonthattoday.

Bell-workandAttendance[5minutes]

IntroductionandHomeworkDistribution[5minutes]

1. Returnstudenthomeworkpackets,orhavestudentsplacetheirreturnedhomeworksinapileontheirdesk.

2. Explaintostudentsthattheyhavetheopportunitytogetfullcreditontheirhomeworkgradesbycorrectingthemnow,inclass.Askstudentsforsuggestions/ideasonhowtomakesuretheydon’tmissanyerrors.

Bynowstudentsshouldbeusedtorelyingontheirerrorchecklist/algorithm.

StudentWork[35minutes]

Havestudentsworkindividuallytocorrecttheirhomeworkgrades.

Offertimechecksforstudentssotheystayontask.

Ifstudentshavenotfinishedhomeworkassignments,allowthemtimetodaytocompletetheseassignmentstoturninforpartialcredit.

Studentstradework,check,andturnin[10minutes]

Attheendofclass,havestudentstradetheirhomeworkassignmentstoevaluateeachother’scorrectionsbeforesubmission.

Lesson5.05:Finding&FixingErrors

353

Page 354: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

AccommodationandDifferentiationInELLclassrooms,pairstudentsandallowthemtoworktogethertocorrecttheirwork.Ifyounoticedaparticularproblemwasdifficultforthemajorityofstudents,readthequestionaloudandhelpstudentsworkthroughit.

Forthosestudentswhohavenothingtocorrect(orfinishveryearly),rewardthemwithsilentfreetime,orallowthemtoworkonafree-choiceprogrammingproject.

ForumdiscussionLesson5.05Finding&FixingErrors(TEALSDiscourseaccountrequired)

Lesson5.05:Finding&FixingErrors

354

Page 355: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson5.06—PictureLab

Overview

Objectives—Studentswillbeableto…

Completealong-formlab,usingtwo-dimensionalarraysofobjects,arraytraversingalgorithms,programanalysis,binarynumbers,inheritance,andinterfaces.

Assessments—Studentswill…

CompletethePictureLab

Homework—Studentswill…

Alistofhomeworkassignmentsisprovidedbelow.

Materials&PrepProjectorandcomputerPictureLabTeacher’sGuideClassroomcopiesofthePictureLabStudentGuideAssociatedPictureLab&PictureLabExtensionFilesDigitalcamera(optional)CD(optional)Eggcartonsandsmallcandies(SkittlesorM&Ms)(optional)Photonegative(optional)Rectangularmirror(optional)

ReadthroughtheTeacher,Student,andExtensionguidesaheadoftimetofamiliarizeyourselfwiththepartsofthislong-formlab.Usingtheguides,completethelabonyourowntospotpossiblechallengesforyourstudents.Uploadallstudentfilesontoeachcomputerdesktopforstudentaccess.Don’tgivethefinalClassesfoldertoyourstudents—itcontainssampleanswers!

NOTE:Ifyourstudentsentertheclassroomwithpriorprogrammingknowledge,orifyourclassismovingthroughtheAPcoursequicklywithease,youmaywanttodelivertheTextExcellab(includedinUnit5materials)instead.

Lesson5.06:PictureLab(9Days)

355

Page 356: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

PacingGuide:Day1

Section TotalTime

StudentActivity1&2 Fullclass

Homework:Summarizeyournotesinyournotebooks.Notebookchecksinclasstomorrow!

TONIGHT

PacingGuide:Day2

Section TotalTime

StudentActivity3&4 Fullclass

NotebookChecks Duringclass

Homework:OutlineChapter8 TONIGHT

PacingGuide:Day3

Section TotalTime

StudentActivity5 Fullclass

NotebookChecks Duringclass

Homework:ReadandhighlightChapter2ofBarron’sreviewbook.Skip“ThethisKeyword”.

TONIGHT

PacingGuide:Day4

Section TotalTime

StudentActivity5&6 Fullclass

NotebookChecks Duringclass

Homework:TaketheChapter2examinBarron’sreviewbook,skipping#20.Gradeyouranswers.

TONIGHT

Lesson5.06:PictureLab(9Days)

356

Page 357: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

PacingGuide:Day5

Section TotalTime

StudentActivity6,continued Fullclass

CheckBarron’sreviewbooksforhighlightingnote-taking,andpracticetestcompletionandcorrection Duringclass

Homework:ReadandhighlightChapter5ofBarron’sreviewbook. TONIGHT

PacingGuide:Day6

Section TotalTime

StudentActivity7 Fullclass

Homework:ReadBJP8.5andanswerself-checkquestions29–30 TONIGHT

PacingGuide:Day7

Section TotalTime

StudentActivity8 Fullclass

Creatingacollage Duringclass

Homework:Finishupcreatingacollage TONIGHT

PacingGuide:Day8

Section TotalTime

StudentActivity9 Fullclass

Simpleedgedetectionalgorithmandimplementation Duringclass

Homework:ContinueworkingonSimpleedgedetection. TONIGHT

PacingGuide:Day9

Lesson5.06:PictureLab(9Days)

357

Page 358: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

StudentActivity9,continued Fullclass

FinishSimpleedgedetection Duringclass

Homework:Submit5reviewquestionsontheelectronicsurvey. TONIGHT

AboutBarron’sBarron’sisanAPCSAreviewbookthatsomeschoolprovidestudents.Ifyourschooldoesn’tprovideBarron’stherearemanyalternativehomeworkassignmentsthatcanbefoundathttp://codingbat.com/java(noclasses)orpractice-it.

Alternatively,youcansavetimespentonthelabbycheckingactivitiesasHomework.

ProcedureAllguides,samplecode,answercode,andexamplecodemaybefoundinthefolder“Milestone2PictureLab.”

1. Tohelpstudentsstartthelabsmoothly,startActivity1asawholegroup.

2. EncouragestudentstousetheirTrickyCodeCheatSheets,4CommandmentsofScope,notebooks,textbooks,classroomposters,andhomeworkassignments.

3. Offeroccasionaltime-checkstohelpkeepstudentsonpace.

4. Gradenotebooksandreviewbooksinbetweenhelpingstudentssostudentscankeepnotebooksforhomeworkandstudyingintheevenings.

AccommodationandDifferentiationInELLclassrooms,readalldirectionsaloudbeforebreakingintoindividualpractice,andallowuptotwicetheamountoftimeforcompletionofthelab.

Tosavetimeontherestofthelab,don’tspendtoomuchtimereviewingbinarynumbers,andrestrictcolorexploration(Activity2)to~20minutes.

Usethetactileexercisesassuggestedonpage6oftheTeacher’sguide(candyexerciseandexploringthedigitalcamera).

Lesson5.06:PictureLab(9Days)

358

Page 359: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Asneeded,allowstudentstopairuptohelpeachotherwithreadingcomprehension(butremindstudentsthattheyeachmustsubmittheirowncode).Eachdaythatyoubeginthelab,startwithaquicksurveyofstudentconcernsandquestions.

Adaptationsforgroupworkcanbefoundonpage19oftheTeacher’sguide.

Assessmentquestionshavebeenrelocatedtothepracticeexam,WS5.7.

ForumdiscussionLesson5.06PictureLab(TEALSDiscourseaccountrequired)

Lesson5.06:PictureLab(9Days)

359

Page 360: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson5.07—Review

Overview

Objectives—Studentswillbeableto…

IdentifyweaknessesintheirUnit5knowledge.

Assessments—Studentswill…

Createapersonalizedlistofreviewtopicstoguidetonight’sstudysession.

Homework—Studentswill…

Studyfortomorrow’stestusingtargetedreviewlist

Materials&PrepProjectorandcomputerWhiteboardandmarkerResultsfromelectronicsurveyofreviewtopicsClassroomcopiesofthepracticetestWS5.7

Oncestudentshavesubmittedtheirreviewrequests,assemblethosetopicsintocategoriesandpreparetore-teachthetopicsasneeded.Ifyouarecrunchedfortime,holdthereviewsessionduringthesecondhalfofDay12ofthePictureLab.

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Reviewofstudentquestions 30min

Sampletestreview 15min

Checkstudentstudylists 5min

Lesson5.07:Review

360

Page 361: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Procedure

Bell-workandAttendance[5minutes]

ReviewofStudentQuestions[30minutes]

1. Clearlyindicatethatyouexpectallstudentstohavealistofreviewtopicstostudythisevening.Periodicallyremindstudentsthatthislistwillbecheckedattheendofclass.

2. Beginwithareviewofstudent-submittedquestionsbeforereviewingthepracticequestions.

SampleTestReview[15minutes]

1. BeginreviewwithpracticetestWS5.7.HavestudentsworkthroughsectionIquestions,thenreviewtheanswersasaclass.

2. GivestudentstimetocompletesectionIIquestions,thenreviewtheanswersasaclass.

3. Finally,workthroughthevariousreviewtopics,prioritizingquestionsthatpoppedupthemost.

a.Somequestionsyoumayaddresswhileworkingthroughthesampletest.

b.Bereadyforadditionalquestionstopopupasyougo.Saveyourselftheworkanduseoldhomeworkquestionsandstudent-generatedtestquestionsasexamplestoworkthrough.

4. Useacombinationofgroup-solvingquestionsonthewhiteboard,think-pair-share,andtimed-responseasreviewstrategies.

5. Afteryou’vecompletedreviewinganidea,remindtheclassthattheyshouldwritedownthattopiciftheyfeeltheystillhavetoreviewittonight.

CheckStudentStudyLists[5minutes]

Spendthelast5minutesofclasscheckingeachstudent’sreviewtopiclist.

ForumdiscussionLesson5.0Unit5Review(TEALSDiscourseaccountrequired)

Lesson5.07:Review

361

Page 362: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson5.07:Review

362

Page 363: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson6.00—TestReview&Reteach

Overview

Objectives—Studentswillbeableto…

Re-learnorstrengthencontentknowledgeandskillsfromUnit5.

Assessments—Studentswill…

Re-submittestanswerswithupdatedcorrectionsforpartialorfullcreditCreditdependsoninstructorpreference

Homework—Studentswill…

ReadBJP9.1Correctanyincorrecttestanswersbyre-answeringonaseparatesheetofpaper

Togetbackcredit,theymustjustifytheirnewanswersStaplenewanswersheettooldtestandturnintomorrow

Materials&PrepProjectorandcomputerWhiteboardandmarkersCorrectedstudenttestsStudentgrades(postedonline,emailedtostudents,orhandedbackonpaperinclass)Digitalcopyoftestquestionsforprojector

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Classdiscussion(ifneeded) 10min

Testreviewandreteach 35min

Checkstudentnotesandreturntests 5min

Lesson6.00:TestReview&Reteach

363

Page 364: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ProcedureReturnstudentgradesbeforeclassbeginsorwhilestudentsarecompletingthebellwork.

Donotreturnstudents’testsbeforethereviewsession,sinceyouwanttomotivatestudentstopayattentiontotheentirereview,takingsupplementalnotestheentiretime.

Bell-workandAttendance[5minutes]

ClassDiscussion(ifneeded)[10minutes]

1. Ifgradesarelow,invitetheclasstoadiscussionofwhatcanbeimproved.Beginwithstudentcomplaintsandsuggestionstobuildstudentbuy-in.Askstudents:

howtheyfelttheyweregoingtodobeforethetestwhatsurprisedthemoncetheyweretakingthetestwhattheyfeltworkedinthefirstunit(lessons,reviewstrategies,assignments)whatdotheythinktheywanttochangeforthesecondunit

2. Onceyoufeelthatadialoguehasbeenestablished,validatestudents’feelings,thenchallengethem(e.g.APcoursesarestressful,butthisisgoodpracticeforcollege,wherethepaceisfasterandprofessorsdon’tgivepersonalizedinstruction).

TestReviewandReteach[30minutes]

1. Walkthestudentsthrougheachquestiononthetest,glossingoverquestionsthateveryoneansweredcorrectly.

a.Youcanaskforstudentstovolunteeranswers,orcallonstudentsrandomly.Makesurethatstudentsexplaintheirlogicwhentheyanswer.Ifastudentgivesanincorrectanswer,theexplanationwilltellyouwhatyouneedtore-teachorclarify.

b.Donotskipquestionsthateveryoneansweredcorrectly,butdonotspendmorethanthetimeittakestoreadthequestion,andcongratulatestudents’correctanswers.

2. Projectacopyofeachquestionasyoureview—thiswillhelpstudentsrecallthequestion/processtheinformation.

3. Makesurethatstudentsaretakingnotesduringthere-teach,remindingstudentsthatforhomework,theywillhaveanopportunitytowinbacksomeofthepointsontheirexam.

4. ForSectionIIquestions,selectasampleofstudentwork(withanyidentifyinginformationobscured),andworkthroughtheanswertogetherasaclass.

Lesson6.00:TestReview&Reteach

364

Page 365: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Checkstudentnotesandreturntests[5minutes]

Attheendofclass,checkstudentnotes,andreturnthetestsinhardcopyformifapplicable.

AccommodationandDifferentiationEncourageadvancedstudentstotakeonadditionalprogrammingchallenges.OneeasywaytodothisistoassignProgrammingProjectsfromthebluepagesattheendofeachChapter.

Ifyouhaveafewstudentsthatarestrugglingwiththeclass,choosethesestudentstocreateyourclassroompostersafterschoolorforextracredit.

ForumdiscussionLesson6.00TestReview&Reteach(TEALSDiscourseaccountrequired)

Lesson6.00:TestReview&Reteach

365

Page 366: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson6.01—InheritanceBasics

Overview

Objectives—Studentswillbeableto…

Correctlydefineinheritance.Usepropersyntaxtoextendaclass.Illustrateis-arelationships.Properlyimplementconstructorsofderivedclassesusingsuper.

Assessments—Studentswill…

CompleteaClassHierarchyposterasindicatedinWS6.1

Homework—Studentswill…

ReadBJP9.2upto“DividendStockBehavior.”Collectimagesthatrepresentinstancesoftheclassescreatedforin-classposterproject.

Materials&PrepProjectorandcomputer(ifyouareableto/opttouseEclipsewithyourstudents)WhiteboardandmarkersClassroomcopiesofWS6.1Startclassposter,Example6.1PicturesofPokémon(http://tinyurl.com/l6mybmr)orPokémonCardsStudentpairassignmentsArtsuppliesforeachgroup:

PosterpaperorcutsheetsofbutcherpaperLinedpaper(atleast3sheetspergroup)MarkersGlueSticksOldmagazines,flyers,newspaperstocutupforcollageScissorsYarn,string,orembroideryflossTape,magnets,ortackstohangfinishedwork

Lesson6.01:InheritanceBasics(2Days)

366

Page 367: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Mostofthesuppliesrequiredforthislessonarereadilyavailableinhighschools.Iftheschooldoesn’thaveposterpaper,butcherpaperworkswell.OthersuppliesmaybeavailabletoborrowfromtheMath,Science,orArtteachers.Togetanideawhatafinalstudentprojectshouldlooklike,checkoutthepictureofsamplestudentwork“Example6.1.”

PacingGuide:Day1

Section TotalTime

Bell-workandattendance 5min

Introduction 20min

Reviewoftheproject 5min

Studentwork 25min

PacingGuide:Day2

Section TotalTime

Studentwork&teachercheck 20min

Peerreview 10min

Whole-groupdiscussionandreteachifneeded 15min

Quiz 5min

ProcedureHookyourstudentsbyprominentlydisplayingpicturesorcardsofPokémon,artmaterials,andsamplework(ofyourownmaking,orsavedfromapreviousyear).Tofeaturethemostengagingstudentexamples,lookforworkthathasmanyinstancesofeachclass,andusesclasses/objectsthatarepopularwithyourclass.Invokeanairofmysteryanddon’tofferanexplanationforanyofit.

Bell-workandAttendance[5minutes]

Introduction[20minutes]

Lesson6.01:InheritanceBasics(2Days)

367

Page 368: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

1. HaveaclassdiscussionaboutthePokémonpicture/cards.Askafewprobingquestionstomodeltheuseofproperprogrammingterminologyasyouhavestudentsworkthroughastarterassignment:

2. Askstudentswhatthepictureisof.DotheyknowthenamesortypesofthePokémonfeatured?AssignaquickThink-Pair-ShareassignmenthavingthestudentscreatingtheinstanceofthatPokémon.Here’sasampleprompt:

“CreatetheobjectPikachu.Pikachushouldhaveatype,alevel,and2methods.”

3. Showafewmorecards/pictures.AskstudentstodoanotherThink-Pair-Sharewithanotherprompttocreateanotherinstance(yourpromptshouldhavewhateverPokémonyou’vejustdiscussed):

“CreatetheobjectSquirtle.Squirtleshouldhaveatype,alevel,and2methods.”

4. Repeatthissequenceonemoretime;showingthecards,andhavingstudentscreateaPokémoninstanceobject.Yourstudentsshouldbegettingannoyedathavingtowritethesamethingsoverandoveragain.

5. AskstudentswhatallofthePokémonhaveincommon.Encouragethemtolistadditionaltraitsotherthantheonesyou’verequiredthemtoincludeinyourclassexercises.

6. AskstudentsiftheycanthinkofawaytocreatenewPokémonobjectswithouthavingto“reinventthewheel”eachtime.(Theymightbeabletosketchoutananswerbasedonthepreviousnight’sreadings.)

7. StudentsmightsuggestsubclassesofPokémon,inwhichcaseyoushouldpointoutthatthey’recreatingaclassthatisincludedwithinthelargerclassificationof“allPokémon.”

TheindividualPokémondemonstrateaninstanceofthePokémonclass.EachsubclassofPokémonisaspecializedversionoftheparentclass(orsuperclass)Pokémon.

Examples

AnelectricPokémonisaPokémon.Acomputersciencestudentisastudent.Amathteacherisateacher.Sodaisadrink.

Havestudentsdescribethehierarchicalstructureofeachrelationshipabove.ElectricPokémonisasubclass,Pokémonisthesuperclass.Studentisthesuperclass,computersciencestudentisthesubclass.Drinkisthesuperclass,sodaisthesubclass.

Lesson6.01:InheritanceBasics(2Days)

368

Page 369: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

8. Confirmunderstandingbyaskingforstudentstogeneratesomeexamples.Ineachcase,theirtwocategoriesexhibitahierarchicalconnection;onetypeisaspecializedversionoftheother.

9. Askstudentstodefineaninheritancehierarchyintheirownwords.Brieflydiscusswhyyouwouldwanttouseinheritanceinprogramming.

Aninheritancehierarchyisasetofhierarchicalrelationshipsbetweenclassesofobjects.

Inheritanceisaprogrammingtechniquethatallowsaderivedclasstoextendthefunctionalityofabaseclass,inheritingallofitsstateandbehavior.)

Superclassistheparentclassinaninheritancerelationship.

Subclass,orchildclassisthederivedclassinaninheritancerelationship.

10. Checkforunderstandingbyreturningtotheexamplesabove,andaskingstudentstogiveanexampleofsomecharacteristics(fields)theparentclasswouldhave,andwhatcharacteristicsstudentswouldaddtothespecializedsubclasses.

Example:DrinkscouldhaveaStringnameandbooleancarbonated,andSodacouldaddabooleancaffeinated.

11. Theclassheaderforasubclassthatextendsthefunctionalityoftheparentclasslookslikethis:

publicclassMammalextendsAnimal{

publicclassMotorcycleextendsVehicle{

publicclassChurroextendsPastry{

Pointoutthatthesubclassnamesarecapitalizedbyconvention,andthatyoualwaysusetheextendskeyword.Givestudentsamomenttothinkofafewhierarchicalrelationshipsinathink-pair-share,andaskseveralvolunteerstocometothefrontoftheroomtodemonstratethecorrectclassheader.

12. Forthefollowingexample,wewillcreatesubclassesthatextendtheDrinksuperclasswrittenbelow.Ifyourstudentsneedadditionalpracticebuildingclassesofobjects,youcanhavethemhelpyouwritethiscode.Inmoreadvancedclasses,youmayjustrevealthisclassasafully-formedstartingpointtodemonstratehowtowritesubclasses.

Lesson6.01:InheritanceBasics(2Days)

369

Page 370: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

publicclassDrink{

privateStringname;

privatebooleanhasCarbonation;

privatedoublegramsOfSugar;

privatedoubleounces;

publicDrink(Stringn,Booleanh,doubleg){

name=n;

hasCarbonation=h;

gramsOfSugar=g;

ounces=8;//FDAdefinesaservingas8oz.

}

publicvoidchug(doublegulp){

if(ounces<gulp){

thrownewIllegalArgumentException("Notenough"+name+"left.");

}else{

System.out.println("Glug,glug,glug!");

ounces-=gulp;

System.out.println("Youhave"+ounces+"oz.of"+name+"left.");

}

}

publicStringgetState(){

return"liquid";

}

publicvoidprintLabel(){

System.out.println("Enjoyrefreshing"+name+"!");

}

}

13. Becausethesubclassisstillaclass,youshouldaddfieldsandconstructors,asyoudowithanyclass:

publicclassSugarFreeDrinkextendsDrink{

privatebooleanhasSweetener;

privatedoublecaffeineContent;

TheadditionalfieldshasSweetenerandcaffeineContentcharacterizeallSugarFreeDrinkDrinkobjects.YoupointouttostudentsthatSugarFreeDrink“isakindofDrink.”Spot-checkstudentunderstandingbyaskingifobjectsoftheDrinksuperclasswillinitializewithavalueforhasSweetenerorcaffeineContent.(No.)

14. SugarFreeDrinkdrinksstillhaveaname,abooleancarbonationvalue,sugarcontent,andounces,butwe’veaddedanewfieldsspecifyingwhetherornotthesugarfreedrinkshavecaffeineandartificialsweeteners.Theconstructorthenlookslikethis:

Lesson6.01:InheritanceBasics(2Days)

370

Page 371: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

publicSugarFreeDrink(Stringname,booleanhasCarbonation,booleanh,doublec){

Thefieldsinthesubclass’constructornowcontain<type><superclassparametervalues>(highlighted),exceptforthenewfields,whichstillhaveaformalparameter(inthiscasehandc).

Tocompletetheconstructorsoitcanaccessthefieldsyoualreadywroteinthesuperclass,youusethekeywordsuper:

//mustbefirstlineafterconstructorheader

super(name,hasCarbonation,0.0);

Noticethatwe’veinitializedallobjectsintheSugarFreeDrinkclasstohave0.0gramsofsugar.

Completetheconstructorwithyoursubclass’newfields:

hasSweetener=h;

caffieneContent=c;

}

15. Youcanalsoaddmethodsthatonlyapplytoyoursubclass,justthewayyounormallywriteobjectmethods:

publicvoidprintWarningLabel(){

if(hasSweetener){

System.out.println("ThisdrinkisnotsafeforPhenylketonurics.");

}else{

System.out.println("Thisdrinkcontainsnoartificialsweeteners.");

}

}

ReviewoftheProject[5minutes]

1. Brieflyreviewtheassignmentwithyourstudents,readingthedirectionsaloudifneedbe.

2. Ifyouhaven’talreadydistributedprojectmaterialsatthispoint,dosowhileyourstudentsarerearrangingintopartnerpairs.

StudentWork[25minutes]

Lesson6.01:InheritanceBasics(2Days)

371

Page 372: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

1. Encouragestudentstotake5–10minutesonStep1.Theyshouldreviewallstepsoftheprojecttoensurethattheirselectionofclasseslendsitselftotheproject(e.g.theyshouldn’tpicksomethingtheydon’tknowalotaboutbecausethey’llhavetroublecomingupwithfieldsandmethods).

2. Offertimechecksevery10minutessostudentscanstayonpace.Bytheendofthefirstday,theyshouldhavegottentostep6or7.Visiteachgrouptomakesurethattheyhaven’tveeredoffcourse.

3. Ondaytwo,checkstudentworkandhelpstudentsdisplaytheirworkaroundtheroom.

4. Checkthattheflow-of-controlstring(seeWS6.1forexplanation)correctlyshowshowamethodispassedthroughsubclassestothesuperclass.

5. Remindstudentstotakenotes(Step11onWS6.1)tohelpthemremembertalkingpointsforlaterintheclass.

6. Asawholegroup,askstudentstovolunteerwhattheyreallylikedaboutothers’projects.Solicitquestionsandcritiques,re-teachingifneeded.

7. Administerquiz6.1toassessstudentunderstanding.

AccommodationandDifferentiationEncourageadvancedstudentstoaddadditionalclasses,fields,methods,andclientcode.Ifstudentsstillhavetimetospare,encouragethemtoreadonmethodoverriding,andinvitethemtoaddthatcodeaswell.Studentscanattachthis“extracode”usingpaperandtape/glueorstickynotes.

Ifyouhaveafewstudentsthatarestrugglingwiththeclass,givethemyourstarterDrinkclassandSugarFreesubclass,andletthembuildoffofyourexamples.Youcanprintoutyourstartercodeandcutitintopiecesandshufflethemsostudentshavetoplaceeachlineinthecorrectlocation(aswithaParsonproblem).

Ifyourstudentsneedfurtherinstructiononcallingasuperclass’constructor,gothroughafewmoreexamplesusingtheDrinksuperclass,orclassesthatyoucreatedasawholegroup.Oneexamplehasbeenoutlinedbelow:

Lesson6.01:InheritanceBasics(2Days)

372

Page 373: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

publicclassSugarDrinkextendsDrink{

privatebooleanisJuice;

publicSugarDrink(Stringname,booleanhasCarbonation,doublegramsOfSugar,

doubleounces,booleaniJ){

super(name,hasCarbonation,gramsOfSugar,ounces);

isJuice=iJ;

}

TeacherPriorCSKnowledgeTheObjectOrientedProgramming(OOP)paradigmcouldbethoughtofasmimickingtherealworldwhereobjectsconsistsofdatathatdefinethemandactionsthatcanbeperformedonthedata.Asyouwillsee,theprocessoflearningOOPisinfinitelymorecomplex.

ThepillarsofObjectOrientedProgramming(OOP):inheritance,encapsulation,andpolymorphism.Inanutshellinheritanceallowsforcodereusebydefiningmethodsonceinasuperclass,encapsulationprovidesdatasecuritybyhidingdataimplementationfromtheuserandonlyallowingmethodsintheclasstomodifythedata,andpolymorphismoffersflexibilitytothedesignerbywayofmethodsdefinedinmanyforms.

MisconceptionsStudents’useof“inheritance”priortocomputerscienceareinthecontextofinheritancefromanancestorandgeneticinheritanceoftraits.However,incomputerscience,inheritanceisusedforclassificationwheretheclassthatinherits(extends)fromamoregeneralclass(superclass).Neitherofthestudents’priorknowledgeanduseofinheritanceisanaccuraterepresentationofJava’sclassstructure.

CommonMistakesObjectorientedconceptscommonmistakes:http://interactivepython.org/runestone/static/JavaReview/OOBasics/ooMistakes.html

VideoBJP9-1,Inheritance:InteractingwiththeSuperclasshttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c9-1

Lesson6.01:InheritanceBasics(2Days)

373

Page 374: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

CSHomeworkBytes,Inheritance,withZachhttps://www.youtube.com/watch?v=Alv2ApK_jdo

CSE142,Inheritance(23:28–35:06)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=8a0a0287-877b-42df-99fc-e9f551929bef&start=1408

ForumdiscussionLesson6.01InheritanceBasics(TEALSDiscourseaccountrequired)

Lesson6.01:InheritanceBasics(2Days)

374

Page 375: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson6.02—OverridingMethods&AccessingInheritedCode

Overview

Objectives—Studentswillbeableto…

Replacesuperclassbehaviorbywritingoverridingmethodsinthesubclass.Writesubclassmethodsthataccesssuperclassmethods.

Assessments—Studentswill…

AddcodetotheirClassPostersfromthepreviouslesson.

Homework—Studentswill…

ReadtherestofBJP9.2startingfrom“TheObjectClass.”

Materials&PrepProjectorandcomputerWhiteboardandmarkersClassroomcopiesofWS6.2Classpostersfrom6.1Artsuppliesforeachgroup:

MarkersPosterpaper(alternativelyprinterpaperandtape)Tape,magnets,ortackstohangfinishedwork

PacingGuide

Lesson6.02:OverridingMethods&AccessingInheritedCode

375

Page 376: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Introduction&reviewoftheproject 10min

Studentwork 15min

Peerreview 10min

Whole-groupdiscussion/critique 10min

ProcedureHookyourstudentsbyprominentlydisplayingartmaterials,andsamplework(ofyourownmaking,orsavedfromapreviousyear).Tofeaturethemostengagingstudentexamples,lookforworkthathasaparticularlycomplexorimpressiveflow-of-controlpattern(seeWS.6.2forexplanation).Ifyouhavethetime,thiswouldbeagreatopportunitytodisplaysomecomplexcodeforstudentstoexamineontheirowntime.Themoreintricatethestringpatternontheposter,themoreintriguingthesamplewillappear.

Bell-workandAttendance[5minutes]

Introduction&ReviewoftheProject[10minutes]

1. Inheritancemakesitconvenienttoreusecodebetweenclasses.However,sometimeswe’llwanttospecializecodeinasubclass,orignoreamethodthatdoesn’tapply.Askstudentsforexampleswhenthismightbethecase.Ifthey’rehavingtroublethinkingofconcreteexamples,askthemtothinkofanexamplefromtheirownclasshierarchythattheycreatedinthepreviouslesson.Someexamplestogettheclassstarted:

SubclassMammalmighthaveaspecialcaseofAnimalsuperclassmethodfeedYoung(becausetheylactate).

SubclassHotDrinkmightuseadifferentmethodchugfromtheDrinksuperclass(maybethemethodinvolvessippingorburningyourtongue).

2. Replacingsuperclassbehaviorbywritinganewversionofthemethodsinthesubclassiscalledoverriding.Tooverrideamethod,writethemethodyouwanttoreplaceinthesubclass!Nospecialsyntaxisrequired!

BuildingonourDrinkexamplefromthelastlesson,wecanwriteourownchugmethodforsubclassSugarFreeDrink:

Lesson6.02:OverridingMethods&AccessingInheritedCode

376

Page 377: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

publicvoidchug(doublegulp){

System.out.println(“Yuck,thistastesterrible!”);

}

ComparethistotheDrinksuperclassmethodchug,whichisreproducedhereforconvenience:

publicvoidchug(doublegulp){//SuperclassDrinkmethod

if(ounces<gulp){

thrownewIllegalArgumentException();

}else{

System.out.println("Glug,glug,glug!");

ounces-=gulp;

System.out.println("Youhave"+ounces+"oz.ofdrinkleft.");

}

}

3. Havestudentspointoutthedifferencesbetweenthetwomethods,predictthenewoutput,andofferadditionaloralternativechangestotheoverriddenSugarFreeDrinkchugmethod.

Makesurethatthey(oryou)pointoutthatthenumberofouncesinthedrinkwillNOTbeupdatedintheoverriddenmethodasitstands.

4. Itwouldbealotofextraworktore-writetherestoftheglugmethodifallyouhadwantedtodowasaddanextraprintlnstatementthatweputintheoverriddenmethod.Fortunately,thereisawaytoaccessthatmethodtoputitbackintoournew,overriddenmethod(highlightedbelow):

publicvoidchug(doublegulp){

System.out.println("Yuck,thistastesterrible!");

super.chug(gulp);

}

Thismethodnowoutputs“Yuck,thistastesterrible!”,updatesthenumberofouncestoreflecttheamountyoudrank,throwsanexceptionifyoudon’thaveanyounces,andoutputsthenumberofouncesleftinthedrink.

Askstudentswhyit’svalidtocalltheoverriddenmethodchug,andreferencethesuperclassmethodchugbythesamename.(Thesuperclassmethodisaccessedusingdotnotation,whichtellsJavawheretodirecttheflowofcontrol.)

5. WhatifwewanttoaccessotherinformationdirectlyfromtheDrinkclass?Remember,ourdrinkclasshadafieldsforname,hasCarbonation,gramsOfSugar,andounces,butthey’reallprivatebecauseweweresmartandrememberedtoencapsulatethem.

Lesson6.02:OverridingMethods&AccessingInheritedCode

377

Page 378: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

IfwewantedtowriteamethodinourSugarFreeDrinksubclassthataccessesthedatacontainedinname,wewouldhavetoaddagetmethodfirstintheSuperclassDrink:

publicdoublegetName(){//WritteninsuperclassDrink.

returnname;

}

Thismakesacopyofnamethatispublic,andcanbeaccessedoutsideoftheDrinkclass.Nowwecangoaheadandwriteoursubclassmethodusingtheaccessor(highlightedbelow):

publicvoidadvertising(){

System.out.println(

"Avoidtheextracaloriesbydrinkingdelicious"+getName()+"ever

yday!!"

);

}

6. HavestudentsofferadditionalexamplesusingtheDrinksuperclass,orusingexamplesfromtheirownclasshierarchy.

7. Completetheintroductionbyaskingstudentstoexplainwhatthedifferenceisbetweenoverridingandoverloadingmethods.(Overloadingmethodsiswhenoneclasscontainsmultiplemethodswiththesamename,butadifferentnumberofparameters—sometimescalledtheparametersignature.)

StudentWork[15minutes]

1. BrieflyreviewWS6.2withyourstudents,readingthedirectionsaloudifneedbe.

2. Ifyouhaven’talreadydistributedprojectmaterialsatthispoint,dosowhileyourstudentsarerearrangingintopartnerpairs.

3. Encouragestudentstotake5–10minutesonStep1.Theyshouldreviewallstepsoftheprojecttoensurethattheiradditionalmethodsmakesense.

Announcethatyou’llofferextracredittofunnyorcreativecode(ifthatfitsinwithyourteachingstyle).

4. Offertimecheckssostudentscanstayonpace.Beforeyouallowstudentstobeginthepeerreviewtourofothers’work,remindthemtotakenotesontheirfeedbacksotheywillbeabletocontributetothegroupcritique/discussionattheendofclass.

Lesson6.02:OverridingMethods&AccessingInheritedCode

378

Page 379: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

PeerReview[10minutes]

Allowstudents10minutestotoureachother’sworkandofferfeedback.

Whole-groupDiscussion/Critique[10minutes]

Ifpossible,rearrangestudentseatsintoacircleforthecritiquetoencourageinformaldiscussion.

Asawholegroup,askstudentstovolunteerwhattheyreallylikedaboutothers’projects.

Solicitquestionsandcritiques,andre-teachifneeded.

Awardclassroomparticipationpointstoallstudentswhocontributetothediscussion.

AccommodationandDifferentiationEncourageadvancedstudentstoaddadditionalclasses,fields,methods,andclientcode.Ifstudentsstillhavetimetospare,encouragethemtoincreasecodecomplexity,addadditionallevelstotheclasshierarchy,orhelptheirpeers.

Ifyouhaveafewstudentsthatarestrugglingwiththeassignment,allowthemtoworkingroupsof4,eachpairhelpingtheotherwiththeircode.Ifstudentsneedadditionalguidance,havestudentscompletetheworksheetasaseriesofthink-pair-shares,whereyoureturntowholegrouptoshareanddiscussanswersbeforemovingontothenextstep.Teachingtheclassthiswaywillroughlydoublethetimerequiredtocompletetheexercise.

MisconceptionsWhenfirstlearningpolymorphism,studentslearnmethodoverridebeforemethodoverload.However,inordertosuccessfullyoverrideamethod,thesubclassmethodmusthavethesamemethodsignatureasthesuperclass,otherwisethemethodwillbeoverloaded.Thecodemustmatchthemethodparametersandreturntypeandthemethodspublic,theycannotbeprivateorstatic.Whenhelpingstudentsdebugtheircodewheretheoverriddenmethodisnotbehavingasanticipated,askingthestudentifthemethodsignaturesmatchcanhelpfindtheerrorontheirown.

Video

Lesson6.02:OverridingMethods&AccessingInheritedCode

379

Page 380: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

BJP9-2,Polymorphismhttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c9-2

CSE142,Polymorphism(35:07–49:57)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=8a0a0287-877b-42df-99fc-e9f551929bef&start=2107

ForumdiscussionLesson6.02OverridingMethods&AccessingInheritedCode(TEALSDiscourseaccountrequired)

Lesson6.02:OverridingMethods&AccessingInheritedCode

380

Page 381: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson6.03—InteractingwiththeObjectSuperclass

Overview

Objectives—Studentswillbeableto…

Replacesuperclassbehaviorbywritingoverridingmethodsinthesubclass.Writesubclassmethodsthataccesssuperclassmethods.

Assessments—Studentswill…

CompletePractice-ItquestionsCompleteaworksheet

Homework—Studentswill…

ReadBJP9.3upto“InterpretingInheritanceCode.”

Materials&PrepProjectorandcomputerWhiteboardandmarkersClassroomcopiesofWS6.3,Poster6.3Poster6.3Empty&washed,ornon-refrigerated,drinkbottles,withlabelsaffixed(optional)

Poster6.3issettoprintamovie-sizedposterof15”x20”.Ifyoudonotwanttoprintaposterthissize,accessthe.pptxversionoftheposter,andresetthepagesizetolegal,ledger,orwhateverlarger-formatpaperyouhaveavailabletoyou.Note:Somefontsonthisposterprintincrediblysmall.

Arrangethedrinkbottlesinaspacewherestudentscanpickthemupandlookatthemifneedbe.EncouragestudentstolookatthebottlestogetideasforfieldstheycanuseintheirDrinksubclasses.

PacingGuide

Lesson6.03:InteractingwiththeObjectSuperclass

381

Page 382: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Reviewoftheproject 10min

Studentpractice:Practice-It 15min

Studentpractice:WS6.3 25min

ProcedureMostofstudentpracticetodayisareviewandfurtherintegrationoftheconceptsthatwereintroducedsincethebeginningofthisunit.Theonlynewconceptbeingdrilledtodayistheequalsmethod.

Bell-workandAttendance[5minutes]

ReviewoftheProject[10minutes]

1. AllclassesaresubclassesoftheObjectclass.Whetheryouwriteextendsintheheaderornot,allclassesinherittheObjectclass.ItisbuiltintoJavathisway,soyouneverhavetoexplicitlywriteextendsObjectinaclassheader.

ThismeansthatallcodeinheritssomegeneralizedmethodsthatcomeautomaticallywiththeObjectclass.

2. TheAPexamcoverstoStringandequalsmethodsonly.

AskstudentsiftheyrememberwhattoStringmethoddoes.(Itgivestheclassnamefollowedbyalocationinmemory,whichisn’tveryhelpful,sowealwayscreateourowntoStringmethodswhenwecreateaclass.)

Askstudentsiftheyrememberwhywecan’tjustuse==totestforequalitybetweenobjects.

3. The==operatortestswhethertwoobjectshavethesameidentity,iftheyrefertothesameobject,notwhetherthetwoobjectsareinthesamestate.

Lesson6.03:InteractingwiththeObjectSuperclass

382

Page 383: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Stringz="z";

Stringa=z+z;

Stringb="zz";

a==b;//EvaluatestofalsebecauseaandbrefertodifferentStrings

Stringc=b;

c==b;//EvaluatestotruebecausecandbrefertothesameString

4. Thedefaultequalsmethod(thatcomeswithyourObjectsuperclass)doesthesamethingasthe==operator.(SincetheequalsmethodcomesfromtheObjectsuperclass,itinterpretsitsinputparameterasanobject.)ButforStrings,theequalsmethoddoessomethingsmarter:

a.equals(b);//Evaluatestotruebecausethecontentofaandbarethesame"

zz"

c.equals(b);//EvaluatestotruebecausecandbrefertothesameString

Torewriteanequalsmethodthatcomparesobjectstate(tooverridetheObjectversionoftheequalsmethod),youneedtocasttheobjectinordertoletJavaknowthattheobjectsreallycanbecompared.

TotestiftwoDrinkobjectshavethesamenameandservingsize,youwouldwriteanequalsmethodthatlookslikethis:

publicbooleanequals(Objecto){

Drinkother=(Drink)o;

returnname.equals(other.name)&&(ounces==other.ounces);

}

StudentPractice:Practice-It[15minutes]

1. HavestudentsworkindividuallyorinpairstocompletethefollowingPractice-Itquestions:

a.subclassSyntaxb.inheritanceVariableSyntaxc.CarTruckd.CarTruck2e.MonsterTruck

StudentPractice:WS6.3[25minutes]

Lesson6.03:InteractingwiththeObjectSuperclass

383

Page 384: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Oncestudentshavecompletedtheseexercises,distributeworksheet6.3.

Readthroughthequestionsaloud,ifneeded.

IfyouarehavingthestudentsworkinEclipse,besuretoreviewyourprocedureforsubmittingworkelectronicallybeforestudentsbegin.

EncouragestudentstoexplorethedrinkbottlestogetideasforfieldstheycanuseintheirDrinksubclasses.

AccommodationandDifferentiationAtthispointofthecourse,introducingTextExcelmaybebeneficial.Althoughthestudentsdon’thavetherequiredknowledgetocompletetheproject(yet),TextExcelandcanbeusefulwhenexplainingpolymorphisminthefollowinglessonbecauseofhowcellsaredisplayed.Ifyoudodecidetogothisroute,it’sagoodideatogiveyourclassatleastahalf-daytoworkonTextExceltogetabetterunderstandingofthepromptandwheretheygetstuckintheproject.

Encourageadvancedstudentstoaddadditionalclasses,fields,methods,andclientcode.Ifstudentsstillhavetimetospare,encouragethemtoincreasecodecomplexity,addadditionallevelstotheclasshierarchy,orhelptheirpeers.

Ifyouhaveafewstudentsthatarestrugglingwiththeassignment,allowthemtoworkingroupsof4,eachpairhelpingtheotherwiththeircode.Ifstudentsneedadditionalguidance,havestudentscompletetheworksheetasaseriesofthink-pair-shares,whereyoureturntowholegrouptoshareanddiscussanswersbeforemovingontothenextstep.Teachingtheclassthiswaywillroughlydoublethetimerequiredtocompletetheexercise.

MisconceptionsStudentsoftenhaveconfusiononthedifferencebetweenoverridingvsoverloadingmethods.Thefollowingisachartofthedifferences:

Lesson6.03:InteractingwiththeObjectSuperclass

384

Page 385: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

OverridingMethodwithsamename,

parameters,andreturntype

OverloadMethodswithsamenamebutparametersand/orreturntype

MethodSignature Same Different

Classhierarchy Subclassoverridessuperclass Overloadedmethodcanexist

anywhereinclasshierarchy

Behavior Changebehaviorofsuperclassmethod Multiplebehavior

Execution RunTime CompileTime

VideoCSE143,InteractingwithObjects(2:46–30:39)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=ed2ec8fa-511a-43fe-9c51-7929dc4f10d8&start=166

CSE143,Interactingwalkthrough(30:40–40:10)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=ed2ec8fa-511a-43fe-9c51-7929dc4f10d8&start=1840

ForumdiscussionLesson6.03InteractingwiththeObjectSuperclass(TEALSDiscourseaccountrequired)

Lesson6.03:InteractingwiththeObjectSuperclass

385

Page 386: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson6.04—Polymorphism

Overview

Objectives—Studentswillbeableto…

Definepolymorphism.Tracetheexecutionofmethodsthroughaclasshierarchyandpredictoutput.

Assessments—Studentswill…

CompleteaTracingInheritanceguideCompleteWS6.4

Homework—Studentswill…

ReadBJP9.4“Is-aVersusHas-aRelationships.”Completeself-checkquestions#18,20

Materials&PrepProjectorandcomputerWhiteboardandmarkersClassroomcopiesofWS6.4.1TracingInheritanceGuideWS6.4.2ClasshierarchiesandclientcodefromSection9.3(onboardorprojector)

TheRoundRobinworksheetis11pageslong,soitmaytakeawhiletoprintout/copy.

PacingGuide

Lesson6.04:Polymorphism

386

Page 387: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

IntroductiontoPolymorphism 10min

TracingInheritanceGuide 10min

Studentpractice:WS6.4.1 25min

Gradeaworksheetandannounceclassgrade 5min

ProcedureHookyourclasstodaybydisplayingasampleofpolymorphiccode,andaskingstudentstovoteastowhethertheythinkthecodeisvalid.Raisethestakesbyofferingextraclassparticipationpointstothestudentsthatvotecorrectly.Askstudentstoexplaintheirreasoningbehindtheanswer,andallowalittletimefordebate.

Bell-workandAttendance[5minutes]

IntroductiontoPolymorphism[10minutes]

1. Beforewarnedthatstudentsmayhaveahardtimewithpolymorphicsyntax.Upuntilnow,we’vebeendrillingmatchingkeywordsandtypes.Passingdifferenttypesasparameterswithinthesamemethodmayseemcounterintuitive.Youshoulddrillandrepeatthatsuchbehaviorisonlyvalidwhensubstitutingsubclassobjects.

2. Polymorphismistheabilityforthesamecodetobeusedwithseveraldifferenttypesofobjects.Althoughthesamecodeisused,itwillbehavedifferentlydependingonthetype(class)ofobjectused.

Whydoesthiswork?Itislegalforasuperclassvariabletorefertoanobjectofitssubclass.Referencevariablesdonothavetoexactlymatchthetypeofobjecttheyreferto!

IfpublicclassLionextendsAnimal{…},

thenAnimalsimba=newAnimal();orAnimalsimba=newLion();orLionsimba=newLion();butnotLionsimba=newAnimal();

TheobjectreferredtobysimbareferstoaLionobject,notanAnimalobject.MethodscalledonsimbawillbehavelikeaLionobject(e.g.theLionroars).Itmaybebeneficialtodiscussthefollowingpointswithyourstudents:

Lesson6.04:Polymorphism

387

Page 388: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

i. LionisatypeofAnimalsoitisokaytoassignsimbatoanAnimal.

ii. SinceLionoverridessomeofthemethodsofAnimal,whenwecallthoseoverriddenmethods,we’llstillseethebehaviorLiondefines.

iii. WhenweassignsomethingtoanAnimal,theonlyrequirementisthatitis-a-particularAnimal.Sowecanonlyaccessbehavior(methods)thattheAnimalclassknowsabout.

3. Askstudentstothink-pair-sharetoprovideexamplesofothercorrectassignmentstatements.Whenyoucallonstudentsforexamples,besuretohavestudentsexplainhowthenewobjectswillbehave(whatmethodsapply).

4. IfTextExcelhasalreadybeenintroducedinanycapacity,it’seasytousetheCellsasexamples.TheRealCellclassisthesuperclasstotheValueCell,PercentCellandFormulaCellmakingiteasytogetreturnedvaluesasadouble:

RealCellmyCell=(anysubcell);

myCell.getDoubleValue();//Returnsthedoublevaluetobedisplayed.

5. AskstudentstowalkthroughtheMusicalInstrumentexamplewithyou.

MusicalInstrument[]instruments={

newMusicalInstrument(),

newElectricKeyboard(),

newGuitar(),

newElectricGuitar()

};

for(inti=0;i<instruments.length;i++){

System.out.println(instruments[i]);

instruments[i].pickSound();

instruments[i].playNote();

System.out.println();

}

Haveyourstudentsreadthetableofoutputs(ontheslides)andfillintheoriginalmethodtofindtheiranswer.Itwillhelpthemwiththeworksheet.

TracingInheritanceGuide[10minutes]

1. DistributecopiesofWS6.4.2andreviewthestepsthatallstudentsshouldusetodeterminetheoutputofapolymorphicprogramliketheexampleyoujustshowed.Theyshouldusethishandoutthewaytheyusetheirproblem-solvingalgorithm,asaproceduretobeusedoneverypolymorphicproblem.

Lesson6.04:Polymorphism

388

Page 389: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

2. DemonstrateStep1:UsingtheABCexampleinsection9.3ofthebook,diagramtheclasshierarchy.GivethefirstexamplewithTrickyCodeTipthattheheaderwithoutextendsisthesuperclass,thenhavestudentshelpyoufillouttherestofthisdiagram.

3. DemonstrateStep2:StartingwithclassA(asemphasizedbelow),determinetheoutputforeachmethodlisted.Havestudentsfillinthistableintheirnotes,volunteeringanswersforclassesB,C,andD.

4. DemonstrateStep3:ProjecttheclientcodeABCDMainandaskstudentstousethetabletopredicttheoutcomefromthecode.Thecorrectoutputisgivenbelow:

Lesson6.04:Polymorphism

389

Page 390: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

A

A1

A2

A

A1

B2

C

C1

A2

C

C1

D2

PlacetheclasshierarchyforclassesE,F,GandHontheprojector(alsoinsection9.3).GivestudentsafewminutestousetheTracingInheritanceguidetocreateatableofoutputforclassesE,F,GandH.

StudentPractice:WS6.4.1[25minutes]1. Round-robinisadrillinganderror-checkingexerciseusedwithworksheets.Students

writetheirnameontheworksheet,completethefirstproblem,thenpassthepapertothestudentontheright(orwhateverdirectionyouchoose).Thenextstudentfirstchecksthepreviousanswer,correctingitifneedbe,thencompletesthesecondquestion.Eachstudentthenpassesonthepaperagain.Bytheendoftheexercise,eachstudenthascheckedandcompletedeachquestionontheworksheet.

2. ThehookisthatyouchooseonlyONEworksheetfromthepiletograde.Allstudentsgetagradefromthatoneworksheet.Thiskeepsstudentsinvestedthroughouttheexercise.Advancedstudentswillcheckquestionsthroughoutthewholeworksheet,andallstudentswilltrytheirbesttocatchtheirown(andothers’)mistakes,sincethewholeclasssharestherandomly-selected-paper’sgrade.

i. Sincetoday’sworksheetonlyhas13questions,yourchosenworksheetwillonlyrepresentasubsetoftheclass.

ii. Youshouldstillgradeoneworksheetonly,andgiveneveryonethesamegradefromthatonepaper.Thiswillkeepstakeshighforallstudents,sincetheywon’tknowwhichpaperyouwillselecttograde.

Lesson6.04:Polymorphism

390

Page 391: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

iii. Youshouldtimeeachquestion/checkinginterval,andcall“SWITCH!”whenitistimeforstudentstopassalongpapers.Suggestedtimelimitsaregivenbelow.Ifyounoticethatatimespanistooshortortoolong,adjustalltimespansaccordingly.TimeestimatesasgivenarebasedoffofAPTesttiming.

i. Question1shouldtake5minutes;projecttheA,B,C,andDclassesontheoverhead.

ii. Question2shouldtake1minute.iii. Question3shouldtake5minutes.iv. Question4shouldtake3minutes.v. Question5shouldtake2minutes.vi. Question6shouldtake5minutesvii. Question7shouldtake3minutes.viii. Question8shouldtake5minutes.ix. Question9–13shouldtake2minutesAdjustthetimingonthesequestionsasneeded,buttrytokeepabriskpace.Partoftheengagementfactoristhesenseofurgency.

GradeAWorksheetandAnnounceClassGrade[5minutes]

Iftimeallows,randomlyselecttheworksheetandannouncetheclassgradewithabitoffanfare,congratulatingtheclassonajobwelldone.Otherwise,selectonepapertogradeafterclass,thenreturnthepapertothestudentforstudypractice.

AccommodationandDifferentiationTooptimizethisexercise,youmightconsiderrearrangingstudents(orcreatingapassing-path)thatmixesstudentsofdifferentcodingabilities.Theadvancedstudentscanusetheextratimetocorrectmistakesmadebyothers;iftheyaresittinginproximitytothestudentthatmadetheerror,theywillhaveabetterchanceofexplainingthecorrectanswertothem.

Duetothebriskpaceoftheround-robinrotation,thereshouldn’tbetoomuchdowntimeforanyonestudent.Ifyoudofindastudentthatislookingbored,makeeyecontactwiththemasyouremindtheentireclassthateveryoneshouldbecheckingtheproblemshandedtothemoncetheyaredonewithsolvingtheirassignedproblem.

IntheELLclassroom,youmayneedtoreducethenumberorcomplexityofquestionsofferedontheworksheettocompletethislessoninoneclassperiod.

Reassigntheremovedquestionsashomework,bellwork,orquizzes.

Readeachquestionaloudfortheclass.

Lesson6.04:Polymorphism

391

Page 392: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Dothefirstfewproblems(orasmatteringofproblemsthroughouttheworksheet)asawholegroupforadditionalscaffolding.

Alternatively,youcandotheentireassignment,butallow2classperiodstocompleteeachgroup.

ForumdiscussionLesson6.04Polymorphism(TEALSDiscourseaccountrequired)

Lesson6.04:Polymorphism

392

Page 393: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson6.05—Has-aRelationships

Overview

Objectives—Studentswillbeableto…

Identifyandexplainwhytwoclasseshaveanis-aorahas-arelationship.Createahas-arelationshipbetweentwoclasses

Assessments—Studentswill…

CompleteanAPSectionIIquestion“Trio”

Homework—Studentswill…

ReadBJP9.5

Materials&PrepProjectorandcomputer(ifyouareableto/opttouseEclipsewithyourstudents)WhiteboardandmarkersProjectionorclassroomcopiesofWS6.5(anAPSectionIIquestion)StudentpairassignmentsVideoforhook:https://vimeo.com/18439821

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Introduction(withpairwork) 15min

Studentpractice 25min

Studentshare/wholegroupreview 10min

Procedure

Lesson6.05:Has-aRelationships

393

Page 394: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

HookyourclasstodaywiththeShapeshiftervideo(linkin“Materials&Prep”).Askstudentswhatthedifferentanimalshadincommoninthevideo,andwhatrealanimalshaveincommon.Whatbehaviorsdidtheanimalshaveincommon?Whatwasabehaviorthatstuckoutasuniquetoeachanimal?Theideahereistogetstudentsthinkingabouthowtouseinheritance(andeventuallypolymorphism)toreusecodefordifferentclasses.

Bell-workandAttendance[5minutes]

Introduction(withpairwork)[15minutes]

1. Continuetheclassdiscussionbypromptingstudentstopairupanddrawoutaclasshierarchyincluding:Animal,Carnivore,Tiger,andDonkey.

2. Afterstudentshavecreatedthehierarchy,askthemtoconsidersomebehaviorsthatwouldalsoapplytotheclassesZooandZookeeper.Studentsshouldsharethesebehaviorsandjotthemdownintheirnotebooksforlaterreference.

3. Usingstudent-generatedexamples,illustratetheis-arelationships,andareaswhereyoumightincludehas-arelationships:

Anis-adescribesinheritancebetweenasubclassandasuperclass.Thesuperclassinheritsallthecodefromthesuperclassbecauseyoucanthinkofitasasubsetofthesuperclass.(Hopefullyastudentcanvolunteerananswerlikethis.)

HavestudentscreateclasshierarchiesforZooStaffandZooFacilities.(Somestafftitlescouldbezookeeper,customerservicerepresentative,ortrainer.Typicalzoofacilitiesincludebathrooms,giftshops,andcafeterias.)

Lesson6.05:Has-aRelationships

394

Page 395: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Has-adescribestherelationshipbetweenaclassthatisclientcodeofanotherclass.Theclassisacomponentofthe“clientclass,”andoneobjectcontainstheother.Tocreateahas-arelationship,writeafieldintheclassthatreferstotheotherclass:

publicclassZoo{

privateAnimal[]animals;

privateZooMember[]zooMembers;

privateZooFacility[]zooFacilities;

Wecreatefieldsthatrefertootherclasses(highlighted)tocreateahas-arelationship.Whenyoucan’tsubstituteoneclassforanother,youshoulduseahas-arelationship.Azooisnotananimal(orarrayofanimals),norisitastaffmember(orarrayofstaffmembers).Azoocontains,orhas,allofthesecomponents.

StudentPractice[25minutes]

1. Studentsshouldremainintheirstudentpairs.Ifyourclassroomhascomputers,studentsshouldcompletethefollowingexerciseinEclipse,andyoushouldreviewtheprotocolforsubmittingassignmentselectronically.

2. Beforestudentsgetstarted,askstudentswhattypesofmealstheyseeinfastfoodrestaurants,andwhatoptionsaretypicallybundledtogether.Guidestudentstodiscuss:

i. Sandwiches:chicken,burger,fish

ii. Drinks:soda,water,juice,coffee,milk

iii. Sides:Frenchfries,onionrings,tatertots,salad,appleslices

Intheexampleshere,ChickenSandwich,BurgerSandwich,FishSandwich,SodaDrink(etc.)aresubclasses.Averyrichclasshierarchycanbeformedhere!Explaintostudentsthatthey’regoingtogeneratecomplexcodethatusesinheritanceandpolymorphismtomodelthestateandbehaviorofValueMeals.

Lesson6.05:Has-aRelationships

395

Page 396: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

3. Ontheprojector,whiteboard,orasahandout,givestudentsthe2014APexamSectionIIquestion4problem“Trio.”AcopyofthisproblemhasbeenincludedinyourmaterialsasWS6.5.

4. Givestudents≈20minutestowriteanddebugtheirsamplecode.Walkaroundtheroomcheckingonstudentsandofferingguidanceiftheyarestuckoronthewrongpath.Chooseoneortwostudentpairstosharetheircodewiththeclassduringwhole-groupdiscussion,andhelpthosestudentssaveandtransfertheirfilestotheprojectingcomputer.

StudentShare/WholeGroupReview[10minutes]

Inawholegroup,askforstudentstosharetheircodeandexplainhowtheestablishedthehas-arelationshipbetweenclasses.Checkforstudentunderstandingbyaskingwhyahas-arelationshipwasmoreappropriatethancreatingais-a(hierarchical)relationship.

AccommodationandDifferentiation

CommonQuestions/Issues

YoumayhavetoremindstudentstowritetoStringmethodsintheotherclassesaswell.HavestudentsdemonstrateflowofcontrolonthetoStringmethodtodemonstratewhyatoStringmethodinthe“clientclass”willrequireatoStringmethodintheotherclasses.

Checktomakesurestudentsareusingprivatefields.Ifyou’reseeingmanystudentsusingpublicfields,pausetheclasstoleadawholegroupdiscussionaboutwhyencapsulationissoimportant.(TheY2Kbugisaparticularlyexcitingexampleofwhathappenswhenwedon’tencapsulatecode.Besuretodescribethepanicanddoomsdaypredictionsthatthiscaused!)

Ifyourstudentshavebeenhavingtroubletracingtheflowofcontrolasamethodcallsanothermethodinadifferentclass,takesometimetodemonstratehowtousethestep-intoandstep-overbuttonsinEclipse.

Thestep-overandstep-intobuttonscanbefoundinthetoptoolbar.

Inthescreenshotbelow,thepointerrestsonthestep-intobutton,whichwilladvancetheflowofcontrolonestepatatime.Thestep-overbuttonwilljumptotheendlocationofcontroloncetheentiremethodhasexecuted.

Lesson6.05:Has-aRelationships

396

Page 397: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Ifstudentscompletethisassignmentquickly,encouragethemtoincreasethecomplexityanddepthoftheprogram.Someideastogetstudentsstarted:

IntroduceanAquariumclasswithassociatedhas-aandis-arelationshipstosomeoftheclassesyoualreadycreated.

CreateadditionalsubclassesinAnimal,orclassessuchasAquariumStaffasneeded.

Ifyou’dlikeforstudentstoexpandontheAPquestiongiven,havestudents:

CreateadditionalsubclassesforDrink/Sandwich/Salad(ifnotalreadydone)

CreateaMenuofValueMealoptions,andallowusertoselecttheoptionstheywanttocreateameal

AddservingsizestoDrinkandSide,andcreateaSuperSizeValueMeal

AddpricetoSandwich/Drink/SaladandhaveValueMealpricesbe85%ofthetotalitemprices.

Ifstudentsarestrugglingwiththeassignment,allowmoretime(uptotwoclassperiods)tocompletethelesson.Readthepromptaloudfortheclass,anddothestepstogetherifneeded.InclasseswithELLs,youcandistributesavedEclipsefilesthatcontainanentirefunctionalprogram,withshuffledcomponents.Studentswillneedtoorganizethecodefragmentsintotheproperorder(aParsonsproblem).

TeacherPriorCSKnowledgeIs-arelationshipsdefineclasshierarchythroughinheritance,whilehas-arelationshipsdefineclassesthroughtheincorporationofcomponentclasses.

MisconceptionsHas-aimpliesaone-to-onerelationship,whileinmanycases,classeshaveaone-to-manyrelationship.Useexampleswherethehas-a(composition)relationshipismorethanjusta1∶1relationship.Forexample,adeckofcardshas52cards.

Forumdiscussion

Lesson6.05:Has-aRelationships

397

Page 398: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson6.05Has-aRelationships(TEALSDiscourseaccountrequired)

Lesson6.05:Has-aRelationships

398

Page 399: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson6.06—Interfaces

Overview

Objectives—Studentswillbeableto…

Implementanduseinterfaces.

Assessments—Studentswill…

Completeanin-classcompetition

Homework—Studentswill…

ReadBJP9.6Summarizenotesinnotebookfortomorrow’snotebookcheckForextracredit:

GenerateyourownclasshierarchythatdemonstratesthesameconceptsillustratedbytheFinancialClassHierarchyoutlinedinthebook.Theextra-creditprojectisdue[oneweekfromassignment].

Materials&PrepProjectorandcomputer(ifyouareableto/opttouseEclipsewithyourstudents)WhitepaperandmarkersInClassPoster6.6Smallgroupassignments(≈4peoplepergroup)

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Introduction 15min

Classcompetition(smallgroups) 20min

Wholegroupreviewandcompetitionjudging/award 15min

Lesson6.06:Interfaces

399

Page 400: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ProcedureHookyourclassbyannouncingaclasscompetition.FeatureTEALSswag,extracreditpoints,freehomeworkpasses,orraffleticketsasprizes.Breakstudentsintotheirsmallgroupsbeforebeginningyourintroduction.

Bell-workandAttendance[5minutes]

Introduction[10minutes]

1. Beginwithalecture/discussionaboutinheritanceandinterfaces.

2. We’veseenthatinheritanceisausefultoolforprogramming.(Askstudentswhyinheritanceisuseful:itenablespolymorphismandcodesharing.)

Butinheritancehaslimitations:

Askstudentsifwecaninheritcodefrommorethanonesuperclass.(No.)

Ifyouwantanis-arelationshiporpolymorphism,butyoudon’twanttogiveasubclassaccesstothecode,inheritancewon’tgiveyoutheencapsulationyouneed.

3. There’saspecialtoolwecanusecalledaninterfacethatallowsyoutorepresentacommonsupertypebetweenclasseswithoutactuallysharingcode.

Aninterfaceconsistsofasetofmethoddeclarationswithoutamethodbody.

Thinkoftheinterfaceasapromiseofbehavior;themethodisdeclared,butnotdefined.Themethodwillbe(ispromisedtobe)definedinthesubclassmethod.

Ifyoudon’tdefinethemethodinyoursubclass(ifyoudon’tfollowthroughonyourpromise),you’llgetanerror.

4. Demonstratewhatthislookslikeinpractice.Youcanusetheexamplegivenbelow,orasktheclasstohelpyougenerateanexampleoftheirownchoosing.Startwithasketchsostudentscanvisualizetherelationshipsbetweeninterfacesandclasses,andreviewinheritancevocabularyasyouconstructthediagram:

Lesson6.06:Interfaces

400

Page 401: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Interfacesarerepresentedbydottedboxesandarrows,classandclasshierarchiesarerepresentedbysolidlinesandboxes.

Ifyouwishtoshowyourstudentsthatinterfacescanbesharedbyunrelatedclasshierarchies,youcanaddtothediagramaboveasshownbelow.Thecoloroftheinterfacearrowshasbeenchangedtoredsoit’seasiertoseewheretodrawthelines.

Lesson6.06:Interfaces

401

Page 402: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

publicinterfaceSalty{//ThisisapromisetoimplementthesodiumCont

ent

doublesodiumContent();//intheclassthatimplementstheSaltyinterf

ace.

}

publicinterfaceAromatic{

StringdescribeAroma();//Noticethelackof"public"!Publicis*assum

ed*.

}

publicinterfaceGreasy{//Pointoutthatinterfaceslookjustlikeclas

ses

doubleamountOfGreaseInMg();//butwithoutfieldsormethodbodies

}

publicinterfaceEdible{

doublecalories();

}

5. Asyouwritetheclassheaderbelow,pointoutthekeywordimplementsandmatchuptheinterfacesintheheaderwiththeinterfacesinthediagram.

publicclassBaconextendsPorkimplementsSalty,Aromatic,Greasy,Edible{

privatedoubleamountInKg;

publicBacon(doubleamount){

amountInKg=amount;

}

publicdoublecalories(){

returnamountInKg*CALORIES_PER_KG_OF_BACON;

}

Askstudentstopointouttheheaderandtheconstructor.Askthemiftheycanguesswhyyouincludedacaloriesmethod.Iftheydon’tremembertheanswerfromtheirreadingassignment,pointtotheinterfaceswithoutanyadditionalcomment(you’refollowingthroughonyourpromisetoimplementthemethod).

AskstudentsiftheBaconclassiscomplete.HavethemhelpyoufixitbyaddingtheothermethodsyoupromisedtoimplementintheAromatic,Greasy,andSaltyinterfaces.PointoutPoster6.6asanaidtohelpstudentswriteinterfacescorrectly.

ClassCompetition(SmallGroups)[20minutes]

Lesson6.06:Interfaces

402

Page 403: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

1. Ontheboardoroverhead,projectaseriesoffiveinterfacesonathemethatyoufeelwillcreativelyengageyourclass(youshouldblankoutthepartsthatyoufeelwillmaketheexamplemostengaging).Somesampleclassesandinterfaceswithsuggestedmethods:

i. Subclasses:Red,Orange,Yellow,Green,Blue

Interface:colorSampleMethods:doublewavelengthInNm,BooleanisPrimaryColor

ii. Subclasses:Wood,Brick,Adobe,Stone,Canvas

Interface:buildingMaterialSampleMethods:StringmovableHousing,doublecostPerLb

iii. Subclasses:Boeing747,Pheasant,PaperAirplane,Cannonball

Interface:fliesSampleMethods:getMaximumAltitude,getRange,getSpeed

2. Inviteeachteamtoprovideateamname,andexplainthechallenge:

i. Studentsshoulddefineclassestoimplementasmanycombinationsofinterfacesaspossible.

ii. Studentsmustincludeatleast1methodforeachinterface.

iii. Eachclasshastoimplementtheinterfacemethodsandincludeaconstructor.

3. Theteamwiththemostcombinationsofinterfacesattheendofthetimelimit(≈20minutes)winthecompetition.

WholeGroupReview&CompetitionJudging/Award[15minutes]

Leavetimetohavegroupssharetheirinterfaceswiththerestoftheclassduringwholegroupdiscussion.Payattentiontoanyparticularlycreativeorwackyexamplesthatstudentscomeupwith.

AccommodationandDifferentiationIfyourstudentsrequireadditionalpracticewithinterfacesbeforebeginningtheclasscompetition,workthroughbuildingaclassLardthatimplementstheinterfacesGreasyandFoodItem.

DuringtheActivity

Lesson6.06:Interfaces

403

Page 404: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Ifyourstudentsrequireextrascaffolding,generate1methodforeachinterfaceasawholegroupbeforethecompetitionbegins.Writethesemethodsontheboardwiththeinterfacesforeasyreference.

Ifyourstudentsrequireanextrachallenge,changerulec(instep2ofActivity)toincludeadditionalmethodsand/orfields.

TeacherPriorCSKnowledgeAstudentmayaskabouttheIs-AandHas-Arelationshipsintroducedinthepreviouslesson,whicharegreatfordescribinginheritancevscomposition.Butwhataboutinterfaces?TherelationshipthatcanbeusedisCan-Do.Aclassthatimplementsaninterfacecandothebehaviorsspecifiedintheclassitimplements.

MisconceptionsStudentsoftenhaveconfusiononthedifferencebetweenextendsvsimplements.Syntacticallyisfairlystraightforwardtoextendfromasuperclassandimplementfromaninterface.Conceptually,inheritance(extends)isusedtodefineaclasshierarchywherecommonfunctionallyisfactoredoutintothesuperclass.Incontract,interfaces(implements)isusedtoseparateoutthemethodsdefinitionfromthemethodimplementation.Noclasshierarchyisimpliedwhenimplementinganinterface.

VideoBJP9-3,ImplementComparableInterfacehttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c10-3

CSHomeworkBytes,InterfaceandAbstractClasses,withElizabethhttps://www.youtube.com/watch?v=iiZ_TIZsE6Q

CSE143,Interfaces(note:usesArrayIntListwritteninclassasanexample)(3:43–26:35)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=696d623a-dca4-4b64-bdfd-71d49fc9b47d&start=223

ForumdiscussionLesson6.06Interfaces(TEALSDiscourseaccountrequired)

Lesson6.06:Interfaces

404

Page 405: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson6.06:Interfaces

405

Page 406: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson6.07—ProgrammingProject

Overview

Objectives—Studentswillbeableto…

Writecomplexcodethatusespolymorphism,inheritance,andinterfaces.

Assessments—Studentswill…

SubmitmultipleprogramselectronicallyTaketwoquizzesfromtheBarron’sreviewbook

Homework—

AlistofhomeworkassignmentsislistedinthePacingGuide

Materials&PrepProjectorandcomputerWhiteboardandmarkersClassroomcopiesoftextbook(forDay4)Asamplegroceryreceipt(forDay4)

PacingGuide:Day1

Section TotalTime

ProgrammingProjectI Fullclass

Gradestudentnotebooks Duringclass

Homework:OutlineChapter9 TONIGHT

PacingGuide:Day2

Lesson6.07:ProgrammingProject(5Days)

406

Page 407: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

ProgrammingProjectI(Project9.1fromthetextbook) Fullclass

Checkstudentoutlinesforcompleteness Duringclass

Homework:ReadandoutlineChapter4inBarron’sreviewbook TONIGHT

PacingGuide:Day3

Section TotalTime

ProgrammingProjectII(Project9.3fromthetextbook) Fullclass

Homework:TaketheChapter4quiz.Gradeyouranswers. TONIGHT

PacingGuide:Day4

Section TotalTime

ProgrammingProjectIII(Exercise9.3fromthetextbook) Fullclass

Homework:ReadandoutlineChapter3inBarron’sreviewbook. TONIGHT

PacingGuide:Day5

Section TotalTime

TakeChapter3quizINCLASSStudentsgradetheirownanswersandsubmitreviewbooksforagrade.

Fullclass

CheckBarron’sreviewbooksforhighlighting,note-taking,andquizcompletion/grading Duringclass

Homework:ReviewChapter9andsubmit5questionsforreview. TONIGHT

Procedure

Lesson6.07:ProgrammingProject(5Days)

407

Page 408: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Studentsshouldcompletetheprogrammingprojectsontheirown.Readthroughtheinstructionswiththeclass,andhelpstudentspacethemselvesbysettingprogressgoalsforeachday.

Beforelettingstudentsbegintheprojects,askstudentswhatresourcesareavailabletothemsotheycanhelpthemselvesbeforecallingyouover.(Notebooks,textbook,classhandouts,studentworkandpostershangingaroundtheroom,onlineresources.

AboutBarron’s

Barron’sisanAPCSAreviewbookthatsomeschoolsprovidestudents.Ifyourschooldoesn’tprovideBarron’stherearemanyalternativehomeworkassignmentsthatcanbefoundatcodingbat.com/javaorpractice-it.

Alternatively,youcansavetimespentonthelabbycheckingactivitiesashomework.

Ifyou’vechosentointroduceTextExcelearlier,youcanassignportionsofTextExcelashomeworkheretosavetimelaterinthecourse.TextExcellikeFracCalctakesalotofinandoutofclasstimetocomplete,andtimesavedheresavestimeforAPtestreview.

ProgrammingProjects

Ontheoverheadorsharedelectronically,providestudentswiththefollowingprogrammingprompts:

ProgrammingProjectI

Writeaninheritancehierarchyofthree-dimensionalshapes:

1. Makeatop-levelshapeinterfacethathasmethodsforgettinginformationsuchasthevolumeandsurfaceareaofathree-dimensionalshape.

2. Thenmakeclassesandsubclassesthatimplementvariousshapessuchascubes,rectangularprisms,spheres,triangularprisms,cones,andcylinders.

3. Placecommonbehaviorinsuperclasseswheneverpossible,anduseabstractclassesasappropriate.

4. Addmethodstothesubclassestorepresenttheuniquebehaviorofeachthree-dimensionalshape,suchasamethodtogetasphere’sradius.

ProgrammingProjectII

Writeaninheritancehierarchythatstoresdataaboutsportsplayers.

Lesson6.07:ProgrammingProject(5Days)

408

Page 409: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

1. Createacommonsuperclassorinterfacetostoreinformationcommontoanyplayerregardlessofsport,suchasname,number,andsalary.

2. Thencreatesubclassesforplayersofyourfavoritesports,suchasbasketball,soccerortennis.

3. Placesport-specificinformationandbehavior(suchaskicking,verticaljumpheight,orspeed)intosubclasseswheneverpossible.

ProgrammingProjectIII

HavestudentssubmitanswerstoExercise9.3intheirtextbooks.Thisassignmentwillbesubmittedonpaper.Aswritten,studentsarenotgivensomecodethatimplementsGroceryBill,Employee,andItem.Ifyouwishtomakethisanelectronicassignment,youshouldconsiderprovidingstudentswithsomestartercode.

AccommodationandDifferentiationInsomeclassrooms,youmaywanttoprovidethemathematicalformulasforfindingthevolumeofspheres,triangularprisms,cones,andcylinderssostudentscanfocusoncodingratherthanfindingandtranslatingthemath.Youcanalsointroduceandreinforceusefulvocabularybyprovidingphysicalexamplesoftheseshapes.Ifyouarehavingtroublefindingprisms,cones,andcylinders,youcanmaketheseitemsoutofpaperbyprintingouttemplatesandfollowingtheinstructionsatthiswebsite:(http://tinyurl.com/asz6e69)

TohelpstudentsprocessProgrammingProjectIII,youmaywanttoreadthroughexercise9.3inthetextbookwiththeclass,breakingdowntheproblemintoitspartsasawholegroup.InELLclassrooms,youshouldbringinphysicalsamplesofgroceryreceiptsandpassthemaroundorviewthemontheprojector.Havestudentspointoutthedifferentpartsofthereceiptastheyrelatetotheassignment.

Remindstudentstoalwaysdrawastructurediagram,sketchouttheirplanusingpseudocode,andincludecommentstoremindthemselves(andyou!)ofwhateachsectionofcodeisfor.

ForumdiscussionLesson6.07ProgrammingProject(TEALSDiscourseaccountrequired)

Lesson6.07:ProgrammingProject(5Days)

409

Page 410: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson6.07:ProgrammingProject(5Days)

410

Page 411: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson6.08—Finding&FixingErrors

Overview

Objectives—Studentswillbeableto…

Finderrorsintheirreturnedhomeworkassignments.Correcttheircode

Assessments—Studentswill…

Re-submitallhomeworkassignmentswithcorrectedanswers.

Homework—Studentswill…

Reviewforthetestbyby:ReadingoverthebluepagesattheendofChapter9

Submit5questionsforreviewinclasstomorrowusingelectronicsurvey

Materials&PrepAnystudenthomeworkassignmentsthatyouhavenotyetreturnedStudentself-helpsystem(suchasC2B4orstudentpairing)Electronicsurveyforstudentreviewrequests

Thehomeworktonightasksstudentstosubmit5questionsforreview.Createanelectronicsurveyforstudentstocompletewith6textfields,oneforname,and5forquestionstheyhaveaboutCh.9content.Setadeadlinebywhichtimestudentsmusthavesubmitted5questionsfromCh.9Ifstudentsdonothavequestions,stipulatethattheystillhavetosubmitsomethingtoreceivecredit,evenifitisonlyquestionstheythinkotherstudentsmayhave.

PacingGuide

Lesson6.08:Finding&FixingErrors

411

Page 412: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Introductionandhomeworkdistribution 5min

Studentwork 35min

Studentstradework,check,andsubmit 10min

ProcedureTodaywecontinuereinforcingconceptsandapplyingthetools,procedures,andcodethatwereintroducedlastweek.Studentswillhavetheopportunitytocorrectanyincorrecthomeworkorclassworkassignments.Ifstudentsdidnothavetimetofinishthehomeworkfromyesterday,youmayallowthemtimetoworkonthattoday.

Bell-workandAttendance[5minutes]

IntroductionandHomeworkDistribution[5minutes]

1. Returnstudenthomeworkpackets,orhavestudentsplacetheirreturnedhomeworksinapileontheirdesk.

2. Explaintostudentsthattheyhavetheopportunitytogetfullcreditontheirhomeworkgradesbycorrectingthemnow,inclass.Askstudentsforsuggestions/ideasonhowtomakesuretheydon’tmissanyerrors.

Bynowstudentsshouldbeusedtorelyingontheirerrorchecklist/algorithm.

StudentWork[35minutes]

Havestudentsworkindividuallytocorrecttheirhomeworkgrades.

Offertimechecksforstudentssotheystayontask.

Ifstudentshavenotfinishedhomeworkassignments,allowthemtimetodaytocompletetheseassignmentstoturninforpartialcredit.

Studentstradework,check,andturnin[10minutes]

Attheendofclass,havestudentstradetheirhomeworkassignmentstoevaluateeachother’scorrectionsbeforesubmission.

Lesson6.08:Finding&FixingErrors

412

Page 413: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

AccommodationandDifferentiationInELLclassrooms,pairstudentsandallowthemtoworktogethertocorrecttheirwork.

Forthosestudentswhohavenothingtocorrect(orfinishveryearly),rewardthemwithsilentfreetime,orallowthemtoworkonafree-choiceprogrammingproject.

ForumdiscussionLesson6.08Finding&FixingErrors(TEALSDiscourseaccountrequired)

Lesson6.08:Finding&FixingErrors

413

Page 414: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson6.09—Review

Overview

Objectives—Studentswillbeableto…

IdentifyweaknessesintheirUnit6knowledge.

Assessments—Studentswill…

Createapersonalizedlistofreviewtopicstoguidetonight’sstudysession.

Homework—Studentswill…

Studyfortomorrow’stestusingtargetedreviewlist

Materials&PrepProjectorandcomputerWhiteboardandmarkerResultsfromelectronicsurveyofreviewtopics

Oncestudentshavesubmittedtheirreviewrequests,assemblethosetopicsintocategoriesandpreparetore-teachthetopicsasneeded.

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Reviewofstudentquestions 40min

Checkstudentstudylists 5min

Procedure

Bell-workandAttendance[5minutes]

Lesson6.09:Review

414

Page 415: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ReviewofStudentQuestions[30minutes]

1. Clearlyindicatethatyouexpectallstudentstohavealistofreviewtopicstostudythisevening.Periodicallyremindstudentsthatthislistwillbecheckedattheendofclass.

2. Beginwithareviewofstudent-submittedquestionsbeforereviewingthepracticequestions.

3. Finally,workthroughthevariousreviewtopics,prioritizingquestionsthatpoppedupthemost.

Somequestionsyoumayaddresswhileworkingthroughthesampletest.

Bereadyforadditionalquestionstopopupasyougo.Saveyourselftheworkanduseoldhomeworkquestionsandstudent-generatedtestquestionsasexamplestoworkthrough.

4. Useacombinationofgroup-solvingquestionsonthewhiteboard,think-pair-share,andtimed-responseasreviewstrategies.

5. Afteryou’vecompletedreviewinganidea,remindtheclassthattheyshouldwritedownthattopiciftheyfeeltheystillhavetoreviewittonight.

CheckStudentStudyLists[5minutes]

Spendthelast5minutesofclasscheckingeachstudent’sreviewtopiclist.

ForumdiscussionLesson6.09Unit6Review(TEALSDiscourseaccountrequired)

Lesson6.09:Review

415

Page 416: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Test5GuideAswritten,thetestforthisunitisprobablytoolongforstudentstocompleteinoneclassperiod.Extraquestionshavebeenincludedsoyoucan:

1. Pickandchoosewhichquestionswillappropriatelyassessyourstudents.

2. Createdifferentversionsofthetest(ifyou’venoticedthatcheatingisaproblem).

3. SimulateanauthenticAPtestexperience.

Whenmodifyingthetesttosuityourstudents,don’tforgetto:

1. ChangetheheadingsonSectionI&IItoreflecttheactualnumberofquestions.

2. ChangetheheadingsonSectionI&IItoreflectthecorrectpercentagesoftheirtotaltestscore.TheAPexamweightsSectionI&IIat50%oftheoverallscore,each.

3. Adjustthetestpacingforyourclassperiod’stimespan.Theultimategoalistoworkyourstudentsuptoapaceof90secondsperSectionIquestion,and26minutesperSectionIIquestion(includingtimeforchecking).

4. KeeptrackofwhichquestionsyouremovefromthetestsoyoucanusethemduringUnit9testprep/review.

Eveninthefinal(reduced-size)version,thetestwillbeverylong.Besuretotakethisintoaccountwhenphotocopyingversionsofthetest.Ifyouteachmultiplesectionsofthisclass,youmaywanttohavestudentsusebubble-insheetssoyoucanerasestudentmarkingsandre-usetestpacketsbetweenclassperiods.

ForumdiscussionTest5Guide(TEALSDiscourseaccountrequired)

Test5Guide

416

Page 417: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson7.00—TestReview&ReteachN.B.THISLESSONISOPTIONAL(Seebelowfordetails.)

Overview

Objectives—Studentswillbeableto…

Re-learnorstrengthencontentknowledgeandskillsfromUnit6.

Assessments—Studentswill…

Re-submittestanswerswithupdatedcorrectionsforpartialorfullcreditCreditdependsoninstructorpreference

Homework—Studentswill…

ReadBJP13.1upto“Sorting.”Correctanyincorrecttestanswersbyre-answeringonaseparatesheetofpaper

Togetbackcredit,theymustjustifytheirnewanswersStaplenewanswersheettooldtestandturnintomorrow

Materials&PrepProjectorandcomputerWhiteboardandmarkersCorrectedstudenttestsStudentgrades(postedonline,emailedtostudents,orhandedbackonpaperinclass)Digitalcopyoftestquestionsforprojector

Toaccommodateforlate-yearschedulingdrift,Unit7isplannedwith4periodsof“wiggleroom.”Unit7includesalong-formatlabthattakesaminimumof1155-minuteclassperiodstocomplete.IfyoufeelthatyouneedtoplanadditionaltimeforstudentstocompletetheElevenslab,skipthisreviewlesson,andassigntestreviewandcorrectionasahomeworkassignment.Allowstudentstoworktogetherontheassignmentsotheycan

Lesson7.00:TestReview&Reteach

417

Page 418: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

helpeachotherwithcorrectinganswers.ItisagoodideatocheckwitheachgroupbeforetheyleaveclasstoensurethattheyhaveA)exchangedcontactinformation,B)havesetupalocationandtimetodotheassignmenttogether.

Therestofthehomeworkassignmentscanbeshiftedaccordingly,sincetherearefewerhomeworkassignmentsthantherearedaysoftheElevenslab(seeLP7.3forhomeworkschedule).

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Classdiscussion(ifneeded) 10min

Testreviewandreteach 35min

Checkstudentnotesandreturntests 5min

ProcedureReturnstudentgradesbeforeclassbeginsorwhilestudentsarecompletingthebellwork.

Donotreturnstudents’testsbeforethereviewsession,sinceyouwanttomotivatestudentstopayattentiontotheentirereview,takingsupplementalnotestheentiretime.

Bell-workandAttendance[5minutes]

ClassDiscussion(ifneeded)[10minutes]

1. Ifgradesarelow,invitetheclasstoadiscussionofwhatcanbeimproved.Beginwithstudentcomplaintsandsuggestionstobuildstudentbuy-in.Askstudents:

howtheyfelttheyweregoingtodobeforethetestwhatsurprisedthemoncetheyweretakingthetestwhattheyfeltworkedinthefirstunit(lessons,reviewstrategies,assignments)whatdotheythinktheywanttochangeforthesecondunit

2. Onceyoufeelthatadialoguehasbeenestablished,validatestudents’feelings,thenchallengethem(e.g.APcoursesarestressful,butthisisgoodpracticeforcollege,wherethepaceisfasterandprofessorsdon’tgivepersonalizedinstruction).

Lesson7.00:TestReview&Reteach

418

Page 419: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

TestReviewandReteach[30minutes]

1. Walkthestudentsthrougheachquestiononthetest,glossingoverquestionsthateveryoneansweredcorrectly.

i. Youcanaskforstudentstovolunteeranswers,orcallonstudentsrandomly.Makesurethatstudentsexplaintheirlogicwhentheyanswer.Ifastudentgivesanincorrectanswer,theexplanationwilltellyouwhatyouneedtore-teachorclarify.

ii. Donotskipquestionsthateveryoneansweredcorrectly,butdonotspendmorethanthetimeittakestoreadthequestion,andcongratulatestudents’correctanswers.

2. Projectacopyofeachquestionasyoureview—thiswillhelpstudentsrecallthequestion/processtheinformation.

3. Makesurethatstudentsaretakingnotesduringthere-teach,remindingstudentsthatforhomework,theywillhaveanopportunitytowinbacksomeofthepointsontheirexam.

4. ForSectionIIquestions,selectasampleofstudentwork(withanyidentifyinginformationobscured),andworkthroughtheanswertogetherasaclass.

Checkstudentnotesandreturntests[5minutes]

Attheendofclass,checkstudentnotes,andreturnthetestsinhardcopyformifapplicable.

AccommodationandDifferentiationEncourageadvancedstudentstotakeonadditionalprogrammingchallenges.OneeasywaytodothisistoassignProgrammingProjectsfromthebluepagesattheendofeachChapter.

Ifyouhaveafewstudentsthatarestrugglingwiththeclass,choosethesestudentstocreateyourclassroompostersafterschoolorforextracredit.

ForumdiscussionLesson7.00TestReview&Reteach(TEALSDiscourseaccountrequired)

Lesson7.00:TestReview&Reteach

419

Page 420: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson7.01—SearchingAlgorithms

Overview

Objectives—Studentswillbeableto…

Compareandcontrastthedifferentsearchalgorithms.

Assessments—Studentswill…

Completesomeshort-answerquestions.

Homework—Studentswill…

ReadBJP13.1“Sorting.”Completeself-checkquestions#4-6andexercises#1-3

Materials&PrepProjectorandcomputerWhiteboardandmarkersClassroomcopiesofWS7.1CSUnpluggedActivity:SearchingAlgorithms(http://csunplugged.org/searching-algorithms/)ClassroomcopiesofBattleship1A,1A’,1B,1B’,2A,2A’,2B,2B’

IncludedintheCSUnpluggedactivity10-15slipsofpaperwithdifferentintegersprintedonthem(1integerperpaper)IndividuallywrappedsmallcandiesStudentpairassignments

PacingGuide

Lesson7.01:SearchingAlgorithms

420

Page 421: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Intro&demonstration 10min

Studentactivity1:BattleshipLinearSearching 15min

Studentactivity2:BattleshipBinarySearching 15min

Worksheetcompletion/wholegroupdiscussion 10min

ProcedureHookyourstudentsbyplacingthebowlofcandysomewherevisible.Beforetheintroductorylecture,announcethattoday’sclassisa“gameday,”andstudentswillspendtheirtimeinvestigatingcomputeralgorithmsbyplayingBattleship.

Bell-workandAttendance[5minutes]

Intro&Demonstration[10minutes]

1. Beginwithalecture/discussionaboutsearchalgorithms.

2. Computersareusefulbecausetheycanmanagelargecollectionsofdataquicklyandeasily.Askstudentstogivesomeexamplesabouthowlargecollectionsofinformationaremanagedbycomputers.

Examples:Dataaboutitemsforsaleareaccessedasbarcodes,schoolsstoredataaboutstudents,whichcanbeaccessedbystudentname,IDnumber,orgradelevel,weathermenstorehistoricalandcurrentdataaboutatmosphericconditions,etc.

3. Largecollectionsofdataaren’tmanageableunlessweareabletosearchforaparticulardatapoint(datum).

Example:Whenyousearchtheinternet,you’researchingforasinglekeyword(orphrase)calleda“searchkey”withinaparticularwebpage(orsetofwebpages).

4. Eventhoughcomputersworkveryquickly,whenwedealwithsearchinglargedatasets,weneedtousealgorithmsthatarequicktouse.Adifferenceofasecondortwoisactuallyquitealotwhenyouthinkabouthowmanytimesadayweusesearches.

Usingyourphone,theclassclock,awatch,stopwatch,oryourcomputer,demonstratefortheclasswhat3secondsfeelslike.Askstudentstoimagineeachwebsearchtakingthatlong.

Lesson7.01:SearchingAlgorithms

421

Page 422: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Demonstrate10seconds,andaskstudentstoimaginewhatwouldhappeninagrocerystoreifeachitemscannedtook10secondsforthepricelook-up.Askforestimatesonhowlongitwouldtakeasinglefamilytocheckoutgroceriesfortheweek,andhavestudentsofferpredictionsastohowthiswouldaffectbusinessandconsumerexperienceinthestore.

5. Whenwedecideasprogramdesignerswhichsearchingorsortingalgorithmstouse,wefactorin:

i. Thesizeofthedataarrayii. Thespaceefficiencyofthealgorithm(howmuchmemoryituses)iii. Run-timeefficiency(howfastitexecutes)

6. DEMONSTRATION:UsingtheCSUnpluggedguide“IntroductoryActivity,”getyourstudentsthinkingabouttheprocessofandrelationshipbetweensearchingandsortingdata.UsetheintroductoryactivitytointroducetheBattleshipgames.

StudentActivity1:BattleshipLinearSearching[15minutes]

1. Ontheprojectorortheboard,reviewtherulesforBattleships–ALinearSearchingGamefromtheCSUnpluggedactivity.Distributesheets1Aand1Btostudentpairs(facedownsostudentsdon’tseeeachother’spapers).

2. DistributeWS7.1sostudentscananswerquestionsastheyplaytheBattleshipgames.

3. Givestudents≈15minutestoplaytheBattleshipgameandanswerthecorrespondingquestionsontheirworksheets.Studentsthatcompletethegamewithenoughtimetodoasecondroundshouldreceive1A’and1B’.Besuretopaceyourstudentsbyannouncing5minutesbeforetransition.

StudentActivity2:BattleshipBinarySearching[15minutes]

1. UsingtheCSUnpluggedguideforBattleships–ABinarySearchingGame,explaintheupdatedrulesforthisgame.Distributesheets2Aand2Btostudentpairs(facedown).

2. Remindstudentstoanswerthequestionsontheirworksheets.

3. Givestudents≈15minutestocompletethegameandanswertheirworksheets,thencalltheclasstogetherforawholegroupdiscussionoftheiranswers.Studentsthatcompletethegamewithenoughtimetodoasecondroundshouldreceive2A’and2B’.

WorksheetCompletion/Whole-GroupDiscussion[10minutes]

Lesson7.01:SearchingAlgorithms

422

Page 423: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Discusstheworksheetquestionsasaclass,assessingstudentunderstandingandre-teachingasneeded.

AccommodationandDifferentiationToensurethatstudentsunderstandtheassignment,readthequestionsonWS7.1beforestudentsbegintheactivity.

Helpstudentswithmetacognitionbycheckinginwithstudentpairsduringtheactivities.Askthemtoexplaintheirdecisionmakingprocesstoyou,andiftheyarehavingtroublearticulatingtheiralgorithms,askthemtoexplainonedecisionatatime.

Wheneverpossible,youshouldencouragestudentstodo2roundsofBattleshipforeachsearchalgorithm.Thiswillallowstudentstotracktheirownlearning.

Ifyourstudentsareadvancingthroughthecoursequicklyandeasily,youcanaugmentthisunitbyhavingstudentswritecodetoimplementsequentialorbinarysearch.Assignfurtherreadinginthetextbook(thelatter½ofChapter13),anddiscusswithstudentshowtheycanimplementcodethatoperateliketheprocessesexploredduringclass.

TeacherPriorCSKnowledgeAbinarysearchcanbewrittenusingiteration,butbinarysearchlendsitselftowelltorecursion.Atthispointinthecurriculum,studentshavenotlearnedrecursion.Youcanrevisitthebinarysearchalgorithmafterintroducingrecursion.

Big-OnotationisnotpartoftheAPCSAexam.However,somemethodofdenotingrelativesize,whetheritbetimeormemoryusage,needstobeintroduced.Youcanusebig-Onotationorinventoneyourown.

Theexecutiontimeofalinearsearchisn²whiletheexecutiontimeofbinarysearchisn·log (n).Itisnotnecessaryforstudentstofullyunderstandlogarithmsinordertounderstandthatbinarysearchisfasterthanlinearsearchforlargevaluesofn.

VideoBJP13-1,BinarySearchhttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c13-1

2

Lesson7.01:SearchingAlgorithms

423

Page 424: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

CSE143,BinarySearch(1:57–12:41)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=67aa1877-adc1-41d9-9bb6-1621cfa8a99e&start=107

ForumdiscussionLesson7.01SearchingAlgorithms(TEALSDiscourseaccountrequired)

Lesson7.01:SearchingAlgorithms

424

Page 425: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson7.02—SortingAlgorithms

Overview

Objectives—Studentswillbeableto…

Compareandcontrastdifferentsortingmethodsandevaluatetheirrelativespeedandefficiency.

Assessments—Studentswill…

Completesomeshortanswerquestionsonworksheets

Homework—Studentswill…

ReadBJP13.1“Shuffling.”(CheckDifferentiationforadvancedhomeworkassignmentandalternateclassroomactivities)

Materials&PrepProjectorandcomputerWhiteboardandmarkersCSUnpluggedActivity:SortingAlgorithms(http://csunplugged.org/sorting-algorithms)Balancescales(oneforeachgroupofstudents)Classroomcopiesofworksheetactivities(includedinCSUnpluggedActivity)Setsof8containersofequalsizebutdifferentweights(oneforeachgroup)Studentpair/groupassignments

Yourphysics,mathematics,orchemistryteachermayhaveweightsetsandscalesthatyoucanuseforthislesson.Ifyoudonothaveweightsets,usingprescriptionbottles,M&MMinicontainers,oroldfilmcanistersfilledwithdifferentamountsofsandwillalsowork.Ifyoudonothavetimetocollectentiresetsoftheseitems,placingpennies,beans,orsandinsealedpaperlunchbagswillworkinapinch(warning:thiscangetmessyifyourstudentsaren’tcareful!).It’simportanttochooseopaquecontainerssostudentsdon’ttaketheshortcutofeyeballingtheweightsinsteadofusingthescale.

Ifyoucannotfindbalancescales,directionsonhowtomakeasetcanbefoundonthesewebsites:

Lesson7.02:SortingAlgorithms

425

Page 426: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

https://kriegerscience.wordpress.com/2011/09/28/how-to-make-a-set-of-weighing-scales/http://www.wikihow.com/Make-a-Balance-Scale-for-Kids

PacingGuide:Day1

Section TotalTime

Bell-workandattendance 5min

Introduction 10min

Studentactivity1:SortingWeights 35min

PacingGuide:Day2

Section TotalTime

Introduction&Setup 5min

Studentactivity2:DivideandConquer 30min

Wholegroupdiscussion&codedemo 10min

ProcedureHookyourstudentsbyplacingthematerialsforthelessonoutaroundtheroom.

Bell-workandAttendance[5minutes]

Introduction[10minutes]

1. Leadaclassdiscussionaboutwhyitwouldbeimportanttosortdata:

Askstudentswhichsearchingmethodwentfasteryesterday(binarysearch),andwhataprerequisiteforthistypeofsearchwas(arrayneedstobeordered/sorted).

Askforadditionalexamplesofwhenitmightbeimportanttosortdata.(SortingsongsiniTunes,sortinghomeworkassignmentfilesonyourhomecomputer,sortinggoodsinastorebylocation,price,ortype,etc.)

StudentActivity1:SortingWeights[35minutes]

Lesson7.02:SortingAlgorithms

426

Page 427: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

1. Distributeworksheetsfor“SortingWeights”tostudentpairsorgroups.

2. Reviewthedirectionswiththeclass,anddistributematerials.

Ifyourclassisnotfamiliarwithhowtousethescales,takeafewminutestodemonstratetheproperwaytoreadthescalesandrecordtheweightdata.

Besuretoremindstudentstocounthowmanycomparisonstheymakeduringtheactivity!

Makethe“extraforexperts”questionmandatory.

3. Givestudents≈35minutestocompletethisactivity—theywillneedtomake28comparisonsforthisexercise.

DAY2

StudentActivity2:DivideandConquer[30minutes]

1. Brieflyreviewthenextactivityforthe“DivideandConquer”activity.

Pointouttostudentsthattheymusttryouttheadditionalsortingmethodsonthelastpage(insertionsortorbubblesort).

Remindstudentstokeeptrackofhowmanycomparisonstheymakeforeachtypeofsort.

2. Givestudents~30minutestocompletethisactivity,thencalltheclasstogetherforawholegroupdiscussionoftheiranswers.

WholeGroupDiscussion&CodeDemonstration[10minutes]

1. Discusstheworksheetquestionsasaclass;askstudents:

whatsortingalgorithmswerethequickest

whichsortingalgorithmsshouldusemorememory

whichsortingalgorithmsthey’veusedintheirlives,andwhatthosesituationswere.(Someexamplestogetthemstartedincludesortingnotesorhomeworkintodateorder,organizingshuffledcards,etc.)

Lesson7.02:SortingAlgorithms

427

Page 428: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

2. TheAPsubsetdoesnotincludespecificsortingcode,butstudentsarerequiredtoconceptuallyunderstandthemechanismsusedineachofthesortingalgorithms.Studentsshouldbefamiliarwiththebest-andworst-casescenariosforeachofthesortingalgorithms.Givethestudentsasummaryofthisinformationbyhavingstudentscopythenotesbelow,orbyofferingthisinformationasahandout.

SORTINGALGORITHMS

SelectionSort

Foranarrayofnelements,thearrayissortedaftern-1passes.Aftertheithpass,thefirstielementsareintheirsortedposition.

Thestepsare:

1. Thealgorithmdividestheinputlistintotwoparts:thesublistofitemsalreadysorted,whichisbuiltupfromlefttorightatthefront(left)ofthelist,andthesublistofitemsremainingtobesortedthatoccupytherestofthelist.

2. Initially,thesortedsublistisemptyandtheunsortedsublististheentireinputlist.

3. Thealgorithmproceedsbyfindingthesmallest(orlargest,dependingonsortingorder)elementintheunsortedsublist,exchangingitwiththeleftmostunsortedelement(puttingitinsortedorder),andmovingthesublistboundariesoneelementtotheright.

AusefulanimationofselectionsortcanbefoundonWikipediahere:(http://tinyurl.com/muo8ycd).

InsertionSort

Foranarrayofielements,thearrayissortedaftern-1passes.Aftertheithpass,thefirstielementsaresortedwithrespecttoeachother,butnotintheirfinalsortedpositions.Theworst-caseforinsertionsortiswhenthearrayisinitiallysortedinreverseorder(becausesortingtakesthemostnumberofcomparisons/moves).Thebest-casescenarioisifthearrayisinitiallysortedinincreasingorder(becausenoelementswillhavetobemoved).

Thestepsare:

1. Insertionsortiterates,consumingoneinputelementeachrepetition,andgrowingasortedoutputlist.

2. Eachiteration,insertionsortremovesoneelementfromtheinputdata,findsthelocationitbelongswithinthesortedlist,andinsertsitthere.

3. Itrepeatsuntilnoinputelementsremain.

Lesson7.02:SortingAlgorithms

428

Page 429: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

AusefulanimationofinsertionsortcanbefoundonWikipediahere:(http://tinyurl.com/ldw8bj6).

AccommodationandDifferentiationIfyourstudentsneedmoretimetocompletetheexercise,havethemskipthebubblesearchexercise.

Haveseveralshuffleddecksofcardsavailableforstudentstosortiftheyfinishtheexerciseearly.Youcantimestudentsortingandturnitintoacompetitionifyouneedtoofferextraengagement/motivation.

Encouragestudentstowritethealgorithmsfordifferentsortingmethodsintheirownwords.Ifastudentcomesupwithaparticularlywell-wordedexample,encouragethemtoturnitintoaposterorhandoutfortheentireclasstouse.

Ifyouhaveenoughtime,andyourstudentsarefollowingalongwell,haveyourstudentspracticeimplementingsortingcode.UseAPquestions(like#17inthe2009exam)togivestudentspracticeatrecognizingaright-to-leftselectionsortandchoosingthecorrectinnerforloop.

OptionalLesson

Analternativelessonplanisoutlinedhere.Thislessonexaminesthesortingmethodsingreaterdetail,andtakesatleast2classperiodstoconduct.Ifyouarepressedfortime,youshouldnotusetheseplanssincetheytakemoretimetocover,andaddressthematerialinamorechallengingway(thoughtheactivitiesarecleverlydisguisedasfun)!

1. Introducetheseactivitiesinlieuoftheonesmentionedinthelessonplanabove.

Bring8studentstofrontofclassroom,giveeachapieceofpaperwithauniquesimplenumberonit,whichtheyholdsoclasscansee.

Pick“SortMasters”fromtheremainderoftheclasstogivethe8studentsinstructionsabouthowtogetintosmallest-to-biggestorder.

AllowthefirsttwoSortMasterstogiveinstructionswithoutcommentary,unlessitlooksliketheyareexplicitlyusingselectionsort(movelowest/biggestnumbertooneend)orinsertionsort(moveanumbertocorrectposition)orbubblesort(AandBareinwrongorder,soswap),inwhichcasenamewhattheyaredoingandencouragethemtobeexplicitindescribingtheirinstructions.

Lesson7.02:SortingAlgorithms

429

Page 430: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Inthisfirstactivity,donotworryaboutexplicitcomparisonsoftwonumbersatatime,SortMasterscanpicksmallest/largestdirectly.

IfthefirsttwoSortMastershavenotshowninsertionorselectionsort,telltheclassthatthey’regoingtolookatthismoresystematically/algorithmicallynow.

Ifselectionsortnotcovered–askanewSortMasterwhoshouldgofirst?Whoshouldgosecond(selectionsort)?

Ifinsertionsortnotcovered–askanewSortMastertostartwithaskingwhethersecondpersonshouldgobeforeorafterfirst?Wherethirdpersonshouldgorelativetofirstandsecond?

Studentsbacktoseats;askforacomparisonofselectionvs.insertionsort:

Selection:Whogoesinthenextposition?

Insertion:Intowhichpositiondoesthenextpersongo?

2. Activity1A:IntroduceideathatwhileSortMasterscouldeyeballeveryonetoseewhogoesnext,computerscanonlycomparetwothingsatatime.

Distributebalancesandweights.Instructeachteamtostartwithweights1-8inorder.Activity1AisessentiallysameasActivity1,exceptyouexplicitlytellstudentstousetheideaofSelectionSortwhenorderingtheirweights.

Studentsdiscussquestionsintheirgroups,answeringquestionsincludingnumberofcomparisons.

3. Activity1B:StudentsthenmoveontoActivity1B,sameas1A,exceptexamininginsertionsort.Studentsshouldbeexplicitlytoldtoresettheirweightsininitialorder.

Asatrick,setupinitialweightsformostgroupsinrandomorder,butatleastonegroupshouldhaveinitialpositionsinascendingweightorder,andanotherwithweightsindescendingweightorder.

Comebacktoclassdiscussion.Expectgroupstohavesimilarnumbersofcomparesforselectionsort,butwidelydifferentnumbersforinsertionsort.

Asa“grandreveal,”announcethedifferentstartconditions,sostudentswilldiscoverthissignificantbehaviordifferencebetweenselectionandinsertion.

TeacherPriorCSKnowledge

Lesson7.02:SortingAlgorithms

430

Page 431: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Manystudentslearnbubblesortasoneofthefirstsortingalgorithms.Givenbubblesortslargeamountofswappingintheworstcase,itisaterriblesortingalgorithm.However,ifyouaskstudentstoformalinecreatingarandomlistandthentogetinsizeplaceorder,thealgorithmtheyusuallyuseissomesortofbubblesortwhereeachstudentiscomparedtothestudentnexttothem.

Whengivenadeckofrandomcardsandaskedtosortthem,studentsusuallycomeupwitheitherselectionsortorinsertionsort.However,theselectinsortusedtosorttherandomcardsisdifferentfromtheactualalgorithmused.Selectionsortswapsthenextsmallest(orlargest)iteminthelist.However,whenstudentsselectthenextsmallestitem,theyinsertitinthecardsalreadysortedandshifttheremainingcardsdown.Youcanimplementaselectionsortinthismanner,ittakesamuchlargernumberofswaps.

MisconceptionsSelectionsortrequirestheuseofindexesinanarrayinordertokeeptrackofthenextlowest(orhighest)item.Thisrequiresstudentstothinkinonemorelevelofabstraction.Oftentimesstudentswillstartwithsavingthenumberandthenrealizetheyneedtheindex.Whattheyendupwithistwovariables,oneforthesavednumberandonefortheindex.

VideoBJP13-2,Sortinghttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c13-2

CSE143,BubbleSort(optional)(8:34–13:38)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=1fdd364a-4d01-49cf-96b3-ce2f67b77dcf&start=514

CSE143,InsertionSort(13:39–16:13)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=1fdd364a-4d01-49cf-96b3-ce2f67b77dcf&start=819

CSE143,SelectionSort(16:14–17:21)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=1fdd364a-4d01-49cf-96b3-ce2f67b77dcf&start=974

ForumdiscussionLesson7.02SortingAlgorithms(TEALSDiscourseaccountrequired)

Lesson7.02:SortingAlgorithms

431

Page 432: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson7.02:SortingAlgorithms

432

Page 433: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson7.03—ElevensLab

Overview

Objectives—Studentswillbeableto…

Completealong-formlab,demonstratingeffectiveuseofobject-orientedprogramdesign,programimplementationandanalysis,andstandarddatastructuresandalgorithms.

Assessments—Studentswill…

CompletetheElevensLab

Homework—Studentswill…

Alistofhomeworkassignmentsisprovidedbelow.

Materials&PrepElevensLabTeacher’sGuideClassroomcopiesoftheElevensLabStudentGuideAssociatedElevensLabActivityStarterCode

ReadthroughtheTeacher,Student,andExtensionguidesaheadoftimetofamiliarizeyourselfwiththepartsofthislong-formlab.Usingtheguides,completethelabonyourowntospotpossiblechallengesforyourstudents.Sincelaterstartercodepackagesincludeanswerstotheearliersectionsofthelab,werecommendthatyoudonotuploadallstudentfilesontocomputerdesktopsforstudentaccess.Ifpossible,emailActivityNStarterCodetostudentsthedayofthelab.Otherwise,uploadfilesmanuallytoeachdesktopbeforeeachclassperiod.

PacingGuide:Day1

Lesson7.03:ElevensLab(16Days)

433

Page 434: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

StudentActivity1 Fullclass

Homework:Readsection13.3Completeself-checkquestions#16–21,23–24

TONIGHT

PacingGuide:Day2

Section TotalTime

StudentActivity2 Fullclass

Homework:Readsection13.4Completeself-checkquestions#27-30

TONIGHT

PacingGuide:Day3

Section TotalTime

StudentActivity2,continued Fullclass

Homework:Summarizenotesandfillinmissingdaysfornotebookchecktomorrow.

TONIGHT

PacingGuide:Day4

Section TotalTime

StudentActivity3Seenotesforleadingclassroomdiscussionbelow Fullclass

NotebookChecks Duringclass

Homework:OutlineChapter13 TONIGHT

PacingGuide:Day5

Lesson7.03:ElevensLab(16Days)

434

Page 435: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

StudentActivity3,continued Fullclass

NotebookChecks Duringclass

Homework:ReadandhighlightChapter8ofBarron’s(OPTIONAL)

TONIGHT

PacingGuide:Day6

Section TotalTime

StudentActivity4 Fullclass

Gradestudentoutlines Duringclass

Homework:TaketheChapter8examinBarron’sreviewbook.Gradeyouranswers.(OPTIONAL)

TONIGHT

PacingGuide:Day7

Section TotalTime

StudentActivity5(OPTIONAL) Fullclass

CheckBarron’sReviewbooksforhighlighting,notetaking,andpracticetestcompletionandcorrection.(OPTIONAL)

Duringclass

PacingGuide:Day8

Section TotalTime

StudentActivity5,continued(OPTIONAL) Fullclass

CheckBarron’sReviewbooksforhighlighting,notetaking,andpracticetestcompletionandcorrection.(OPTIONAL)

Duringclass

PacingGuide:Day9

Lesson7.03:ElevensLab(16Days)

435

Page 436: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

**StudentActivity6 Fullclass

CheckBarron’sReviewbooksforhighlighting,notetaking,andpracticetestcompletionandcorrection.(OPTIONAL)

Duringclass

Homework:Correctallhomework&classworkassignmentsforresubmissionandgrading

TONIGHT

PacingGuide:Day10

Section TotalTime

StudentActivity7 Fullclass

Homework:Correctallhomework&classworkassignmentsforresubmissionandgrading

TONIGHT

PacingGuide:Day11

Section TotalTime

StudentActivity8 Fullclass

Re-gradecorrectedassignments Duringclass

PacingGuide:Day12

Section TotalTime

StudentActivity9 Fullclass

Re-gradecorrectedassignments Duringclass

PacingGuide:Day13

Lesson7.03:ElevensLab(16Days)

436

Page 437: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

StudentActivity9,continued Fullclass

Re-gradecorrectedassignments Duringclass

Homework:Submit5questionsviaelectronicsurveyfortestreview TONIGHT

PacingGuide:Day14

Section TotalTime

StudentActivity10(OPTIONAL) Fullclass

Re-gradecorrectedassignments Duringclass

PacingGuide:Day15

Section TotalTime

StudentActivity11(OPTIONAL) Fullclass

PacingGuide:Day16

Section TotalTime

StudentActivity11(OPTIONAL) Fullclass

ProcedureAllguides,samplecode,answercode,andexamplecodemaybefoundinthefolder“Milestone3ElevensLab.”

1. Tohelpstudentsstartthelabsmoothly,startActivity1asawholegroup.

2. EncouragestudentstousetheirTrickyCodeCheatSheets,4CommandmentsofScope,notebooks,textbooks,classroomposters,andhomeworkassignments.

3. Offeroccasionaltime-checkstohelpkeepstudentsonpace.

4. Gradenotebooksandreviewbooksinbetweenhelpingstudentssostudentscankeepnotebooksforhomeworkandstudyingintheevenings.

Lesson7.03:ElevensLab(16Days)

437

Page 438: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

AboutBarron’s

Barron’sisanAPCSAreviewbookthatsomeschoolsprovidestudents.Ifyourschooldoesn’tprovideBarron’stherearemanyalternativehomeworkassignmentsthatcanbefoundatcodingbat.com/javaorpractice-it.

Alternatively,youcansavetimespentonthelabbycheckingactivitiesashomework.

NotesforIntroductionLectureforActivity3

1. Theteacher’sguiderecommendsleadingtheactivitywithadiscussiononwhatmakesagoodshufflingalgorithm.

TheCollectionsclasshasamethodcalledshufflethatacceptsalistasitsparameter,andrearrangesitselementsrandomly:

Collections.shuffle(list);//Wherelististhenameofthearrayyouwant

toshuffle.

AskstudentswhatSystem.out.printlnmethodtheycouldcalltogetthetopcard(orfirstelement)ofthearray.

System.out.println("Topcard="+list.get(0));

AccommodationandDifferentiationEachdaythatyoubeginthelab,startwithaquicksurveyofstudentconcernsandquestions.Asneeded,allowstudentstopairuptohelpeachotherwithreadingcomprehension(butremindstudentsthattheyeachmustsubmittheirowncode).

Adaptationsforgroupworkcanbefoundonpage17oftheTeacher’sguide.

InELLclassrooms,readalldirectionsaloudbeforebreakingintoindividualpractice,andallowuptotwicetheamountoftimeforcompletionofthelab.

Tosavetimeonthelab,skiplessonsmarkedasoptional.

Encourageadvancedstudentstoworkthroughtheoptionallabactivities.Otherwise,thesestudentscanserveasstudentTAs,helpingotherswhentheygetstuckoncode.RemindstudentTAsnottogiveanswersdirectly,buttoaskleadingquestionsandmodelingsolutionstosimilarproblems.

Lesson7.03:ElevensLab(16Days)

438

Page 439: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ForumdiscussionLesson7.03ElevensLab(TEALSDiscourseaccountrequired)

Lesson7.03:ElevensLab(16Days)

439

Page 440: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson7.04—Review

Overview

Objectives—Studentswillbeableto…

IdentifyweaknessesintheirUnit7knowledge.

Assessments—Studentswill…

Createapersonalizedlistofreviewtopicstoguidetonight’sstudysession.

Homework—Studentswill…

Studyfortomorrow’stestusingtargetedreviewlist

Materials&PrepProjectorandcomputerWhiteboardandmarkerResultsfromelectronicsurveyofreviewtopics

Oncestudentshavesubmittedtheirreviewrequests,assemblethosetopicsintocategoriesandpreparetore-teachthetopicsasneeded.

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Reviewofstudentquestions 40min

Checkstudentstudylists 5min

Procedure

Bell-workandAttendance[5minutes]

Lesson7.04:Review

440

Page 441: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ReviewofStudentQuestions[30minutes]

1. Clearlyindicatethatyouexpectallstudentstohavealistofreviewtopicstostudythisevening.Periodicallyremindstudentsthatthislistwillbecheckedattheendofclass.

2. Beginwithareviewofstudent-submittedquestionsbeforereviewingthepracticequestions.

3. Finally,workthroughthevariousreviewtopics,prioritizingquestionsthatpoppedupthemost.

Somequestionsyoumayaddresswhileworkingthroughthesampletest.

Bereadyforadditionalquestionstopopupasyougo.Saveyourselftheworkanduseoldhomeworkquestionsandstudent-generatedtestquestionsasexamplestoworkthrough.

4. Useacombinationofgroup-solvingquestionsonthewhiteboard,think-pair-share,andtimed-responseasreviewstrategies.

5. Afteryou’vecompletedreviewinganidea,remindtheclassthattheyshouldwritedownthattopiciftheyfeeltheystillhavetoreviewittonight.

CheckStudentStudyLists[5minutes]

Spendthelast5minutesofclasscheckingeachstudent’sreviewtopiclistasaclassparticipationgrade.

ForumdiscussionLesson7.04Unit7Review(TEALSDiscourseaccountrequired)

Lesson7.04:Review

441

Page 442: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Test6GuideAswritten,thetestforthisunitisprobablytoolongforstudentstocompleteinoneclassperiod.Extraquestionshavebeenincludedsoyoucan:

1. Pickandchoosewhichquestionswillappropriatelyassessyourstudents.

2. Createdifferentversionsofthetest(ifyou’venoticedthatcheatingisaproblem).

3. SimulateanauthenticAPtestexperience.

Whenmodifyingthetesttosuityourstudents,don’tforgetto:

1. ChangetheheadingsonSectionI&IItoreflecttheactualnumberofquestions.

2. ChangetheheadingsonSectionI&IItoreflectthecorrectpercentagesoftheirtotaltestscore.TheAPexamweightsSectionI&IIat50%oftheoverallscore,each.

3. Adjustthetestpacingforyourclassperiod’stimespan.Theultimategoalistoworkyourstudentsuptoapaceof90secondsperSectionIquestion,and26minutesperSectionIIquestion(includingtimeforchecking).

4. KeeptrackofwhichquestionsyouremovefromthetestsoyoucanusethemduringUnit9testprep/review.

Eveninthefinal(reduced-size)version,thetestwillbeverylong.Besuretotakethisintoaccountwhenphotocopyingversionsofthetest.Ifyouteachmultiplesectionsofthisclass,youmaywanttohavestudentsusebubble-insheetssoyoucanerasestudentmarkingsandre-usetestpacketsbetweenclassperiods.

ForumdiscussionTest6Guide(TEALSDiscourseaccountrequired)

Test6Guide

442

Page 443: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson8.00—TestReview&Reteach

Overview

Objectives—Studentswillbeableto…

Re-learnorstrengthencontentknowledgeandskillsfromUnit7.

Assessments—Studentswill…

Re-submittestanswerswithupdatedcorrectionsforpartialorfullcreditCreditdependsoninstructorpreference

Homework—Studentswill…

ReadBJP12.1upto“StructureofRecursiveSolutions”Correctanyincorrecttestanswersbyre-answeringonaseparatesheetofpaper

Togetbackcredit,theymustjustifytheirnewanswersStaplenewanswersheettooldtestandturnintomorrow

Materials&PrepProjectorandcomputerWhiteboardandmarkersCorrectedstudenttestsStudentgrades(postedonline,emailedtostudents,orhandedbackonpaperinclass)Digitalcopyoftestquestionsforprojector

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Classdiscussion(ifneeded) 10min

Testreviewandreteach 35min

Checkstudentnotesandreturntests 5min

Lesson8.00:TestReview&Reteach

443

Page 444: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ProcedureReturnstudentgradesbeforeclassbeginsorwhilestudentsarecompletingthebellwork.

Donotreturnstudents’testsbeforethereviewsession,sinceyouwanttomotivatestudentstopayattentiontotheentirereview,takingsupplementalnotestheentiretime.

Bell-workandAttendance[5minutes]

ClassDiscussion(ifneeded)[10minutes]

1. Ifgradesarelow,invitetheclasstoadiscussionofwhatcanbeimproved.Withyourco-teachersand/orTAsyoushoulddecidehowtoshiftfocusastheAPtestisrightaroundthecorner.Withyourstudents,youshouldfollowthesamepost-mortemformatasinotherreviewunits,butwiththeAPexaminmind.

DoyourstudentswanttofocusonSectionIItesttakingstrategies?

Perhapstheyfeeltheyneedtodrillquick-responseSectionIquestions?

Asasanity-check,studentsshouldberemindedthattheyonlyhave1.5minutestosolveeachSectionIquestionontheAP.Iftheyarenotenearthispace,orifthisisanunrealisticgoal(duetolanguageand/orreadingbarriers),decideasaclasstofocusontest-takingstrategies(skipping,guessing,processofelimination)toreduceanxietyandrecoupsomepotentiallylostpoints.

2. Onceyoufeelthatadialoguehasbeenestablished,validatestudents’feelingsthenchallengethem(e.g.APcoursesarestressful,butthisisgoodpracticeforcollege,wherethepaceisfasterandprofessorsdon’tgivepersonalizedinstruction).Studentscangetverydiscouragedduringthistimeofyear.Inspireandamuseyourclassbypointingoutoldwordwallsorassignments(ifyoustillhavethemup),showingstudentshowfartheyhavecomesincethebeginningoftheschoolyear.

TestReviewandReteach[30minutes]

1. Walkthestudentsthrougheachquestiononthetest,glossingoverquestionsthateveryoneansweredcorrectly.

Youcanaskforstudentstovolunteeranswers,orcallonstudentsrandomly.Makesurethatstudentsexplaintheirlogicwhentheyanswer.Ifastudentgivesanincorrectanswer,theexplanationwilltellyouwhatyouneedtore-teachorclarify.

Lesson8.00:TestReview&Reteach

444

Page 445: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Donotskipquestionsthateveryoneansweredcorrectly,butdonotspendmorethanthetimeittakestoreadthequestion,andcongratulatestudents’correctanswers.

2. Projectacopyofeachquestionasyoureview—thiswillhelpstudentsrecallthequestion/processtheinformation.

3. Makesurethatstudentsaretakingnotesduringthere-teach,remindingstudentsthatforhomework,theywillhaveanopportunitytowinbacksomeofthepointsontheirexam.

4. ForSectionIIquestions,selectasampleofstudentwork(withanyidentifyinginformationobscured),andworkthroughtheanswertogetherasaclass.

Checkstudentnotesandreturntests[5minutes]

Attheendofclass,checkstudentnotes,andreturnthetestsinhardcopyformifapplicable.

AccommodationandDifferentiationEncourageadvancedstudentstotakeonadditionalprogrammingchallenges.OneeasywaytodothisistoassignProgrammingProjectsfromthebluepagesattheendofeachChapter.

Ifyouhaveafewstudentsthatarestrugglingwiththeclass,choosethesestudentstocreateyourclassroompostersafterschoolorforextracredit.

ForumdiscussionLesson8.00TestReview&Reteach(TEALSDiscourseaccountrequired)

Lesson8.00:TestReview&Reteach

445

Page 446: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson8.01—ThinkingRecursively

Overview

Objectives—Studentswillbeableto…

Definerecursion.

Assessments—Studentswill…

DescriberecursivemethodsCompareiterativeandrecursivemethodsduringaclassdiscussion

Homework—Studentswill…

ReadtherestofBJP12.1

Materials&PrepProjectorandcomputerWhiteboardandmarkersBookmarksoneachcomputer(orURLonprojector)for(http://www.softschools.com/games/logic\_games/tower\_of\_hanoi)

YoushouldfamiliarizeyourselfwiththeTowerofHanoiasneeded.The(exhaustive)Wikipediaarticlecoversthedifferentalgorithmsthatmaybeusedtosolvetheproblem(here:http://en.wikipedia.org/wiki/Tower_of_Hanoi).Ifyouarepressedfortime,youshouldreadtheintroduction,origins,iterativeandrecursivesolutionsonly.Thestory/legendassociatedwiththepuzzleissummarizedhere:(http://www.qef.com/oise/hanoi/hanoi01.html).

PacingGuide

Lesson8.01:ThinkingRecursively

446

Page 447: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Activity:TowerofHanoiGame 15min

ClassDiscussion&Solutions 20min

Lecture 10min

ProcedureYourhooktodayistoinvitestudentstoplaytheTowerofHanoigameassoonastheyentertheclassroom.Youshouldnotofferanycluesorhintsastowhytheyareplayingthegame;onlysupplytheinformationoutlinedinthe“Activity”sectionbelow.

Bell-workandAttendance[5minutes]

Activity:TowerofHanoiGame[15minutes]

1. HavestudentsnavigatetotheTowerofHanoigameatthelinklistedin“Materials&Prep”.

2. Tellstudentsthattheyhave15minutestowinthegame.

Astheyplaythegame,theyshouldtakenotesonwhatstrategieshaveworkedandwhichoneshavefailed.(Pointoutthattheyaredevisingtheirownalgorithms.)

Theyarenotallowedtonavigatetoanyotherwebsite.(Ifyoudocatchstudentscheating,it’sactuallyabonus!They’retakingtheinitiativetolearnandunderstandanalgorithmthatusesrecursionJ)

3. Ifstudentsfinishearly:

InvitethemtotrytooptimizetheirsolutionInvitethemtotrythegameusingalargerstackofrings.

4. After10–15minutesofplay(orsooner,ifyouhaveaparticularlyadvancedclass),calltheclassbacktogetherforawholegroupdiscussion.

ClassDiscussion&Solutions[20minutes]

1. Beginthegroupdiscussionwiththefollowingseriesofwarm-upquestions.Usethesesoft-ballquestionstoengagestudentswhoareusuallyshyorquietinclass.

Didyouenjoythegame?

Lesson8.01:ThinkingRecursively

447

Page 448: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Didyouwin/solvethegame?Howlongdidittakeyoutosolvethegame?Haveanyofyoueverplayedthisgamebefore?Haveyouheardofthisgamebefore?

2. Ifyourclassisinterestedinsuchthings,explaintothemthehistoryofthegameanditsinitiallegend(thisinformationcanbefoundfollowingthelinksin“Materials&Prep.”)

3. Askyourstudentsabouttheirsolutions(ornon-solutions,ifnoonehascorrectlysolvedtheprobleminthetimeallotted).

Whatstepsdoyoutaketosolvetheproblem?Whatdoesyouralgorithmlooklike?

Ifstudentssuggestaniterativesolution(foranexample,refertotheWikipediapage),pointoutthatthereisafaster/moreefficientalgorithmtheycanuse.

Ifastudentsuggestsarecursivesolution(ifyouneedanexample,checktheWikipediapage),pointoutthatthissolutionisthefastestsolutiontotheproblem.Intheworldofcomputing,that’sagreatthing!ButinthestoryabouttheBuddhistmonks,weprobablywouldn’twanttosharethissolutionwiththem.

Didanyoneuseadifferentsetofstepsorrules(heuristics)tosolvetheproblem?

Asadesignapproach,whatshouldbeourfirststepinthinkingaboutsolvingthissolution?(Canwebreaktheproblemdownintosmallerproblemsthatareeasiertosolve?)

4. Onceyou’vecompletedadiscussionaboutthealgorithms’studentsused,watchtheanimationasaclass,askingstudentstopointoutwhatpatternstheyseeinthesolution.

Linktoanimationishere:http://www.eisbox.net/blog/2009/04/06/tower-of-hanoi-animation/

Alessattractive,buteasiertofollowanimationcanbefoundhere:https://www.youtube.com/channel/UCMDuzeB8MqT_-AwFGT8qQ-g/search?query=Hanoi

Lecture[10minutes]

1. Providestudentswiththefollowingdefinitions:

Iteration/Iterative:Aprogrammingtechniqueinwhichyoudescribeactionstoberepeatedtypicallyusingaloop.

Recursion/Recursive:Aprogrammingtechniqueinwhichyoudescribeactionstoberepeatedusingamethodthatcallsitself.

Lesson8.01:ThinkingRecursively

448

Page 449: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

2. Askstudentswhichalgorithmsfromyourclassdiscussionwereiterative,andwhichoneswererecursive.Youshouldseeifstudentscancomeupwitha“ruleofthumb”thathelpsthemdecidewhenamethodisrecursiveinsteadofiterative.(Thekeyisthatthemethodwillcallitselfinthemethodbody!)

3. Iftimeallows,watchtheanimationagain,andaskstudentstonarratetheanimationusingrecursivepseudocode.(Correctanswerswillincluderuleslike“TomoveapileofheightNfromAtoC,movethepileofheightN-1fromAtoB,movetheNthdiscfromAtoC,thenmovethepileofheightN-1fromBtoC.”Thisisatoughproblemtoarticulate—theimportantpartisthatstudentsunderstandthatbreakingtheproblemintosmallerpartsisthekeytofindingthesimplestproblemtosolve(nextlessonwilldiscussthe“basecase.”)

Besuretospotcheckstudentsforunderstandingduringtheclassdiscussionandnote-takingsession.Ifyouwouldratherassessstudentsformally,givestudentsaquickticket-to-leaveassignment:havethemhandyouapieceofpaperwiththeirnameandtheirdefinitionofrecursionastheywalkoutthedoor.

AccommodationandDifferentiationIfstudentsneedadditionalmodelingofiterativeandrecursivemethods,reviewtheseexamplesoutlinedinthebookchapter:

ThewriteStarsprogramtakesanintegerparameternandproducesalineofoutputwithnstarsonit.Here’stheiterativesolution(youknowit’siterativebecauseitusesaloop):

publicstaticvoidwriteStars(intn){

for(inti=1;i<=n;i++){

System.out.print("*");

}

System.out.println();

}

ThissameprogramcanbewrittenusingarecursiveversionofthewriteStarsmethod(weknowit’sarecursivemethodbecauseitcallsitselfinthemethodbody):

Lesson8.01:ThinkingRecursively

449

Page 450: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

publicstaticvoidwriteStars(intn){

if(n==0){

System.out.println();

}else{

System.out.print("*");

writeStars(n-1);

}

}

Ifyourstudentsarespeedingthroughthislesson,askthemtotryoutthealgorithmsproposedduringtheclassdiscussion.Havestudentstrackhowmanymoveseachapproachtakes,andhaveyourstudentsexplainifarecursivemethodisfaster.

Forabroaderdiscussionofself-referenceinothercontexts(language,art,andliterature)getstudentsthinkingabouttermslike“neveragain”orplayCarliSimon’s“You’reSoVain”(https://youtu.be/b6UAYGxiRwU).

TeacherPriorCSKnowledgeManyproblemscanbesolvedwitheitheriterationorrecursion.Ingeneral,iterativesolutionsrunfasterthanrecursivesolutionsbecausetherecursivecallhastheaddedoverheadofmakingafunctioncall.Inaddition,thereisamemorycosttoeachfunctioncall.Manycompilerscanoptimizecertaintypesofrecursivealgorithmsliketailrecursiontominimizethedifferenceinexecutiontimeandmemoryusage.

MisconceptionsWhenthebasecaseismetexecutionoftherecursivecallendsandexecutioncontinuesfromtheinitialrecursivecall.Thismaybeconceptuallytruefortailrecursionbutalthoughdesirable,notallrecursivecallsconformtothispattern.

CommonMistakesRecursioncommonmistakes:http://interactivepython.org/runestone/static/JavaReview/Recursion/rMistakes.html

Video

Lesson8.01:ThinkingRecursively

450

Page 451: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

BJP12-1,RecursiveTracinghttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c12-1

CSHomeworkBytes,Recursion,withMaxinehttps://www.youtube.com/watch?v=a2Op-yPcm-A

CSE143,Recursion(6:32–32:28)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=c698c41a-6872-46d3-9c55-87ce2ba78276&start=392

ForumdiscussionLesson8.01ThinkingRecursively(TEALSDiscourseaccountrequired)

Lesson8.01:ThinkingRecursively

451

Page 452: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson8.02—WritingRecursiveSolutions

Overview

Objectives—Studentswillbeableto…

Identifyrecursivemethods.Predicttheoutput(orreturnvalue)ofrecursivemethods.

Assessments—Studentswill…

Evaluatestatementsandpredictoutputduringagameofgrudgeball

Homework—Studentswill…

ReadBJP12.2Completeself-checkquestions#5,7-9andexercise#1

Materials&PrepProjectorandcomputer(optional)WhitepaperandmarkersRulesforgrudgeball(seewebsitefordetails:http://toengagethemall.blogspot.com/2013/02/grudgeball-review-game-where-kids-attack.html)Teamassignmentsthatdivideyourclassinto5or6teamsNerfhoop&ball(orwastepaperandtrashcan)Taped2-and3-pointlines

BrieflyreviewtherulesofGrudgeballifyouhaveforgottenthem.Ifyouhaveremovedyour2and3pointlinesfromlasttimeyouplayed,testoutyour2and3pointlinesbeforeclassbegins.IfyoudonotwishtoplayGrudgeballinyourclassroom(orifyouareunableto),mostGrudgeballquestionscanbefoundintheself-checkquestionbankfor12.1.

PacingGuide

Lesson8.02:WritingRecursiveSolutions

452

Page 453: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Introductionandnote-taking 15min

Activity:Grudgeball 35min

ProcedureTohookyourclassfortoday’smaterial,andifspaceandwhiteboardsetupallow,setupthegrudgeball“court”andscoreboardbeforeclassbegins.Remindstudentsthatlecturecontentwillbetestedduringthegame.

Bell-workandAttendance[5minutes]

Introductionandnote-taking[10minutes]

1. Beginbyaskingstudentswhatmakesamethodrecursive(itcallsitself).Askstudentstooffersuggestionsastohowtowritearecursivemethod.Usingpseudocode(oractualcode,iftheyofferit),outlinetheirsuggestionontheboard.Itshouldlooksomethinglikethis:

publicstaticvoidwriteStars(intx){

writeStars(x-1);//Printsastar.

}

2. Don’tworryifstudentsdon’tincludeabasecase!Congratulateyourstudentsonrememberingthatthemethodcallsitself,thenaskstudentshowthismethodissupposedtostop.(Itwon’t!Thisiscalledinfiniterecursion.)Tomakesurethatyouwriterecursivemethodsthatwork,youneedtoremember2keyingredients:

Basecase:acasewithinarecursivesolutionthatissosimple,itcanbesolvedwithoutneedingtocallthemethodagain(arecursivecall).

Recursivecase:Acasewithinarecursivesolutionthatinvolvesreducingtheoverallproblemtoasimplerproblemofthesamekindthatcanbesolvedbyarecursivecall.

3. Addthese2ingredientstotheexampleyoucurrentlyhaveontheboard.Itshouldlooksomethinglikethis:

Lesson8.02:WritingRecursiveSolutions

453

Page 454: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

publicstaticvoidwriteStars(intx){

if(x==0){

//Thisisthebasecase:"write0stars"needsnoadditionalmethod.

System.out.println();

}else{

//Thisistherecursivecase:writeonestar,thenwritehowevermany

//starsareleft.

System.out.println("*");

writeStars(x–1);

}

}

4. Emphasizetostudentsthatyoucanwritemorethanonerecursivecase,butyoumustalwayshaveatleast1basecaseand1recursivecase,orthecodewon’twork.(Becauseyouneedbothtypesofcases,recursivesolutionsareoftenwrittenasif/elseornestedstatements.)

5. Askstudentstoexplainwhatdoesn’tworkaboutthiscode,andaskthemtocorrecttherecursivecodehere:

publicstaticvoidwriteStars(intx){

System.out.print("*");

writeStars(n-1);

}

There’sarecursivecase,whichisgood,butthereisnobasecase!Thiscausesinfiniterecursionsinceithasnowayofstopping.Insteadofstoppingat0stars(whichiswhatthebasecasewouldbe),thecodewilltrytowrite-1,-2,-3…starsforever!

Activity:Grudgeball[35minutes]

1. Dividestudentsintotheirassignedteams.

2. Reviewtherulesforgrudgeball,andhavethestudentsrepeattherulesbacktoyou.

3. Usingtheproblemslistedbelow(andanyyoumayadd,dependingonyourclass’needs),playgrudgeballuntilateamwins,oruntiltheclassperiodends.

Ifaclassgetstheanswerwrong,BRIEFLYpausethegametohavestudentsoffercorrectionsbeforemovingtothenextteam’squestion.

Ifcorrectionseemstobedraggingon,jumpinandquicklyre-teachusingtheincorrectanswerasyourexample.Itisimportanttokeepthepacegoingtomaintainstudentinterestinthegame!

Lesson8.02:WritingRecursiveSolutions

454

Page 455: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Gudgeballproblems&answershavebeengroupedassumingthatyouhave6teams.Ifyouhavefewerteams,each“round”willbeshiftedaccordingly,soyoumayhaveroundswheredifferentteamsarepracticingdifferentconcepts.Judgeeachteam’sknowledgegaps,andadjustwhichquestionsyouaskeachgroupaccordingly.

4. QuestionsforyourGrudgeballgamearelistedbelow:

GRUDGEBALLPROBLEMS

ConceptualQuestions

a)Whatisrecursion?b)Howdoesarecursivemethoddifferfromaniterativemethod?c)Whatdoyoulookforinarecursivemethod?(Whatpartsdoesithave?)d)Whatisabasecase?e)Whatisarecursivecase?f)Doesarecursivemethodneedtohavebothbaseandrecursivecases?g)Whydoesarecursivemethodneedtohaveabasecaseandarecursivecase?h)Canarecursivemethodhavemorethanonebasecase?i)Canarecursivemethodhavemorethanonerecursivecase?j)Whathappensifarecursivesolutionismissingabasecase?

Predict-the-OutputQuestions

Usethefollowingmethodforquestionsk–s:

publicstaticvoidmystery1(intn){

if(n<=1){

System.out.print(n);

}else{

mystery1(n/2);

System.out.print(","+n);

}

}

Whatistheoutputproducedbythemethodcallindicated?

k)mystery1(1);l)mystery1(2);m)mystery1(3);n)mystery1(4);

Lesson8.02:WritingRecursiveSolutions

455

Page 456: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

o)mystery1(16);p)mystery1(30);q)mystery1(100);r)mystery1(-1);s)mystery1(2.2);

Predict-the-OutputQuestions(continued)

Usethefollowingmethodforquestionst–x:

publicstaticvoidmystery2(intn){

if(n>100){

System.out.print(n);

}else{

mystery2(2*n);

System.out.print(","+n);

}

}

Whatoutputisproducedbythemethodcallindicated?

t)mystery2(113);u)mystery2(70);v)mystery2(42);w)mystery2(30);x)mystery2(10);

AccommodationandDifferentiationInELLclassrooms,readthequestionsaloudinadditiontoshowingthequestionontheboardorprojector.Considerdistributingaworksheetwiththequestionsonitsostudentscanwritedownanswersduringthegame.

Ifstudentsarehavingdifficultywiththe“predicttheoutput”questions,astep-by-stepexplanationofhowarecursivemethodexecutescanbefoundhere(http://tinyurl.com/lablr3h).Youcanpatternyourexplanations/re-teachingtostudentsusingthesamemethod.

Misconceptions

Lesson8.02:WritingRecursiveSolutions

456

Page 457: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Whentherecursivecallismade,mistakenlythinkingthesameparameterisbeingusedinsteadofadistinctcopyfortherecursivecall.

Theonlytimethebasecaseiscalledisiftheinitialcallisthebasecase.

VideoBJP12-2,ImplementingaRecursiveFunctionhttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c12-2

ForumdiscussionLesson8.02WritingRecursiveSolutions(TEALSDiscourseaccountrequired)

Lesson8.02:WritingRecursiveSolutions

457

Page 458: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson8.03—MechanicsofRecursion

Overview

Objectives—Studentswillbeableto…

Modelhowrecursivemethodsexecute.

Assessments—Studentswill…

WritearecursivemethodModeltheexecutionofthatmethodfortheinstructorModelamethodwrittenbytheirpeers

Homework—Studentswill…

Completeself-check#6,10andexercise#3

Materials&PrepProjectorandcomputerforhook(https://youtu.be/3WBvS_n2oTY)WhiteboardandmarkersClassroomcopiesofWS8.3,TeacherDemo8.3OnepairofscissorsforeachgroupSmallgroupassignments(~4studentspergroup)Classroomcopiesofthetextbook(optional)PrintoutforTeacherDemo8.3(optional)

Carefullyreadthroughthe“MechanicsofRecursion”exampleinsection12.2.YoushouldmakeacopyofWS8.3foryourselfanddotoday’sactivitybeforedeliveringthelessonsoyoucansmoothlydemonstrate(andcheck)howtomodelarecursivemethod.Ifyoudecidetomodelanexamplefortheclassbeforetheactivity,usethepre-printedexamplesostudentscan’tjustcopytheirsamplemethodfromthebook.

PacingGuide[Optional,LessonsVary]

Lesson8.03:MechanicsofRecursion

458

Page 459: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Discussionofhook&introduction 15min

Activity1:ModelingRecursiveMethods 20min

Activity2:ModelingaPeer’sMethods 10min

ProcedureOnyourclassroomprojectororscreen,havetheanimationoftheDragonCurveplayingonaloop(linkin“MaterialsandPrep”).Adjusttheplayertoplay2xspeedtokeepstudentinterest;youmaywanttomutethemusic.Asbell-work,askstudentshowthisanimationisanexampleofrecursion.Theirexplanationshoulddescribetherecursivecaseinpseudocode.

Bell-workandAttendance[5minutes]

DiscussionofHook&Introduction[15minutes]

1. Beginbyreviewingthehook/Bellworkwithstudents.Theremaybesomedebateastowhattherecursiveandbasecasesareforthiscurve;allowtimeforstudentstoargueandcometoconsensus.Studentsshouldunderstandthat(A)thebasecaseisjustasinglestraightline,and(B)therecursivecaseinvolvesrepeatedthelinewitha90°turn.

2. There’sanimportantdistinctiontobemadehere:theanimationslinkedtofromthislessonshowrecursionfromthe“bottomup.”Thisisnotthewaythatrecursionworks.Themodelingactivityisabetterrepresentationoftherecursiveprocess;theanimationsaremeantonlytodemonstratehoweventhesimplestrecursivemethodcanquicklyyieldlarge,complexresults.

Ifyoufeelitmightbehelpfultoshowyourstudentsarecursiveimplementationofdrawingthedragoncurve,youcanfindonehere:https://scratch.mit.edu/projects/65378560/.

Ifyourclassisfairlyadvanced,youmaywanttoskipTeacherDemo8.3.AdvancedstudentswillbenefitfromexploringthemodelontheirownasoutlinedinWS8.3.However,formanyclassesadditionalscaffoldingwillbeneeded.

3. Toperformthedemo,youshould:

CutoutthecardsintheTeacherDemo8.3

Lesson8.03:MechanicsofRecursion

459

Page 460: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Ifyouhaveaclassroomprojector,dothedemonstrationunderthecapturesoyourcardsaremagnifiedtothepointwherestudentsinthebackoftheclassroomcanseewhatyouaredoing.Ifyoudonothaveamagnifyingprojector,youmaywanttodothisdemoasyouwalkaroundtheclass,showingstudentswhatisoneachcard.

ExplaintostudentsthatyouaremodelingJava’scallstack.AcallstackisthewaythatJavakeepstrackofthesequenceofmethodsthathavebeencalled.Themodelyourusingtodayisanotherwayoftrackingflow-of-control.

Tellstudentsthatinyourexampleyou’llbemodelingamethodthatreversesalistofwords.Whenstudentsbreakintogroupsfortheactivity,theywillbewritingtheirownrecursivemethodsandmodelingJava’scallstackforthemethodsthathavebeencalled.

Brieflyreviewthereversemethodintroducedin12.2.

4. ShowstudentsthefirstpieceofpaperformTeacherDemo8.3withthemethoddefinition.

i. Thisshouldlookprettyfamiliartostudents,buthavethempointouttoyoutherecursivecase(input.nextLine())toreview.

ii. Pointouttostudentsthenewfeatureonyourmodelthatholdsthelocalvariableline.Askstudentswhattheythinkthisrepresents?(Itisaplaceinthecomputer’smemorythatstoresthevariableline.)

iii. Askstudentstonarratewhathappenswhenwecallthereversemethod.

iv. Writethethisvariableontheslipofpaper,andaskstudentswhathappensnext.Themethodwillgetcalledagain—butbecauserecursionworksdifferentlythaniterativecode,wedon’tjustrunthroughthemethodagainlikewithaloop.

v. Takeoutthesecondcopyofthereversemethod,andplaceitoverthefirstpaper,asindicatedinthetextbook.Havestudentswalkyouthroughthemethodagainandtellyouwhatlocalvariablewillgetwritteninthestoragespaceatthebottomofthepaper(“is”).

vi. Repeatthesestepsuntilyouhavereachedthebasecase(thefifthsheetofpaper).Askstudentswhatthelocalvariableis,anddiscusswhathappenswhenthereisnowordlefttoreverse.(Theinput.hasNextLine()returnsfalse,sothatmethodterminates.)

vii. Nowremovethatfifthcardfromthepile,revealingthefourthcopyofthemethodagain.LetstudentsknowthatJavareturnstowhereitwasbeforeitexecutedthecallthatjustterminated.

Lesson8.03:MechanicsofRecursion

460

Page 461: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

i. Askstudentswhathappensnext.(Weprinttheline“no?”andterminate.)Writethisoutputontheboardsostudentscankeeptrackoftheoutput.

ii. ThismeansthatJavanowgoestotheplacewhereitwasbeforeitterminatedthiscall.Askstudentswhatyoushoulddonowinyourmodelingofthisrecursivemethod.(Takeoffthiscard,andrevealthethirdmethodcard.)

viii. Continueinthiswayuntilyouhavereturnedtothefirstcard.

ix. Ifyouneedtorepeatsectionsofthisdemo,dosountilyoufeelthat50%ofyourclassunderstandstheprocess.Atthispoint,studentsshouldbeabletohelpeachotherlearntheconceptsduringtheiractivity.

Activity1:ModelingRecursiveMethods[20minutes]

1. Directstudentstoreadthroughallthedirectionsfirstbeforebeginningtheactivity.Pointouttothemthattheywillbecompletingtheirowndemo(similartotheoneyoujustcompleted)usingtheirowncode.

2. Breakstudentsintosmallgroupsanddistributeworksheetsandscissors.

3. Keepstudentsonpacebyannouncing10-and5-minutewarnings.

4. Ifstudentscomplainabouthavingtorewritetheirrecursivecodesomanytimes,pointoutthatit’sagoodthingthatweonlyhavetotypeouttherecursivecodeonce!Inreality,themethoddoesn’texistasmanycopies(thatwouldtakeupalotofmemory!)We’rejustusingphysicalexamplestokeeptrackofhowJavaiscallingeach“round”oftherecursivemethod.

5. Asstudentswork,checkfirstforcorrectrecursivemethods,thenmakeasecondroundhavingstudentsperformtheirmodelingactivityforyou.

6. Besureeachgroupexplains:

Wherethebasecaseis,andwhenthebasecaseoccurs.

Wheretherecursivecaseis.

Whatcausesthemethodtoadvancetothenextroundofrecursion.

Whatcausesthemethodtoterminate.

WhereJavareturnstoafteramethodhasterminated.

Whattheoutputis.

7. Ifstudentsdonotanswerallofthesequestionscorrectly,givethemtimetoregroupandassessthemagainaftertheyhavecorrectedtheirthinking.

Lesson8.03:MechanicsofRecursion

461

Page 462: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Activity2:ModelingaPeer’sMethods[10minutes]

1. After20minutes(orwhenstudentsfinish),havegroupstradecodesheets,andchallengethegroupstoworktheirwaythroughthecodeagain.

2. Keepthemonpacebyannouncingtime(theyonlyhave10minutesforthissecondactivity).Visiteachgroupandaskforgroupstomodelthesenewmethodsforyou.

3. Youcanopttoselectsomestudentgroupsthathaveasmoothpresentationtosharewiththeentireclassbeforeclassdismisses.

Activity3:IterativetoRecursiveandVice-Versa[Optional]

1. Introduceiterativeandrecursivemethodsthatproducethesameresult.Forexample,hereisaniterativeandrecursiveexampleforsolvingfactorials:

//Recursive|//Iteration

intfactorial(intn){|intfactorial(intn){

if(n==1){|intproduct=1;

return1;|for(inti=2;i<=n;i++)

{

}else{|product*=i;

returnn*factorial(n-1);|}

}|returnproduct;

}|}

2. Inviteyourclasstotakearecursivefunctionandturnitintoaniterativefunction.Youcanprovideanewrecursivefunctionortheycanuseone’sthey’vepreviouslyworkedwith.Tohelpyourclass,puttherecursivestepintoaforloopthatworkedtoreachthebasecase[i(=<>)(#)].

3. Discusswhatneededtochangebetweentherecursiveanditerativecalls.

4. Now,askyourclasstodotheinverse;takeaniterativefunctionandturnitintoarecursiveone.Basedoffyourdiscussionandthepreviouschangebetweenrecursionanditeration,thistaskshouldbeeasier.

Activity4:CreatingFractalswithRecursion[Optional]

1. Explaintoyourstudentsthatthedragoncurveweworkedwithearlieriscalledafractal,afractalbeingageometricfigureinwhicheachparthasthesamestatisticalcharacterasthewhole.Theyfollowapatterninwhichsimilarpatternsrecuratprogressivelysmallerscales.

Lesson8.03:MechanicsofRecursion

462

Page 463: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

2. Inviteyourclasstocreatethedragoncurveinpseudocode,theyshouldnoticethatthefigure(theydon’tknowhowtodraw)rotates90°arounditsnearpoint.

3. Now,asaneasieractivity,we’regoingtoplaywiththeKochcurve,whichthecodecanbefoundhereonstack:http://stackoverflow.com/questions/13000994/koch-snowflake-java-recursion.Explainallpartsofthisprogram,specificallythelevel,turning,therecursionindrawKochCurve,andthegpdrawpackagebeingused(myPencilandmyPaper).

TheKochcurvefollowsthreerules:

i. Dividethelinesegmentintothreesegmentsofequallength.

ii. Drawanequilateraltrianglethathasthemiddlesegmentfromstep1asitsbaseandpointsoutward.

iii. Removethelinesegmentthatisthebaseofthetrianglefromstep2.

4. Asafunlesson,letyourclassplaywiththevalues,alteringtheKochcurvetocreatenewdesigns.Awardprizestospecialanduniquefractalsstudentscreateorrequirethatafractal(anditscode)beturnedinattheendofclass.Ifyourclassiscomfortablewiththeactivity,youcanintroducecolorformyPencilwhichopensadoorforinterestingdesigns.

AccommodationandDifferentiationWhileallstudentsshouldwritetheirOWNalgorithm,youshouldencouragestudentstoworkinpairsorsmallgroupssotheycanshareideasandhelpeachotherorganizetheirthoughts.ThisisparticularlyimportantinELLclassrooms,whereemergentEnglishspeakerscanpairwithadvancedEnglishlearners.Ifsomestudentswanttodothisprojectallontheirown,letthem.

Ifyouhavestudentswhoarespeedingthroughthislesson,youshouldencouragethemto:

CreateamnemonicoracrostictorememberallthestepsforcheckingsyntaxerrorsMakeaposterfortheclassroomillustratingthemnemonicoracrosticHelpanotherstudentwiththeworksheet(explain,notsolve-for-them)

AboutErrorCheckinginEclipseIfyourstudentsareenthusiasticabouttheDragonCurve,expandonthediscussionbypointingoutthatthereare2repetitionsintheDragoncurve,oneleftandoneright.Thismeansthatthereare2listsintherecursivecode.

Lesson8.03:MechanicsofRecursion

463

Page 464: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Askstudentstospeculateonwhatthecurvewouldlooklikewith4repetitions.Ananimationofa3Ddragoncurvecanbefoundhere:(https://youtu.be/BnUTikyR1CU)

Forless-advancedclassrooms,youmaywanttopre-populatethegroupworksheetswithrecursivemethods.Thiswillallowstudentstofocusonprocessingtheexecutionofthemethodratherthanstrugglingwithsyntax.Thisisnotrecommendedunlessyouareverypressedfortime.Inmostcases,studentsshouldbepracticingproperlywritingrecursivecode.

VideoBJP12-3,ImplementingaRecursiveMethodhttp://media.pearsoncmg.com/aw/aw_reges_bjp_2/videoPlayer.php?id=c12-3

ForumdiscussionLesson8.03MechanicsofRecursion(TEALSDiscourseaccountrequired)

Lesson8.03:MechanicsofRecursion

464

Page 465: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson8.04—MergeSort

Overview

Objectives—Studentswillbeableto…

UsemergeSorttosortanArrayList.UserecursiontotraverseandArray.

Assessments—Studentswill…

BuildamergealgorithmtobeappliedinmergeSort.

Homework—Studentswill…

Summarizenotesfornotebookchecktomorrow

Materials&PrepProjectorandComputerWhiteboardandMarkersElectronicsurveyforstudentreviewrequests

Thehomeworktonightasksstudentstosubmit2questionsforreview;thenumberisreducedforthisuntilsincethereisfarlessmaterialthanusual.Createanelectronicsurveyforstudentstocompletewith3textfields,oneforname,and2forquestionstheyhaveaboutCh.12content.Setadeadlinebywhichtimestudentsmusthavesubmitted2questionsfromCh.12Ifstudentsdonothavequestions,stipulatethattheystillhavetosubmitsomethingtoreceivecredit,evenifitisonlyquestionstheythinkotherstudentsmayhave.

PacingGuide

Lesson8.04:MergeSort

465

Page 466: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Introductionandhomeworkdistribution 5min

Studentwork 35min

Studentstradework,check,andsubmit 10min

ProcedureTodaywewillreturntosortingandcoverMergeSort.MergeSortactsrecursively;ittakesalist,splitsitdownintosingleelements,andcomparestheelements,mergingthemtogetherinanorderlyfashion.Thefirstpartofthelessoncoversmergeasit’sconceptuallyeasier,thesecondpartofthelessoncoversthesplittingofthelist.

Bell-workandAttendance[5minutes]

IntroductiontoMergeSort[5minutes]

1. Beginyourlecturebybringingtheclassbacktoselectionandinsertionsort.Makethecasethatselectionandinsertionsortbothwork,buttakemoretimeforyourcomputertoprocess(graphinslides).

2. ShowyourclassanexamplediagramofmergeSort;theyshouldrealize(withyourhelp)thattheworstcaseperformanceformergeSortisfasterthaneitherselectionorinsertionsort.

Merge[15minutes]

1. Inviteyourclasstotryandmergetwosortedlistsofnumbers.Howwouldwecomputeasinglesortedlistcontainingallthenumbersinlist1andlist2?Haveyourclasssetupthepseudocode.

Wemustmaintainanindexforeachliststartingat0.

Wemustcreateandemptylisttoholdtheresult.

Whenwehaven’texhaustedourtwolists,insertthesmallestelementatthepointinthenewlistandadvancetheindex.

Lesson8.04:MergeSort

466

Page 467: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

2. Letyourclassworkfor10minutestotryandcreatethemergefunction.Usingtheresponsestheycomeupwith,leadthemtothecorrectmergefunction.(Shownonslides,usingArrayList<Integer>)

MergeSort[30minutes]1. Challengeyourclasstotryandimplementmergeintoasortingalgorithm.Thosewho

havedonethereadingshouldhaveanideaaboutwheretogetstarted,butmaygetstuckontherecursiveportion.

Youcangivethemtheseinstructionstogetstarted:

i. Ifthelist’ssizeis0or1,justreturntheoriginallist(asitisalreadysorted)

ii. Splitthelistparameterintotwolists,of(roughly)equalsize:list1and2.

iii. Sortbothlist1and2.

iv. Mergethetwosortedlists,andreturntheresult.

2. Forlabtoday,yourclasswillbetaskedwithmakingthismergeSortalgorithm.Attheendofclasspostthesolutionupontheboard.

Providehintsthroughouttheprocess,namely:

i. Whenthelist’ssizeis0or1andyoureturntheoriginal,thatisyourbasecase.

ii. SplityourlistsbasedoffArrayList.size().

iii. Themergefunctiondoesmerging.

3. Iftheclassisstruggling,walkthroughtheentiremergeSortalgorithmwiththem,mergeSortiscoveredbytheAPsoabaselevelofunderstandingisimportant.

AccommodationandDifferentiationInELLclassrooms,pairstudentsandallowthemtoworktogethertocorrecttheirwork.Ifyounoticedaparticularproblemwasdifficultforthemajorityofstudents,readthequestionaloudandhelpstudentsworkthroughit.

Forthosestudentswhohavenothingtocorrect(orfinishveryearly),rewardthemwithsilentfreetime,orallowthemtoworkonafree-choiceprogrammingproject.

Video

Lesson8.04:MergeSort

467

Page 468: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

CSE143,SelectionSort(17:22–28:11)https://uw.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=1fdd364a-4d01-49cf-96b3-ce2f67b77dcf&start=1042

ForumdiscussionLesson8.04MergeSort(TEALSDiscourseaccountrequired)

Lesson8.04:MergeSort

468

Page 469: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson8.05—Finding&FixingErrors

Overview

Objectives—Studentswillbeableto…

Finderrorsintheirreturnedhomeworkassignments.Correcttheircode

Assessments—Studentswill…

Re-submitallhomeworkassignmentswithcorrectedanswers.

Homework—Studentswill…

Reviewmaterialsforthequizby:ReviewingallthebluepagesattheendofChapter12forsections12.1and12.2OutlineChapter12uptosection12.3

Submit2questionsforreviewinclasstomorrowusingelectronicsurvey

Materials&PrepAnystudenthomeworkassignmentsthatyouhavenotyetreturnedStudentself-helpsystem(suchasC2B4orstudentpairing)Electronicsurveyforstudentreviewrequests

Thehomeworktonightasksstudentstosubmit2questionsforreview;thenumberisreducedforthisuntilsincethereisfarlessmaterialthanusual.Createanelectronicsurveyforstudentstocompletewith3textfields,oneforname,and2forquestionstheyhaveaboutCh.12content.Setadeadlinebywhichtimestudentsmusthavesubmitted2questionsfromCh.12Ifstudentsdonothavequestions,stipulatethattheystillhavetosubmitsomethingtoreceivecredit,evenifitisonlyquestionstheythinkotherstudentsmayhave.

PacingGuide

Lesson8.05:Finding&FixingErrors

469

Page 470: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Section TotalTime

Bell-workandattendance 5min

Introductionandhomeworkdistribution 5min

Studentwork 35min

Studentstradework,check,andsubmit 10min

ProcedureTodaywecontinuereinforcingconceptsandapplyingthetools,procedures,andcodethatwereintroducedearlier.Studentswillhavetheopportunitytocorrectanyincorrecthomeworkorclassworkassignments.Itmaybethecasethatstudentsneedtopracticethemodelingexercisefromthepreviouslesson.Youshouldsetupasectionoftheroomforstudentstohelpeachothermodelcodeexecutionquietly.

Bell-workandAttendance[5minutes]

IntroductionandHomeworkDistribution[5minutes]

1. Returnstudenthomeworkpackets,orhavestudentsplacetheirreturnedhomeworksinapileontheirdesk.

2. Collectthehomeworkassignmentsfromlastnight,andquicklygradethemwhilestudentsareworkingontheirotherassignments.Returnthoseworksbackimmediatelysostudentscancorrectanyerrors.

Someoftheassignmentsfromthenightbeforemaytakeawhiletograde(especiallyexercise12.3).Youmaywanttohavestudentshelpyouwiththegrading,orextendtheclassworktohomework.Ifyoucannotgrade12.3beforetheendofclass,youmightwanttointegratethisexerciseintoyourtestreviewsession.

3. Explaintostudentsthattheyhavetheopportunitytogetfullcreditontheirhomeworkgradesbycorrectingthemnow,inclass.Askstudentsforsuggestions/ideasonhowtomakesuretheydon’tmissanyerrors.

Bynowstudentsshouldbeusedtorelyingontheirerrorchecklist/algorithm.

StudentWork[35minutes]

Havestudentsworkindividuallytocorrecttheirhomeworkgrades.

Lesson8.05:Finding&FixingErrors

470

Page 471: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Offertimechecksforstudentssotheystayontask.

Ifstudentshavenotfinishedhomeworkassignments,allowthemtimetodaytocompletetheseassignmentstoturninforpartialcredit.

Studentstradework,check,andturnin[10minutes]

Attheendofclass,havestudentstradetheirhomeworkassignmentstoevaluateeachother’scorrectionsbeforesubmission.

AccommodationandDifferentiationInELLclassrooms,pairstudentsandallowthemtoworktogethertocorrecttheirwork.Ifyounoticedaparticularproblemwasdifficultforthemajorityofstudents,readthequestionaloudandhelpstudentsworkthroughit.

Forthosestudentswhohavenothingtocorrect(orfinishveryearly),rewardthemwithsilentfreetime,orallowthemtoworkonafree-choiceprogrammingproject.

ForumdiscussionLesson8.05Finding&FixingErrors(TEALSDiscourseaccountrequired)

Lesson8.05:Finding&FixingErrors

471

Page 472: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson8.06—Review

Overview

Objectives—Studentswillbeableto…

IdentifyweaknessesintheirUnit8knowledge.

Assessments—Studentswill…

CompleteQuiz8.5.

Homework—Studentswill…

ReadandhighlightStudyforQuiz

Materials&PrepProjectorandcomputerWhiteboardandmarkerResultsfromelectronicsurveyofreviewtopics

Oncestudentshavesubmittedtheirreviewrequests,assemblethosetopicsintocategoriesandpreparetore-teachthetopicsasneeded.Ratherthanusinganentireclassperiodforatest,we’recondensedtheChapter12topicsintoaquiz.ThisshouldallowyoumoretimetostartreviewingfortheAPexam.

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Reviewofstudentquestions 40min

Procedure

Lesson8.06:Review

472

Page 473: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Atthebeginningofclasstoday:

Remindstudentsthatthequizisattheendofclasstoday.

Reviewstudent-submittedquestions.

Bell-workandAttendance[5minutes]

ReviewofStudentQuestions[30minutes]

1. Workthroughthevariousreviewtopics,prioritizingquestionsthatpoppedupthemost.

Somequestionsyoumayaddresswhileworkingthroughthesampletest.

Bereadyforadditionalquestionstopopupasyougo.Saveyourselftheworkanduseoldhomeworkquestionsandstudent-generatedtestquestionsasexamplestoworkthrough.

2. Useacombinationofgroup-solvingquestionsonthewhiteboard,think-pair-share,andtimed-responseasreviewstrategies.

3. Afteryou’vecompletedreviewinganidea,remindtheclassthattheyshouldwritedownthattopiciftheyfeeltheystillhavetoreviewittonight.

CheckStudentStudyLists[5minutes]

Spendthelast5minutesofclasscheckingeachstudent’sreviewtopiclist.

Accommodation&DifferentiationThequizfeaturesarecursivemethodtoproducetheFibonaccisequence.Ifyourstudentsneedextrahelp/scaffolding,youmightwanttoshowstudentsthisYouTubevideo(https://youtu.be/dsmBRUCzS7k)andleadaclassdiscussiontoensurestudentsarefamiliarwiththemathinvolved.

ForumdiscussionLesson8.06Review&Quiz(TEALSDiscourseaccountrequired)

Lesson8.06:Review

473

Page 474: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson8.08—QuizReview&Reteach

Overview

Objectives—Studentswillbeableto…

Re-learnorstrengthencontentknowledgeandskillsfromUnit8.

Assessments—Studentswill…

Re-submittestanswerswithupdatedcorrectionsforpartialorfullcreditCreditdependsoninstructorpreference

Homework—Studentswill…

CompletetheassessmentinChapter7ofBarron’sReviewBookCorrectanyincorrectquizanswersbyre-answeringonaseparatesheetofpaper

Togetbackcredit,theymustjustifytheirnewanswersStaplenewanswersheettooldtestandturnintomorrow

Materials&PrepProjectorandcomputerWhiteboardandmarkersCorrectedstudenttestsStudentgrades(postedonline,emailedtostudents,orhandedbackonpaperinclass)Digitalcopyoftestquestionsforprojector

PacingGuide

Section TotalTime

Bell-workandattendance 5min

Quizreviewandreteach 30min

Returnquizzes/starthomeworkassignment 15min

Lesson8.08:QuizReview&Reteach

474

Page 475: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

ProcedureReturnstudentgradesbeforeclassbeginsorwhilestudentsarecompletingthebellwork.

Donotreturnstudents’quizzesbeforethereviewsession,sinceyouwanttomotivatestudentstopayattentiontotheentirereview,takingsupplementalnotestheentiretime.

Bell-workandAttendance[5minutes]

QuizReview&Reteach[30minutes]

1. Ifgradesarelow,invitetheclasstoadiscussionofwhatcanbeimproved.Withyourco-teachersand/orTAsyoushoulddecidehowtoshiftfocusastheAPtestisrightaroundthecorner.Withyourstudents,youshouldfollowthesamepost-mortemformatasinotherreviewunits,butwiththeAPexaminmind.

DoyourstudentswanttofocusonSectionIItesttakingstrategies?

Perhapstheyfeeltheyneedtodrillquick-responseSectionIquestions?

Asasanity-check,studentsshouldberemindedthattheyonlyhave1.5minutestosolveeachSectionIquestionontheAP.Iftheyarenotenearthispace,orifthisisanunrealisticgoal(duetolanguageand/orreadingbarriers),decideasaclasstofocusontest-takingstrategies(skipping,guessing,processofelimination)toreduceanxietyandrecoupsomepotentiallylostpoints.

Studentscangetverydiscouragedduringthistimeofyear.Inspireandamuseyourclassbypointingoutoldwordwallsorassignments(ifyoustillhavethemup),showingstudentshowfartheyhavecomesincethebeginningoftheschoolyear.

2. Walkthestudentsthrougheachquestiononthetest,glossingoverquestionsthateveryoneansweredcorrectly.

Youcanaskforstudentstovolunteeranswers,orcallonstudentsrandomly.Makesurethatstudentsexplaintheirlogicwhentheyanswer.Ifastudentgivesanincorrectanswer,theexplanationwilltellyouwhatyouneedtore-teachorclarify.

Donotskipquestionsthateveryoneansweredcorrectly,butdonotspendmorethanthetimeittakestoreadthequestion,andcongratulatestudents’correctanswers.

3. Projectacopyofeachquestionasyoureview—thiswillhelpstudentsrecallthequestion/processtheinformation.

Lesson8.08:QuizReview&Reteach

475

Page 476: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

4. Makesurethatstudentsaretakingnotesduringthere-teach,remindingstudentsthatforhomework,theywillhaveanopportunitytowinbacksomeofthepointsontheirexam.

5. ForSectionII-typequestions,selectasampleofstudentwork(withanyidentifyinginformationobscured),andworkthroughtheanswertogetherasaclass.

ReturnQuizzes/StartHomeworkAssignment[15minutes]

Attheendofclass,iftimeallows,returnthequizzesandallowstudentssometimetobegintheirhomeworkassignment.

AccommodationandDifferentiationEncourageadvancedstudentstotakeonadditionalprogrammingchallenges.OneeasywaytodothisistoassignProgrammingProjectsfromthebluepagesattheendofeachChapter.Section12.5hasanexcellentrecursivegraphicslabthatwouldbeawonderfulassignmentforadvancedstudents.

Ifyouhaveafewstudentsthatarestrugglingwiththeclass,choosethesestudentstocreateyourclassroompostersafterschoolorforextracredit.

ForumdiscussionLesson8.08QuizReview&Reteach(TEALSDiscourseaccountrequired)

Lesson8.08:QuizReview&Reteach

476

Page 477: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Lesson9.00—ReviewingfortheAPExam

TopicReview&Re-teachingTogetasenseforwhichtopicsyourclassneedstoreview,werecommendadministeringaBarron’spracticeexamasapre-test,anotherasapost-testaftersomereview,thenthe2009releasedAPCSAexam(themostrecentfully-releasedexam)asafinalpractice.

The2009examincludesGridWorldquestions(Freeresponsequestion2,multiplechoicequestions21–25).Instructorscouldhavestudentsskipthesenowobsoletequestions,orreplacethemwithquestionsofsimilardifficultyfromthe2004examtoallowanAPscoretobereasonablycomputed.

Asyoure-teachconcepts,practicequestionsandassessmentscanbegleanedfromtheBellevueInternationalMasteryTests(includedasafilewithintheUnit9materials).Thesetests,writtenandgraciouslysharedbyArthurWatson,provideaneasywaytoretestyourstudents.Shouldyoudecidetousetheseresources,keepthefollowinginmind:

1. Thetestsdonotincluderecursion,searching,orsortingsincethesewerethemostrecentlycoveredunitsbeforewhole-yearreview.

2. Thereare3versionsofeachtest(A,B,andC).Versionsaresimilar,sostudentscanre-takeeachexamafterworkingonmaterialtoearnahigherscore.

3. AsitgetsclosertoAPtesttime,ArthurletshisclassusetheAversiontest/answerkeystostudyfortheBandCversions.

PracticeQuestionsWhetherin-classorforhomework,givingstudentsampleopportunitiestodrilltestquestionswillhelpthemovercometestanxiety.Theresourceslistedbelowprovidepracticematerialusingdifferentlearningmodalities:

Lesson9.00:ReviewingfortheAPExam

477

Page 478: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

WebsiteURL Features

http://APcomputersciencetutoring.comPracticeproblems&solutionsbrokendownbytopic.OldAPmultiple-choicequestions&answers.

http://tinyurl.com/obwpm39 175multiple-choicequestions(self-checking)

http://tinyurl.com/nkauhfb Timedpracticetests,flashcards,featured“questionoftheday.”

TestTakingStrategiesIfyouhavebeenusingtheexamsprovidedwiththiscurriculum,studentsshouldbefamiliarwiththedirectionsandguidingtextoftheAPexam.Duringreview,youshouldpushthetest-takingstrategiescoveredinthewebsitesreferencedbelow:

WebsiteURL Features

http://tinyurl.com/APCSTips OfficialtipsfromtheCollegeBoard.

http://tinyurl.com/APCSlist Test-takingtipsandSectionIItipsfromateacher.

http://tinyurl.com/APCSquickReference SeepageA1forquickreferenceguideincludedwiththeexam.

Accommodation&DifferentiationThereare3availablepracticeexamsyoucangivetoyourstudents.ForELLclassrooms,startbygivingthefirstpracticeexamwithalittleextratime(~10minutes)oneachsection,sotheyhavetimetogetusedtopacingandreading.

Afteryouhavere-taughttopics,assignedpracticetimedpracticeathome,givethenextexamatfulltime,andaskthestudentstoreportbacktoyouwhattheyfeltwerethemostchallengingaspectsoftheexam.

Ifstudentsreportthatreadingisslowingthemdown,takeaclassperiodortwotodrillthewordwallvocabulary.Havestudentspracticereadingandexplainingquestionstoeachother.Atthispoint,repetitioniskey.Strengtheningtopic-specificvocabularyandrecallwillbemorebeneficialthanreviewingadditionaltopics.

Somefunvocabularyreviewstrategiesinclude:

Pictionary:encouragestudentstowritesomecode(orfind,orcircleitinasampleofcodeontheboardorprojector)toillustrateaconceptorterm.

Lesson9.00:ReviewingfortheAPExam

478

Page 479: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Vocabularybingo:Printoutwordwallwords(orchallengingconcepts)onbingocards(youcanmakethemonlinehere:http://osric.com/bingo-card-generator/).Ratherthanjustcallingoutwords,callthedefinitionofthetermorprojectanexampleoftheconceptinsamplecode,havingstudentscomeupwiththewordtheyneedtofindonthebingosheet.

Ifyourstudentsarespeedingthroughthereviewsessions,addadditionalchallengesbystickingtoSectionIIquestions.StudentscanaccessSectionIIquestionsfrom2009–2014ontheAPCSwebsitehere:http://tinyurl.com/m7ljyec.ThemostrecentreleasedSectionIItestquestionsandscoringrubricareincludedwithUnit9materials.2014’squestionsandscoringrubricareavailableontheAPwebsite.

ForumdiscussionLesson9.0ReviewingfortheAPExam(TEALSDiscourseaccountrequired)

Lesson9.00:ReviewingfortheAPExam

479

Page 480: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

APComputerScienceACurriculumDevelopmentThisprojectcontainsthesourcefortheTEALSAPComputerScienceACurriculum.Contentcanbebrowsedinthefollowingways:

OnGitBook—TheofficialsourceforthebookOnGitHub—FromtherepositorycontentsonGitHubLocally–Fromalocalcloneofthedevelopmentrepository

StyleGuidelinesPleasereadtheStyleGuidelinesbeforemodifyingthecontentsofthisrepo.They'reshortandensureconsistencyacrossthedocset.

AuthorsChristineKeefe(CurriculumDeveloper)NathanielGranor(TEALSCoordinator)

LicenseThisworkislicensedunderaCreativeCommonsAttribution-NonCommercial-ShareAlike4.0Internationallicense.SeeLICENSE.mdforthefulllicense.

Acknowledgements

TEALSSummerFellows

BenWatskyJulianBoss

MarkdownConversion&RepoSetup

SteveHollasch

AboutThisCurriculum

480

Page 481: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

KenneyChan

SpecialThanks

GlennDurfeePeterDurham

APCSCurriculumSquadVolunteers

KevinWilsonLeoFranchiMikiFriedmanJimSteinbergerRobynMoscowitzEricHalseyKevinTrotterAndrewSmithPaulRoalesDavidBromanYaelElmatadGlennDurfeePeterDurhamNelsonCollinRalphCaseCharleyWilliamsJeffreyBooth

APCSCurriculumSquadTeachers

NateBinzJanetRobertsBrettWortzmanIngridRoche

AboutThisCurriculum

481

Page 482: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

TEALSAPCSACurriculum—HowtoContribute

RepositoryLocationThecurriculum'ssourcecodeishostedonGithubathttps://github.com/TEALSK12/apcsa-public.Restrictedinstructor-onlycontentishostedathttps://github.com/TEALSK12/apcsa-instructor.

DidyoucatchanerrorintheTEALSAPCSAcurriculum,orperhapshaveanideaforanadditionthatwouldmakeitbetter?Ifso,we'dlovetoseewhatyou'vegot!

MethodsofContributingWecanacceptchangesandsuggestionstothisrepoinabunchofdifferentways,soheretheyarefromleastinvolvedtomost.

CasualCommunication

YoucanmakecommentseitherinourSlackchannel(#apcsa-curriculuminhttps://tealsk12.slack.com)ortouspersonallyviaemailtoKenneyChanorSteveHollasch.IfyouhaveaGitHubaccount,though,it'sbettertosubmitanissue,asthere'sahigherguaranteethatitwon'tgetlost.

SubmitanIssue

Thebestwaytomakesureyourfeedbackisrecognized,tracked,andhandledistosubmitanissueonGitHub.You'llneedaGitHubaccounttodothis.

SubmitaPullRequest(PR)

Thisisthemostinvolvedroute,butmorepowerful.Itworksforallkindsofissues,fromfixingtypostomakingradicalchangesincurriculum.Ofcourse,ifyoudecideonsomethingmassive,makesuretovettheideawithusfirst.

Contributing

482

Page 483: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

Ifyou'redoingsomethingsmallorobvious,andyou'recomfortable,feelfreetojustgostraighttoapullrequest.Foranythingelse,youmightwanttofirstsubmitanissue.Intheissue,mentionthatyou'rewillingtodotheworkyourself.Iftheideaissound,we'llgiveyouthegreenlightbeforeyoucommitanyeffortortime.

HowtoSubmitaPullRequest(Advanced)ThefollowingstepsoutlinetheeasiestwaytosubmitaPR:

1. Createalocalworkingcloneoftheapcsarepository.Ifyouhaven'tdonethisbefore,justgotothemaincodepageandhitthe"Cloneordownload"button.ExplaininghowtouseGitisoutsidethescopeofthispage,soyou'llneedtoknowhowtodothisalready.

2. Createandcheckoutafeaturebranchforyourwork.(Themasterbranchisprotected,andyouwon'tbeabletosubmitchangesthere.)

3. Makeyourchangesinthefeaturebranch.Makesureyoufollowthestyleguidelinesasyoudoso.

4. PushyourbranchuptotheGitHubrepo.Forexample,ifyouworkonthecommandline,andyourfeaturebranchisnamed"moar-glitter",thenyou'ddothis:

gitpushorigin--set-upstreammoar-glitter

ThisjustneedstohappenoncetoestablishtheconnectionbetweenyourlocalbranchandabranchofthesamenameuponGitHub.Afterthat,ifyouhavemorechangestoadd,youcanjustgitpushwhileworkinginyourfeaturebranch.

5. Whenyou'redoneandreadyforreview(andallofyourcommitshavebeenpushed),headtothemaincodepage.Thereyoushouldseeyourbranchinahighlightedboxwitha"Compare&pullrequest"buttonontheright.Ifnot,youcanjusthitthe"Newpullrequest"button.Ifyoudidthelatter,therewillbetwobuttonstocontrolwhichbranchisgoingtomergeintowhich.Inthiscase,thebasebranchshouldbemaster,andthecomparebranchshouldbemoar-glitter.Oncethat'sset,besuretoenteradescriptivecommentaboutthepullrequest.Ifthere'sanassociatedissue,includetheissuenumber,prefixedwitha#character.Forexample,ifthisisafixforissue137,include#137inthecomments.

6. Finally,hitthe"Createpullrequest"button.Thiswillautomaticallynotifythereviewers.Severalthingscouldhappen:

AreviewerapprovesyourPRandmergesitintomaster.Gitbookwillseethechangesandautomaticallybuildanupdatewithyourchangeswithinafewminutes.

Contributing

483

Page 484: Table of Contents - TEALS · Unit 5: Object-Oriented Programming (4 weeks) Lesson 5.00: Test Review & Reteach Lesson 5.01: Object Oriented Programming Lesson 5.02: Object State &

AreviewerrejectsyourPR.Thisshouldn'thappenifyougotapprovalinasubmittedissue.Ifnot,youshouldgetaclearexplanationwhythechangewasnotaccepted.

AreviewermaypointoutproblemswithyourPR,andrequestchangesbeforeapproving.You'llneedtomonitoryourPRtocatchthis.OneaidisthatGitHubtracksnoficationsintheupperrightcornerofthewebpages(thebellicon),andshouldalertyoutochangerequests.

7. Afterthedusthassettled,pleasedeleteyourfeaturebranchfromtheGitHubrepo.Youmayofcoursechoosetokeepitinanylocalclones,butthiswillkeeptheprimaryrepocleanofbranchclutter.Theoneexceptiontothisisifyourfeatureislong-running,andyouplantoissueastringofPRsasworkprogresses.

Hopefully,allwentwell,andyou'vehelpedtomakeourcurriculumevenbetter--thankyou!

Contributing

484