├── .gitignore
├── LICENSE.txt
├── README.md
├── _sources
├── .DS_Store
├── Appendix
│ ├── DrJava.rst
│ ├── Figures
│ │ ├── AddJarToPrefs.png
│ │ └── DrJavaInteractions.png
│ └── gridWorld.rst
├── Array2dBasics
│ ├── .DS_Store
│ ├── Array2dParsonsPractice.rst
│ ├── Exercises.rst
│ ├── Figures
│ │ ├── 2015Q1PartB.png
│ │ ├── 2015q1arr1.png
│ │ ├── 2015q1partB2.png
│ │ ├── 2015q1partBmethods.png
│ │ ├── 2015q1partC.png
│ │ ├── 2015q1partc2.png
│ │ ├── 2DLockers.jpg
│ │ ├── ArrayRowsAndCols.png
│ │ ├── grayImageA.png
│ │ ├── grayImageB.png
│ │ ├── intAndStringArrays.png
│ │ ├── routeCipherFig.png
│ │ ├── routeCipherFig2.png
│ │ ├── routeCipherTable.png
│ │ ├── routeCipherTable2.png
│ │ └── rowMajor.png
│ ├── Summary.rst
│ ├── a2dBasics.rst
│ ├── a2dDAS.rst
│ ├── a2dEasyMC.rst
│ ├── a2dHardMC.rst
│ ├── a2dLoop.rst
│ ├── a2dLoopPart.rst
│ ├── a2dMedMC.rst
│ ├── a2dMistakes.rst
│ ├── a2dPractice.rst
│ ├── freeResponse.rst
│ ├── grayImageA.rst
│ ├── grayImageB.rst
│ ├── routeCipherA.rst
│ ├── routeCipherB.rst
│ └── toctree.rst
├── ArrayBasics
│ ├── .DS_Store
│ ├── ArrayParsonsPractice.rst
│ ├── Exercises.rst
│ ├── Figures
│ │ ├── 2DLockers.jpg
│ │ ├── arrayIndicies.png
│ │ ├── arrayIntAndString.png
│ │ ├── bcTable.png
│ │ ├── bcTable2.png
│ │ ├── bcTable3.png
│ │ ├── horseBarnA.png
│ │ ├── horseBarnB.png
│ │ ├── intAndStringArrays.png
│ │ ├── numberLine.png
│ │ ├── pill.jpg
│ │ ├── rowLockers.jpg
│ │ ├── soundTable.png
│ │ ├── soundTable2.png
│ │ ├── soundTable3.png
│ │ └── soundTable4.png
│ ├── Summary.rst
│ ├── aEasyMC.rst
│ ├── aForEach.rst
│ ├── aHardMC.rst
│ ├── aLoopBackToFront.rst
│ ├── aLoopFrontToBack.rst
│ ├── aLoopPart.rst
│ ├── aMedMC.rst
│ ├── aMistakes.rst
│ ├── aPractice.rst
│ ├── aProcessAll.rst
│ ├── abasics.rst
│ ├── arrayExam.rst
│ ├── freeResponse.rst
│ ├── horseBarnA.rst
│ ├── horseBarnB.rst
│ ├── numberCubeA.rst
│ ├── numberCubeB.rst
│ ├── selfDivisorB.rst
│ ├── soundA.rst
│ ├── soundB.rst
│ └── toctree.rst
├── Conditionals
│ ├── .DS_Store
│ ├── CondParsonsPractice.rst
│ ├── Exercises.rst
│ ├── Figures
│ │ ├── Condition-three.png
│ │ ├── Condition-two.png
│ │ └── Condition.png
│ ├── Summary.rst
│ ├── cComplex.rst
│ ├── cDeMorgans.rst
│ ├── cEasyMC.rst
│ ├── cHardMC.rst
│ ├── cMedMC.rst
│ ├── cMistakes.rst
│ ├── cPractice.rst
│ ├── cShortCircuit.rst
│ ├── cbasics.rst
│ ├── threeOrMore.rst
│ ├── timeFRQ.rst
│ └── toctree.rst
├── FreeResponse
│ ├── ArrayTesterA.rst
│ ├── ArrayTesterB.rst
│ ├── Exercises.rst
│ ├── Figures
│ │ ├── HiddenWordExamples.png
│ │ ├── HiddenWordHints.png
│ │ ├── LatinSquareEx.png
│ │ ├── LatinSquareEx2.png
│ │ ├── NumberGroup.png
│ │ ├── SkyViewBEx.png
│ │ ├── SkyViewClassInfo.png
│ │ ├── SkyViewEx2Array.png
│ │ ├── SkyViewExArray.png
│ │ ├── SkyViewOrder.png
│ │ ├── SkyViewRes1.png
│ │ ├── SkyViewRes2.png
│ │ ├── StringCoderEx.png
│ │ └── StudentAnswerSheetEx.png
│ ├── HiddenWord.rst
│ ├── NumberGroupA.rst
│ ├── NumberGroupB.rst
│ ├── NumberGroupC.rst
│ ├── RandomStringChooserA.rst
│ ├── RandomStringChooserB.rst
│ ├── SkyViewA.rst
│ ├── SkyViewB.rst
│ ├── StringCoderA.rst
│ ├── StringCoderB.rst
│ ├── StudentAnswerSheetA.rst
│ ├── StudentAnswerSheetB.rst
│ └── toctree.rst
├── GettingStarted
│ ├── Exercises.rst
│ ├── Figures
│ │ ├── AddJarToPrefs.png
│ │ ├── BugsRocksFlowers.png
│ │ ├── CreateNewGridWorld.png
│ │ ├── DrJavaBugRunner.png
│ │ ├── DrJavaInteractions.png
│ │ ├── DrJavaPicLab.png
│ │ ├── DrJavaPicLab2.png
│ │ ├── cats.png
│ │ ├── cats2.png
│ │ ├── compile.png
│ │ ├── compiling.png
│ │ ├── cookieCutter.jpg
│ │ ├── finishExam.png
│ │ ├── next.png
│ │ ├── nullStringRef.png
│ │ ├── pause.png
│ │ ├── prev.png
│ │ └── start.png
│ ├── preface.rst
│ ├── pretest.rst
│ └── toctree.rst
├── JavaBasics
│ ├── .DS_Store
│ ├── Exercises.rst
│ ├── Figures
│ │ ├── PersonRun.png
│ │ ├── cats.png
│ │ ├── cats2.png
│ │ ├── checkMe.png
│ │ ├── classVehicleExample.png
│ │ ├── compile.png
│ │ ├── compiling.png
│ │ ├── cookieCutter.jpg
│ │ ├── nullStringRef.png
│ │ ├── run-button.png
│ │ ├── start-audio-tour.png
│ │ └── vehicleDiag.png
│ ├── Summary.rst
│ ├── compileTimeErrors.rst
│ ├── firstClass.rst
│ ├── firstOOClass.rst
│ ├── introClassObject.rst
│ ├── partsOfAClass.rst
│ ├── runClass.rst
│ ├── toctree.rst
│ └── whatIsJava.rst
├── Labs
│ ├── Exercises.rst
│ ├── magpie1.rst
│ ├── magpie2.rst
│ ├── magpie3.rst
│ ├── magpie4.rst
│ └── toctree.rst
├── ListBasics
│ ├── .DS_Store
│ ├── 2016freeresponseQ4A.rst
│ ├── 2016freeresponseQ4B.rst
│ ├── Exercises.rst
│ ├── Figures
│ │ ├── 2016FRQ4A1.png
│ │ ├── 2016FRQ4A2.png
│ │ ├── 2016FRQ4B1.png
│ │ ├── 2016FRQ4C1.png
│ │ ├── checkerTable.png
│ │ ├── checkerTable2.png
│ │ ├── checkerTable3.png
│ │ ├── climbClubA.png
│ │ ├── climbClubA.zip
│ │ ├── climbClubB.png
│ │ ├── cookieOrderTable.png
│ │ ├── cookieOrderTable2.png
│ │ ├── flightTable.png
│ │ ├── fuelDepotTable.png
│ │ ├── fuelDepotTable2.png
│ │ ├── fuelDepotTable3.png
│ │ ├── listInterface.png
│ │ ├── lists.jpg
│ │ ├── stringCoder.png
│ │ ├── stringScrambleB.png
│ │ ├── tileGameDiagram.png
│ │ ├── tileGameDiagram2.png
│ │ ├── tileGameDiagram3.png
│ │ ├── tileGameDiagram4.png
│ │ ├── usb.jpg
│ │ └── whyLists.png
│ ├── ListParsonsPractice.rst
│ ├── Summary.rst
│ ├── climbClubA.rst
│ ├── climbClubB.rst
│ ├── climbClubC.rst
│ ├── cookieOrderA.rst
│ ├── cookieOrderB.rst
│ ├── freeResponse.rst
│ ├── lPractice.rst
│ ├── listAdd.rst
│ ├── listArrayList.rst
│ ├── listDeclareAndCreate.rst
│ ├── listEasyMC.rst
│ ├── listHardMC.rst
│ ├── listInterface.rst
│ ├── listLoop.rst
│ ├── listMedMC.rst
│ ├── listMethods.rst
│ ├── listMistakes.rst
│ ├── listVsArray.rst
│ ├── listbasics.rst
│ ├── stringScrambleB.rst
│ └── toctree.rst
├── LoopBasics
│ ├── Exercises.rst
│ ├── Figures
│ │ ├── ForLoopFlow.png
│ │ ├── WhileLoopFlow.png
│ │ ├── compareForAndWhile.png
│ │ ├── scrambleA.png
│ │ ├── stringScrambleA-ABRACADABRA.png
│ │ ├── stringScrambleA-TAN.png
│ │ └── whileLoopTrace.png
│ ├── LoopParsonsPractice.rst
│ ├── Summary.rst
│ ├── freeResponse.rst
│ ├── lEasyMC.rst
│ ├── lFor.rst
│ ├── lHardMC.rst
│ ├── lMedMC.rst
│ ├── lMistakes.rst
│ ├── lNested.rst
│ ├── lPractice.rst
│ ├── lWhile.rst
│ ├── lbasics.rst
│ ├── selfDivisorA.rst
│ ├── stringScrambleA.rst
│ └── toctree.rst
├── MixedFreeResponse
│ ├── Exercises.rst
│ ├── Figures
│ │ ├── HiddenWordExamples.png
│ │ ├── HiddenWordHints.png
│ │ ├── SkyViewBEx.png
│ │ ├── SkyViewClassInfo.png
│ │ ├── SkyViewEx2Array.png
│ │ ├── SkyViewExArray.png
│ │ ├── SkyViewOrder.png
│ │ ├── SkyViewRes1.png
│ │ ├── SkyViewRes2.png
│ │ ├── StringCoderEx.png
│ │ └── StudentAnswerSheetEx.png
│ ├── RandomStringChooserA2.rst
│ ├── RandomStringChooserB2.rst
│ ├── RandomStringChooserParsonsA.rst
│ ├── RandomStringChooserParsonsB.rst
│ └── toctree.rst
├── OOBasics
│ ├── APLine.rst
│ ├── Exercises.rst
│ ├── Figures
│ │ ├── 1-dice.jpeg
│ │ ├── 2015FRQ2A.png
│ │ ├── 2015FRQ2B.png
│ │ ├── SeeNSay.jpg
│ │ ├── Shape.png
│ │ ├── TrioGrading.png
│ │ ├── TrioPenalities.png
│ │ ├── TrioStudentSol1.png
│ │ ├── TrioStudentSol2a.png
│ │ ├── TrioStudentSol2b.png
│ │ ├── TrioStudentSol3.png
│ │ ├── apLineTable.png
│ │ ├── assoc.png
│ │ ├── course.png
│ │ ├── equalsEx.png
│ │ ├── menuItemObjs.png
│ │ ├── overrideEquals.png
│ │ ├── person.png
│ │ ├── petDiagram.png
│ │ ├── shapeSoftware.png
│ │ ├── trioUML.png
│ │ └── vehicle.png
│ ├── Summary.rst
│ ├── TrioA.rst
│ ├── TrioScore1.rst
│ ├── TrioScore2.rst
│ ├── TrioScore3.rst
│ ├── freeResponse.rst
│ ├── objectObasics.rst
│ ├── objectsAndClasses.rst
│ ├── ooAbstract.rst
│ ├── ooAssocVsInherit.rst
│ ├── ooComparable.rst
│ ├── ooEasyMC.rst
│ ├── ooHardMC.rst
│ ├── ooInheritance.rst
│ ├── ooInheritanceAccess.rst
│ ├── ooInheritanceAndConstructors.rst
│ ├── ooInheritanceAndInterfaces.rst
│ ├── ooMedMC.rst
│ ├── ooMistakes.rst
│ ├── ooOverrideInherited.rst
│ ├── ooOverrideVsOverload.rst
│ ├── ooParsonsPractice.rst
│ ├── ooPoly.rst
│ ├── ooPractice.rst
│ ├── ooSuper.rst
│ └── toctree.rst
├── PictureLab
│ ├── Exercises.rst
│ ├── Figures
│ │ └── run-button.png
│ ├── imageBasics.rst
│ └── toctree.rst
├── Recursion
│ ├── Exercises.rst
│ ├── Figures
│ │ ├── callTree.png
│ │ ├── codeForCallStack.png
│ │ ├── cupStack.jpg
│ │ ├── errorCallStack.png
│ │ ├── sakura_by_velvet__glove-d8i38i2.jpg
│ │ └── triangleSub.png
│ ├── Summary.rst
│ ├── rBasePractice.rst
│ ├── rEasyMC.rst
│ ├── rHardMC.rst
│ ├── rMedMC.rst
│ ├── rMistakes.rst
│ ├── rMixedUpCodePractice.rst
│ ├── rParsonsPractice.rst
│ ├── rTraceMethods.rst
│ ├── rTracePractice.rst
│ ├── rWhyUseIt.rst
│ ├── recursionbasics.rst
│ └── toctree.rst
├── SearchSort
│ ├── Exercises.rst
│ ├── Summary.rst
│ ├── binarySearch.rst
│ ├── insertionSort.rst
│ ├── mergeSort.rst
│ ├── searchBasics.rst
│ ├── selSort.rst
│ ├── seqSearch.rst
│ ├── ssEasyMC.rst
│ ├── ssHardMC.rst
│ ├── ssMedMC.rst
│ └── toctree.rst
├── Strings
│ ├── Exercises.rst
│ ├── Figures
│ │ ├── greeting.png
│ │ ├── nullStringRef.png
│ │ ├── stringIndicies.png
│ │ ├── stringObject.png
│ │ ├── stringRef.png
│ │ ├── stringRefExamplev2.png
│ │ ├── stringRefWithObj.png
│ │ ├── twoStringRefs.png
│ │ ├── twoStringRefsLiteral.png
│ │ └── twoStringRefsv2.png
│ ├── StringPracticeParsons.rst
│ ├── Summary.rst
│ ├── sEasyMC.rst
│ ├── sEquality.rst
│ ├── sHardMC.rst
│ ├── sMedMC.rst
│ ├── sMethods.rst
│ ├── sMistakes.rst
│ ├── sOperators.rst
│ ├── sResources.rst
│ ├── sbasics.rst
│ └── toctree.rst
├── Tests
│ ├── .DS_Store
│ ├── Exercises.rst
│ ├── Figures
│ │ ├── .DS_Store
│ │ ├── finishExam.png
│ │ ├── next.png
│ │ ├── pause.png
│ │ ├── prev.png
│ │ └── start.png
│ ├── test1nt.rst
│ ├── test2nt.rst
│ ├── test3nt.rst
│ ├── test4nt.rst
│ ├── test5nt.rst
│ └── toctree.rst
├── TimedTests
│ ├── Exercises.rst
│ ├── Figures
│ │ ├── finishExam.png
│ │ ├── next.png
│ │ ├── pause.png
│ │ ├── prev.png
│ │ └── start.png
│ ├── test1.rst
│ ├── test2.rst
│ ├── test3.rst
│ ├── test4.rst
│ └── toctree.rst
├── TurtleGraphics
│ ├── Exercises.rst
│ ├── Figures
│ │ ├── mindstorms_turtle.jpg
│ │ ├── run-button.png
│ │ ├── turtleA.png
│ │ └── turtleUMLClassDiagram.png
│ ├── toctree.rst
│ └── turtleBasics.rst
├── VariableBasics
│ ├── Exercises.rst
│ ├── Figures
│ │ ├── casting.jpg
│ │ ├── classVehicleExample.png
│ │ ├── mod-py.png
│ │ ├── pongScore.png
│ │ ├── typeName.png
│ │ ├── typeNameValue.png
│ │ ├── typesAndSpace.png
│ │ ├── variables.png
│ │ └── vehicleDiag.png
│ ├── Summary.rst
│ ├── VariablePracticeParsons.rst
│ ├── casting.rst
│ ├── changeVars.rst
│ ├── commonMistakes.rst
│ ├── declareVars.rst
│ ├── minAndMax.rst
│ ├── nameVars.rst
│ ├── operators.rst
│ ├── randomNumbers.rst
│ ├── toctree.rst
│ ├── vEasyMC.rst
│ ├── vHardMC.rst
│ ├── vIntro.rst
│ └── vMedMC.rst
├── assignments.rst
└── index.rst
├── _static
├── .gitignore
├── Interfaces.mp4
├── Interfaces.png
├── activecodethumb.png
├── algorithmVideo.png
├── arch.jpg
├── audio
│ ├── mag1-line1.wav
│ ├── mag1-line11-13.wav
│ ├── mag1-line14-15.wav
│ ├── mag1-line16.wav
│ ├── mag1-line18.wav
│ ├── mag1-line19.wav
│ ├── mag1-line20.wav
│ ├── mag1-line22-26.wav
│ ├── mag1-line24.wav
│ ├── mag1-line25.wav
│ ├── mag1-line3-7.wav
│ ├── mag1-line8-28.wav
│ └── mag1-line8-9.wav
├── blockly1.html
├── clock.png
├── close.png
├── codeVideo.png
├── first.png
├── last.png
├── next.png
├── pause.png
├── play.png
├── prev.png
├── run-button.png
├── untitled.png
└── videoStart.png
├── _templates.bak
└── plugin_layouts
│ └── sphinx_bootstrap
│ ├── globaltoc.html
│ ├── layout.html
│ ├── localtoc.html
│ ├── relations.html
│ ├── sourcelink.html
│ ├── static
│ ├── bootstrap-3.0.0
│ │ ├── css
│ │ │ └── bootstrap.min.css
│ │ ├── fonts
│ │ │ ├── glyphicons-halflings-regular.eot
│ │ │ ├── glyphicons-halflings-regular.svg
│ │ │ ├── glyphicons-halflings-regular.ttf
│ │ │ └── glyphicons-halflings-regular.woff
│ │ └── js
│ │ │ └── bootstrap.min.js
│ ├── bootstrap-sphinx.css_t
│ ├── bootstrap-sphinx.js
│ └── img
│ │ ├── Facebook.png
│ │ ├── Facebook_icon.png
│ │ ├── Twitter.png
│ │ ├── Twitter_icon.png
│ │ └── logo_small.png
│ ├── subchapter.html
│ └── theme.conf
├── _templates
└── plugin_layouts
│ └── sphinx_bootstrap
│ ├── globaltoc.html
│ ├── layout.html
│ ├── localtoc.html
│ ├── relations.html
│ ├── sourcelink.html
│ ├── static
│ ├── bootstrap-3.0.0
│ │ ├── css
│ │ │ └── bootstrap.min.css
│ │ ├── fonts
│ │ │ ├── glyphicons-halflings-regular.eot
│ │ │ ├── glyphicons-halflings-regular.svg
│ │ │ ├── glyphicons-halflings-regular.ttf
│ │ │ └── glyphicons-halflings-regular.woff
│ │ └── js
│ │ │ └── bootstrap.min.js
│ ├── bootstrap-sphinx.css_t
│ ├── bootstrap-sphinx.js
│ └── img
│ │ ├── Facebook.png
│ │ ├── Facebook_icon.png
│ │ ├── Twitter.png
│ │ ├── Twitter_icon.png
│ │ └── logo_small.png
│ ├── subchapter.html
│ └── theme.conf
├── build
└── student_source
│ └── turtleTest.py
├── conf.py
├── pavement.py
├── requirements.txt
├── sphinx-enki-info.txt
└── sphinx_settings.json
/.gitignore:
--------------------------------------------------------------------------------
1 | # Ignore unique build info
2 | build_info
3 |
4 | # Miscellaneous source files
5 | _sources/Tests/test6.rst
6 | _sources/Tests/test5.rst
7 | _sources copy/Appendix/DrJava.rst
8 | _sources copy/Appendix/DrJava.rst
9 | _sources copy/Appendix/Figures/AddJarToPrefs.png
10 | _sources copy/Appendix/DrJava.rst
11 |
12 | # Compiled Python files
13 | *.pyc
14 |
15 | # Machine specific files
16 | .DS_Store
17 | _sources/.DS_Store
18 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # APCSAReview
2 | This is an eBook to help students review for the Advanced Placement Computer Science A Exam.
3 |
4 | # Authors
5 | Most of the book was written by Barbara Ericson of Georgia Tech - @ericsonga
6 | Many undergraduate students and high school students in Georgia also contributed to the ebook.
7 |
8 | For the most up to date listing of who contributed to the ebook see the preface in the Getting Started chapter of the ebook
9 |
10 |
--------------------------------------------------------------------------------
/_sources/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/.DS_Store
--------------------------------------------------------------------------------
/_sources/Appendix/DrJava.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 16-1-
3 | :start: 1
4 |
5 |
6 | DrJava (an IDE)
7 | ----------------
8 |
9 | .. index::
10 | single: IDE
11 | single: Integrated Development Environment
12 | single: DrJava
13 | single: compiler
14 | single: interactions pane
15 |
16 | The tool that we use to compile a Java source file into a Java class file is called a **compiler**. I recommend using an **Integrated Development Environment** (IDE). An IDE helps you write, compile, run, and debug programs. I recommend using DrJava (from http://DrJava.org). It is free and easy to use. I particularly like the **interactions pane** (the bottom area) which lets you try out Java code without having to create a class first.
17 |
18 | .. figure:: Figures/DrJavaInteractions.png
19 | :width: 600px
20 | :align: center
21 | :figclass: align-center
22 |
23 | Figure 2: DrJava with the interactions pane at the bottom of the window.
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/_sources/Appendix/Figures/AddJarToPrefs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Appendix/Figures/AddJarToPrefs.png
--------------------------------------------------------------------------------
/_sources/Appendix/Figures/DrJavaInteractions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Appendix/Figures/DrJavaInteractions.png
--------------------------------------------------------------------------------
/_sources/Appendix/gridWorld.rst:
--------------------------------------------------------------------------------
1 | Setting up DrJava for GridWorld
2 | -------------------------------
3 |
4 | .. index::
5 | single: GridWorld
6 | single: lab
7 |
8 | The AP CS A exam isn't requiring **GridWorld** (the old required lab) after the 2014 exam, but teachers are still allowed to use it. However, I recommend checking out Greenfoot instead at http://www.greenfoot.org/door. Greenfoot is a free IDE that makes it easy to create 2D animations and games in Java.
9 |
10 | If you want to use GridWorld you can still get the GridWorld materials at http://www.horstmann.com/gridworld/. To allow DrJava to run any GridWord code you need to tell it where to find the ``gridworld.jar`` file. To do this you add the ``gridworld.jar`` file to the **classpath**, which is a list of the places to look for classes. GridWorld isn't part of the Java language, but is a set of additional classes developed for the Advanced Placement Computer Science A exam so we need to tell the compiler where to find these classes.
11 |
12 | To add to the classpath in DrJava click on ``Edit`` in the top menu and then ``Preferences`` and finally on ``Resource Locations``. Then click on the ``Add`` button below the ``Extra Classpath`` area. Use the file browser to find the ``gridworld.jar`` file and select that file. Then click on ``OK``.
13 |
14 | .. figure:: Figures/AddJarToPrefs.png
15 | :width: 600px
16 | :align: center
17 | :figclass: align-center
18 |
19 | Figure 3: Adding gridworld.jar to the classpath in DrJava
--------------------------------------------------------------------------------
/_sources/Array2dBasics/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Array2dBasics/.DS_Store
--------------------------------------------------------------------------------
/_sources/Array2dBasics/Figures/2015Q1PartB.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Array2dBasics/Figures/2015Q1PartB.png
--------------------------------------------------------------------------------
/_sources/Array2dBasics/Figures/2015q1arr1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Array2dBasics/Figures/2015q1arr1.png
--------------------------------------------------------------------------------
/_sources/Array2dBasics/Figures/2015q1partB2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Array2dBasics/Figures/2015q1partB2.png
--------------------------------------------------------------------------------
/_sources/Array2dBasics/Figures/2015q1partBmethods.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Array2dBasics/Figures/2015q1partBmethods.png
--------------------------------------------------------------------------------
/_sources/Array2dBasics/Figures/2015q1partC.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Array2dBasics/Figures/2015q1partC.png
--------------------------------------------------------------------------------
/_sources/Array2dBasics/Figures/2015q1partc2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Array2dBasics/Figures/2015q1partc2.png
--------------------------------------------------------------------------------
/_sources/Array2dBasics/Figures/2DLockers.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Array2dBasics/Figures/2DLockers.jpg
--------------------------------------------------------------------------------
/_sources/Array2dBasics/Figures/ArrayRowsAndCols.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Array2dBasics/Figures/ArrayRowsAndCols.png
--------------------------------------------------------------------------------
/_sources/Array2dBasics/Figures/grayImageA.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Array2dBasics/Figures/grayImageA.png
--------------------------------------------------------------------------------
/_sources/Array2dBasics/Figures/grayImageB.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Array2dBasics/Figures/grayImageB.png
--------------------------------------------------------------------------------
/_sources/Array2dBasics/Figures/intAndStringArrays.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Array2dBasics/Figures/intAndStringArrays.png
--------------------------------------------------------------------------------
/_sources/Array2dBasics/Figures/routeCipherFig.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Array2dBasics/Figures/routeCipherFig.png
--------------------------------------------------------------------------------
/_sources/Array2dBasics/Figures/routeCipherFig2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Array2dBasics/Figures/routeCipherFig2.png
--------------------------------------------------------------------------------
/_sources/Array2dBasics/Figures/routeCipherTable.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Array2dBasics/Figures/routeCipherTable.png
--------------------------------------------------------------------------------
/_sources/Array2dBasics/Figures/routeCipherTable2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Array2dBasics/Figures/routeCipherTable2.png
--------------------------------------------------------------------------------
/_sources/Array2dBasics/Figures/rowMajor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Array2dBasics/Figures/rowMajor.png
--------------------------------------------------------------------------------
/_sources/Array2dBasics/a2dEasyMC.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 9-7-
3 | :start: 1
4 |
5 | Easy Multiple Choice Questions
6 | ----------------------------------
7 |
8 | These problems are easier than most of those that you will usually see on the AP CS A exam.
9 |
10 |
11 | .. mchoice:: qa2de_1
12 | :answer_a: 2
13 | :answer_b: 4
14 | :answer_c: 8
15 | :correct: b
16 | :feedback_a: The size of outer array is the number of rows. Remember that two-dimensional arrays are actually an array of arrays in Java.
17 | :feedback_b: The size of the inner array is the number of columns.
18 | :feedback_c: This is the total number of items in the array.
19 |
20 | How many columns does ``a`` have if it is created as follows ``int[][] a = { {2, 4, 6, 8}, {1, 2, 3, 4} };``?
21 |
22 | You can see how the array looks by clicking on the following `Ex-9-7-1 `_.
23 |
24 | .. mchoice:: qa2de_2
25 | :answer_a: strGrid[0][2] = "S";
26 | :answer_b: strGrid[1][3] = "S";
27 | :answer_c: strGrid[3][1] = "S";
28 | :answer_d: strGrid[2][0] = "S";
29 | :answer_e: strGrid[0][0] = "S";
30 | :correct: d
31 | :feedback_a: The code letterGrid[0][2] = "S";
actually sets the 1st row and 3rd column to hold a reference to the String
object "S".
32 | :feedback_b: This would be true if row and column indicies started at 1 instead of 0 and if this was in column major order.
33 | :feedback_c: This would be true if row and column indicies started at 1 instead of 0.
34 | :feedback_d: In row-major order the row is specified first followed by the column. Row and column indicies start with 0. So letterGrid[2][0]
is the 3rd row and 1st column.
35 | :feedback_e: This would set the element at the first row and column.
36 |
37 | Which of the following statements assigns the letter S to the third row and first column of a two-dimensional array named ``strGrid`` (assuming row-major order).
38 |
39 | .. mchoice:: qa2de_3
40 | :answer_a: a[0][3]
41 | :answer_b: a[1][3]
42 | :answer_c: a[0][2]
43 | :answer_d: a[2][0]
44 | :answer_e: a[3][1]
45 | :correct: c
46 | :feedback_a: This would be true if the row index started at 0, but the column index started at 1.
47 | :feedback_b: Both the row and column indicies start with 0.
48 | :feedback_c: The value 6 is at row 0 and column 2.
49 | :feedback_d: The row index is specified first, then the column index.
50 | :feedback_e: The row index is specified first and the indicies start at 0.
51 |
52 | How would you get the value 6 out of the following array ``int[][] a = { {2, 4, 6, 8}, {1, 2, 3, 4} };``?
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/_sources/Array2dBasics/a2dLoopPart.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 9-4-
3 | :start: 1
4 |
5 | Loop Through Part of a 2D Array
6 | ======================================
7 |
8 | .. index::
9 | pair: 2D Array; loop range
10 |
11 | You can loop through just part of a 2D array. For example, you might want to sum all of the values in a given row.
12 |
13 | .. activecode:: lca2dloopPart
14 | :language: java
15 |
16 |
17 | public class Test
18 | {
19 |
20 | public static int getTotalForRow(int row, int[][] a)
21 | {
22 | int total = 0;
23 | for (int col = 0; col < a[0].length; col++)
24 | {
25 | total = total + a[row][col];
26 | }
27 | return total;
28 | }
29 |
30 | public static void main(String[] args)
31 | {
32 | int[][] matrix = { {1,2,3},{4,5,6} };
33 | System.out.println(getTotalForRow(0,matrix));
34 | }
35 | }
36 |
37 | You can change the starting value and ending value to loop through a subset of a 2D array.
38 |
39 | .. activecode:: lca2dloopPart2
40 | :language: java
41 |
42 |
43 | public class Test
44 | {
45 |
46 | public static int countValues(int value, int[][] a,
47 | int rowStart, int rowEnd,
48 | int colStart, int colEnd)
49 | {
50 | int count = 0;
51 | for (int row = rowStart; row <= rowEnd; row++)
52 | {
53 | for (int col = colStart; col <= colEnd; col++)
54 | {
55 | if (a[row][col] == value) count++;
56 | }
57 | }
58 | return count;
59 | }
60 |
61 | public static void main(String[] args)
62 | {
63 | int[][] matrix = { {3,2,3},{4,3,6},{8,9,3},{10,3,3} };
64 | System.out.println(countValues(3,matrix,0,2,0,2));
65 | }
66 | }
67 |
68 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/_sources/Array2dBasics/a2dMistakes.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 9-5-
3 | :start: 1
4 |
5 |
6 | Common Mistakes
7 | ===============
8 | - forgetting to create the array - only declaring it (``int[][] nums;``).
9 | - using 1 as the first index not 0 for rows and/or columns.
10 | - using ``array.length`` as the last valid row index, not ``array.length - 1``.
11 | - using ``array[0].length`` as the last valid column index, not ``array[0].length - 1``.
12 | - using ``array.length()`` instead of ``array.length`` (not penalized on the free response)
13 | - going out of bounds when looping through an array (using ``index <= array.length``). You will get an ``ArrayIndexOutOfBoundsException``.
14 | - jumping out an loop by using one or more return statements before every value has been processed.
15 | - using the wrong starting and ending indices on loops.
16 | - using ``array.length`` for both the number of rows and columns. Use ``array[0].length`` for the number of columns.
17 |
--------------------------------------------------------------------------------
/_sources/Array2dBasics/a2dPractice.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 9-6-
3 | :start: 1
4 |
5 |
6 | More Practice
7 | ===============
8 |
9 | For more practice with 2D arrays see http://coweb.cc.gatech.edu/ice-gt/1277 Question 4 from 2012 and Question 4 from 2011.
10 |
--------------------------------------------------------------------------------
/_sources/Array2dBasics/freeResponse.rst:
--------------------------------------------------------------------------------
1 | Free Response Questions
2 | ::::::::::::::::::::::::
3 |
4 | .. toctree::
5 | :maxdepth: 3
6 |
7 | grayImageA.rst
8 | grayImageB.rst
9 | routeCipherA.rst
10 | routeCipherB.rst
11 |
12 |
--------------------------------------------------------------------------------
/_sources/Array2dBasics/toctree.rst:
--------------------------------------------------------------------------------
1 | Two-dimensional Arrays
2 | :::::::::::::::::::::::
3 |
4 | .. toctree::
5 | :maxdepth: 3
6 |
7 | a2dBasics.rst
8 | a2dDAS.rst
9 | a2dLoop.rst
10 | a2dLoopPart.rst
11 | a2dMistakes.rst
12 | a2dPractice.rst
13 | a2dEasyMC.rst
14 | a2dMedMC.rst
15 | a2dHardMC.rst
16 | freeResponse.rst
17 | Summary.rst
18 | Exercises.rst
19 | Array2dParsonsPractice.rst
20 |
--------------------------------------------------------------------------------
/_sources/ArrayBasics/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ArrayBasics/.DS_Store
--------------------------------------------------------------------------------
/_sources/ArrayBasics/Figures/2DLockers.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ArrayBasics/Figures/2DLockers.jpg
--------------------------------------------------------------------------------
/_sources/ArrayBasics/Figures/arrayIndicies.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ArrayBasics/Figures/arrayIndicies.png
--------------------------------------------------------------------------------
/_sources/ArrayBasics/Figures/arrayIntAndString.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ArrayBasics/Figures/arrayIntAndString.png
--------------------------------------------------------------------------------
/_sources/ArrayBasics/Figures/bcTable.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ArrayBasics/Figures/bcTable.png
--------------------------------------------------------------------------------
/_sources/ArrayBasics/Figures/bcTable2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ArrayBasics/Figures/bcTable2.png
--------------------------------------------------------------------------------
/_sources/ArrayBasics/Figures/bcTable3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ArrayBasics/Figures/bcTable3.png
--------------------------------------------------------------------------------
/_sources/ArrayBasics/Figures/horseBarnA.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ArrayBasics/Figures/horseBarnA.png
--------------------------------------------------------------------------------
/_sources/ArrayBasics/Figures/horseBarnB.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ArrayBasics/Figures/horseBarnB.png
--------------------------------------------------------------------------------
/_sources/ArrayBasics/Figures/intAndStringArrays.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ArrayBasics/Figures/intAndStringArrays.png
--------------------------------------------------------------------------------
/_sources/ArrayBasics/Figures/numberLine.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ArrayBasics/Figures/numberLine.png
--------------------------------------------------------------------------------
/_sources/ArrayBasics/Figures/pill.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ArrayBasics/Figures/pill.jpg
--------------------------------------------------------------------------------
/_sources/ArrayBasics/Figures/rowLockers.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ArrayBasics/Figures/rowLockers.jpg
--------------------------------------------------------------------------------
/_sources/ArrayBasics/Figures/soundTable.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ArrayBasics/Figures/soundTable.png
--------------------------------------------------------------------------------
/_sources/ArrayBasics/Figures/soundTable2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ArrayBasics/Figures/soundTable2.png
--------------------------------------------------------------------------------
/_sources/ArrayBasics/Figures/soundTable3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ArrayBasics/Figures/soundTable3.png
--------------------------------------------------------------------------------
/_sources/ArrayBasics/Figures/soundTable4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ArrayBasics/Figures/soundTable4.png
--------------------------------------------------------------------------------
/_sources/ArrayBasics/aHardMC.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 7-11-
3 | :start: 1
4 |
5 | Hard Multiple Choice Questions
6 | ----------------------------------
7 |
8 | These problems are harder than most of those that you will usually see on the AP CS A exam.
9 |
10 | .. mchoice:: qahard_1
11 | :answer_a: Both implementations work as intended and are equally fast.
12 | :answer_b: Both implementations work as intended, but implementation 1 is faster than implementation 2.
13 | :answer_c: Both implementations work as intended, but implementation 2 is faster than implementation 1.
14 | :answer_d: Implementation 1 does not work as intended, because it will cause an ArrayIndexOutOfBoundsException.
15 | :answer_e: Implementation 2 does not work as intended, because it will cause an ArrayIndexOutOfBoundsException.
16 | :correct: d
17 | :feedback_a: Implementation 1 doesn't work and will cause an ArrayIndexOutOfBoundsException. If Implementation 1 was correct, it would be faster.
18 | :feedback_b: Implementation 1 doesn't work and will cause an ArrayIndexOutOfBoundsException.
19 | :feedback_c: Implementation 1 doesn't work and will cause an ArrayIndexOutOfBoundsException. If it did work, it would be faster than 2.
20 | :feedback_d: When j
is 0, sum[j-1]
will be sum[-1]
which will cause an ArrayIndexOutOfBoundsException.
21 | :feedback_e: Implementation 1 doesn't work and will cause an ArrayIndexOutOfBoundsException.
22 |
23 | Consider the following data field and incomplete method, ``partialSum``, which is intended to return an integer array ``sum`` such that for all ``i``, ``sum[i]`` is equal to ``arr[0] + arr[1] + ... + arr[i]``. For instance, if arr contains the values ``{1, 4, 1, 3}``, the array ``sum`` will contain the values ``{1, 5, 6, 9}``. Which of the following is true about the two implementations of ``missing code`` on line 9 that are proposed?
24 |
25 | .. code-block:: java
26 | :linenos:
27 |
28 | private int[] arr;
29 |
30 | public int[] partialSum() {
31 | int[] sum = new int[arr.length];
32 |
33 | for (int j = 0; j < sum.length; j++)
34 | sum[j] = 0;
35 |
36 | /* missing code */
37 | return sum;
38 | }
39 |
40 |
41 | Implementation 1
42 |
43 | for (int j = 0; j < arr.length; j++)
44 | sum[j] = sum[j - 1] + arr[j];
45 |
46 |
47 | Implementation 2
48 |
49 | for (int j = 0; j < arr.length; j++)
50 | for (int k = 0; k <= j; k++)
51 | sum[j] = sum [j] + arr[k];
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/_sources/ArrayBasics/aLoopFrontToBack.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 7-3-
3 | :start: 1
4 |
5 | Using a For Loop to Loop Through an Array
6 | ==========================================
7 |
8 | .. index::
9 | single: for loop
10 | pair: loop; from front to back
11 |
12 | You can also use a ``for`` loop to loop through all the elements of an array. Just start the index at 0 and loop while the index is less than the length of the array.
13 |
14 | .. activecode:: lcal1
15 | :language: java
16 |
17 | public class ArrayWorker
18 | {
19 | private int[ ] values;
20 |
21 | public ArrayWorker(int[] theValues)
22 | {
23 | values = theValues;
24 | }
25 |
26 | public void multAll(int amt)
27 | {
28 | for (int i = 0; i < values.length; i++)
29 | {
30 | values[i] = values[i] * amt;
31 | } // end for loop
32 | } // end method
33 |
34 | public void printValues()
35 | {
36 | for (int val : values )
37 | {
38 | System.out.println(val);
39 | }
40 | }
41 |
42 | public static void main(String[] args)
43 | {
44 | int[] numArray = {2, 6, 7, 12, 5};
45 | ArrayWorker aWorker = new ArrayWorker(numArray);
46 | aWorker.multAll(2);
47 | aWorker.printValues();
48 |
49 | }
50 | }
51 |
52 | **Mixed up programs**
53 |
54 | .. parsonsprob:: pab_1r
55 | :numbered: left
56 | :adaptive:
57 |
58 | The following method has the correct code to subtract amt from all the values in the array values (a field of the current object), but the code is mixed up. Drag the blocks from the left into the correct order on the right and indent them correctly. You will be told if any of the blocks are in the wrong order or not indented correctly.
59 | -----
60 | public void subAll(int amt)
61 | {
62 | =====
63 | for (int i = 0;
64 | i < values.length;
65 | i++)
66 | {
67 | =====
68 | values[i] = values[i] - amt;
69 | =====
70 | } // end for loop
71 | =====
72 | } // end method
73 |
74 |
--------------------------------------------------------------------------------
/_sources/ArrayBasics/aMistakes.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 7-7-
3 | :start: 1
4 |
5 |
6 | Common Mistakes
7 | ===============
8 | - forgetting to create the array - only declaring it (``int[ ] nums;``)
9 | - using 1 as the first index not 0
10 | - using ``array.length`` as the last valid index in an array, not ``array.length - 1``.
11 | - using ``array.length()`` instead of ``array.length`` (not penalized on the free response)
12 | - using ``array.get(0)`` instead of ``array[0]`` (not penalized on the free response)
13 | - going out of bounds when looping through an array (using ``index <= array.length``). You will get an ``ArrayIndexOutOfBoundsException``.
14 | - jumping out an loop too early by using one or more return statements before every value has been processed.
--------------------------------------------------------------------------------
/_sources/ArrayBasics/aPractice.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 7-8-
3 | :start: 1
4 |
5 |
6 | More Practice
7 | ===============
8 |
9 | For practice with simple array manipulation and conditionals, but no loops see http://codingbat.com/java/Array-1.
10 | For more practice with loops and arrays go to http://codingbat.com/java/Array-2.
11 |
12 | Here are problems without loops
13 |
14 | * http://codingbat.com/prob/p167011
15 | * http://codingbat.com/prob/p191991
16 | * http://codingbat.com/prob/p146256
17 | * http://codingbat.com/prob/p199519
18 | * http://codingbat.com/prob/p109537
19 |
20 | Here are problems with loops
21 |
22 | * http://codingbat.com/prob/p180920
23 | * http://codingbat.com/prob/p104627
24 | * http://codingbat.com/prob/p199612
25 | * http://codingbat.com/prob/p105031
26 | * http://codingbat.com/prob/p100246
--------------------------------------------------------------------------------
/_sources/ArrayBasics/aProcessAll.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 7-6-
3 | :start: 1
4 |
5 |
6 | Things to Watch For When Looping Through an Array
7 | ==================================================
8 |
9 | When processing all array elements be careful to start at the first index which is ``0`` and end at the last index which is ``arrayName.length - 1``. Be careful not to go past the bounds of the array which means don't use a negative number as an index or a number that is equal to or greater than the length of the array.
10 |
11 | Also, be careful not to jump out of loop too early when you are looking for a value in an array. The method below uses **return** statements to stop the execution of the method and return a value to the method that called this method. If a return statement returns a value, the type of that value must match the return type in the method header. Methods with a return type of **void** can't return any values, but can have one or more return statements.
12 |
13 | .. activecode:: lcap1
14 | :language: java
15 |
16 | public class StringWorker
17 | {
18 | private String[ ] arr = {"Hello", "Hey", "Good morning!"};
19 |
20 | public int findString(String target)
21 | {
22 | String word = null;
23 | for (int index = 0; index < arr.length; index++)
24 | {
25 | word = arr[index];
26 |
27 | if (word.equals(target))
28 | {
29 | return index;
30 | }
31 | else return -1;
32 | }
33 | return -1;
34 | }
35 |
36 | public static void main(String[] args)
37 | {
38 | StringWorker sWorker = new StringWorker();
39 | System.out.println(sWorker.findString("Hey"));
40 | }
41 | }
42 |
43 | What is wrong with the code above? The first time through the loop it will start with the element at index 0 and check if the item at the array index equals the passed target string. If they have the same characters in the same order it will return 0, otherwise it will return -1. But, it has only processed one element of the array. How would you fix the code to work correctly (process all array elements before returning)?
44 |
45 |
--------------------------------------------------------------------------------
/_sources/ArrayBasics/freeResponse.rst:
--------------------------------------------------------------------------------
1 | Free Response Questions
2 | :::::::::::::::::::::::::
3 |
4 | .. toctree::
5 | :maxdepth: 3
6 |
7 | selfDivisorB.rst
8 | horseBarnA.rst
9 | horseBarnB.rst
10 | soundA.rst
11 | soundB.rst
12 | numberCubeA.rst
13 | numberCubeB.rst
14 |
--------------------------------------------------------------------------------
/_sources/ArrayBasics/toctree.rst:
--------------------------------------------------------------------------------
1 | Arrays
2 | ::::::::::::::::::::
3 |
4 | .. toctree::
5 | :maxdepth: 3
6 |
7 | abasics.rst
8 | aForEach.rst
9 | aLoopFrontToBack.rst
10 | aLoopBackToFront.rst
11 | aLoopPart.rst
12 | aProcessAll.rst
13 | aMistakes.rst
14 | aPractice.rst
15 | aEasyMC.rst
16 | aMedMC.rst
17 | aHardMC.rst
18 | arrayExam.rst
19 | freeResponse.rst
20 | Summary.rst
21 | Exercises.rst
22 | ArrayParsonsPractice.rst
23 |
--------------------------------------------------------------------------------
/_sources/Conditionals/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Conditionals/.DS_Store
--------------------------------------------------------------------------------
/_sources/Conditionals/Figures/Condition-three.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Conditionals/Figures/Condition-three.png
--------------------------------------------------------------------------------
/_sources/Conditionals/Figures/Condition-two.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Conditionals/Figures/Condition-two.png
--------------------------------------------------------------------------------
/_sources/Conditionals/Figures/Condition.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Conditionals/Figures/Condition.png
--------------------------------------------------------------------------------
/_sources/Conditionals/cEasyMC.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 5-8-
3 | :start: 1
4 |
5 | Easy Multiple Choice Questions
6 | ----------------------------------
7 |
8 | These problems are easier than most of those that you will usually see on the AP CS A exam.
9 |
10 | .. mchoice:: qce_1
11 | :answer_a: x is negative
12 | :answer_b: x is zero
13 | :answer_c: x is positive
14 | :correct: c
15 | :feedback_a: This will only print if x has been set to a number less than zero. Has it?
16 | :feedback_b: This will only print if x has been set to 0. Has it?
17 | :feedback_c: The first condition is false and x is not equal to zero so the else will execute.
18 |
19 | What does the following code print when x has been set to 187?
20 |
21 | .. code-block:: java
22 |
23 | if (x < 0) System.out.println("x is negative");
24 | else if (x == 0) System.out.println("x is zero");
25 | else System.out.println("x is positive");
26 |
27 | .. mchoice:: qce_2
28 | :answer_a: first case
29 | :answer_b: second case
30 | :correct: b
31 | :feedback_a: This will print if x is greater than or equal 3 and y is less than or equal 2. In this case x is greater than 3 so the first condition is true, but the second condition is false.
32 | :feedback_b: This will print if x is less than 3 or y is greater than 2.
33 |
34 | What is printed when the following code executes and x equals 4 and y equals 3?
35 |
36 | .. code-block:: java
37 |
38 | if (!(x < 3 || y > 2)) System.out.println("first case");
39 | else System.out.println("second case");
40 |
41 | .. mchoice:: qce_3
42 | :answer_a: A
43 | :answer_b: B
44 | :answer_c: C
45 | :answer_d: D
46 | :answer_e: E
47 | :correct: d
48 | :feedback_a: Notice that each of the first 4 statements start with an if. What will actually be printed? Try it.
49 | :feedback_b: Each of the first 4 if statements will execute.
50 | :feedback_c: Check this in DrJava.
51 | :feedback_d: Each of the if statements will be executed. So grade will be set to B then C and finally D.
52 | :feedback_e: This will only be true when score is less than 60.
53 |
54 | What is the value of grade when the following code executes and score is 80?
55 |
56 | .. code-block:: java
57 |
58 | if (score >= 90) grade = "A";
59 | if (score >= 80) grade = "B";
60 | if (score >= 70) grade = "C";
61 | if (score >= 60) grade = "D";
62 | else grade = "E";
63 |
64 | .. mchoice:: qce_4
65 | :answer_a: first case
66 | :answer_b: second case
67 | :answer_c: You will get a error because you can't divide by zero.
68 | :correct: c
69 | :feedback_a: This will print if either of the two conditions are true. The first isn't true but the second will cause an error.
70 | :feedback_b: This will print if both of the conditions are false. But, an error will occur when testing the second condition.
71 | :feedback_c: The first condition will be false so the second one will be executed and lead to an error since you can't divide by zero.
72 |
73 | What is printed when the following code executes and x has been set to zero and y is set to 3?
74 |
75 | .. code-block:: java
76 |
77 | if (x > 0 || (y / x) == 3) System.out.println("first case");
78 | else System.out.println("second case");
79 |
--------------------------------------------------------------------------------
/_sources/Conditionals/cMistakes.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 5-6-
3 | :start: 1
4 |
5 | Common Mistakes
6 | ===============
7 |
8 | - Using two ``if``'s one after the other instead of an ``if`` and ``else``.
9 |
10 | - Trouble with complex conditionals which are two or more Boolean expressions joined by ``&&`` or ``||``.
11 |
12 | - Trouble with understanding or applying negation (``!``). See the section on DeMorgan's Laws.
13 |
14 | - Not understanding short circuit evaluation which is that if evaluation of the first Boolean expression is enough to determine the truth of a complex conditional the second expression will not be evaluated.
--------------------------------------------------------------------------------
/_sources/Conditionals/cPractice.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 5-6-
3 | :start: 1
4 |
5 | More Practice
6 | ===============
7 |
8 | For more practice with conditionals, and especially complex conditionals, go to http://codingbat.com/java/Logic-1 and http://codingbat.com/java/Logic-2
9 |
10 | In particular we recommend solving the following problems
11 |
12 | * http://codingbat.com/prob/p118290
13 | * http://codingbat.com/prob/p183071
14 | * http://codingbat.com/prob/p110973
15 | * http://codingbat.com/prob/p103360
16 | * http://codingbat.com/prob/p169213
17 | * http://codingbat.com/prob/p178728
18 | * http://codingbat.com/prob/p115233
19 |
20 |
--------------------------------------------------------------------------------
/_sources/Conditionals/toctree.rst:
--------------------------------------------------------------------------------
1 | Conditionals
2 | ::::::::::::::::::::
3 |
4 | .. toctree::
5 | :maxdepth: 3
6 |
7 | cbasics.rst
8 | threeOrMore.rst
9 | cComplex.rst
10 | cShortCircuit.rst
11 | cDeMorgans.rst
12 | cMistakes.rst
13 | cPractice.rst
14 | cEasyMC.rst
15 | cMedMC.rst
16 | cHardMC.rst
17 | timeFRQ.rst
18 | Summary.rst
19 | Exercises.rst
20 | CondParsonsPractice.rst
21 |
--------------------------------------------------------------------------------
/_sources/FreeResponse/ArrayTesterB.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 16-10-
3 | :start: 1
4 |
5 | ArrayTester - Part B
6 | ===============================
7 |
8 | .. index::
9 | single: ArrayTester
10 | single: free response
11 |
12 | **Part b.** Write the static method ``isLatin``, which returns ``true`` if a given two-dimensional square array is a ``Latin square``, and otherwise, returns false.
13 |
14 | A two-dimensional square array of integers is a Latin square if the following conditions are true.
15 | 1) The first row has no duplicate values.
16 | 2) All values in the first row of the square appear in each row of the square.
17 | 3) All values in the first row of the square appear in each column of the square.
18 |
19 | .. figure:: Figures/LatinSquareEx.png
20 | :align: center
21 | :figclass: align-center
22 |
23 | The ``ArrayTester`` class provides two helper methods: ``containsDuplicates`` and ``hasAllValues``. The method ``containsDuplicates`` returns ``true`` if the given one-dimensional array ``arr`` contains any duplicate values and ``false`` otherwise. The method ``hasAllValues`` returns ``true`` if and only if every value in ``arr1`` appears in ``arr2``. You do not need to write the code for these methods.
24 |
25 | .. figure:: Figures/LatinSquareEx2.png
26 | :align: center
27 | :figclass: align-center
28 |
29 | Complete method ``isLatin`` below. Assume that ``getColumn`` works as specified, regardless of what
30 | you wrote in part (a). You must use ``getColumn``, ``hasAllValues``, and ``containsDuplicates``
31 | appropriately to receive full credit.
32 |
33 | Try and Solve It
34 | ----------------
35 |
36 | Complete the method ``isLatin`` below.
37 |
38 | .. activecode:: isLatinTwo
39 | :language: java
40 |
41 | public class ArrayTester
42 | {
43 |
44 | public static boolean isLatin(int[] [] square)
45 | {
46 |
47 | }
48 |
49 | // Main method to test getColumn method
50 | public static void main(String[] args)
51 | {
52 | int [] [] arr2D = { { 1, 2, 3 }, { 2, 3, 1 }, { 3, 1, 2 }};
53 | bool test = isLatin(arr2D);
54 | System.out.println("If isLatin is implemented correctly, then test should be false.");
55 | if (!test)
56 | {
57 | System.out.print("Uh oh! isLatin(test) was false, but it should be true.");
58 | }
59 |
60 | } // end of main
61 | } // end of the class
62 |
--------------------------------------------------------------------------------
/_sources/FreeResponse/Exercises.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 16-10-
3 | :start: 1
4 |
5 | Exercises
6 | ===============================
7 |
8 | None yet
9 |
--------------------------------------------------------------------------------
/_sources/FreeResponse/Figures/HiddenWordExamples.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/FreeResponse/Figures/HiddenWordExamples.png
--------------------------------------------------------------------------------
/_sources/FreeResponse/Figures/HiddenWordHints.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/FreeResponse/Figures/HiddenWordHints.png
--------------------------------------------------------------------------------
/_sources/FreeResponse/Figures/LatinSquareEx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/FreeResponse/Figures/LatinSquareEx.png
--------------------------------------------------------------------------------
/_sources/FreeResponse/Figures/LatinSquareEx2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/FreeResponse/Figures/LatinSquareEx2.png
--------------------------------------------------------------------------------
/_sources/FreeResponse/Figures/NumberGroup.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/FreeResponse/Figures/NumberGroup.png
--------------------------------------------------------------------------------
/_sources/FreeResponse/Figures/SkyViewBEx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/FreeResponse/Figures/SkyViewBEx.png
--------------------------------------------------------------------------------
/_sources/FreeResponse/Figures/SkyViewClassInfo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/FreeResponse/Figures/SkyViewClassInfo.png
--------------------------------------------------------------------------------
/_sources/FreeResponse/Figures/SkyViewEx2Array.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/FreeResponse/Figures/SkyViewEx2Array.png
--------------------------------------------------------------------------------
/_sources/FreeResponse/Figures/SkyViewExArray.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/FreeResponse/Figures/SkyViewExArray.png
--------------------------------------------------------------------------------
/_sources/FreeResponse/Figures/SkyViewOrder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/FreeResponse/Figures/SkyViewOrder.png
--------------------------------------------------------------------------------
/_sources/FreeResponse/Figures/SkyViewRes1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/FreeResponse/Figures/SkyViewRes1.png
--------------------------------------------------------------------------------
/_sources/FreeResponse/Figures/SkyViewRes2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/FreeResponse/Figures/SkyViewRes2.png
--------------------------------------------------------------------------------
/_sources/FreeResponse/Figures/StringCoderEx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/FreeResponse/Figures/StringCoderEx.png
--------------------------------------------------------------------------------
/_sources/FreeResponse/Figures/StudentAnswerSheetEx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/FreeResponse/Figures/StudentAnswerSheetEx.png
--------------------------------------------------------------------------------
/_sources/FreeResponse/HiddenWord.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 16-9-
3 | :start: 1
4 |
5 | Hidden Word - Write Class
6 | ===============================
7 |
8 | .. index::
9 | single: Hidden Word
10 | single: free response
11 |
12 | The following is a free response question from 2015. It was question 2 on the exam. You can see all the free response questions from past exams at https://apstudent.collegeboard.org/apcourse/ap-computer-science-a/exam-practice.
13 |
14 | **Question 2.** Consider a guessing game in which a player tries to guess a hidden word. The hidden word contains only capital
15 | letters and has a length known to the player. A guess contains only capital letters and has the same length as the
16 | hidden word.
17 |
18 | After a guess is made, the player is given a hint that is based on a comparison between the hidden word and the guess. Each position in the hint contains a character that corresponds to the letter in the same position in the guess. The following rules determine the characters that appear in the hint.
19 |
20 | .. figure:: Figures/HiddenWordHints.png
21 | :width: 600px
22 | :align: center
23 | :figclass: align-center
24 |
25 | Figure 1: The hints
26 |
27 | The ``HiddenWord`` class will be used to represent the hidden word in the game. The hidden word is passed to the constructor. The class contains a method, ``getHint`` that takes a guess and produces a hint.
28 |
29 | For example, suppose the variable ``puzzle`` is declared as follows.
30 |
31 | .. code-block:: java
32 |
33 | HiddenWord puzzle = new HiddenWord("HARPS");
34 |
35 | The following table shows several guesses and the hints that would be produced.
36 |
37 | .. figure:: Figures/HiddenWordExamples.png
38 | :width: 600px
39 | :align: center
40 | :figclass: align-center
41 |
42 | Figure 2: Example guesses and hints
43 |
44 | Try and Solve It
45 | ----------------
46 |
47 | Write the complete ``HiddenWord`` class, including any necessary instance variables, its constructor, and the method,
48 | ``getHint``, described above. You may assume that the length of the guess is the same as the length of
49 | the hidden word.
50 |
51 | The code below has comments to help you get started. It also has a main method for testing. Finish writing the class and use the main method to test it.
52 |
53 | .. activecode:: HiddenWordClass
54 | :language: java
55 |
56 | // Declare the HiddenWord class below
57 |
58 | {
59 |
60 | /** Declare any fields (instance variables) **/
61 |
62 | /** Declare a constructor */
63 |
64 | /** Write the getHint method */
65 |
66 | /** This is a main method for testing the class */
67 | public static void main(String[] args)
68 | {
69 | HiddenWord puzzle = new HiddenWord("HARPS");
70 | System.out.println(puzzle.getHint("AAAAA") + " it should print +A+++");
71 | System.out.println(puzzle.getHint("HELLO") + " it should print H****");
72 | System.out.println(puzzle.getHint("HEART") + " it should print H*++*");
73 | System.out.println(puzzle.getHint("HARMS") + " it should print HAR*S");
74 | System.out.println(puzzle.getHint("HARPS") + " it should print HARPS");
75 |
76 | } // end of main
77 |
78 | } // end of class
79 |
--------------------------------------------------------------------------------
/_sources/FreeResponse/NumberGroupA.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 16-11-
3 | :start: 1
4 |
5 | NumberGroup - Part A
6 | ===============================
7 |
8 | .. index::
9 | single: NumberGroup
10 | single: free response
11 |
12 | The following is a free response question from 2015. It was question 4 on the exam. You can see all the free response questions from past exams at https://apstudent.collegeboard.org/apcourse/ap-computer-science-a/exam-practice.
13 |
14 | **Question 4.** This question involves the design of an interface, writing a class that implements the interface, and writing
15 | a method that uses the interface.
16 |
17 | **Part a.** A number group represents a group of integers defined in some way. It could be empty, or it could contain one or more integers.
18 | Write an interface called ``NumberGroup`` that represents a group of integers.
19 | Write an interface named NumberGroup that represents a group of integers. The interface should have
20 | a single ``contains`` method that determines if a given integer is in the group. For example, if ``group1`` is of type ``NumberGroup``, and it only contains the two members -5 and 3, then ``group1.contains(-5)`` would return ``true`` , and ``group1.contains(2)`` would return ``false`` .
21 |
22 | Write the complete ``NumberGroup`` interface. It must have exactly one method.
23 |
24 | Try and Solve It
25 | ----------------
26 |
27 | Write the interface ``NumberGroup`` below.
28 |
29 | .. activecode:: NumberGroupA
30 | :language: java
31 |
32 | public interface NumberGroup{
33 | //Finish the interface here!
34 | }
--------------------------------------------------------------------------------
/_sources/FreeResponse/NumberGroupB.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 16-12-
3 | :start: 1
4 |
5 | NumberGroup - Part B
6 | ===============================
7 |
8 | .. index::
9 | single: NumberGroup
10 | single: free response
11 |
12 | **Part b.** A range represents a number group that contains all (and only) the integers between a minimum value and
13 | a maximum value, inclusive.
14 | Write the ``Range`` class, which is a ``NumberGroup``. The ``Range`` class represents the group of ``int`` values that range from a given minimum value up through a given maximum value, inclusive. For example, the declaration ``NumberGroup range1 = new Range(-3, 2);`` represents the group of integer values -3, -2, -1, 0, 1, 2.
15 |
16 | Write the complete ``Range`` class. Include all necessary instance variables and methods as well as a constructor that takes two ``int`` parameters. The first parameter represents the minimum value, and the second parameter represents the maximum value of the range. You may assume that the minimum is less than or equal to the maximum.
17 |
18 | Try and Solve It
19 | ----------------
20 |
21 | Write the class ``Range`` below.
22 |
23 | The code below has a main method for testing the ``NumberGroup`` method.
24 |
25 | .. activecode:: NumberGroupB
26 | :language: java
27 |
28 | public class Range implements NumberGroup
29 | {
30 | //Write the Range class here!
31 |
32 | //Main method to test the class
33 | public static void main(String[] args)
34 | {
35 | System.out.println("This is testing the constructor");
36 | Range test = Range(5, 8);
37 | System.out.println("The program says the minimum is " + test.getMin() + ", it really should be 5.";
38 | System.out.println("The program says the maximum is " + test.getMax() + ", it really should be 8.";
39 | System.out.println("This is testing the contains function.");
40 | System.out.println("The program says that 6 is within the range of the function, which is correct.");
41 | } // end of main
42 |
43 | } // end of class
44 |
--------------------------------------------------------------------------------
/_sources/FreeResponse/NumberGroupC.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 16-13-
3 | :start: 1
4 |
5 | NumberGroup - Part C
6 | ===============================
7 |
8 | .. index::
9 | single: NumberGroup
10 | single: free response
11 |
12 | **Part c.** The ``MultipleGroups`` class (not shown) represents a collection of ``NumberGroup`` objects and is
13 | a ``NumberGroup``. The ``MultipleGroups`` class stores the number groups in the instance variable
14 | ``groupList`` (shown below), which is initialized in the constructor.
15 |
16 | ``private List groupList;``
17 |
18 | Write the ``MultipleGroups`` method ``contains``. The method takes an integer and returns ``true``
19 | if and only if the integer is contained in one or more of the number groups in ``groupList``.
20 |
21 | For example, suppose ``multiple1`` has been declared as an instance of ``MultipleGroups`` and
22 | consists of the three ranges created by the calls ``new Range(5, 8)``, ``new Range(10, 12)``,
23 | and ``new Range(1, 6)``. The following table shows the results of several calls to ``contains``.
24 |
25 | .. figure:: Figures/NumberGroup.png
26 | :align: center
27 | :figclass: align-center
28 |
29 | Try and Solve It
30 | ----------------
31 |
32 | .. code-block:: java
33 |
34 | /** Returns true if at least one of the number groups in this multiple group contains num;
35 | * false otherwise
36 | */
37 |
38 | Write the method ``contains`` below.
39 |
40 |
41 | .. activecode:: NumberGroupC
42 | :language: java
43 |
44 | public boolean contains(int num){
45 |
46 | }
--------------------------------------------------------------------------------
/_sources/FreeResponse/RandomStringChooserA.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 16-1-
3 | :start: 1
4 |
5 | RandomStringChooser - Part A
6 | ===============================
7 |
8 | .. index::
9 | single: RandomStringChooser
10 | single: free response
11 |
12 | The following is a free response question from 2016. It was question 1 on the exam. You can see all the free response questions from past exams at https://apstudent.collegeboard.org/apcourse/ap-computer-science-a/exam-practice.
13 |
14 | **Question 1.** This question involves the implementation and extension of a ``RandomStringChooser`` class.
15 |
16 | **Part a.** A ``RandomStringChooser`` object is constructed from an array of non-null ``String`` values. When the object is first constructed,
17 | all of the strings are considered available. The ``RandomStringChooser`` class has a ``getNext`` method, which has the following behavior. A call to ``getNext`` returns a randomly chosen string from the available strings
18 | in the object. Once a particular string has been returned from a call to ``getNext``, it is no longer available to be returned from subsequent calls to ``getNext``. If no strings are available to be returned, ``getNext`` returns ``"NONE``.
19 |
20 | The following code segment shows an example of the behavior of ``RandomStringChooser``.
21 |
22 |
23 | .. code-block:: java
24 |
25 | String[] wordArray = {"wheels", "on", "the", "bus"};
26 | RandomStringChooser sChooser = new RandomStringChooser(wordArray);
27 | for (int k = 0; k < 6; k++)
28 | {
29 | System.out.println(sChooser.getNext() + " ");
30 | }
31 |
32 | One possible output is shown below. Because ``sChooser`` has only four strings, the string ``"NONE`` is printed twice.
33 |
34 | .. code-block:: java
35 |
36 | bus the wheels on NONE NONE
37 |
38 |
39 | Try and Solve It
40 | ----------------
41 |
42 | Write the entire ``RandomStringChooser`` class. Your implementation must include an appropriate constructor and any necessary methods. Any instance variables must be ``private``. The code segment in the example above should have the indicated behavior (that is, it must compile and produce a result like the possible output shown. Neither the constructor or any of the methods should alter the parameter passed to the constructor, but your implementation may copy the contents of the array.
43 |
44 | The code below has comments to help you get started. It also has a main method for testing. Finish writing the class and use the main method to test it.
45 |
46 | .. activecode:: RandomStrChooserA1
47 | :language: java
48 |
49 | import java.util.List;
50 | import java.util.ArrayList;
51 |
52 | // Declare the RandomStringChooser class
53 |
54 | {
55 |
56 | /** Declare any fields (instance variables) **/
57 |
58 | /** Declare any constructors */
59 |
60 | /** Write the getNext method */
61 |
62 | /** This is a main method for testing the class */
63 | public static void main(String[] args)
64 | {
65 | System.out.println("It should print the words in the array in a random order and then NONE twice");
66 | String[] wordArray = {"wheels", "on", "the", "bus"};
67 | RandomStringChooser sChooser = new RandomStringChooser(wordArray);
68 | for (int k = 0; k < 6; k++)
69 | {
70 | System.out.println(sChooser.getNext() + " ");
71 | }
72 |
73 | } // end of main
74 |
75 | } // end of class
76 |
--------------------------------------------------------------------------------
/_sources/FreeResponse/toctree.rst:
--------------------------------------------------------------------------------
1 | Free Response Practice Exam
2 | :::::::::::::::::::::::::::::
3 |
4 | .. toctree::
5 | :maxdepth: 3
6 |
7 | RandomStringChooserA.rst
8 | RandomStringChooserB.rst
9 | StringCoderA.rst
10 | StringCoderB.rst
11 | StudentAnswerSheetA.rst
12 | StudentAnswerSheetB.rst
13 | SkyViewA.rst
14 | SkyViewB.rst
15 | HiddenWord.rst
16 | ArrayTesterA.rst
17 | ArrayTesterB.rst
18 | NumberGroupA.rst
19 | NumberGroupB.rst
20 | NumberGroupC.rst
21 | Exercises.rst
22 |
--------------------------------------------------------------------------------
/_sources/GettingStarted/Exercises.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 1-3-
3 | :start: 1
4 |
5 | Exercises
6 | ===============================
7 |
8 | None yet
9 |
--------------------------------------------------------------------------------
/_sources/GettingStarted/Figures/AddJarToPrefs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/GettingStarted/Figures/AddJarToPrefs.png
--------------------------------------------------------------------------------
/_sources/GettingStarted/Figures/BugsRocksFlowers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/GettingStarted/Figures/BugsRocksFlowers.png
--------------------------------------------------------------------------------
/_sources/GettingStarted/Figures/CreateNewGridWorld.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/GettingStarted/Figures/CreateNewGridWorld.png
--------------------------------------------------------------------------------
/_sources/GettingStarted/Figures/DrJavaBugRunner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/GettingStarted/Figures/DrJavaBugRunner.png
--------------------------------------------------------------------------------
/_sources/GettingStarted/Figures/DrJavaInteractions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/GettingStarted/Figures/DrJavaInteractions.png
--------------------------------------------------------------------------------
/_sources/GettingStarted/Figures/DrJavaPicLab.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/GettingStarted/Figures/DrJavaPicLab.png
--------------------------------------------------------------------------------
/_sources/GettingStarted/Figures/DrJavaPicLab2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/GettingStarted/Figures/DrJavaPicLab2.png
--------------------------------------------------------------------------------
/_sources/GettingStarted/Figures/cats.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/GettingStarted/Figures/cats.png
--------------------------------------------------------------------------------
/_sources/GettingStarted/Figures/cats2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/GettingStarted/Figures/cats2.png
--------------------------------------------------------------------------------
/_sources/GettingStarted/Figures/compile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/GettingStarted/Figures/compile.png
--------------------------------------------------------------------------------
/_sources/GettingStarted/Figures/compiling.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/GettingStarted/Figures/compiling.png
--------------------------------------------------------------------------------
/_sources/GettingStarted/Figures/cookieCutter.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/GettingStarted/Figures/cookieCutter.jpg
--------------------------------------------------------------------------------
/_sources/GettingStarted/Figures/finishExam.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/GettingStarted/Figures/finishExam.png
--------------------------------------------------------------------------------
/_sources/GettingStarted/Figures/next.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/GettingStarted/Figures/next.png
--------------------------------------------------------------------------------
/_sources/GettingStarted/Figures/nullStringRef.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/GettingStarted/Figures/nullStringRef.png
--------------------------------------------------------------------------------
/_sources/GettingStarted/Figures/pause.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/GettingStarted/Figures/pause.png
--------------------------------------------------------------------------------
/_sources/GettingStarted/Figures/prev.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/GettingStarted/Figures/prev.png
--------------------------------------------------------------------------------
/_sources/GettingStarted/Figures/start.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/GettingStarted/Figures/start.png
--------------------------------------------------------------------------------
/_sources/GettingStarted/toctree.rst:
--------------------------------------------------------------------------------
1 | Preface and Getting Setup
2 | :::::::::::::::::::::::::::::::::::::::::::
3 |
4 | .. toctree::
5 | :caption: Preface and Getting Setup
6 | :maxdepth: 3
7 |
8 | preface.rst
9 | pretest.rst
10 | Exercises.rst
11 |
--------------------------------------------------------------------------------
/_sources/JavaBasics/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/JavaBasics/.DS_Store
--------------------------------------------------------------------------------
/_sources/JavaBasics/Exercises.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 2-9-
3 | :start: 1
4 |
5 | Exercises
6 | -------------------------
7 |
8 | None yet
9 |
--------------------------------------------------------------------------------
/_sources/JavaBasics/Figures/PersonRun.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/JavaBasics/Figures/PersonRun.png
--------------------------------------------------------------------------------
/_sources/JavaBasics/Figures/cats.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/JavaBasics/Figures/cats.png
--------------------------------------------------------------------------------
/_sources/JavaBasics/Figures/cats2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/JavaBasics/Figures/cats2.png
--------------------------------------------------------------------------------
/_sources/JavaBasics/Figures/checkMe.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/JavaBasics/Figures/checkMe.png
--------------------------------------------------------------------------------
/_sources/JavaBasics/Figures/classVehicleExample.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/JavaBasics/Figures/classVehicleExample.png
--------------------------------------------------------------------------------
/_sources/JavaBasics/Figures/compile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/JavaBasics/Figures/compile.png
--------------------------------------------------------------------------------
/_sources/JavaBasics/Figures/compiling.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/JavaBasics/Figures/compiling.png
--------------------------------------------------------------------------------
/_sources/JavaBasics/Figures/cookieCutter.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/JavaBasics/Figures/cookieCutter.jpg
--------------------------------------------------------------------------------
/_sources/JavaBasics/Figures/nullStringRef.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/JavaBasics/Figures/nullStringRef.png
--------------------------------------------------------------------------------
/_sources/JavaBasics/Figures/run-button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/JavaBasics/Figures/run-button.png
--------------------------------------------------------------------------------
/_sources/JavaBasics/Figures/start-audio-tour.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/JavaBasics/Figures/start-audio-tour.png
--------------------------------------------------------------------------------
/_sources/JavaBasics/Figures/vehicleDiag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/JavaBasics/Figures/vehicleDiag.png
--------------------------------------------------------------------------------
/_sources/JavaBasics/toctree.rst:
--------------------------------------------------------------------------------
1 | Java Basics: Classes and Objects
2 | :::::::::::::::::::::::::::::::::::::::::::
3 |
4 | .. toctree::
5 | :caption: Java Basics: Class and Objects
6 | :maxdepth: 3
7 |
8 | whatIsJava.rst
9 | introClassObject.rst
10 | firstClass.rst
11 | compileTimeErrors.rst
12 | firstOOClass.rst
13 | runClass.rst
14 | partsOfAClass.rst
15 | Summary.rst
16 | Exercises.rst
17 |
--------------------------------------------------------------------------------
/_sources/JavaBasics/whatIsJava.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 2-1-
3 | :start: 1
4 |
5 | What is Java?
6 | ===============
7 |
8 | .. index::
9 | single: Java
10 | single: javac
11 | single: compile
12 | single: programming language
13 | pair: programming; language
14 | pair: Java; source file
15 | pair: Java; class file
16 |
17 | Java is a **programming language**, which means that we can use Java to tell a computer what to do. Computers don't actually speak Java so we have to
18 | **compile** (translate) Java source files (they end in .java) into class files (they end in .class). The source file is something humans can read and edit and the class file is code that a computer can understand and can run.
19 |
20 | In this book the Java code is actually being sent to a server to compile and run (as long as you have an internet connection) and the output will be shown in the browser, so you won't actually create a source file or class file.
21 |
22 | If you have the Java development environment loaded on your computer you can use the Java command ``javac`` to compile your Java source code at a command line. You can use ``java ClassName`` to execute the ``main`` method in a Java class. In Java all source code must be part of a class (defined inside a class).
23 |
24 | .. figure:: Figures/compile.png
25 | :width: 300px
26 | :align: center
27 | :figclass: align-center
28 |
29 | Figure 1: Compiling Java source (Person.java) into a class file (Person.class)
30 |
31 | You can copy the Java source code shown in this book into a file and save it if you want to run it locally on your computer. Be sure to name the file the same name as the class name with ".java" as the extension. All code (programs) in Java must be part of a **class** (defined inside a class) in a source file and the name of the class must match the file name.
32 |
33 | You can also use an integrated development environment on your local computer. We recommend Dr Java at http://www.drjava.org (see the appendix for more information), but there are many good ones such as JGrasp, BlueJ, Greenfoot, and Eclipse.
34 |
35 |
--------------------------------------------------------------------------------
/_sources/Labs/Exercises.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: lab-1e-
3 | :start: 1
4 |
5 | .. highlight:: java
6 | :linenothreshold: 4
7 |
8 |
9 | Mixed Up Code Practice
10 | ------------------------------
11 |
12 | .. parsonsprob:: chat-labp1
13 | :numbered: left
14 | :adaptive:
15 | :noindent:
16 |
17 | The following program segment should print if your guess is too low, correct, or too high But, the blocks have been mixed up. Drag the blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.
18 | -----
19 | private String getRandomResponse()
20 | {
21 | =====
22 | final int NUMBER_OF_RESPONSES = 4;
23 | double r = Math.random();
24 | =====
25 | int whichResponse = (int)(r * NUMBER_OF_RESPONSES);
26 | String response = "";
27 | =====
28 | if (whichResponse == 0) {
29 | response = "Interesting, tell me more.";
30 | =====
31 | } else if (whichResponse == 1) {
32 | response = "Hmmm.";
33 | =====
34 | } else if (whichResponse == 2) {
35 | response = "Do you really think so?";
36 | =====
37 | } else if (whichResponse == 3) {
38 | response = "You don't say.";
39 | }
40 | =====
41 | return response;
42 | =====
43 | }
44 |
--------------------------------------------------------------------------------
/_sources/Labs/magpie1.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: lab-1a-
3 | :start: 1
4 |
5 | .. highlight:: java
6 | :linenothreshold: 4
7 |
8 | Lab Requirement
9 | ======================
10 |
11 | As of 2014-2015 the Advanced Placement Computer Science A course must include at least 20 hours of hands-on labs. Three labs were created as exemplars and can be used to satisfy this requirement, but teachers can do other labs instead of these three. The three labs are Magpie, Picture, and Elevens. See https://apstudent.collegeboard.org/apcourse/ap-computer-science-a/course-details/lab-requirements for the student guides for each of these labs. Your teacher will provide the lab code to you. The particular code in each of these labs will not be on the exam, but the concepts covered by the labs will be on the exam.
12 |
13 | Magpie Lab
14 | ===============
15 |
16 | The Magpie lab allows the student to work with the ``String`` class and conditionals with a **chatbot**. A **chatbot** is a computer program that tries to hold a conversation with a user. This chapter will walk you through the activities in the Magpie chatbot lab.
17 |
18 | The first activity in Magpie is to explore some existing chatbots.
19 |
20 | Activity 1: Exploring Chatbots
21 | ===============================
22 |
23 | Go to https://sites.google.com/site/webtoolsbox/bots to try out some chatbots.
24 |
25 | Record the chatbot response to each of the following.
26 |
27 | * Where do you come from?
28 | * asdfghjkl;
29 | * My mother and I talked last night.
30 | * The weather is nice.
31 | * I said no!
32 |
33 | Ask the chatbot other questions.
34 |
35 | * Record the most interesting response.
36 | * Record the most peculiar response.
37 |
38 | Work with another student or group to have two chatbots converse with each other. Type the responses from one chatbot into the input area for the other and vice-versa.
39 |
40 | Keywords
41 | ==========
42 |
43 | Some chatbots look for particular keywords and respond based on those keywords. What are some of the keywords that your chatbot seems to be responding to? Why do you think it responds to those keywords?
44 |
45 |
--------------------------------------------------------------------------------
/_sources/Labs/toctree.rst:
--------------------------------------------------------------------------------
1 | Magpie Chatbot Lab
2 | ::::::::::::::::::::
3 |
4 | .. toctree::
5 | :maxdepth: 3
6 |
7 | magpie1.rst
8 | magpie2.rst
9 | magpie3.rst
10 | magpie4.rst
11 | Exercises.rst
12 |
--------------------------------------------------------------------------------
/_sources/ListBasics/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/.DS_Store
--------------------------------------------------------------------------------
/_sources/ListBasics/Figures/2016FRQ4A1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/Figures/2016FRQ4A1.png
--------------------------------------------------------------------------------
/_sources/ListBasics/Figures/2016FRQ4A2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/Figures/2016FRQ4A2.png
--------------------------------------------------------------------------------
/_sources/ListBasics/Figures/2016FRQ4B1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/Figures/2016FRQ4B1.png
--------------------------------------------------------------------------------
/_sources/ListBasics/Figures/2016FRQ4C1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/Figures/2016FRQ4C1.png
--------------------------------------------------------------------------------
/_sources/ListBasics/Figures/checkerTable.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/Figures/checkerTable.png
--------------------------------------------------------------------------------
/_sources/ListBasics/Figures/checkerTable2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/Figures/checkerTable2.png
--------------------------------------------------------------------------------
/_sources/ListBasics/Figures/checkerTable3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/Figures/checkerTable3.png
--------------------------------------------------------------------------------
/_sources/ListBasics/Figures/climbClubA.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/Figures/climbClubA.png
--------------------------------------------------------------------------------
/_sources/ListBasics/Figures/climbClubA.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/Figures/climbClubA.zip
--------------------------------------------------------------------------------
/_sources/ListBasics/Figures/climbClubB.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/Figures/climbClubB.png
--------------------------------------------------------------------------------
/_sources/ListBasics/Figures/cookieOrderTable.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/Figures/cookieOrderTable.png
--------------------------------------------------------------------------------
/_sources/ListBasics/Figures/cookieOrderTable2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/Figures/cookieOrderTable2.png
--------------------------------------------------------------------------------
/_sources/ListBasics/Figures/flightTable.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/Figures/flightTable.png
--------------------------------------------------------------------------------
/_sources/ListBasics/Figures/fuelDepotTable.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/Figures/fuelDepotTable.png
--------------------------------------------------------------------------------
/_sources/ListBasics/Figures/fuelDepotTable2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/Figures/fuelDepotTable2.png
--------------------------------------------------------------------------------
/_sources/ListBasics/Figures/fuelDepotTable3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/Figures/fuelDepotTable3.png
--------------------------------------------------------------------------------
/_sources/ListBasics/Figures/listInterface.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/Figures/listInterface.png
--------------------------------------------------------------------------------
/_sources/ListBasics/Figures/lists.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/Figures/lists.jpg
--------------------------------------------------------------------------------
/_sources/ListBasics/Figures/stringCoder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/Figures/stringCoder.png
--------------------------------------------------------------------------------
/_sources/ListBasics/Figures/stringScrambleB.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/Figures/stringScrambleB.png
--------------------------------------------------------------------------------
/_sources/ListBasics/Figures/tileGameDiagram.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/Figures/tileGameDiagram.png
--------------------------------------------------------------------------------
/_sources/ListBasics/Figures/tileGameDiagram2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/Figures/tileGameDiagram2.png
--------------------------------------------------------------------------------
/_sources/ListBasics/Figures/tileGameDiagram3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/Figures/tileGameDiagram3.png
--------------------------------------------------------------------------------
/_sources/ListBasics/Figures/tileGameDiagram4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/Figures/tileGameDiagram4.png
--------------------------------------------------------------------------------
/_sources/ListBasics/Figures/usb.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/Figures/usb.jpg
--------------------------------------------------------------------------------
/_sources/ListBasics/Figures/whyLists.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/ListBasics/Figures/whyLists.png
--------------------------------------------------------------------------------
/_sources/ListBasics/freeResponse.rst:
--------------------------------------------------------------------------------
1 | Free Response Questions
2 | :::::::::::::::::::::::::
3 |
4 | .. toctree::
5 | :maxdepth: 3
6 |
7 | stringScrambleB.rst
8 | climbClubA.rst
9 | climbClubB.rst
10 | climbClubC.rst
11 | cookieOrderA.rst
12 | cookieOrderB.rst
13 | 2016freeresponseQ4A.rst
14 | 2016freeresponseQ4B.rst
15 |
--------------------------------------------------------------------------------
/_sources/ListBasics/lPractice.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 8-10-
3 | :start: 1
4 |
5 | More Practice
6 | =============
7 | For practice with free response questions with Interfaces and Lists see question 1 from 2012 at http://home.cc.gatech.edu/ice-gt/320, question 3 from 2011 at http://home.cc.gatech.edu/ice-gt/306, question 1 from 2008 at http://coweb.cc.gatech.edu/ice-gt/1279, and question 3 from 2007 at http://coweb.cc.gatech.edu/ice-gt/1280.
8 |
--------------------------------------------------------------------------------
/_sources/ListBasics/listArrayList.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 8-3-
3 | :start: 1
4 |
5 | The ArrayList Class
6 | ===================
7 |
8 | .. index::
9 | single: ArrayList
10 | single: implements
11 | pair: list; ArrayList
12 |
13 | Luckily Java has a class that handles when you run out of room in an array and want to add more items to it or when the amount of space reserved for an array is much larger than what you actually need. It is called **ArrayList**. It **implements** the ``List`` interface using an array and allows the underlying array to grow or shrink as needed. This also means that the ``ArrayList`` class contains the code for the methods defined in the ``List`` interface.
14 |
15 | Java actually has several classes that **implement** the ``List`` interface (provide method bodies for the abstract methods defined in the interface). These are just some of the classes that implement the ``List`` interface: ``ArrayList``, ``LinkedList``, ``Stack``, and ``Vector``. You only need to learn about the ``ArrayList`` class for the exam.
16 |
17 | The Import Statement
18 | ====================
19 |
20 | .. index::
21 | single: import statement
22 |
23 | The ``List`` interface and ``ArrayList`` class are both in the ``java.util`` **package**. A **package** is a set of related classes. If you want to use any class other than those in ``java.lang`` (like ``System`` or ``Math``) you will need to either use the full name (packageName.ClassName) like (``java.util.List`` and ``java.util.ArrayList``) or use one or more import statements.
24 |
25 | Import statements have to be the first code in a Java source file. An import statement tells Java which class you mean when you use a short name (like ``List``). It tells Java where to find the definition of that class.
26 |
27 | You can import just the classes you need from a package as shown below. Just provide an ``import`` statement for each class that you want to use.
28 |
29 | .. code-block:: java
30 |
31 | import java.util.List; // import just the List interface
32 | import java.util.ArrayList; // import just the ArrayList class
33 |
34 | .. index::
35 | single: package
36 | pair: statement; import
37 |
38 | Another option is to import everything at the same level in a package using ``import packageName.*``.
39 |
40 |
41 | .. code-block:: java
42 |
43 | import java.util.*; // import everything including List and ArrayList
44 |
45 | .. note::
46 |
47 | Don't worry about adding import statements on the AP CS A exam. Any that you need will be provided for you.
48 |
49 | .. mchoice:: qlib_1
50 | :answer_a: You can only have one import statement in a source file.
51 | :answer_b: You must specify the class to import.
52 | :answer_c: Import statements must be before other code in a Java source file.
53 | :answer_d: You must import java.lang.String to use the short name of String.
54 | :correct: c
55 | :feedback_a: You can have an many import statements as you need.
56 | :feedback_b: You can use * to import all classes at the specified level.
57 | :feedback_c: Import statements have to be the first Java statements in a source file.
58 | :feedback_d: You do not have to import any classes that are in the java.lang package.
59 |
60 | Which of the following is true about import statements?
61 |
62 |
--------------------------------------------------------------------------------
/_sources/ListBasics/listMistakes.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 8-9-
3 | :start: 1
4 |
5 | Common Mistakes
6 | ===============
7 | - forgetting that ``set`` replaces the item at the index
8 | - forgetting that ``remove`` at an index moves all items that were to the right of that index left one index
9 | - forgetting that ``add`` at an index moves everything that was at the index and greater to the right one index
10 | - incrementing an index when looping through a list even though you removed an item from the list
11 | - using ``nameList[0]`` instead of ``nameList.get(0)``.
12 | - using ``nameList.length`` instead of ``nameList.size()`` to get the number of elements in a list
13 |
--------------------------------------------------------------------------------
/_sources/ListBasics/listbasics.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 8-1-
3 | :start: 1
4 |
5 | Lists
6 | =====
7 |
8 | .. index::
9 | single: list
10 | pair: list; defintion
11 |
12 | When you go shopping, you might create a **list**. As you shop you might check things off your list (remove them from the list). You might search your list to see if something is already on it. You might add to a list. A **list** holds items in an order.
13 |
14 | .. figure:: Figures/lists.jpg
15 | :width: 400px
16 | :align: center
17 | :figclass: align-center
18 |
19 | Figure 1: A couple of lists
20 |
21 | The List Interface
22 | =====================
23 |
24 | .. index::
25 | single: interface
26 | pair: interface; defintion
27 |
28 | Java uses the notion of a **list** too. It defines the **interface** ``List`` which is in the java.util **package**. An interface lets you define a type based on what you want it to do, not how it does it. Several classes can implement the same interface and you can pick the one to use that works best in your situation.
29 |
30 | See http://docs.oracle.com/javase/7/docs/api/java/util/List.html for the Java documentation for the ``List`` interface (a portion of this is shown below). All classes in the Java language are organized into **packages**. A package contains related classes. The ``String`` and ``Object`` classes are in the ``java.lang`` package. The full name for any class is the package name followed by a ``.`` and the class name. So the full name for the ``String`` class is ``java.lang.String``. The full name for the ``List`` interface is ``java.util.List``.
31 |
32 | .. figure:: Figures/listInterface.png
33 | :width: 700px
34 | :align: center
35 | :figclass: align-center
36 |
37 | Figure 2: The List interface in Java
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/_sources/ListBasics/toctree.rst:
--------------------------------------------------------------------------------
1 | List and ArrayList
2 | ::::::::::::::::::::
3 |
4 | .. toctree::
5 | :maxdepth: 3
6 |
7 | listbasics.rst
8 | listInterface.rst
9 | listArrayList.rst
10 | listDeclareAndCreate.rst
11 | listAdd.rst
12 | listMethods.rst
13 | listLoop.rst
14 | listVsArray.rst
15 | listMistakes.rst
16 | lPractice.rst
17 | listEasyMC.rst
18 | listMedMC.rst
19 | listHardMC.rst
20 | freeResponse.rst
21 | Summary.rst
22 | Exercises.rst
23 | ListParsonsPractice.rst
24 |
--------------------------------------------------------------------------------
/_sources/LoopBasics/Figures/ForLoopFlow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/LoopBasics/Figures/ForLoopFlow.png
--------------------------------------------------------------------------------
/_sources/LoopBasics/Figures/WhileLoopFlow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/LoopBasics/Figures/WhileLoopFlow.png
--------------------------------------------------------------------------------
/_sources/LoopBasics/Figures/compareForAndWhile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/LoopBasics/Figures/compareForAndWhile.png
--------------------------------------------------------------------------------
/_sources/LoopBasics/Figures/scrambleA.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/LoopBasics/Figures/scrambleA.png
--------------------------------------------------------------------------------
/_sources/LoopBasics/Figures/stringScrambleA-ABRACADABRA.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/LoopBasics/Figures/stringScrambleA-ABRACADABRA.png
--------------------------------------------------------------------------------
/_sources/LoopBasics/Figures/stringScrambleA-TAN.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/LoopBasics/Figures/stringScrambleA-TAN.png
--------------------------------------------------------------------------------
/_sources/LoopBasics/Figures/whileLoopTrace.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/LoopBasics/Figures/whileLoopTrace.png
--------------------------------------------------------------------------------
/_sources/LoopBasics/Summary.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 6-12-
3 | :start: 1
4 |
5 | Loops - Summary
6 | -------------------------
7 |
8 | In this chapter you learned about **loops**. **Loops** are used to repeat a statement or block of statements inside a pair of curly braces.
9 |
10 | .. index::
11 | single: loop
12 | single: body of a loop
13 | single: while loop
14 | single: nested loop
15 | single: for loop
16 | single: for each loop
17 | single: trace code
18 | single: out of bounds error
19 |
20 |
21 |
22 | Concept Summary
23 | =================
24 |
25 |
26 | - **Body of a Loop** - The single statement or a block of statements that *can* be repeated (a loop may not execute at all if the condition is false to start with). In Java the body of the loop is either the first statement following a ``while`` or ``for`` loop is the body of the loop or a block of statements enclosed in ``{`` and ``}``.
27 | - **For Loop** - A loop that has a header with 3 optional parts: initialization, condition, and change. It does the initialization one time before the body of the loop executes, executes the body of the loop if the condition is true, and executes the change after the body of the loop executes before checking the condition again.
28 | - **For Each Loop** - Used to loop through all the elements of a collection (like a list or an array) and each time through the loop set a variable to the next item from the collection
29 | - **Infinite Loop** - A loop that never ends.
30 | - **Loop** - A way to repeat one or more statements in a program.
31 | - **Nested Loop** - One loop inside of another.
32 | - **Out of Bounds error** - A run-time error that occurs when you try to access past the end of a string or list in a loop.
33 | - **Trace Code** - Writing down the values of the variables and how they change each time the body of the loop executes.
34 | - **While Loop** - A loop that repeats while a Boolean expression is true.
35 |
36 | Java Keyword Summary
37 | =========================
38 |
39 | - **while** - used to start a while loop
40 | - **for** - used to start a for loop or a for each loop
41 | - **System.out.println(variable)** - used to print the value of the variable. This is useful in tracing the execution of code and when debugging.
42 |
43 | Practice
44 | ===========
45 |
46 | .. dragndrop:: ch6_loops1
47 | :feedback: Review the summaries above.
48 | :match_1: a loop that repeats while a Boolean condition is true|||while loop
49 | :match_2: a loop that has three parts: initialization, condition, and change|||for loop
50 | :match_3: a loop that repeats one or more statements for each item in a collection like a list|||for each loop
51 | :match_4: one loop inside of another|||nested loop
52 |
53 | Drag the definition from the left and drop it on the correct concept on the right. Click the "Check Me" button to see if you are correct
54 |
55 | .. dragndrop:: ch6_loops2
56 | :feedback: Review the summaries above.
57 | :match_1: the statement or block of statements following a loop header that is repeated|||body of a loop
58 | :match_2: a loop that never ends|||infinite loop
59 | :match_3: an error that occurs when a loop tries to access outside the bounds of a string or list|||out of bounds error
60 | :match_4: writing down the values of variables for each execution of the loop body|||trace code
61 |
62 | Drag the definition from the left and drop it on the correct method on the right. Click the "Check Me" button to see if you are correct.
63 |
--------------------------------------------------------------------------------
/_sources/LoopBasics/freeResponse.rst:
--------------------------------------------------------------------------------
1 | Free Response Questions
2 | ::::::::::::::::::::::::::
3 |
4 | .. toctree::
5 | :maxdepth: 3
6 |
7 | selfDivisorA.rst
8 | stringScrambleA.rst
--------------------------------------------------------------------------------
/_sources/LoopBasics/lHardMC.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 6-9-
3 | :start: 1
4 |
5 | Hard Multiple Choice Questions
6 | ----------------------------------
7 |
8 | These problems are harder than most of those that you will usually see on the AP CS A exam.
9 |
10 | This problem is about big O notation which is not covered on the A exam. It used to be covered on the AB exam, but they
11 | stopped offering that exam several years ago.
12 |
13 | .. mchoice:: qlh_1n
14 | :answer_a: O(log n)
15 | :answer_b: O(n log n)
16 | :answer_c: O(n)
17 | :answer_d: O(n*n)
18 | :answer_e: O(n!)
19 | :correct: b
20 | :feedback_a: This would be correct if there was just the inner loop.
21 | :feedback_b: The outer loop is n but the inner loop is log n since k is multiplied by 2 each time through the loop.
22 | :feedback_c: This would be correct if there was just the outer loop.
23 | :feedback_d: This would be correct if the inner lop was incremented by 1 instead of multiplied by 2.
24 | :feedback_e: To get n! as big-oh we would need n nested loops.
25 |
26 | Which best characterizes the running time of the following code segment?
27 |
28 | .. code-block:: java
29 |
30 | for (int j = 1; j <= n; j++) {
31 | for (int k = 1; k <= n; k = k * 2)
32 | System.out.println(j + " " + k);
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/_sources/LoopBasics/lMistakes.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 6-5-
3 | :start: 1
4 |
5 | Common Mistakes
6 | ===============
7 |
8 | - Forgetting to change the thing you are testing in a ``while`` loop and ending up with an infinite loop.
9 |
10 | - Getting the start and end conditions wrong on the ``for`` loop. This will often result in you getting an **out of bounds error**. An **out of bounds** error occurs when you try to access past the end of a string.
11 |
12 | - Jumping out of a loop too early by using one or more return statements inside of the loop.
13 |
14 |
15 | Here is an example of a while loop that doesn't ever change the value in the loop so it never ends. If you run it refresh the page to stop it. Fix it.
16 |
17 | .. activecode:: while_loop_mistake1
18 | :language: java
19 |
20 | public class Test
21 | {
22 | public static void main(String[] args)
23 | {
24 | int x = 3;
25 | while (x > 0)
26 | {
27 | System.out.println(x);
28 | }
29 | }
30 | }
31 |
32 | Here is an example of going past the bounds of a string. This code should double all but the first and last letter in message. Fix the code so that it doesn't cause an out of bounds an error.
33 |
34 | .. activecode:: while_loop_oob
35 | :language: java
36 |
37 | public class Test
38 | {
39 | public static void main(String[] args)
40 | {
41 | String result = "";
42 | String message = "watch out";
43 | int pos = 0;
44 | while (pos < message.length())
45 | {
46 | result = result + message.substring(pos,pos+2);
47 | pos = pos + 1;
48 | }
49 | System.out.println(result);
50 | }
51 | }
52 |
53 | Here is an example of jumping out of a loop too early. The code below is intended to test if all of the letters in a string are in ascending order from left to right. But, it doesn't work correctly. Can you fix it?
54 |
55 | .. activecode:: while_loop_early_leave
56 | :language: java
57 |
58 | public class Test
59 | {
60 |
61 | public static boolean isInOrder(String check)
62 | {
63 | int pos = 0;
64 | while (pos < check.length() - 1)
65 | {
66 | if (check.substring(pos, pos+1).compareTo(check.substring(pos+1, pos+2)) < 0)
67 | return true;
68 | pos++;
69 | }
70 | return false;
71 | }
72 |
73 | public static void main(String[] args)
74 | {
75 | System.out.println(isInOrder("abca"));
76 | System.out.println(isInOrder("abc"));
77 |
78 | }
79 | }
80 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/_sources/LoopBasics/lPractice.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 6-6-
3 | :start: 1
4 |
5 | More Practice
6 | ===============
7 |
8 | For more practice with loops and strings see http://codingbat.com/java/Warmup-2. For practice with loops and arrays see http://codingbat.com/java/Array-2.
9 |
10 | Here are some recommended problems
11 |
12 | * http://codingbat.com/prob/p142270
13 | * http://codingbat.com/prob/p101475
14 | * http://codingbat.com/prob/p165666
15 | * http://codingbat.com/prob/p117334
16 | * http://codingbat.com/prob/p121596
--------------------------------------------------------------------------------
/_sources/LoopBasics/toctree.rst:
--------------------------------------------------------------------------------
1 | Loops
2 | ::::::::::::::::::::
3 |
4 | .. toctree::
5 | :maxdepth: 3
6 |
7 | lbasics.rst
8 | lWhile.rst
9 | lFor.rst
10 | lNested.rst
11 | lMistakes.rst
12 | lPractice.rst
13 | lEasyMC.rst
14 | lMedMC.rst
15 | lHardMC.rst
16 | freeResponse.rst
17 | Summary.rst
18 | Exercises.rst
19 | LoopParsonsPractice.rst
20 |
--------------------------------------------------------------------------------
/_sources/MixedFreeResponse/Exercises.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 17-10-
3 | :start: 1
4 |
5 | Exercises
6 | ===============================
7 |
8 | None yet
9 |
--------------------------------------------------------------------------------
/_sources/MixedFreeResponse/Figures/HiddenWordExamples.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/MixedFreeResponse/Figures/HiddenWordExamples.png
--------------------------------------------------------------------------------
/_sources/MixedFreeResponse/Figures/HiddenWordHints.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/MixedFreeResponse/Figures/HiddenWordHints.png
--------------------------------------------------------------------------------
/_sources/MixedFreeResponse/Figures/SkyViewBEx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/MixedFreeResponse/Figures/SkyViewBEx.png
--------------------------------------------------------------------------------
/_sources/MixedFreeResponse/Figures/SkyViewClassInfo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/MixedFreeResponse/Figures/SkyViewClassInfo.png
--------------------------------------------------------------------------------
/_sources/MixedFreeResponse/Figures/SkyViewEx2Array.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/MixedFreeResponse/Figures/SkyViewEx2Array.png
--------------------------------------------------------------------------------
/_sources/MixedFreeResponse/Figures/SkyViewExArray.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/MixedFreeResponse/Figures/SkyViewExArray.png
--------------------------------------------------------------------------------
/_sources/MixedFreeResponse/Figures/SkyViewOrder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/MixedFreeResponse/Figures/SkyViewOrder.png
--------------------------------------------------------------------------------
/_sources/MixedFreeResponse/Figures/SkyViewRes1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/MixedFreeResponse/Figures/SkyViewRes1.png
--------------------------------------------------------------------------------
/_sources/MixedFreeResponse/Figures/SkyViewRes2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/MixedFreeResponse/Figures/SkyViewRes2.png
--------------------------------------------------------------------------------
/_sources/MixedFreeResponse/Figures/StringCoderEx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/MixedFreeResponse/Figures/StringCoderEx.png
--------------------------------------------------------------------------------
/_sources/MixedFreeResponse/Figures/StudentAnswerSheetEx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/MixedFreeResponse/Figures/StudentAnswerSheetEx.png
--------------------------------------------------------------------------------
/_sources/MixedFreeResponse/RandomStringChooserA2.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 17-2-
3 | :start: 1
4 |
5 | RandomStringChooser - Part A
6 | ===============================
7 |
8 | .. index::
9 | single: RandomStringChooser
10 | single: free response
11 |
12 | The following is a free response question from 2016. It was question 1 on the exam. You can see all the free response questions from past exams at https://apstudent.collegeboard.org/apcourse/ap-computer-science-a/exam-practice.
13 |
14 | **Question 1.** This question involves the implementation and extension of a ``RandomStringChooser`` class.
15 |
16 | **Part a.** A ``RandomStringChooser`` object is constructed from an array of non-null ``String`` values. When the object is first constructed,
17 | all of the strings are considered available. The ``RandomStringChooser`` class has a ``getNext`` method, which has the following behavior. A call to ``getNext`` returns a randomly chosen string from the available strings
18 | in the object. Once a particular string has been returned from a call to ``getNext``, it is no longer available to be returned from subsequent calls to ``getNext``. If no strings are available to be returned, ``getNext`` returns ``"NONE``.
19 |
20 | The following code segment shows an example of the behavior of ``RandomStringChooser``.
21 |
22 |
23 | .. code-block:: java
24 |
25 | String[] wordArray = {"wheels", "on", "the", "bus"};
26 | RandomStringChooser sChooser = new RandomStringChooser(wordArray);
27 | for (int k = 0; k < 6; k++)
28 | {
29 | System.out.println(sChooser.getNext() + " ");
30 | }
31 |
32 | One possible output is shown below. Because ``sChooser`` has only four strings, the string ``"NONE`` is printed twice.
33 |
34 | .. code-block:: java
35 |
36 | bus the wheels on NONE NONE
37 |
38 |
39 | Try and Solve It - Again
40 | ----------------------------
41 |
42 | Now that you have had practice with mixed up code, write the entire ``RandomStringChooser`` class again. Your implementation must include an appropriate constructor and any necessary methods. Any instance variables must be ``private``. The code segment in the example above should have the indicated behavior (that is, it must compile and produce a result like the possible output shown. Neither the constructor or any of the methods should alter the parameter passed to the constructor, but your implementation may copy the contents of the array.
43 |
44 | The code below has comments to help you get started. It also has a main method for testing. Finish writing the class and use the main method to test it.
45 |
46 | .. activecode:: RandomStrChooserA1-2
47 | :language: java
48 |
49 | import java.util.List;
50 | import java.util.ArrayList;
51 |
52 | // Declare the RandomStringChooser class
53 |
54 | {
55 |
56 | /** Declare any fields (instance variables) **/
57 |
58 | /** Declare any constructors */
59 |
60 | /** Write the getNext method */
61 |
62 | /** This is a main method for testing the class */
63 | public static void main(String[] args)
64 | {
65 | System.out.println("It should print the words in the array in a random order and then NONE twice");
66 | String[] wordArray = {"wheels", "on", "the", "bus"};
67 | RandomStringChooser sChooser = new RandomStringChooser(wordArray);
68 | for (int k = 0; k < 6; k++)
69 | {
70 | System.out.println(sChooser.getNext() + " ");
71 | }
72 |
73 | } // end of main
74 |
75 | } // end of class
76 |
--------------------------------------------------------------------------------
/_sources/MixedFreeResponse/RandomStringChooserParsonsB.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 17-3-
3 | :start: 1
4 |
5 | RandomStringChooser - Part B
6 | ==================================================
7 |
8 | **Part b.** The following partially completed ``RandomLetterChooser`` class is a subclass of the ``RandomStringChooser`` class. You will put blocks in order to create the constructor for the ``RandomLetterChooser`` class.
9 |
10 | .. code-block:: java
11 |
12 | public class RandomLetterChooser extends RandomStringChooser
13 | {
14 | /** Constructs a random letter chooser using the given string str.
15 | * Precondition: str contains only letters.
16 | */
17 | public RandomLetterChooser (String str)
18 | { /* to be implemented in part (b) */ }
19 |
20 | /** Returns an array of single-letter strings.
21 | * Each of these strings consists of a single letter from str. Element k
22 | * of the returned array contains the single letter at position k of str.
23 | * For example, getSingleLetters("cat") return the
24 | * array {"c", "a", "t" }.
25 | */
26 | public static String[] getSingleLetters(String str)
27 | { /* implementation not shown */ }
28 | }
29 |
30 |
31 | The following code segment shows an example of using ``RandomLetterChooser``.
32 |
33 |
34 | .. code-block:: java
35 |
36 | RandomLetterChooser letterChooser = new RandomLetterChooser("cat");
37 | for (int k = 0; k < 4; k++)
38 | {
39 | System.out.print(letterChooser.getNext());
40 | }
41 |
42 | The code segment will print the three letters in ``"cat"`` in one of the possible orders. Because there are only three letters in the original string, the code segment prints ``"NONE"`` the fourth time through the loop. One posible output is shown below.
43 |
44 |
45 | .. code-block:: java
46 |
47 | actNONE
48 |
49 | Assume that the ``RandomStringChooser`` class that you wrote in part (a) has been implemented correctly and that
50 | ``getSingleLetters`` works as specified. You must use ``getSingleLetters``.
51 |
52 |
53 | .. parsonsprob:: ch17RandStr1
54 | :numbered: left
55 | :adaptive:
56 | :noindent:
57 |
58 | The code below will copy the strings from the array to a list in the constructor using a general for loop. In ``getNext`` it will return "NONE" if the length of the list is 0. Otherwise it till calculate a random index in the list and remove and return the string at that index. The blocks have been mixed up and include extra blocks that aren't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.
59 | -----
60 | public RandomLetterChooser (String str)
61 | {
62 | =====
63 | super(getSingleLetters(str));
64 | =====
65 | super(str); #paired
66 | =====
67 | } // end constructor
68 |
--------------------------------------------------------------------------------
/_sources/MixedFreeResponse/toctree.rst:
--------------------------------------------------------------------------------
1 | Mixed Up Code - Free Response Practice
2 | :::::::::::::::::::::::::::::::::::::::::
3 |
4 | .. toctree::
5 | :maxdepth: 3
6 |
7 | RandomStringChooserParsonsA.rst
8 | RandomStringChooserA2.rst
9 | RandomStringChooserParsonsB.rst
10 | RandomStringChooserB2.rst
11 | Exercises.rst
12 |
--------------------------------------------------------------------------------
/_sources/OOBasics/APLine.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 10-23-
3 | :start: 1
4 |
5 | Free Response - APLine
6 | ======================
7 |
8 | .. index::
9 | single: apline
10 | single: free response
11 |
12 | The following is a free response question from 2010. It was question 2 on the exam. You can see all the free response questions from past exams at https://apstudent.collegeboard.org/apcourse/ap-computer-science-a/exam-practice.
13 |
14 | **Question 2.** An `APLine` is a line defined by the equation ``ax + by + c = 0``,where ``a`` is not equal to zero, ``b`` is not equal to
15 | zero, and ``a``, ``b``, and ``c`` are all integers. The slope of an `APLine` is defined to be the double value ``-a / b`` . A point (represented by integers ``x`` and ``y``) is on an `APLine` if the equation of the `APLine` is satisfied when those ``x`` and ``y`` values are substituted into the equation. That is, a point represented by ``x`` and ``y`` is on the line if
16 | ``ax + by + c`` is equal to 0. Examples of two `APLine` equations are shown in the following table.
17 |
18 | .. figure:: Figures/apLineTable.png
19 | :width: 850px
20 | :align: center
21 | :figclass: align-center
22 |
23 | Assume that the following code segment appears in a class other than `APLine`. The code segment shows an example of using the `APLine` class to represent the two equations shown in the table.
24 |
25 | .. code-block:: java
26 |
27 | APLine line1 = new APLine(5, 4, -17);
28 | double slope1 = line1.getSlope(); // slope1 is assigned -1.25
29 | boolean onLine1 = line1.isOnLine(5, -2); // true because 5(5) + 4(-2) + (-17) = 0
30 |
31 | APLine line2 = new APLine(-25, 40, 30);
32 | double slope2 = line2.getSlope(); // slope2 is assigned 0.625
33 | boolean onLine2 = line2.isOnLine(5, -2); // false because -25(5) + 40(-2) + 30 != 0
34 |
35 | Try and Solve It
36 | ----------------
37 |
38 | Write the `APLine` class. Your implementation must include a constructor that has three integer parameters that represent ``a``, ``b``, and ``c``, in that order.
39 | You may assume that the values of the parameters representing ``a`` and ``b`` are not zero.
40 | It must also include a method ``getSlope`` that calculates and returns the slope of the line, and a method ``isOnLine`` that returns ``true`` if the point represented by its two parameters (``x`` and ``y``, in that order) is on the ``APLine`` and returns ``false`` otherwise.
41 | Your class must produce the indicated results when invoked by the code segment given above.
42 | You may ignore any issues related to integer overflow.
43 |
44 | .. activecode:: APLineFRQ
45 | :language: java
46 |
47 | // Declare the APLine class
48 | {
49 | /** State variables. Any numeric type; object or primitive. */
50 |
51 | /** Constructor with 3 int parameters. */
52 |
53 | /** Determine the slope of this APLine. */
54 |
55 | /** Determine if coordinates represent a point on this APLine. */
56 | }
57 |
--------------------------------------------------------------------------------
/_sources/OOBasics/Figures/1-dice.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/OOBasics/Figures/1-dice.jpeg
--------------------------------------------------------------------------------
/_sources/OOBasics/Figures/2015FRQ2A.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/OOBasics/Figures/2015FRQ2A.png
--------------------------------------------------------------------------------
/_sources/OOBasics/Figures/2015FRQ2B.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/OOBasics/Figures/2015FRQ2B.png
--------------------------------------------------------------------------------
/_sources/OOBasics/Figures/SeeNSay.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/OOBasics/Figures/SeeNSay.jpg
--------------------------------------------------------------------------------
/_sources/OOBasics/Figures/Shape.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/OOBasics/Figures/Shape.png
--------------------------------------------------------------------------------
/_sources/OOBasics/Figures/TrioGrading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/OOBasics/Figures/TrioGrading.png
--------------------------------------------------------------------------------
/_sources/OOBasics/Figures/TrioPenalities.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/OOBasics/Figures/TrioPenalities.png
--------------------------------------------------------------------------------
/_sources/OOBasics/Figures/TrioStudentSol1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/OOBasics/Figures/TrioStudentSol1.png
--------------------------------------------------------------------------------
/_sources/OOBasics/Figures/TrioStudentSol2a.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/OOBasics/Figures/TrioStudentSol2a.png
--------------------------------------------------------------------------------
/_sources/OOBasics/Figures/TrioStudentSol2b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/OOBasics/Figures/TrioStudentSol2b.png
--------------------------------------------------------------------------------
/_sources/OOBasics/Figures/TrioStudentSol3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/OOBasics/Figures/TrioStudentSol3.png
--------------------------------------------------------------------------------
/_sources/OOBasics/Figures/apLineTable.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/OOBasics/Figures/apLineTable.png
--------------------------------------------------------------------------------
/_sources/OOBasics/Figures/assoc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/OOBasics/Figures/assoc.png
--------------------------------------------------------------------------------
/_sources/OOBasics/Figures/course.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/OOBasics/Figures/course.png
--------------------------------------------------------------------------------
/_sources/OOBasics/Figures/equalsEx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/OOBasics/Figures/equalsEx.png
--------------------------------------------------------------------------------
/_sources/OOBasics/Figures/menuItemObjs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/OOBasics/Figures/menuItemObjs.png
--------------------------------------------------------------------------------
/_sources/OOBasics/Figures/overrideEquals.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/OOBasics/Figures/overrideEquals.png
--------------------------------------------------------------------------------
/_sources/OOBasics/Figures/person.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/OOBasics/Figures/person.png
--------------------------------------------------------------------------------
/_sources/OOBasics/Figures/petDiagram.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/OOBasics/Figures/petDiagram.png
--------------------------------------------------------------------------------
/_sources/OOBasics/Figures/shapeSoftware.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/OOBasics/Figures/shapeSoftware.png
--------------------------------------------------------------------------------
/_sources/OOBasics/Figures/trioUML.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/OOBasics/Figures/trioUML.png
--------------------------------------------------------------------------------
/_sources/OOBasics/Figures/vehicle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/OOBasics/Figures/vehicle.png
--------------------------------------------------------------------------------
/_sources/OOBasics/freeResponse.rst:
--------------------------------------------------------------------------------
1 | Free Response Questions
2 | ::::::::::::::::::::::::
3 |
4 | .. toctree::
5 | :maxdepth: 3
6 |
7 | TrioA.rst
8 | TrioScore1.rst
9 | TrioScore2.rst
10 | TrioScore3.rst
11 | APLine.rst
12 |
--------------------------------------------------------------------------------
/_sources/OOBasics/objectObasics.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 10-1-
3 | :start: 1
4 |
5 | Object-Oriented Programming Concepts
6 | =====================================
7 |
8 | .. index::
9 | single: objects
10 | single: inheritance
11 | single: polymorphism
12 | single: Unified Modeling Language
13 |
14 | Object-oriented programming has three main features: **objects**, **inheritance**, and **polymorphism**.
15 |
16 | **Objects** have data (fields) and behavior (methods) and do the work in an object-oriented program. Objects are created by classes. A class defines the data (fields) and behavior (methods) for all objects of that class. You can create many objects from the same class. In the video below hundreds of Ant objects are created in Greenfoot. Greenfoot is a free Java development environment that makes it easy to create 2D simulations and games. For more information about Greenfoot see http://greenfoot.org.
17 |
18 |
19 | .. the video is introToAnts.mov
20 |
21 | The following video is also on YouTube at https://youtu.be/7G93HDuqXzY. It introduces the concepts of objects and classes using Greenfoot.
22 |
23 | .. youtube:: 7G93HDuqXzY
24 | :width: 800
25 | :align: center
26 |
27 | **Inheritance** allows for cleaner code since a class can inherit fields and behavior from another class instead of copying code from class to class. The **parent** class is specified using the ``extends`` keyword in the class declaration. The class that is extending the parent class is called the **child** class. In the ants scenario the ``Ant`` class inherits from the ``Actor`` class. The ``Ant`` class is the **child** class and the ``Actor`` class is the **parent** class. The ``Ant`` class inherits the ``act`` method from the ``Actor`` class, but **overrides** it by creating a method with the same signature that will be executed instead of the parent's method. This allows the ``Ant`` class to modify what an ``Ant`` object does when it acts.
28 |
29 | .. the video is inheritance.mov
30 |
31 | The following video is also on YouTube at https://youtu.be/Fq4Wmyu0Oug. It introduces the concept of inheritance using Greenfoot.
32 |
33 | .. youtube:: Fq4Wmyu0Oug
34 | :width: 800
35 | :align: center
36 |
37 | **Polymorphism** allows for specialized behavior based on the run-time type. It also removes the need for conditional execution based on the type. Java uses **inheritance-based polymorphism** where a parent class has a method that the children classes override to provide specialized behavior. In the Ant scenario the ``Balloon`` and ``Bomb`` classes inherit from the Actor class and both override the ``act`` method. The world contains a list of all Actor objects in the world and tells each to act. What happens when an Actor object acts depends on the class that created it (the run-time type).
38 |
39 | .. the video is polymorphism.mov
40 |
41 | The following video is also on YouTube at https://youtu.be/rcj1SjiuRv0. It introduces the concept of polymorphism using Greenfoot.
42 |
43 | .. youtube:: rcj1SjiuRv0
44 | :width: 800
45 | :align: center
46 |
47 | The following sections will explain the ideas of inheritance and polymorphism in more depth.
48 |
49 |
--------------------------------------------------------------------------------
/_sources/OOBasics/ooMistakes.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 10-14-
3 | :start: 1
4 |
5 | Common Mistakes
6 | ===============
7 | - Using inheritance (is a kind of) when you should use association (has a). A school has classes, it is not a type of class. A high school is a kind of school.
8 | - Using a type field instead of subclasses. If you ever find yourself creating conditionals based on the type of object use subclasses instead.
9 | - Copying code instead of creating a subclass or pulling out a common superclass. If you ever find yourself copying object fields or methods try creating a subclass instead or pull out a common superclass.
10 |
11 |
--------------------------------------------------------------------------------
/_sources/OOBasics/ooPractice.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 10-15-
3 | :start: 1
4 |
5 | More Practice
6 | =============
7 | For practice with inheritance see Chapter 9: Inheritance and Interfaces at the Practice-It website. This website requires a login but it is free.
8 | Click on the following link: `Practice-It `_.
9 |
10 | For practice with Free Response Questions see question 2 from 2010, question 4 from 2014, and questions 2 and 4 from the 2015 exam. See past free response questions by clicking on the following link: `exam info `_.
11 |
--------------------------------------------------------------------------------
/_sources/OOBasics/toctree.rst:
--------------------------------------------------------------------------------
1 | Object-Oriented Concepts
2 | ::::::::::::::::::::::::
3 |
4 | .. toctree::
5 | :maxdepth: 3
6 |
7 | objectObasics.rst
8 | objects&Classes.rst
9 | ooInheritance.rst
10 | ooAssocVsInherit.rst
11 | ooOverrideInherited.rst
12 | ooOverrideVsOverload.rst
13 | ooSuper.rst
14 | ooInheritanceAccess.rst
15 | ooInheritanceAndConstructors.rst
16 | ooAbstract.rst
17 | ooInheritanceAndInterfaces.rst
18 | ooComparable.rst
19 | ooPoly.rst
20 | ooMistakes.rst
21 | ooPractice.rst
22 | ooEasyMC.rst
23 | ooMedMC.rst
24 | ooHardMC.rst
25 | freeResponse.rst
26 | Summary.rst
27 | Exercises.rst
28 | ooParsonsPractice.rst
29 |
--------------------------------------------------------------------------------
/_sources/PictureLab/Exercises.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 18-2-
3 | :start: 1
4 |
5 | Exercises
6 | ===============================
7 |
8 | None yet
9 |
--------------------------------------------------------------------------------
/_sources/PictureLab/Figures/run-button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/PictureLab/Figures/run-button.png
--------------------------------------------------------------------------------
/_sources/PictureLab/toctree.rst:
--------------------------------------------------------------------------------
1 | Working with Images
2 | ::::::::::::::::::::::::
3 |
4 | .. toctree::
5 | :maxdepth: 3
6 |
7 | imageBasics.rst
8 | Exercises.rst
9 |
--------------------------------------------------------------------------------
/_sources/Recursion/Exercises.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 12-12-
3 | :start: 1
4 |
5 | Code Practice for Recursion
6 | ---------------------------------------------
7 |
8 | .. tabbed:: recursionCode1
9 |
10 | .. tab:: Question
11 |
12 |
13 | Replace the "ADD CODE HERE" below with the code to complete the findSum method. The method should take the sum of every value that is less than or equal to n. For example, findSum(3) should return 6. The output of the program should be 15.
14 |
15 | .. activecode:: recursionx1q
16 | :language: java
17 |
18 | public class Recursion
19 | {
20 | public static int findSum(int n)
21 | {
22 | // write code here
23 | }
24 |
25 | public static void main(String[] args)
26 | {
27 | System.out.println(findSum(5));
28 | }
29 | }
30 |
31 | .. tab:: Answer
32 |
33 | In order to find the sum of all the numbers that are less than or equal to n, we can use recursion. When findSum(5) is called, since 5 is not equal to 0, the program will go to the else statement. The method will then return 5 + findsum(4). findSum(4) will return 4 + findSum(3), findSum(3) will return 3 + findSum(2), findSum(2) will return findSum(1), findSum(1) will return 1 + findSum(0). findSum(0) will return 0. Therefore, findSum(5) will be 5+4+3+2+1+0, which is euqal to 15.
34 |
35 | .. activecode:: recursionx1a
36 | :language: java
37 |
38 | public class Recursion
39 | {
40 | public static int findSum(int n)
41 | {
42 | if (n == 0)
43 | return 0;
44 | else
45 | return n + findSum(n - 1);
46 | }
47 |
48 | public static void main(String[] args)
49 | {
50 | System.out.println(findSum(5));
51 | }
52 | }
53 |
54 | .. tab:: Discussion
55 |
56 | .. disqus::
57 | :shortname: cslearn4u
58 | :identifier: javareview_recursionx1a
59 |
--------------------------------------------------------------------------------
/_sources/Recursion/Figures/callTree.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Recursion/Figures/callTree.png
--------------------------------------------------------------------------------
/_sources/Recursion/Figures/codeForCallStack.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Recursion/Figures/codeForCallStack.png
--------------------------------------------------------------------------------
/_sources/Recursion/Figures/cupStack.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Recursion/Figures/cupStack.jpg
--------------------------------------------------------------------------------
/_sources/Recursion/Figures/errorCallStack.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Recursion/Figures/errorCallStack.png
--------------------------------------------------------------------------------
/_sources/Recursion/Figures/sakura_by_velvet__glove-d8i38i2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Recursion/Figures/sakura_by_velvet__glove-d8i38i2.jpg
--------------------------------------------------------------------------------
/_sources/Recursion/Figures/triangleSub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Recursion/Figures/triangleSub.png
--------------------------------------------------------------------------------
/_sources/Recursion/Summary.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 12-11-
3 | :start: 1
4 |
5 | Recursion Summary
6 | -------------------------
7 |
8 | In this chapter you learned about **recursion**. A recursive method calls itself (contains a call to the method from inside of the method). A recursive method should have at least one way to stop the recursion. This is called a base case.
9 |
10 | .. index::
11 | single: recursion
12 |
13 | Concept Summary
14 | =================
15 |
16 | - **base case** - A way to stop the recursive calls. This is a return without a recursive call.
17 | - **call stack** - A class defines what all objects of that class know (fields) and can do (methods). You can also have data and behavior in the object that represents the class (class fields and methods). All objects of a class have access to class fields and class methods, but these can also be accessed using ``className.field`` or ``className.method()``.
18 | - **recursive method** - A method that contains at least one call to itself inside the method.
19 |
20 | Practice
21 | ===========
22 |
23 | .. dragndrop:: ch12rec_match_1
24 | :feedback: Review the summaries above.
25 | :match_1: A method that calls itself|||recursive method
26 | :match_2: The stack of calls to methods|||call stack
27 | :match_3: The case when the method doesn't call itself|||base case
28 |
29 | Drag the item from the left and drop it on its corresponding answer on the right. Click the "Check Me" button to see if you are correct.
30 |
--------------------------------------------------------------------------------
/_sources/Recursion/rBasePractice.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 12-5-
3 | :start: 1
4 |
5 | Base Case Practice
6 | ====================
7 |
8 | A recursive method contains a call to itself. The recursion stops when a base case test is true and a value is returned.
9 |
10 | .. clickablearea:: rec_base1
11 | :question: Click on the line or lines that contain the test for the base case
12 | :iscode:
13 | :feedback: When a base case test is true a value is returned and the recursion stops.
14 |
15 |
16 | :click-incorrect:public static int factorial(int n):endclick:
17 | :click-incorrect:{:endclick:
18 | :click-correct:if (n == 0):endclick:
19 | :click-incorrect:return 1;:endclick:
20 | :click-incorrect:else:endclick:
21 | :click-incorrect:return n * factorial(n-1);:endclick:
22 | :click-incorrect:}:endclick:
23 |
24 | .. clickablearea:: rec_base2
25 | :question: Click on the line or lines that contain the test for the base case
26 | :iscode:
27 | :feedback: When a base case test is true a value is returned and the recursion stops
28 |
29 | :click-incorrect:public static int mystery(int n):endclick:
30 | :click-incorrect:{:endclick:
31 | :click-correct:if (n == 0):endclick:
32 | :click-incorrect:return 1;:endclick:
33 | :click-incorrect:else:endclick:
34 | :click-incorrect:return 2 * mystery (n - 1);:endclick:
35 | :click-incorrect:}:endclick:
36 |
37 | .. clickablearea:: rec_base3
38 | :question: Click on the line or lines that contain the test for the base case
39 | :iscode:
40 | :feedback: When a base case test is true a value is returned and the recursion stops
41 |
42 | :click-incorrect:public static int bunnyEars(int bunnies):endclick:
43 | :click-incorrect:{:endclick:
44 | :click-correct:if (bunnies == 0) return 0;:endclick:
45 | :click-correct:else if (bunnies == 1) return 2;:endclick:
46 | :click-incorrect:else return 2 + bunnyEars(bunnies - 1);:endclick:
47 | :click-incorrect:}:endclick:
48 |
49 | .. clickablearea:: rec_base4
50 | :question: Click on the line or lines that contain the test for the base case
51 | :iscode:
52 | :feedback: When a base case test is true a value is returned and the recursion stops
53 |
54 | :click-incorrect:public static void mystery (int x) {:endclick:
55 | :click-incorrect:System.out.print(x % 10);:endclick:
56 | :click-correct:if ((x / 10) != 0) {:endclick:
57 | :click-incorrect:mystery(x / 10);:endclick:
58 | :click-incorrect:}:endclick:
59 | :click-incorrect:System.out.print(x % 10);:endclick:
60 | :click-incorrect:}:endclick:
61 |
62 | .. clickablearea:: rec_base5
63 | :question: Click on the line or lines that contain the test for the base case
64 | :iscode:
65 | :feedback: When a base case test is true a value is returned and the recursion stops
66 |
67 | :click-incorrect:public static int mystery(String str):endclick:
68 | :click-incorrect:{:endclick:
69 | :click-correct:if (str.length() == 1) return 0;:endclick:
70 | :click-incorrect:else:endclick:
71 | :click-incorrect:{:endclick:
72 | :click-incorrect:if (str.substring(0,1).equals("y")) return 1 +:endclick:
73 | :click-incorrect:mystery(str.substring(1));:endclick:
74 | :click-incorrect:else return mystery(str.substring(1));:endclick:
75 | :click-incorrect:}:endclick:
76 | :click-incorrect:}:endclick:
77 |
--------------------------------------------------------------------------------
/_sources/Recursion/rMistakes.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 12-4-
3 | :start: 1
4 |
5 |
6 | Common Mistakes
7 | ===============
8 | - Missing the recursive call. Be sure to look for a call to the same method.
9 | - Getting confused about when a recursive method returns and what it returns.
10 | - Assuming you understand what the recursion is doing without tracing all of it.
11 |
--------------------------------------------------------------------------------
/_sources/Recursion/rWhyUseIt.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 12-2-
3 | :start: 1
4 |
5 | Why use Recursion?
6 | ==================
7 |
8 | .. index::
9 | single: fractal
10 | pair: recursion; purpose
11 |
12 | Recursion is most useful when it is used to solve problems where the structure of the problem repeats. For example, what if you wanted to find out how much space a folder on your computers uses? You could add up the sizes of all the files in that folder, but folders can also contain subfolders. So you will have to repeat the procedure (method) for each subfolder. Each subfolder can also contain subfolders.
13 |
14 | Recursion can also be used to create fractals. A simple example is Sierpinski's triangle in which you subdivide a triangle into 4 new triangles as shown below. You can then do the some procedure with each new triangle except the center one.
15 |
16 | .. figure:: Figures/triangleSub.png
17 | :width: 452px
18 | :align: center
19 | :figclass: align-center
20 |
21 | Figure 1: A sequence of Sierpinski's triangles
22 |
--------------------------------------------------------------------------------
/_sources/Recursion/toctree.rst:
--------------------------------------------------------------------------------
1 | Recursion
2 | :::::::::
3 |
4 | .. toctree::
5 | :maxdepth: 3
6 |
7 | recursionbasics.rst
8 | rWhyUseIt.rst
9 | rTraceMethods.rst
10 | rMistakes.rst
11 | rBasePractice.rst
12 | rTracePractice.rst
13 | rEasyMC.rst
14 | rMedMC.rst
15 | rHardMC.rst
16 | rParsonsPractice.rst
17 | Summary.rst
18 | Exercises.rst
19 | rMixedUpCodePractice.rst
20 |
--------------------------------------------------------------------------------
/_sources/SearchSort/Exercises.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 13-11-
3 | :start: 1
4 |
5 | Exercises
6 | ===============================
7 |
8 | None yet
9 |
--------------------------------------------------------------------------------
/_sources/SearchSort/Summary.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 13-7-
3 | :start: 1
4 |
5 | Searching and Sorting Summary
6 | -------------------------------
7 |
8 | In this chapter you learned about **searching** and **sorting**. Searching means looking for a value in a sequence (array or list). Sorting means changing the order of a sequence (array or list) of items to be in order.
9 |
10 | .. index::
11 | single: recursion
12 |
13 | Concept Summary
14 | =================
15 |
16 | - **binary search** - Searching a sorted sequence by looking in the middle of the remaining search space till either you find the item you are looking for or run out of places to look and thus realize it isn't there.
17 | - **insertion sort** - A sort that inserts the next item in the correct place in a partially sorted sequence. It moves all larger (or smaller) values to make room for the new value.
18 | - **sequential search** - A search that looks at each item in a sequence to find a value or determine if the item isn't in the sequence. It returns the index for the found value or -1 which means the value wasn't in the sequence.
19 | - **sequential sort** - A sort that loops from the current index to the end of the sequence and swaps the value at the current index with the smallest (or largest) value in the rest of the unsorted sequence.
20 | - **merge sort** - A sort that uses recursion to split the items to be sorted into two parts until there is only one item in each part and then merges the two sorted sequences into one sorted sequence.
21 |
22 | Practice
23 | ===========
24 |
25 | .. dragndrop:: ch13ss_match_1
26 | :feedback: Review the summaries above.
27 | :match_1: A search that requires the sequence to be sorted|||binary search
28 | :match_2: A search that searches each item in a sequence for a value|||sequential search
29 | :match_3: A sort that inserts the next value to be sorted into the sorted sequence by moving all larger values right|||insertion sort
30 | :match_4: A sort that uses recursion|||merge sort
31 | :match_5: A sort that loops through a sequence looking for the smallest (or largest) in the remaining sequence|||sequential sort
32 |
33 | Drag the item from the left and drop it on its corresponding answer on the right. Click the "Check Me" button to see if you are correct.
34 |
--------------------------------------------------------------------------------
/_sources/SearchSort/searchBasics.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 13-1-
3 | :start: 1
4 |
5 | Searching and Sorting
6 | ======================
7 |
8 | .. index::
9 | single: sequential search
10 | single: binary search
11 | single: recursion
12 | pair: search; sequential
13 | pair: search; binary
14 |
15 | Computers store vast amounts of data. One of the strengths of computers is their ability to find things quickly. This ability is called **searching**. For the AP CS A exam you will need to know both **sequential search** and **binary search**.
16 |
17 | .. the video is Searching.mov
18 |
19 | The following video is also on YouTube at https://youtu.be/DHLCXXX1OtE. It introduces the concept of searching including sequential search and binary search.
20 |
21 | .. youtube:: DHLCXXX1OtE
22 | :width: 800
23 | :align: center
24 |
25 |
26 | * Sequential search typically starts at the first element in an array or list and looks through all the items one by one until it either finds the desired value and then it returns the index it found the value at or if it searches the entire array or list without finding the value it returns -1.
27 | * Binary search **can only be used on data that has been sorted or stored in order**. It checks the middle of the data to see if that middle value is less than, equal, or greater than the desired value and then based on the results of that it narrows the search. It cuts the search space in half each time.
28 |
29 |
30 |
31 | If binary search requires the values in an array or list to be sorted, how can you do that? There are many sorting algorithms. The three that you need to know for the AP CS A exam are:
32 |
33 | .. index::
34 | single: selection sort
35 | single: insertion sort
36 | single: merge sort
37 | pair: sort; selection
38 | pair: sort; insertion
39 | pair: sort; merge
40 |
41 | * Selection Sort - Select the smallest item from the current location on to the end of the array and swap it with the value at the current position. Do this from index 0 to the array length - 2. You don't have to process the last element in the array, it will already be sorted when you compare the prior element to the last element.
42 | * Insertion Sort - Insert the next unsorted element in the already sorted part of the array by moving larger values to the right. Start at index 1 and loop through the entire array.
43 | * Merge sort - Break the elements into two parts and recursively sort each part. An array of one item is sorted (base case). Then merge the two sorted arrays into one.
44 |
45 | There are many videos on YouTube that show these sorts. Here is a folk dance for selection sort.
46 |
47 | .. youtube:: Ns4TPTC8whw
48 | :align: center
49 |
50 | Here is folk dance for insertion sort.
51 |
52 | .. youtube:: ROalU379l3U
53 | :align: center
54 |
55 | Here is folk dance for merge sort.
56 |
57 | .. youtube:: XaqR3G_NVoo
58 | :align: center
59 |
60 | Here is another video that talks about bubble sort, insertion sort, and quick sort. Of these only insertion sort is on the exam.
61 |
62 |
63 | .. youtube:: WaNLJf8xzC4
64 | :align: center
65 |
--------------------------------------------------------------------------------
/_sources/SearchSort/toctree.rst:
--------------------------------------------------------------------------------
1 | Searching and Sorting
2 | ::::::::::::::::::::::
3 |
4 | .. toctree::
5 | :maxdepth: 3
6 |
7 | searchBasics.rst
8 | seqSearch.rst
9 | binarySearch.rst
10 | selSort.rst
11 | insertionSort.rst
12 | mergeSort.rst
13 | Summary.rst
14 | ssEasyMC.rst
15 | ssMedMC.rst
16 | ssHardMC.rst
17 | Exercises.rst
18 |
--------------------------------------------------------------------------------
/_sources/Strings/Figures/greeting.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Strings/Figures/greeting.png
--------------------------------------------------------------------------------
/_sources/Strings/Figures/nullStringRef.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Strings/Figures/nullStringRef.png
--------------------------------------------------------------------------------
/_sources/Strings/Figures/stringIndicies.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Strings/Figures/stringIndicies.png
--------------------------------------------------------------------------------
/_sources/Strings/Figures/stringObject.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Strings/Figures/stringObject.png
--------------------------------------------------------------------------------
/_sources/Strings/Figures/stringRef.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Strings/Figures/stringRef.png
--------------------------------------------------------------------------------
/_sources/Strings/Figures/stringRefExamplev2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Strings/Figures/stringRefExamplev2.png
--------------------------------------------------------------------------------
/_sources/Strings/Figures/stringRefWithObj.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Strings/Figures/stringRefWithObj.png
--------------------------------------------------------------------------------
/_sources/Strings/Figures/twoStringRefs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Strings/Figures/twoStringRefs.png
--------------------------------------------------------------------------------
/_sources/Strings/Figures/twoStringRefsLiteral.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Strings/Figures/twoStringRefsLiteral.png
--------------------------------------------------------------------------------
/_sources/Strings/Figures/twoStringRefsv2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Strings/Figures/twoStringRefsv2.png
--------------------------------------------------------------------------------
/_sources/Strings/sEasyMC.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 4-7-
3 | :start: 1
4 |
5 | .. highlight:: java
6 | :linenothreshold: 3
7 |
8 | Easy Multiple Choice Questions
9 | ------------------------------
10 |
11 | These problems are mostly easier than what you will see on the AP CS A exam.
12 |
13 | .. mchoice:: qse_1
14 | :answer_a: xyz
15 | :answer_b: xyxyz
16 | :answer_c: xy xy z
17 | :answer_d: xy z
18 | :answer_e: z
19 | :correct: b
20 | :feedback_a: s1 will equal "xy" plus another "xy" then z at the end.
21 | :feedback_b: s1 contains the original value, plus itself, plus "z"
22 | :feedback_c: No spaces are added during concatenation.
23 | :feedback_d: No spaces are added during concatenation, and an additional "xy" should be included at the beginning.
24 | :feedback_e: s1 was set to "xy" initially, so the final answer will be "xyxyz"
25 |
26 | Given the following code segment, what is in the string referenced by s1?
27 |
28 | .. code-block:: java
29 |
30 | String s1 = "xy";
31 | String s2 = s1;
32 | s1 = s1 + s2 + "z";
33 |
34 | .. mchoice:: qse_2
35 | :answer_a: 8
36 | :answer_b: 10
37 | :answer_c: 11
38 | :correct: c
39 | :feedback_a: Be sure to count spaces and punctuation in the length (the number of characters in the string).
40 | :feedback_b: Did you forget to count a space or punctuation?
41 | :feedback_c: The length method returns the number of characters in the string, including spaces and punctuation.
42 |
43 | What is the value of len after the following executes?
44 |
45 | .. code-block:: java
46 |
47 | String s1 = "Hey, buddy!";
48 | int len = s1.length();
49 |
50 | .. mchoice:: qse_3
51 | :answer_a: 3
52 | :answer_b: 4
53 | :answer_c: 5
54 | :answer_d: -1
55 | :correct: a
56 | :feedback_a: The method indexOf returns the first position of the passed str in the current string starting from the left (from 0).
57 | :feedback_b: The first character is at index 0 in a string, not 1.
58 | :feedback_c: Does the indexOf method find the first occurrence of the character, or the last?
59 | :feedback_d: Does the string contain a d? The pos method will return the first index that the character is at in the string.
60 |
61 | What is the value of pos after the following code executes?
62 |
63 | .. code-block:: java
64 |
65 | String s1 = "ac ded ca";
66 | int pos = s1.indexOf("d");
67 |
68 | .. mchoice:: qse_4
69 | :answer_a: Hey
70 | :answer_b: he
71 | :answer_c: H
72 | :answer_d: h
73 | :correct: a
74 | :feedback_a: Strings are immutable, meaning they don't change. Any method that that changes a string returns a new string. So s1 never changes unless you set it to a different string.
75 | :feedback_b: The substring method returns a new string starting at the first index and ending before the second index.
76 | :feedback_c: This would be true if we asked what the value of s2 was after the code executes. What is the value of s1?
77 | :feedback_d: This would be true if we asked what the value of s3 was after the code executes. What is the value of s1?
78 |
79 | What is the value of s1 after the following code executes?
80 |
81 | .. code-block:: java
82 |
83 | String s1 = "Hey";
84 | String s2 = s1.substring(0,1);
85 | String s3 = s2.toLowerCase();
86 |
--------------------------------------------------------------------------------
/_sources/Strings/sHardMC.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 4-9-
3 | :start: 1
4 |
5 | Hard Multiple Choice Questions
6 | ----------------------------------
7 |
8 | These problems are harder than most of those that you will usually see on the AP CS A exam.
9 |
10 | .. mchoice:: qsh_1
11 | :answer_a: II and IV
12 | :answer_b: II, III, and IV
13 | :answer_c: I, II, III, IV
14 | :answer_d: II only
15 | :answer_e: IV only
16 | :correct: b
17 | :feedback_a: III is also correct.
18 | :feedback_b: String overrides equals to check if the two string objects have the same characters. The == operator checks if two object references refer to the same object. So II is correct since s1 and s2 have the same characters. Number II is correct since s3 and s1 are referencing the same string, so they will be ==. And s2 and s3 both refer to string that have the same characters so equals will be true in IV. The only one that will not be true is I, since s1 and s2 are two different objects (even though they have the same characters).
19 | :feedback_c: I is not correct since s1 and s2 are two different objects (even though they have the same characters). If s1 and s2 were both referring to literals, then I would be correct, but the new operator forces a new object to be created.
20 | :feedback_d: III and IV are also correct.
21 | :feedback_e: II and III are also correct.
22 |
23 | Given the following code segment, which of the following is true?
24 |
25 | .. code-block:: java
26 |
27 | String s1 = new String("Hi There");
28 | String s2 = new String("Hi There");
29 | String s3 = s1;
30 |
31 | I. (s1 == s2)
32 | II. (s1.equals(s2))
33 | III. (s1 == s3)
34 | IV. (s2.equals(s3))
35 |
36 | .. mchoice:: qsh_2
37 | :answer_a: 21
38 | :answer_b: 1353
39 | :answer_c: It will give a run-time error
40 | :answer_d: 138
41 | :answer_e: It will give a compile-time error
42 | :correct: b
43 | :feedback_a: This would be correct if it was System.out.println(13 + 5 + 3), but the 13 is a string.
44 | :feedback_b: This is string concatenation. When you apprend a number to a string it get turned into a string and processing is from left to right.
45 | :feedback_c: You can append a number to a string in Java. It turns the number into a string and then appends the second string to the first string.
46 | :feedback_d: This would be correct if it was System.out.println("13" + (5 + 3)), but the 5 is turned into a string and appended to the 13 and then the same is done with the 3.
47 | :feedback_e: You can append a number to a string in Java. It will compile.
48 |
49 | What does the following code print?
50 |
51 | .. code-block:: java
52 |
53 | System.out.println("13" + 5 + 3);
54 |
--------------------------------------------------------------------------------
/_sources/Strings/sMistakes.rst:
--------------------------------------------------------------------------------
1 |
2 | .. qnum::
3 | :prefix: 4-5-
4 | :start: 1
5 |
6 | Common Mistakes
7 | ===============
8 |
9 | - Using ``==`` to test if two strings are equal. This is actually a test to see if they refer to the same object. Usually you only want to know if they have the same characters in the same order. In that case you should use ``equals`` or ``compareTo`` instead.
10 |
11 | - Treating upper and lower case characters the same in Java. If ``s1 = "Hi"`` and ``s2 = "hi"`` then ``s1.equals(s2)`` is false.
12 |
13 | - Thinking that substrings include the character at the last index when they don't.
14 |
15 | - Thinking that strings can change when they can't. They are immutable.
16 |
17 | - Trying to invoke a method like ``indexOf`` on a string reference that is null. You will get a null pointer exception.
18 |
--------------------------------------------------------------------------------
/_sources/Strings/sOperators.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 4-4-
3 | :start: 1
4 |
5 | String Operators - Concatenation
6 | ==================================
7 |
8 | .. index::
9 | pair: String; append
10 |
11 | Strings can be **appended** to each other which creates a new string using the ``+`` operator . This is also called **concatenation**.
12 |
13 | .. activecode:: lcso1
14 | :language: java
15 |
16 | public class Test1
17 | {
18 | public static void main(String[] args)
19 | {
20 | String start = "Happy Birthday";
21 | String name = "Jose";
22 | String result = start + " " + name;
23 | System.out.println(result);
24 | }
25 | }
26 |
27 | .. note::
28 | Note that spaces are not added between strings automatically. If you want a space between two strings then add one.
29 |
30 | .. index::
31 | single: toString
32 | pair: Object; toString
33 |
34 | You can even add other items to a string using the ``+`` operator. The other item will be converted to a string using the ``toString`` operator if it is an object and then appended to the current string. All objects inherit a ``toString`` method that returns a string representation of the object.
35 |
36 | What do you think the following will print?
37 |
38 | .. activecode:: lcso2
39 | :language: java
40 |
41 | public class Test2
42 | {
43 | public static void main(String[] args)
44 | {
45 | String message = "12" + 4 + 3;
46 | System.out.println(message);
47 | }
48 | }
49 |
50 | .. note::
51 | If you are appending a number to a string it will be converted to a string first before being appended.
52 |
53 | Since the same operators are processed from left to right this will print ``1243``. First 4 will be turned into a string and appended to 12 and then 3 will be turned into a string and appended to 124. If you want the addition to take place before the numbers are turned into a string what should you do? Try to modify the code above so that it adds 4 + 3 before appending the value to the string.
54 |
--------------------------------------------------------------------------------
/_sources/Strings/sResources.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 4-6-
3 | :start: 1
4 |
5 | More Practice
6 | ===============
7 |
8 | For more practice with Strings see problems at http://codingbat.com/java/String-1.
9 |
10 | * http://codingbat.com/prob/p161056
11 | * http://codingbat.com/prob/p147483
12 | * http://codingbat.com/prob/p108853
13 | * http://codingbat.com/prob/p130896
14 | * http://codingbat.com/prob/p130781
15 |
16 | If you have covered how to write a method do free response question 2 from 2008 or question 1 (after also covering lists) from 2013 at http://coweb.cc.gatech.edu/ice-gt/1277.
17 |
--------------------------------------------------------------------------------
/_sources/Strings/toctree.rst:
--------------------------------------------------------------------------------
1 | Strings
2 | ::::::::::::::::::::
3 |
4 | .. toctree::
5 | :maxdepth: 3
6 |
7 | sbasics.rst
8 | sMethods.rst
9 | sEquality.rst
10 | sOperators.rst
11 | sMistakes.rst
12 | sResources.rst
13 | sEasyMC.rst
14 | sMedMC.rst
15 | sHardMC.rst
16 | Summary.rst
17 | Exercises.rst
18 | StringPracticeParsons.rst
19 |
--------------------------------------------------------------------------------
/_sources/Tests/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Tests/.DS_Store
--------------------------------------------------------------------------------
/_sources/Tests/Exercises.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 14-1-
3 | :start: 1
4 |
5 | Preparing for the AP CS A Exam
6 | ==================================
7 |
8 | This chapter contains practice tests to help you prepare for the AP CS A exam. I have also listed other
9 | materials that you might find useful below.
10 |
11 | Nice resource with tips on how to do well on the exam from Rebecca Dovi.
12 |
13 | * http://www.supercs.net/wp-content/uploads/2016/01/AP-Review-top-ten-things.pdf
14 |
15 | Flash cards to help you self-test from Rebecca Dovi.
16 |
17 | * http://www.supercs.net/wp-content/uploads/2016/01/AP-Flash_Cards_DOVI.pdf
18 |
19 | Additional material from the University of Washington (including another timed 40 question multiple-choice test)
20 |
21 | * https://courses.cs.washington.edu/courses/cse142/apcs/labs.shtml
22 |
--------------------------------------------------------------------------------
/_sources/Tests/Figures/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Tests/Figures/.DS_Store
--------------------------------------------------------------------------------
/_sources/Tests/Figures/finishExam.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Tests/Figures/finishExam.png
--------------------------------------------------------------------------------
/_sources/Tests/Figures/next.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Tests/Figures/next.png
--------------------------------------------------------------------------------
/_sources/Tests/Figures/pause.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Tests/Figures/pause.png
--------------------------------------------------------------------------------
/_sources/Tests/Figures/prev.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Tests/Figures/prev.png
--------------------------------------------------------------------------------
/_sources/Tests/Figures/start.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/Tests/Figures/start.png
--------------------------------------------------------------------------------
/_sources/Tests/toctree.rst:
--------------------------------------------------------------------------------
1 | Preparing for the Exam
2 | :::::::::::::::::::::::::::::::::
3 |
4 | .. toctree::
5 | :maxdepth: 3
6 |
7 | Exercises.rst
8 | test1nt.rst
9 | test2nt.rst
10 | test3nt.rst
11 | test4nt.rst
12 | test5nt.rst
13 |
--------------------------------------------------------------------------------
/_sources/TimedTests/Figures/finishExam.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/TimedTests/Figures/finishExam.png
--------------------------------------------------------------------------------
/_sources/TimedTests/Figures/next.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/TimedTests/Figures/next.png
--------------------------------------------------------------------------------
/_sources/TimedTests/Figures/pause.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/TimedTests/Figures/pause.png
--------------------------------------------------------------------------------
/_sources/TimedTests/Figures/prev.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/TimedTests/Figures/prev.png
--------------------------------------------------------------------------------
/_sources/TimedTests/Figures/start.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/TimedTests/Figures/start.png
--------------------------------------------------------------------------------
/_sources/TimedTests/toctree.rst:
--------------------------------------------------------------------------------
1 |
2 | Timed Multiple-Choice Exams
3 | :::::::::::::::::::::::::::::::::
4 |
5 | .. toctree::
6 | :maxdepth: 3
7 |
8 | test1.rst
9 | test2.rst
10 | test3.rst
11 | test4.rst
12 | Exercises.rst
13 |
--------------------------------------------------------------------------------
/_sources/TurtleGraphics/Exercises.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 19-2-
3 | :start: 1
4 |
5 | Exercises
6 | ===============================
7 |
8 | None yet
9 |
--------------------------------------------------------------------------------
/_sources/TurtleGraphics/Figures/mindstorms_turtle.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/TurtleGraphics/Figures/mindstorms_turtle.jpg
--------------------------------------------------------------------------------
/_sources/TurtleGraphics/Figures/run-button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/TurtleGraphics/Figures/run-button.png
--------------------------------------------------------------------------------
/_sources/TurtleGraphics/Figures/turtleA.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/TurtleGraphics/Figures/turtleA.png
--------------------------------------------------------------------------------
/_sources/TurtleGraphics/Figures/turtleUMLClassDiagram.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/TurtleGraphics/Figures/turtleUMLClassDiagram.png
--------------------------------------------------------------------------------
/_sources/TurtleGraphics/toctree.rst:
--------------------------------------------------------------------------------
1 | Turtles - Intro to Objects and Methods
2 | :::::::::::::::::::::::::::::::::::::::::
3 |
4 | .. toctree::
5 | :maxdepth: 3
6 |
7 | turtleBasics.rst
8 | Exercises.rst
9 |
--------------------------------------------------------------------------------
/_sources/VariableBasics/Figures/casting.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/VariableBasics/Figures/casting.jpg
--------------------------------------------------------------------------------
/_sources/VariableBasics/Figures/classVehicleExample.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/VariableBasics/Figures/classVehicleExample.png
--------------------------------------------------------------------------------
/_sources/VariableBasics/Figures/mod-py.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/VariableBasics/Figures/mod-py.png
--------------------------------------------------------------------------------
/_sources/VariableBasics/Figures/pongScore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/VariableBasics/Figures/pongScore.png
--------------------------------------------------------------------------------
/_sources/VariableBasics/Figures/typeName.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/VariableBasics/Figures/typeName.png
--------------------------------------------------------------------------------
/_sources/VariableBasics/Figures/typeNameValue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/VariableBasics/Figures/typeNameValue.png
--------------------------------------------------------------------------------
/_sources/VariableBasics/Figures/typesAndSpace.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/VariableBasics/Figures/typesAndSpace.png
--------------------------------------------------------------------------------
/_sources/VariableBasics/Figures/variables.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/VariableBasics/Figures/variables.png
--------------------------------------------------------------------------------
/_sources/VariableBasics/Figures/vehicleDiag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_sources/VariableBasics/Figures/vehicleDiag.png
--------------------------------------------------------------------------------
/_sources/VariableBasics/casting.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 3-5-
3 | :start: 1
4 |
5 | Casting Variables
6 | =================
7 |
8 | Run this code to find how Java handles division and what casting can do to the results.
9 |
10 | .. activecode:: lcct1
11 | :language: java
12 |
13 | public class Test
14 | {
15 | public static void main(String[] args)
16 | {
17 | System.out.println(1 / 3);
18 | System.out.println(1.0 / 3);
19 | System.out.println(1 / 3.0);
20 | System.out.println((double) 1 / 3);
21 | }
22 | }
23 |
24 | Java assumes that if you are doing division with integers that you want an integer result and it will throw away any fractional part (part after the decimal point). But, if you use a mixture of integers (int) and floating point (double) numbers Java will assume that you want a floating point result. If you have integers and you want a floating point result from some mathematical operation **cast** one of the integers to a double using (double) as shown above. By **casting** we don't mean something to do with fishing, but it is a similar idea to casting a pot in clay. In Java when you cast you are changing the "shape" (or type) of the variable to the right of the cast to the specified type.
25 |
26 | .. figure:: Figures/casting.jpg
27 | :width: 300px
28 | :figclass: align-center
29 |
30 | Figure 3: Casting a pot in clay.
31 |
32 | .. index::
33 | pair: double; number of digits
34 |
35 |
36 | Is the result of 1.0 divided by 3 what you expected? Java limits the number of digits you can save for any ``double`` number to about 14-15 digits. You should be aware that the accuracy of any calculation on a computer is limited by the fact that computers can only hold a limited number of digits.
37 |
38 | **Check your understanding**
39 |
40 | .. mchoice:: q2_5
41 | :answer_a: true
42 | :answer_b: false
43 | :correct: b
44 | :feedback_a: Did you try this out in Dr Java? Does it work that way?
45 | :feedback_b: Java throws away any values after the decimal point if you do integer division. It does not round up automatically.
46 |
47 | True or false: Java rounds up automatically when you do integer division.
48 |
49 | .. mchoice:: q2_6
50 | :answer_a: true
51 | :answer_b: false
52 | :correct: b
53 | :feedback_a: Try casting to int instead of double. What does that do?
54 | :feedback_b: Casting results in the type that you cast to. However, if you can't really cast the value to the specified type then you will get an error.
55 |
56 | True or false: casting always results in a double type.
57 |
58 | .. mchoice:: q2_7
59 | :answer_a: (double) (total / 3);
60 | :answer_b: total / 3;
61 | :answer_c: (double) total / 3;
62 | :correct: c
63 | :feedback_a: This does integer division before casting the result to double so it loses the fractional part.
64 | :feedback_b: When you divide an integer by an integer you get an integer result and lose the fractional part.
65 | :feedback_c: This will convert total to a double value and then divide by 3 to return a double result.
66 |
67 | Which of the following returns the correct average when 3 values had been added to an integer total?
68 |
--------------------------------------------------------------------------------
/_sources/VariableBasics/commonMistakes.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 3-8-
3 | :start: 1
4 |
5 | Common Mistakes
6 | ===============
7 |
8 | - forgetting that Java is case sensitive - ``myScore`` is not the same as ``myscore``.
9 |
10 | - forgetting to specify the type when declaring a variable (using ``name = value;`` instead of ``type name = value;``)
11 |
12 | - using a variable name, but never declaring the variable.
13 |
14 | - using the wrong name for the variable. For example calling it ``studentTotal`` when you declare it, but later calling it ``total``.
15 |
16 | - using the wrong type for a variable. Don't forget that using integer types in calculations will give an integer result. So either cast one integer value to double or use a double variable if you want the fractional part (the part after the decimal point).
17 |
18 | - using ``==`` to compare double values. Remember that double values are often an approximation. You might want to test if the absolute value of the difference between the two values is less than some amount instead.
19 |
20 | - assuming that some value like 0 will be smaller than other ``int`` values. Remember that ``int`` values can be negative as well. If you want to set a value to the smallest possible ``int`` values use ``Integer.MIN_VALUE``
21 |
--------------------------------------------------------------------------------
/_sources/VariableBasics/minAndMax.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 3-6-
3 | :start: 1
4 |
5 | Integer Min and Max
6 | ===================
7 |
8 | .. index::
9 | pair: integer; minimum
10 | pair: integer; maximum
11 |
12 | The int type in Java can be used to represent any whole number from -2147483648 to 2147483647. Why those numbers? Integers in Java are represented in 2's complement binary and each integer gets 32 bits of space. In 32 bits of space with one bit used to represent the sign you can represent that many values. Why is there one more negative number than positive number? It is because 0 is considered a positive number.
13 |
14 | .. activecode:: lcmm1
15 | :language: java
16 |
17 | public class Test
18 | {
19 | public static void main(String[] args)
20 | {
21 | System.out.println(Integer.MIN_VALUE);
22 | System.out.println(Integer.MAX_VALUE);
23 | System.out.println(Integer.MIN_VALUE - 1);
24 | System.out.println(Integer.MAX_VALUE + 1);
25 | }
26 | }
27 |
28 | .. index::
29 | single: overflow
30 |
31 | What do the last two lines print out? Did this surprise you? Java will actually return the maximum integer value if you try to subtract one from the minimum value. This is called **underflow**. And, Java will return the minimum integer value if you try to add one to the maximum. This is called **overflow**. It is similar to how odometers work.
32 | When would you ever use Integer.MIN_VALUE or Integer.MAX_VALUE? They are handy if you want to initialize a variable to the smallest possible value and then search a sequence of values for a larger value.
33 |
34 | .. note::
35 |
36 | People sometimes set the initial value to 0 when looking for the largest item in a sequence of integers, but if all of the values in your sequence are negative then this won't work correctly (since all negative numbers are smaller than zero).
37 |
--------------------------------------------------------------------------------
/_sources/VariableBasics/nameVars.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 3-3-
3 | :start: 1
4 |
5 |
6 | Naming Variables
7 | --------------------
8 |
9 | .. index::
10 | pair: variable; names
11 |
12 | While you can name your variable almost anything, there are some rules. A variable name should start with an alphabetic character (like a, b, c, etc). You can't use any of the keywords or reserved words as variable names in Java (``for``, ``if``, ``class``, ``static``, ``int``, ``double``, etc). For a complete list of keywords and reserved words see http://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html.
13 |
14 | The name of the variable should match both the function of the variable and the type of the variable. A name like ``score`` helps make your code easier to read. Do not try to be cute on the exam and name
15 | your variables crazy things like ``thisIsAReallyLongName``. This makes the code very hard to understand. The free response questions are graded by readers (high school AP CS A teachers and college faculty). You want to make the readers' job easier, not harder!
16 |
17 | .. note::
18 |
19 | Remember that a reader is reading thousands of exams, you don't want to make this person work harder than necessary, so use good variable names.
20 |
21 | .. index::
22 | single: camel case
23 | pair: variable; naming convention
24 |
25 | The convention in Java is to always start a variable name with a lower case letter and then uppercase the first letter of each additional word. Variable names can not include spaces so uppercasing the first letter of each additional word makes it easier to read the name. Uppercasing the first letter of each additional word is called **camel case**. Java is case sensitive so ``playerScore`` and ``playerscore`` are not the same.
26 |
27 | .. activecode:: lcnv1
28 | :language: java
29 |
30 | public class Test
31 | {
32 | public static void main(String[] args)
33 | {
34 | int PlayerScore = 0; // variables names using camel case
35 | int playerScore = 1;
36 | System.out.println(PlayerScore);
37 | System.out.println(playerScore);
38 | }
39 | }
40 |
41 | **Check Your Understanding**
42 |
43 | .. fillintheblank:: fillName1
44 |
45 | What is the camel case variable name for a variable that represents a shoe size?
46 |
47 | - :^\s*shoeSize$: Correct. Start with the first word in all lowercase and uppercase the first letter of each additional word
48 | :.*: In camel case just appended the words after each other but uppercase the first letter of each word after the 1st word
49 |
50 |
51 |
52 | .. fillintheblank:: fillName2
53 |
54 | What is the camel case variable name for a variable that represents the top score?
55 |
56 | - :^\s*topScore$: Correct.
57 | :.*: In camel case just appended the words after each other but uppercase the first letter of each word after the 1st word
58 |
59 | .. fillintheblank:: fillName3
60 |
61 | What is the camel case variable name for a variable that represents the last score?
62 |
63 | - :^\s*lastScore$: Correct.
64 | :.*: In camel case just appended the words after each other but uppercase the first letter of each word after the 1st word. This would be lastScore
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/_sources/VariableBasics/toctree.rst:
--------------------------------------------------------------------------------
1 | Variables
2 | ::::::::::::::::::::
3 |
4 | .. toctree::
5 | :maxdepth: 3
6 |
7 | vIntro.rst
8 | declareVars.rst
9 | changeVars.rst
10 | nameVars.rst
11 | operators.rst
12 | casting.rst
13 | minAndMax.rst
14 | randomNumbers.rst
15 | commonMistakes.rst
16 | vEasyMC.rst
17 | vMedMC.rst
18 | vHardMC.rst
19 | Summary.rst
20 | Exercises.rst
21 | VariablePracticeParsons.rst
22 |
--------------------------------------------------------------------------------
/_sources/VariableBasics/vHardMC.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 3-11-
3 | :start: 1
4 |
5 | Hard Multiple Choice Questions
6 | ----------------------------------
7 |
8 | These problems are harder than most of those that you will usually see on the AP CS A exam.
9 |
10 | .. mchoice:: qvh_1
11 | :answer_a: 186
12 | :answer_b: 123
13 | :answer_c: 125
14 | :answer_d: 168
15 | :answer_e: 124
16 | :correct: e
17 | :feedback_a: This would be true if it was 150 + 17 (21 in octal) + 5 (101 in binary) + 14 (E in hexadecimal) which is 186.
18 | :feedback_b: This would be true if it was 150 - 17 (21 in octal) + 5 (101 in binary) - 15 (F in hexadecimal) which is 123.
19 | :feedback_c: This would be true if it was 150 - 17 (21 in octal) + 5 (101 in binary) - 13 (D in hexadecimal) which is 123.
20 | :feedback_d: How did you get this? Maybe look up how to convert from octal and hexadecimal to decimal.
21 | :feedback_e: This is 150 - 17 (21 in octal) + 5 (101 in binary) - 14 (E in hexadecimal) which is 124.
22 |
23 | Which of the following would be the correct result from the following expression: 150 (in decimal) - 21 (in octal) + 101 (in binary) - E (in hexadecimal)?
24 |
25 |
26 | The following question assumes you know about arrays and methods. You can skip it if you haven't covered these yet and come back when you have.
27 |
28 | .. mchoice:: qvh_2
29 | :answer_a: itemArray = {0, 1, 2, 3} and val = 3;
30 | :answer_b: itemArray = {0, 1, 2, 3} and val = 5;
31 | :answer_c: itemArray = {0, 0, 0, 0} and val = 0;
32 | :answer_d: itemArray = {9, 8, 7, 6} and val = 3;
33 | :answer_e: itemArray = {9, 8, 7, 6} and val = 5;
34 | :correct: b
35 | :feedback_a: This would be true if Java used pass by reference rather than pass by value (it creates copies of the values that are passed).
36 | :feedback_b: Java passes parameters by copying the value. With an array it creates a copy of the object reference. So, mod
will change the itemArray
, but val
won't change since mod
only changes the copy of the primitive value.
37 | :feedback_c: How could this have happened?
38 | :feedback_d: Java passes parameters by passing the values this means that the contents of itemArray
will be changed by the mod
method, but val
won't change.
39 | :feedback_e: Java passes parameters by passing the values this means that the contents of itemArray
will be changed by the mod
method.
40 |
41 | Given the following code are the contents of ``itemArray`` and ``val`` after a call of ``mod(itemArray,val)``?
42 |
43 | .. code-block:: java
44 |
45 | int[] itemArray = {9, 8, 7, 6};
46 | int val = 5;
47 |
48 | public static void mod(int[] a, int value)
49 | {
50 | for (int i=0; i < a.length; i++)
51 | {
52 | a[i] = i;
53 | }
54 | value = a[a.length-1];
55 | }
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/_sources/VariableBasics/vMedMC.rst:
--------------------------------------------------------------------------------
1 | .. qnum::
2 | :prefix: 3-10-
3 | :start: 1
4 |
5 | Medium Multiple Choice Questions
6 | ----------------------------------
7 |
8 | These problems are similar to those you will see on the AP CS A exam.
9 |
10 | .. mchoice:: qvm_1
11 | :answer_a: 222
12 | :answer_b: 120
13 | :answer_c: 118
14 | :answer_d: 121
15 | :answer_e: 214
16 | :correct: b
17 | :feedback_a: That would be the answer if these were all decimal values, but they are not.
18 | :feedback_b: 12 in octal is 10 in decimal and 111 in binary is 7 in decimal so this is 123 - 10 + 7.
19 | :feedback_c: This would be the answer if it was 123 - 12 + 111 (binary) but the 12 is in octal.
20 | :feedback_d: Remember that the rightmost digit in any base is the base to the 0th power which is 1.
21 | :feedback_e: Remember that the 111 is in binary (base 2). Its decimal value is 7.
22 |
23 | Which of the following would be the correct result from the following expression: 123 (decimal) - 12 (octal) + 111 (binary)?
24 |
25 | .. mchoice:: qvm_2
26 | :answer_a: 2147483647
27 | :answer_b: 0
28 | :answer_c: There will be a compile time error
29 | :answer_d: -2147483648
30 | :answer_e: There will be a run time error
31 | :correct: d
32 | :feedback_a: This would be true if it was printing just the maximum integer value.
33 | :feedback_b: This might make sense, but adding one to the maximum integer value gives the minimum integer value.
34 | :feedback_c: It will compile, but what will it do when you run it?
35 | :feedback_d: Adding one to the maximum integer value gives the minimum integer value due to overflow.
36 | :feedback_e: This makes sense, but it is not what happens.
37 |
38 | What will be printed by ``System.out.println(Integer.MAX_VALUE + 1);``?
39 |
40 |
41 |
--------------------------------------------------------------------------------
/_sources/assignments.rst:
--------------------------------------------------------------------------------
1 | Class Assignments
2 | -----------------
3 |
4 |
5 | This file allows you to create custom assignments for your class. You write this file
6 | using any valid restructuredText, including the directives that are used in the book.
7 | For example if you want to have a homework problem where the students do some coding
8 | you can do this:
9 |
10 | Write a program that counts from 1 to 10
11 |
12 | .. actex:: unique_id_1
13 | :language: java
14 |
15 | # your code here
16 |
17 |
--------------------------------------------------------------------------------
/_sources/index.rst:
--------------------------------------------------------------------------------
1 |
2 | ==========================================
3 | Java Review for the AP CS A Exam
4 | ==========================================
5 |
6 | .. Here is were you specify the content and order of your new book.
7 |
8 | .. Each section heading (e.g. "SECTION 1: A Random Section") will be
9 | a heading in the table of contents. Source files that should be
10 | generated and included in that section should be placed on individual
11 | lines, with one line separating the first source filename and the
12 | :maxdepth: line.
13 |
14 | .. Sources can also be included from subfolders of this directory.
15 | (e.g. "DataStructures/queues.rst").
16 |
17 | Assignments
18 | :::::::::::::::::
19 |
20 | .. raw:: html
21 |
22 |
25 |
26 | Table of Contents
27 | :::::::::::::::::
28 |
29 | .. toctree::
30 | :numbered:
31 | :maxdepth: 3
32 |
33 | GettingStarted/toctree.rst
34 | JavaBasics/toctree.rst
35 | VariableBasics/toctree.rst
36 | Strings/toctree.rst
37 | Conditionals/toctree.rst
38 | Labs/toctree.rst
39 | LoopBasics/toctree.rst
40 | ArrayBasics/toctree.rst
41 | ListBasics/toctree.rst
42 | Array2dBasics/toctree.rst
43 | OOBasics/toctree.rst
44 | Recursion/toctree.rst
45 | SearchSort/toctree.rst
46 | Tests/toctree.rst
47 | TimedTests/toctree.rst
48 | FreeResponse/toctree.rst
49 | MixedFreeResponse/toctree.rst
50 | PictureLab/toctree.rst
51 | TurtleGraphics/toctree.rst
52 |
53 | Appendix 1
54 | ::::::::::::::::::::::::::::
55 |
56 | .. toctree::
57 | :maxdepth: 2
58 |
59 | Appendix/DrJava.rst
60 | Appendix/gridWorld.rst
61 |
62 | Indices
63 | ::::::::::::::::::
64 |
65 | * :ref:`genindex`
66 | * :ref:`search`
67 |
--------------------------------------------------------------------------------
/_static/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/.gitignore
--------------------------------------------------------------------------------
/_static/Interfaces.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/Interfaces.mp4
--------------------------------------------------------------------------------
/_static/Interfaces.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/Interfaces.png
--------------------------------------------------------------------------------
/_static/activecodethumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/activecodethumb.png
--------------------------------------------------------------------------------
/_static/algorithmVideo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/algorithmVideo.png
--------------------------------------------------------------------------------
/_static/arch.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/arch.jpg
--------------------------------------------------------------------------------
/_static/audio/mag1-line1.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/audio/mag1-line1.wav
--------------------------------------------------------------------------------
/_static/audio/mag1-line11-13.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/audio/mag1-line11-13.wav
--------------------------------------------------------------------------------
/_static/audio/mag1-line14-15.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/audio/mag1-line14-15.wav
--------------------------------------------------------------------------------
/_static/audio/mag1-line16.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/audio/mag1-line16.wav
--------------------------------------------------------------------------------
/_static/audio/mag1-line18.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/audio/mag1-line18.wav
--------------------------------------------------------------------------------
/_static/audio/mag1-line19.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/audio/mag1-line19.wav
--------------------------------------------------------------------------------
/_static/audio/mag1-line20.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/audio/mag1-line20.wav
--------------------------------------------------------------------------------
/_static/audio/mag1-line22-26.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/audio/mag1-line22-26.wav
--------------------------------------------------------------------------------
/_static/audio/mag1-line24.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/audio/mag1-line24.wav
--------------------------------------------------------------------------------
/_static/audio/mag1-line25.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/audio/mag1-line25.wav
--------------------------------------------------------------------------------
/_static/audio/mag1-line3-7.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/audio/mag1-line3-7.wav
--------------------------------------------------------------------------------
/_static/audio/mag1-line8-28.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/audio/mag1-line8-28.wav
--------------------------------------------------------------------------------
/_static/audio/mag1-line8-9.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/audio/mag1-line8-9.wav
--------------------------------------------------------------------------------
/_static/clock.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/clock.png
--------------------------------------------------------------------------------
/_static/close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/close.png
--------------------------------------------------------------------------------
/_static/codeVideo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/codeVideo.png
--------------------------------------------------------------------------------
/_static/first.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/first.png
--------------------------------------------------------------------------------
/_static/last.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/last.png
--------------------------------------------------------------------------------
/_static/next.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/next.png
--------------------------------------------------------------------------------
/_static/pause.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/pause.png
--------------------------------------------------------------------------------
/_static/play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/play.png
--------------------------------------------------------------------------------
/_static/prev.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/prev.png
--------------------------------------------------------------------------------
/_static/run-button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/run-button.png
--------------------------------------------------------------------------------
/_static/untitled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/untitled.png
--------------------------------------------------------------------------------
/_static/videoStart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_static/videoStart.png
--------------------------------------------------------------------------------
/_templates.bak/plugin_layouts/sphinx_bootstrap/globaltoc.html:
--------------------------------------------------------------------------------
1 |
2 | {{ theme_navbar_site_name }}
5 |
7 |
8 |
--------------------------------------------------------------------------------
/_templates.bak/plugin_layouts/sphinx_bootstrap/localtoc.html:
--------------------------------------------------------------------------------
1 |
2 | {{ _('Page') }}
3 |
4 |
5 |
--------------------------------------------------------------------------------
/_templates.bak/plugin_layouts/sphinx_bootstrap/relations.html:
--------------------------------------------------------------------------------
1 | {%- if prev %}
2 |
3 |
4 |
5 |
6 |
7 | {% if not next %}
8 |
9 | {% endif %}
10 |
11 | {%- endif %}
12 |
13 | {%- if next %}
14 |
15 |
16 |
17 |
18 |
19 |
20 | {%- endif %}
21 |
22 |
31 |
--------------------------------------------------------------------------------
/_templates.bak/plugin_layouts/sphinx_bootstrap/sourcelink.html:
--------------------------------------------------------------------------------
1 | {%- if show_source and has_source and sourcename %}
2 | {{ _('Source') }}
4 | {%- endif %}
5 |
--------------------------------------------------------------------------------
/_templates.bak/plugin_layouts/sphinx_bootstrap/static/bootstrap-3.0.0/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_templates.bak/plugin_layouts/sphinx_bootstrap/static/bootstrap-3.0.0/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/_templates.bak/plugin_layouts/sphinx_bootstrap/static/bootstrap-3.0.0/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_templates.bak/plugin_layouts/sphinx_bootstrap/static/bootstrap-3.0.0/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/_templates.bak/plugin_layouts/sphinx_bootstrap/static/bootstrap-3.0.0/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_templates.bak/plugin_layouts/sphinx_bootstrap/static/bootstrap-3.0.0/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/_templates.bak/plugin_layouts/sphinx_bootstrap/static/bootstrap-sphinx.css_t:
--------------------------------------------------------------------------------
1 | /*
2 | * bootstrap-sphinx.css
3 | * ~~~~~~~~~~~~~~~~~~~~
4 | *
5 | * Sphinx stylesheet -- Twitter Bootstrap theme.
6 | */
7 |
8 | .navbar-inverse .brand {
9 | color: #FFF;
10 | }
11 |
12 | .page-top {
13 | top: 0px;
14 | }
15 |
16 | {% if theme_navbar_fixed_top == 'true' %}
17 | body {
18 | {% if theme_bootswatch_theme %}
19 | padding-top: 50px;
20 | {% else %}
21 | padding-top: 40px;
22 | {% endif %}
23 | }
24 | .page-top {
25 | {% if theme_bootswatch_theme %}
26 | top: 50px;
27 | {% else %}
28 | top: 40px;
29 | {% endif %}
30 | }
31 |
32 | .navbar-inner {
33 | padding-left: 12px !important;
34 | padding-right: 12px !important;
35 | }
36 | {% endif %}
37 |
38 | {%- block sidebarlogo %}
39 | {%- if logo %}
40 | @media (min-width: 980px) {
41 | .navbar h3 a, .navbar .brand {
42 | background: transparent url("{{ logo }}") no-repeat 22px 3px;
43 | padding-left: 62px;
44 | }
45 | }
46 | {%- endif %}
47 | {%- endblock %}
48 |
49 | table {
50 | border: 0;
51 | }
52 |
53 | .footer {
54 | width: 100%;
55 | border-top: 1px solid #ccc;
56 | padding-top: 10px;
57 | }
58 |
--------------------------------------------------------------------------------
/_templates.bak/plugin_layouts/sphinx_bootstrap/static/img/Facebook.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_templates.bak/plugin_layouts/sphinx_bootstrap/static/img/Facebook.png
--------------------------------------------------------------------------------
/_templates.bak/plugin_layouts/sphinx_bootstrap/static/img/Facebook_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_templates.bak/plugin_layouts/sphinx_bootstrap/static/img/Facebook_icon.png
--------------------------------------------------------------------------------
/_templates.bak/plugin_layouts/sphinx_bootstrap/static/img/Twitter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_templates.bak/plugin_layouts/sphinx_bootstrap/static/img/Twitter.png
--------------------------------------------------------------------------------
/_templates.bak/plugin_layouts/sphinx_bootstrap/static/img/Twitter_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_templates.bak/plugin_layouts/sphinx_bootstrap/static/img/Twitter_icon.png
--------------------------------------------------------------------------------
/_templates.bak/plugin_layouts/sphinx_bootstrap/static/img/logo_small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_templates.bak/plugin_layouts/sphinx_bootstrap/static/img/logo_small.png
--------------------------------------------------------------------------------
/_templates.bak/plugin_layouts/sphinx_bootstrap/subchapter.html:
--------------------------------------------------------------------------------
1 | {%- if prev %}
2 |
3 |
4 |
5 |
6 |
7 |
8 | {% endif %}
9 |
10 | {%- if next %}
11 |
12 |
13 |
14 |
15 |
16 | Next Section - {{ next.title }}
17 | {%- endif %}
18 |
19 |
25 |
--------------------------------------------------------------------------------
/_templates.bak/plugin_layouts/sphinx_bootstrap/theme.conf:
--------------------------------------------------------------------------------
1 | # Twitter Bootstrap Theme
2 | [theme]
3 | inherit = basic
4 | stylesheet = basic.css
5 | pygments_style = tango
6 |
7 | # Configurable options.
8 | [options]
9 | # Navigation bar title. (Default: ``project`` value)
10 | navbar_title =
11 |
12 | # Tab name for entire site. (Default: "Site")
13 | navbar_site_name = Site
14 |
15 | # Global TOC depth for "site" navbar tab. (Default: 1)
16 | # Switching to -1 shows all levels.
17 | globaltoc_depth = 1
18 |
19 | # Include hidden TOCs in Site navbar?
20 | #
21 | # Note: If this is "false", you cannot have mixed ``:hidden:`` and
22 | # non-hidden ``toctree`` directives in the same page, or else the build
23 | # will break.
24 | #
25 | # Values: "true" (default) or "false"
26 | globaltoc_includehidden = true
27 |
28 | # HTML navbar class (Default: "navbar") to attach to element.
29 | # For black navbar, do "navbar navbar-inverse"
30 | navbar_class = navbar
31 |
32 | # Fix navigation bar to top of page?
33 | # Values: "true" (default) or "false"
34 | navbar_fixed_top = true
35 |
36 | # Location of link to source.
37 | # Options are "nav" (default), "footer" or anything else to exclude.
38 | source_link_position = nav
39 |
40 | # Bootswatch (http://bootswatch.com/) theme.
41 | #
42 | # Options are nothing with "" (default) or the name of a valid theme such as
43 | # "amelia" or "cosmo".
44 | #
45 | # Note that this is served off CDN, so won't be available offline.
46 | bootswatch_theme = ""
47 |
--------------------------------------------------------------------------------
/_templates/plugin_layouts/sphinx_bootstrap/globaltoc.html:
--------------------------------------------------------------------------------
1 |
2 | {{ theme_navbar_site_name }}
5 |
7 |
8 |
--------------------------------------------------------------------------------
/_templates/plugin_layouts/sphinx_bootstrap/localtoc.html:
--------------------------------------------------------------------------------
1 |
2 | {{ _('Page') }}
3 |
4 |
5 |
--------------------------------------------------------------------------------
/_templates/plugin_layouts/sphinx_bootstrap/relations.html:
--------------------------------------------------------------------------------
1 | {%- if prev %}
2 |
3 |
4 |
5 |
6 |
7 | {% if not next %}
8 |
9 | {% endif %}
10 |
11 | {%- endif %}
12 |
13 | {%- if next %}
14 |
15 |
16 |
17 |
18 |
19 |
20 | {%- endif %}
21 |
22 |
31 |
--------------------------------------------------------------------------------
/_templates/plugin_layouts/sphinx_bootstrap/sourcelink.html:
--------------------------------------------------------------------------------
1 | {%- if show_source and has_source and sourcename %}
2 |
{{ _('Source') }}
4 | {%- endif %}
5 |
--------------------------------------------------------------------------------
/_templates/plugin_layouts/sphinx_bootstrap/static/bootstrap-3.0.0/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_templates/plugin_layouts/sphinx_bootstrap/static/bootstrap-3.0.0/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/_templates/plugin_layouts/sphinx_bootstrap/static/bootstrap-3.0.0/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_templates/plugin_layouts/sphinx_bootstrap/static/bootstrap-3.0.0/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/_templates/plugin_layouts/sphinx_bootstrap/static/bootstrap-3.0.0/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_templates/plugin_layouts/sphinx_bootstrap/static/bootstrap-3.0.0/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/_templates/plugin_layouts/sphinx_bootstrap/static/bootstrap-sphinx.css_t:
--------------------------------------------------------------------------------
1 | /*
2 | * bootstrap-sphinx.css
3 | * ~~~~~~~~~~~~~~~~~~~~
4 | *
5 | * Sphinx stylesheet -- Twitter Bootstrap theme.
6 | */
7 |
8 | .navbar-inverse .brand {
9 | color: #FFF;
10 | }
11 |
12 | .page-top {
13 | top: 0px;
14 | }
15 |
16 | {% if theme_navbar_fixed_top == 'true' %}
17 | body {
18 | {% if theme_bootswatch_theme %}
19 | padding-top: 50px;
20 | {% else %}
21 | padding-top: 40px;
22 | {% endif %}
23 | }
24 | .page-top {
25 | {% if theme_bootswatch_theme %}
26 | top: 50px;
27 | {% else %}
28 | top: 40px;
29 | {% endif %}
30 | }
31 |
32 | .navbar-inner {
33 | padding-left: 12px !important;
34 | padding-right: 12px !important;
35 | }
36 | {% endif %}
37 |
38 | {%- block sidebarlogo %}
39 | {%- if logo %}
40 | @media (min-width: 980px) {
41 | .navbar h3 a, .navbar .brand {
42 | background: transparent url("{{ logo }}") no-repeat 22px 3px;
43 | padding-left: 62px;
44 | }
45 | }
46 | {%- endif %}
47 | {%- endblock %}
48 |
49 | table {
50 | border: 0;
51 | }
52 |
53 | .footer {
54 | width: 100%;
55 | border-top: 1px solid #ccc;
56 | padding-top: 10px;
57 | }
58 |
--------------------------------------------------------------------------------
/_templates/plugin_layouts/sphinx_bootstrap/static/img/Facebook.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_templates/plugin_layouts/sphinx_bootstrap/static/img/Facebook.png
--------------------------------------------------------------------------------
/_templates/plugin_layouts/sphinx_bootstrap/static/img/Facebook_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_templates/plugin_layouts/sphinx_bootstrap/static/img/Facebook_icon.png
--------------------------------------------------------------------------------
/_templates/plugin_layouts/sphinx_bootstrap/static/img/Twitter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_templates/plugin_layouts/sphinx_bootstrap/static/img/Twitter.png
--------------------------------------------------------------------------------
/_templates/plugin_layouts/sphinx_bootstrap/static/img/Twitter_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_templates/plugin_layouts/sphinx_bootstrap/static/img/Twitter_icon.png
--------------------------------------------------------------------------------
/_templates/plugin_layouts/sphinx_bootstrap/static/img/logo_small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/_templates/plugin_layouts/sphinx_bootstrap/static/img/logo_small.png
--------------------------------------------------------------------------------
/_templates/plugin_layouts/sphinx_bootstrap/subchapter.html:
--------------------------------------------------------------------------------
1 | {%- if prev %}
2 |
3 |
4 |
5 |
6 |
7 |
8 | {% endif %}
9 |
10 | {%- if next %}
11 |
12 |
13 |
14 |
15 |
16 |
Next Section - {{ next.title }}
17 | {%- endif %}
18 |
19 |
25 |
--------------------------------------------------------------------------------
/_templates/plugin_layouts/sphinx_bootstrap/theme.conf:
--------------------------------------------------------------------------------
1 | # Twitter Bootstrap Theme
2 | [theme]
3 | inherit = basic
4 | stylesheet = basic.css
5 | pygments_style = tango
6 |
7 | # Configurable options.
8 | [options]
9 | # Navigation bar title. (Default: ``project`` value)
10 | navbar_title =
11 |
12 | # Tab name for entire site. (Default: "Site")
13 | navbar_site_name = Site
14 |
15 | # Global TOC depth for "site" navbar tab. (Default: 1)
16 | # Switching to -1 shows all levels.
17 | globaltoc_depth = 1
18 |
19 | # Include hidden TOCs in Site navbar?
20 | #
21 | # Note: If this is "false", you cannot have mixed ``:hidden:`` and
22 | # non-hidden ``toctree`` directives in the same page, or else the build
23 | # will break.
24 | #
25 | # Values: "true" (default) or "false"
26 | globaltoc_includehidden = true
27 |
28 | # HTML navbar class (Default: "navbar") to attach to
element.
29 | # For black navbar, do "navbar navbar-inverse"
30 | navbar_class = navbar
31 |
32 | # Fix navigation bar to top of page?
33 | # Values: "true" (default) or "false"
34 | navbar_fixed_top = true
35 |
36 | # Location of link to source.
37 | # Options are "nav" (default), "footer" or anything else to exclude.
38 | source_link_position = nav
39 |
40 | # Bootswatch (http://bootswatch.com/) theme.
41 | #
42 | # Options are nothing with "" (default) or the name of a valid theme such as
43 | # "amelia" or "cosmo".
44 | #
45 | # Note that this is served off CDN, so won't be available offline.
46 | bootswatch_theme = ""
47 |
--------------------------------------------------------------------------------
/build/student_source/turtleTest.py:
--------------------------------------------------------------------------------
1 | from turtle import *
2 | win = Screen()
3 | jasmine = Turtle()
4 | jasmine.forward(100)
5 | jasmine.right(90)
6 | jasmine.forward(200)
7 | win.exitonclick()
8 |
--------------------------------------------------------------------------------
/pavement.py:
--------------------------------------------------------------------------------
1 | import paver
2 | from paver.easy import *
3 | import paver.setuputils
4 | paver.setuputils.install_distutils_tasks()
5 | from socket import gethostname
6 | import os, sys
7 | from os import environ
8 |
9 | from sphinxcontrib import paverutils
10 |
11 | # new 7/2019 changes
12 | import pkg_resources
13 | from runestone import get_master_url
14 |
15 |
16 | sys.path.append(os.getcwd())
17 |
18 | home_dir = os.getcwd()
19 |
20 | project_name = "APCSA2019"
21 |
22 | # new 7/2019 changes
23 | master_url = None
24 |
25 | if master_url is None:
26 | master_url = get_master_url()
27 |
28 | master_app = 'runestone'
29 | serving_dir = "./build/apcsareview"
30 |
31 | #new 7/2019 changes
32 | # Change to False when running localhost
33 | dynamic_pages = True
34 |
35 | if dynamic_pages:
36 | dest = './published'
37 | else:
38 | dest = '../../static'
39 |
40 | #dest = '../../static'
41 | #master_url = None
42 | #if master_url is None:
43 | # if 'RSHOST' in environ:
44 | # master_url = environ['RSHOST']
45 | # elif gethostname() in ['web608.webfaction.com', 'rsbuilder']:
46 | # master_url = 'http://interactivepython.org'
47 | # elif gethostname() == 'runestone-deploy':
48 | # master_url = 'https://runestone.academy'
49 | # else:
50 | # master_url = 'http://127.0.0.1:8000'
51 |
52 | #master_app = 'runestone'
53 | #serving_dir = "./build/JavaReview"
54 | #dest = '../../static'
55 | #project_name = "javareview"
56 |
57 | options(
58 | sphinx = Bunch(docroot=".",),
59 |
60 | build = Bunch(
61 | builddir="./build/apcsareview",
62 | sourcedir="_sources",
63 | outdir="./build/apcsareview",
64 | confdir=".",
65 | project_name = "apcsareview",
66 | template_args={'course_id': 'apcsareview',
67 | 'login_required':'false',
68 | 'appname':master_app,
69 | 'loglevel': 10,
70 | 'course_url':master_url,
71 | 'use_services': 'true',
72 | 'python3': 'false',
73 | 'dburl': 'postgresql://runestone@localhost/runestone',
74 | 'basecourse': 'apcsareview',
75 | # new 7/2019 changes
76 | 'dynamic_pages': dynamic_pages,
77 | 'downloads_enabled': 'false',
78 | 'enable_chatcodes': 'false',
79 | 'allow_pairs': 'false'
80 | }
81 | )
82 | )
83 |
84 | # Check to see if we are building on our Jenkins build server, if so use the environment variables
85 | # to update the DB information for this build
86 | if 'DBHOST' in environ and 'DBPASS' in environ and 'DBUSER' in environ and 'DBNAME' in environ:
87 | options.build.template_args['dburl'] = 'postgresql://{DBUSER}:{DBPASS}@{DBHOST}/{DBNAME}'.format(**environ)
88 |
89 | version = pkg_resources.require("runestone")[0].version
90 | options.build.template_args['runestone_version'] = version
91 |
92 | from runestone import build # build is called implicitly by the paver driver.
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | runestone>=2.7.4
2 | SQLAlchemy>=1.0.8
3 |
--------------------------------------------------------------------------------
/sphinx-enki-info.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ericsonga/APCSAReview/3c09fbf17867e420b24330f08881789c64c526e5/sphinx-enki-info.txt
--------------------------------------------------------------------------------
/sphinx_settings.json:
--------------------------------------------------------------------------------
1 | {"SPHINX_SOURCE_PATH": "_sources", "SPHINX_OUT_PATH": "build/apcsareview"}
--------------------------------------------------------------------------------