├── exts ├── __init__.py ├── external_links.py ├── replit.py ├── admonition_icons.py ├── ordered_toctree.py └── youtube.py ├── src ├── todos.rst ├── genindex.rst ├── glossary.rst ├── _static │ ├── css │ │ ├── fonts │ │ │ ├── Nexa-XBold.otf │ │ │ ├── NexaRegular.otf │ │ │ ├── Nexa-XBold-Italic.otf │ │ │ └── Nexa-Regular-Italic.otf │ │ └── site.css │ ├── fa │ │ ├── webfonts │ │ │ ├── fa-brands-400.eot │ │ │ ├── fa-brands-400.ttf │ │ │ ├── fa-solid-900.eot │ │ │ ├── fa-solid-900.ttf │ │ │ ├── fa-solid-900.woff │ │ │ ├── fa-brands-400.woff │ │ │ ├── fa-brands-400.woff2 │ │ │ ├── fa-regular-400.eot │ │ │ ├── fa-regular-400.ttf │ │ │ ├── fa-regular-400.woff │ │ │ ├── fa-solid-900.woff2 │ │ │ └── fa-regular-400.woff2 │ │ └── css │ │ │ ├── brands.min.css │ │ │ ├── solid.min.css │ │ │ ├── regular.min.css │ │ │ ├── brands.css │ │ │ ├── regular.css │ │ │ └── solid.css │ └── images │ │ └── logos │ │ ├── lc-ed-logo.png │ │ ├── codergirl-white.png │ │ └── lc-logo.svg ├── assignments │ └── figures │ │ ├── LC-Carly.png │ │ ├── LC-Sally.png │ │ ├── hw-class.png │ │ ├── LC-mentor.png │ │ ├── run-tests.png │ │ ├── test-files.png │ │ ├── url-field.png │ │ ├── run-all-tests.png │ │ ├── run-program.png │ │ ├── techJobsTodos.png │ │ ├── commit-and-push.png │ │ ├── copy-clone-url.png │ │ ├── fix-lang-level.png │ │ ├── green-checkmark.png │ │ ├── run-all-tests2.png │ │ ├── run-single-test.png │ │ ├── techJobsMvcHome.png │ │ ├── add-configuration.png │ │ ├── all-tests-passing.png │ │ ├── check-out-from-vcs.png │ │ ├── choose-test-class.png │ │ ├── job-listing-tables.png │ │ ├── lang-level-error.png │ │ ├── listTableOptions.png │ │ ├── run-test-buttons.png │ │ ├── test-results-fail.png │ │ ├── edit-configurations.png │ │ ├── project-pane-closed.png │ │ ├── running-junit-config.png │ │ ├── single-test-failure.png │ │ ├── test-results-passing.png │ │ ├── TechJobsTest-location.png │ │ ├── initial-failing-tests.png │ │ ├── initial-test-failures.png │ │ ├── junit-run-configuration.png │ │ ├── open-intellij-project.png │ │ ├── run-tests-single-task.png │ │ ├── test-output-comparison.png │ │ ├── test-results-comparison.png │ │ └── select-junit-configuration.png ├── chapters │ ├── auth │ │ ├── figures │ │ │ ├── user-in-db.png │ │ │ ├── hashingdiagram.png │ │ │ ├── session-cookie.png │ │ │ ├── two-way-encryption.png │ │ │ ├── authenticationflowdiagram.png │ │ │ ├── sessionsandcookiesdiagram.png │ │ │ └── simplifiedsessionsandcookies.png │ │ └── index.rst │ ├── data-types │ │ ├── figures │ │ │ ├── addToGit.png │ │ │ ├── nameClass.png │ │ │ ├── newClass.png │ │ │ ├── newPackage.png │ │ │ ├── references.png │ │ │ ├── namePackage.png │ │ │ ├── newClassCreated.png │ │ │ ├── create-new-class.png │ │ │ ├── tempConverterTree.png │ │ │ ├── IDE-flagged-errors.png │ │ │ └── TempConverter-class.png │ │ ├── index.rst │ │ └── studio.rst │ ├── enums │ │ ├── figures │ │ │ ├── weekdaySelect.png │ │ │ └── enumTypeSelection.png │ │ ├── index.rst │ │ └── exercises.rst │ ├── classes-part2 │ │ ├── figures │ │ │ ├── equality.png │ │ │ ├── identity.png │ │ │ ├── chooseFields.png │ │ │ ├── IJgeneratemenu.png │ │ │ └── selectEqualsOption.png │ │ ├── index.rst │ │ ├── exercises.rst │ │ ├── studio.rst │ │ └── equals-shortcut.rst │ ├── orm-part1 │ │ ├── figures │ │ │ ├── categoryform.png │ │ │ ├── finalcategories.png │ │ │ └── initialcategories.png │ │ ├── index.rst │ │ └── repositories.rst │ ├── spring-intro │ │ ├── figures │ │ │ ├── panel-icon.png │ │ │ ├── mvcOverview.png │ │ │ ├── bootrun-output.png │ │ │ ├── gradle-bootrun.png │ │ │ ├── windows-bootrun.png │ │ │ ├── import-gradle-tip.png │ │ │ └── spring-initializr-11.png │ │ ├── index.rst │ │ └── mvc.rst │ ├── inheritance │ │ ├── figures │ │ │ ├── relationships.png │ │ │ ├── inheritance-cat.png │ │ │ ├── inheritance-tree.png │ │ │ ├── class-diagram-java.png │ │ │ └── inheritance-basic.png │ │ ├── index.rst │ │ ├── oop-inheritance.rst │ │ ├── exercises.rst │ │ ├── studio.rst │ │ └── testing-inheritance.rst │ ├── orm-relationships │ │ ├── figures │ │ │ ├── one-to-one.png │ │ │ ├── find-usages.png │ │ │ ├── many-to-many.png │ │ │ ├── many-to-one.png │ │ │ ├── one-to-many.png │ │ │ ├── events-by-category.png │ │ │ ├── event-table-with-data.png │ │ │ ├── event-table-after-update.png │ │ │ ├── event-table-before-update.png │ │ │ └── event-category-table-with-data.png │ │ ├── index.rst │ │ └── exercises.rst │ ├── thymeleaf-views │ │ ├── figures │ │ │ ├── startingform.png │ │ │ ├── completedform.png │ │ │ ├── srcCcFileTree.png │ │ │ ├── templatesFolder.png │ │ │ ├── createNewTemplate.png │ │ │ ├── buildGradleFileTree.png │ │ │ ├── endresultprofilepage.png │ │ │ ├── htmlDefaultButtons.png │ │ │ ├── selectTLdependency.png │ │ │ ├── bootstrapButtonOptions.png │ │ │ ├── thymeleafTemplateCode.png │ │ │ ├── ThymeleafTemplateDiagram.png │ │ │ ├── resourcesFolderFileTree.png │ │ │ └── selectThymeleafTemplate.png │ │ ├── index.rst │ │ ├── exercises.rst │ │ └── src&href.rst │ ├── unit-testing │ │ ├── figures │ │ │ └── add-jar-library.png │ │ ├── index.rst │ │ ├── studio.rst │ │ └── exercises.rst │ ├── exceptions │ │ ├── index.rst │ │ └── exercises.rst │ ├── introduction-and-setup │ │ ├── figures │ │ │ ├── BuiltProject.png │ │ │ ├── IntelliJVCS.png │ │ │ ├── closeProject.png │ │ │ ├── installJava.png │ │ │ ├── HelloWorldBuilt.png │ │ │ ├── HelloWorldMaven.png │ │ │ ├── IJ-github-login.png │ │ │ ├── IntelliJGithub.png │ │ │ ├── IntelliJRunFile.png │ │ │ ├── IntelliJWelcome.png │ │ │ ├── HelloWorldProgram.png │ │ │ ├── IntelliJFileOutput.png │ │ │ ├── IntelliJNewProject.png │ │ │ ├── IntelliJOpenFile.png │ │ │ ├── ij-install-options.png │ │ │ ├── startupWithProject.png │ │ │ ├── IntelliJAddFileToGit.png │ │ │ ├── windowsjavafilepath.png │ │ │ ├── HelloWorldBuildProgram.png │ │ │ ├── IntelliJProjectWindow.png │ │ │ ├── IntelliJRepoSelection.png │ │ │ ├── existingSourcesOption.png │ │ │ ├── startupWithoutProject.png │ │ │ └── HelloWorldBuildProgramConfig.png │ │ ├── index.rst │ │ ├── why-java.rst │ │ ├── intellij.rst │ │ ├── naming-conventions.rst │ │ └── setup.rst │ ├── spring-controllers-and-routes │ │ ├── figures │ │ │ ├── form.png │ │ │ ├── studio-home-page.png │ │ │ ├── blank-studio-form.png │ │ │ ├── mvcOverviewDetail.png │ │ │ └── completed-studio-form.png │ │ ├── index.rst │ │ ├── exercises.rst │ │ ├── studio.rst │ │ └── controllers-classes.rst │ ├── spring-model-classes │ │ ├── figures │ │ │ └── mvcOverviewDetail.png │ │ └── index.rst │ ├── tools-in-intelliJ │ │ ├── figures │ │ │ ├── gradle-refresh-icon.png │ │ │ ├── gradle-refresh-note.png │ │ │ ├── gradle-refresh-point.png │ │ │ └── gradle-refresh-corner.png │ │ ├── index.rst │ │ ├── studio.rst │ │ └── debugging.rst │ ├── spring-model-validation │ │ ├── figures │ │ │ ├── new-empty-event.png │ │ │ ├── validation-exception.png │ │ │ └── display-validation-errors.png │ │ ├── index.rst │ │ ├── exercises.rst │ │ └── server-side-validation.rst │ ├── interfaces-and-polymorphism │ │ ├── figures │ │ │ ├── compare-double.png │ │ │ └── implement-methods.png │ │ ├── index.rst │ │ ├── introduction.rst │ │ ├── testing-interfaces.rst │ │ └── interfaces-and-abstract-classes.rst │ ├── classes │ │ ├── index.rst │ │ ├── srp.rst │ │ ├── exercises.rst │ │ └── studio.rst │ └── control-flow-and-collections │ │ ├── index.rst │ │ ├── collections.rst │ │ ├── studio.rst │ │ └── exercises.rst ├── appendices │ ├── figures │ │ ├── Staff_Chris_Bay.png │ │ ├── Staff_Jim_Flores.png │ │ ├── Staff_Carly_Langlois.png │ │ └── Staff_Sally_Steuterman.png │ ├── software │ │ ├── figures │ │ │ ├── sql-install-1.png │ │ │ ├── sql-install-2.png │ │ │ ├── sql-install-3.png │ │ │ ├── sql-install-4.png │ │ │ ├── sql-install-5.png │ │ │ ├── sql-install-6.png │ │ │ ├── sql-install-7.png │ │ │ ├── sql-install-8.png │ │ │ └── sql-installer.png │ │ ├── index.rst │ │ └── intellij-install.rst │ ├── exercise-solutions │ │ ├── index.rst │ │ ├── spring-model-validation.rst │ │ ├── orm-relationships.rst │ │ ├── thymeleaf-views.rst │ │ ├── classes.rst │ │ ├── spring-controllers-and-routes.rst │ │ ├── unit-testing.rst │ │ ├── enums.rst │ │ ├── inheritance.rst │ │ ├── interfaces-and-polymorphism.rst │ │ ├── data-types.rst │ │ ├── spring-model-classes.rst │ │ └── classes-part2.rst │ └── about-this-book.rst ├── index-full.rst ├── _templates │ └── navbar.html └── index.rst ├── update-theme.sh ├── .gitignore ├── requirements.txt ├── .travis.yml ├── README.md └── .github └── workflows └── deploy-lc.yml /exts/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/todos.rst: -------------------------------------------------------------------------------- 1 | TODOs 2 | ===== 3 | 4 | .. todolist:: 5 | -------------------------------------------------------------------------------- /src/genindex.rst: -------------------------------------------------------------------------------- 1 | .. _genindex: 2 | 3 | Index 4 | ===== 5 | -------------------------------------------------------------------------------- /src/glossary.rst: -------------------------------------------------------------------------------- 1 | .. _glossary: 2 | 3 | Glossary 4 | ======== 5 | 6 | .. glossary:: 7 | :sorted: 8 | 9 | -------------------------------------------------------------------------------- /update-theme.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | pip install --upgrade git+https://github.com/LaunchCodeEducation/sphinx-bootstrap-theme.git@master -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | _build/ 3 | .vscode 4 | __pycache__ 5 | !.nojekyll 6 | .pyc 7 | __pycache__/ 8 | docs/ 9 | .travis.yml 10 | -------------------------------------------------------------------------------- /src/_static/css/fonts/Nexa-XBold.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/_static/css/fonts/Nexa-XBold.otf -------------------------------------------------------------------------------- /src/assignments/figures/LC-Carly.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/LC-Carly.png -------------------------------------------------------------------------------- /src/assignments/figures/LC-Sally.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/LC-Sally.png -------------------------------------------------------------------------------- /src/assignments/figures/hw-class.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/hw-class.png -------------------------------------------------------------------------------- /src/_static/css/fonts/NexaRegular.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/_static/css/fonts/NexaRegular.otf -------------------------------------------------------------------------------- /src/assignments/figures/LC-mentor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/LC-mentor.png -------------------------------------------------------------------------------- /src/assignments/figures/run-tests.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/run-tests.png -------------------------------------------------------------------------------- /src/assignments/figures/test-files.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/test-files.png -------------------------------------------------------------------------------- /src/assignments/figures/url-field.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/url-field.png -------------------------------------------------------------------------------- /src/_static/fa/webfonts/fa-brands-400.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/_static/fa/webfonts/fa-brands-400.eot -------------------------------------------------------------------------------- /src/_static/fa/webfonts/fa-brands-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/_static/fa/webfonts/fa-brands-400.ttf -------------------------------------------------------------------------------- /src/_static/fa/webfonts/fa-solid-900.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/_static/fa/webfonts/fa-solid-900.eot -------------------------------------------------------------------------------- /src/_static/fa/webfonts/fa-solid-900.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/_static/fa/webfonts/fa-solid-900.ttf -------------------------------------------------------------------------------- /src/_static/fa/webfonts/fa-solid-900.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/_static/fa/webfonts/fa-solid-900.woff -------------------------------------------------------------------------------- /src/_static/images/logos/lc-ed-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/_static/images/logos/lc-ed-logo.png -------------------------------------------------------------------------------- /src/assignments/figures/run-all-tests.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/run-all-tests.png -------------------------------------------------------------------------------- /src/assignments/figures/run-program.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/run-program.png -------------------------------------------------------------------------------- /src/assignments/figures/techJobsTodos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/techJobsTodos.png -------------------------------------------------------------------------------- /src/chapters/auth/figures/user-in-db.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/auth/figures/user-in-db.png -------------------------------------------------------------------------------- /src/_static/css/fonts/Nexa-XBold-Italic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/_static/css/fonts/Nexa-XBold-Italic.otf -------------------------------------------------------------------------------- /src/_static/fa/webfonts/fa-brands-400.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/_static/fa/webfonts/fa-brands-400.woff -------------------------------------------------------------------------------- /src/_static/fa/webfonts/fa-brands-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/_static/fa/webfonts/fa-brands-400.woff2 -------------------------------------------------------------------------------- /src/_static/fa/webfonts/fa-regular-400.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/_static/fa/webfonts/fa-regular-400.eot -------------------------------------------------------------------------------- /src/_static/fa/webfonts/fa-regular-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/_static/fa/webfonts/fa-regular-400.ttf -------------------------------------------------------------------------------- /src/_static/fa/webfonts/fa-regular-400.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/_static/fa/webfonts/fa-regular-400.woff -------------------------------------------------------------------------------- /src/_static/fa/webfonts/fa-solid-900.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/_static/fa/webfonts/fa-solid-900.woff2 -------------------------------------------------------------------------------- /src/appendices/figures/Staff_Chris_Bay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/appendices/figures/Staff_Chris_Bay.png -------------------------------------------------------------------------------- /src/appendices/figures/Staff_Jim_Flores.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/appendices/figures/Staff_Jim_Flores.png -------------------------------------------------------------------------------- /src/assignments/figures/commit-and-push.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/commit-and-push.png -------------------------------------------------------------------------------- /src/assignments/figures/copy-clone-url.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/copy-clone-url.png -------------------------------------------------------------------------------- /src/assignments/figures/fix-lang-level.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/fix-lang-level.png -------------------------------------------------------------------------------- /src/assignments/figures/green-checkmark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/green-checkmark.png -------------------------------------------------------------------------------- /src/assignments/figures/run-all-tests2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/run-all-tests2.png -------------------------------------------------------------------------------- /src/assignments/figures/run-single-test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/run-single-test.png -------------------------------------------------------------------------------- /src/assignments/figures/techJobsMvcHome.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/techJobsMvcHome.png -------------------------------------------------------------------------------- /src/_static/css/fonts/Nexa-Regular-Italic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/_static/css/fonts/Nexa-Regular-Italic.otf -------------------------------------------------------------------------------- /src/_static/fa/webfonts/fa-regular-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/_static/fa/webfonts/fa-regular-400.woff2 -------------------------------------------------------------------------------- /src/_static/images/logos/codergirl-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/_static/images/logos/codergirl-white.png -------------------------------------------------------------------------------- /src/assignments/figures/add-configuration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/add-configuration.png -------------------------------------------------------------------------------- /src/assignments/figures/all-tests-passing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/all-tests-passing.png -------------------------------------------------------------------------------- /src/assignments/figures/check-out-from-vcs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/check-out-from-vcs.png -------------------------------------------------------------------------------- /src/assignments/figures/choose-test-class.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/choose-test-class.png -------------------------------------------------------------------------------- /src/assignments/figures/job-listing-tables.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/job-listing-tables.png -------------------------------------------------------------------------------- /src/assignments/figures/lang-level-error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/lang-level-error.png -------------------------------------------------------------------------------- /src/assignments/figures/listTableOptions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/listTableOptions.png -------------------------------------------------------------------------------- /src/assignments/figures/run-test-buttons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/run-test-buttons.png -------------------------------------------------------------------------------- /src/assignments/figures/test-results-fail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/test-results-fail.png -------------------------------------------------------------------------------- /src/chapters/auth/figures/hashingdiagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/auth/figures/hashingdiagram.png -------------------------------------------------------------------------------- /src/chapters/auth/figures/session-cookie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/auth/figures/session-cookie.png -------------------------------------------------------------------------------- /src/chapters/data-types/figures/addToGit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/data-types/figures/addToGit.png -------------------------------------------------------------------------------- /src/chapters/data-types/figures/nameClass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/data-types/figures/nameClass.png -------------------------------------------------------------------------------- /src/chapters/data-types/figures/newClass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/data-types/figures/newClass.png -------------------------------------------------------------------------------- /src/chapters/data-types/figures/newPackage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/data-types/figures/newPackage.png -------------------------------------------------------------------------------- /src/chapters/data-types/figures/references.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/data-types/figures/references.png -------------------------------------------------------------------------------- /src/chapters/enums/figures/weekdaySelect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/enums/figures/weekdaySelect.png -------------------------------------------------------------------------------- /src/appendices/figures/Staff_Carly_Langlois.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/appendices/figures/Staff_Carly_Langlois.png -------------------------------------------------------------------------------- /src/assignments/figures/edit-configurations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/edit-configurations.png -------------------------------------------------------------------------------- /src/assignments/figures/project-pane-closed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/project-pane-closed.png -------------------------------------------------------------------------------- /src/assignments/figures/running-junit-config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/running-junit-config.png -------------------------------------------------------------------------------- /src/assignments/figures/single-test-failure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/single-test-failure.png -------------------------------------------------------------------------------- /src/assignments/figures/test-results-passing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/test-results-passing.png -------------------------------------------------------------------------------- /src/chapters/auth/figures/two-way-encryption.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/auth/figures/two-way-encryption.png -------------------------------------------------------------------------------- /src/chapters/classes-part2/figures/equality.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/classes-part2/figures/equality.png -------------------------------------------------------------------------------- /src/chapters/classes-part2/figures/identity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/classes-part2/figures/identity.png -------------------------------------------------------------------------------- /src/chapters/data-types/figures/namePackage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/data-types/figures/namePackage.png -------------------------------------------------------------------------------- /src/chapters/enums/figures/enumTypeSelection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/enums/figures/enumTypeSelection.png -------------------------------------------------------------------------------- /src/chapters/orm-part1/figures/categoryform.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/orm-part1/figures/categoryform.png -------------------------------------------------------------------------------- /src/chapters/spring-intro/figures/panel-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/spring-intro/figures/panel-icon.png -------------------------------------------------------------------------------- /src/chapters/spring-intro/index.rst: -------------------------------------------------------------------------------- 1 | Spring Into MVC 2 | =============== 3 | 4 | .. toctree:: 5 | :maxdepth: 3 6 | 7 | mvc 8 | initialize 9 | 10 | -------------------------------------------------------------------------------- /src/appendices/figures/Staff_Sally_Steuterman.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/appendices/figures/Staff_Sally_Steuterman.png -------------------------------------------------------------------------------- /src/appendices/software/figures/sql-install-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/appendices/software/figures/sql-install-1.png -------------------------------------------------------------------------------- /src/appendices/software/figures/sql-install-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/appendices/software/figures/sql-install-2.png -------------------------------------------------------------------------------- /src/appendices/software/figures/sql-install-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/appendices/software/figures/sql-install-3.png -------------------------------------------------------------------------------- /src/appendices/software/figures/sql-install-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/appendices/software/figures/sql-install-4.png -------------------------------------------------------------------------------- /src/appendices/software/figures/sql-install-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/appendices/software/figures/sql-install-5.png -------------------------------------------------------------------------------- /src/appendices/software/figures/sql-install-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/appendices/software/figures/sql-install-6.png -------------------------------------------------------------------------------- /src/appendices/software/figures/sql-install-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/appendices/software/figures/sql-install-7.png -------------------------------------------------------------------------------- /src/appendices/software/figures/sql-install-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/appendices/software/figures/sql-install-8.png -------------------------------------------------------------------------------- /src/appendices/software/figures/sql-installer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/appendices/software/figures/sql-installer.png -------------------------------------------------------------------------------- /src/assignments/figures/TechJobsTest-location.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/TechJobsTest-location.png -------------------------------------------------------------------------------- /src/assignments/figures/initial-failing-tests.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/initial-failing-tests.png -------------------------------------------------------------------------------- /src/assignments/figures/initial-test-failures.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/initial-test-failures.png -------------------------------------------------------------------------------- /src/assignments/figures/junit-run-configuration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/junit-run-configuration.png -------------------------------------------------------------------------------- /src/assignments/figures/open-intellij-project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/open-intellij-project.png -------------------------------------------------------------------------------- /src/assignments/figures/run-tests-single-task.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/run-tests-single-task.png -------------------------------------------------------------------------------- /src/assignments/figures/test-output-comparison.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/test-output-comparison.png -------------------------------------------------------------------------------- /src/assignments/figures/test-results-comparison.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/test-results-comparison.png -------------------------------------------------------------------------------- /src/chapters/classes-part2/figures/chooseFields.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/classes-part2/figures/chooseFields.png -------------------------------------------------------------------------------- /src/chapters/data-types/figures/newClassCreated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/data-types/figures/newClassCreated.png -------------------------------------------------------------------------------- /src/chapters/inheritance/figures/relationships.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/inheritance/figures/relationships.png -------------------------------------------------------------------------------- /src/chapters/orm-part1/figures/finalcategories.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/orm-part1/figures/finalcategories.png -------------------------------------------------------------------------------- /src/chapters/spring-intro/figures/mvcOverview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/spring-intro/figures/mvcOverview.png -------------------------------------------------------------------------------- /src/chapters/classes-part2/figures/IJgeneratemenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/classes-part2/figures/IJgeneratemenu.png -------------------------------------------------------------------------------- /src/chapters/data-types/figures/create-new-class.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/data-types/figures/create-new-class.png -------------------------------------------------------------------------------- /src/chapters/data-types/figures/tempConverterTree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/data-types/figures/tempConverterTree.png -------------------------------------------------------------------------------- /src/chapters/inheritance/figures/inheritance-cat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/inheritance/figures/inheritance-cat.png -------------------------------------------------------------------------------- /src/chapters/inheritance/figures/inheritance-tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/inheritance/figures/inheritance-tree.png -------------------------------------------------------------------------------- /src/chapters/orm-part1/figures/initialcategories.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/orm-part1/figures/initialcategories.png -------------------------------------------------------------------------------- /src/chapters/orm-relationships/figures/one-to-one.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/orm-relationships/figures/one-to-one.png -------------------------------------------------------------------------------- /src/chapters/spring-intro/figures/bootrun-output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/spring-intro/figures/bootrun-output.png -------------------------------------------------------------------------------- /src/chapters/spring-intro/figures/gradle-bootrun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/spring-intro/figures/gradle-bootrun.png -------------------------------------------------------------------------------- /src/chapters/spring-intro/figures/windows-bootrun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/spring-intro/figures/windows-bootrun.png -------------------------------------------------------------------------------- /src/chapters/thymeleaf-views/figures/startingform.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/thymeleaf-views/figures/startingform.png -------------------------------------------------------------------------------- /src/chapters/unit-testing/figures/add-jar-library.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/unit-testing/figures/add-jar-library.png -------------------------------------------------------------------------------- /src/appendices/software/index.rst: -------------------------------------------------------------------------------- 1 | Java Web Dev Software Installations 2 | =================================== 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | 7 | intellij-install 8 | -------------------------------------------------------------------------------- /src/assignments/figures/select-junit-configuration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/assignments/figures/select-junit-configuration.png -------------------------------------------------------------------------------- /src/chapters/auth/figures/authenticationflowdiagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/auth/figures/authenticationflowdiagram.png -------------------------------------------------------------------------------- /src/chapters/auth/figures/sessionsandcookiesdiagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/auth/figures/sessionsandcookiesdiagram.png -------------------------------------------------------------------------------- /src/chapters/data-types/figures/IDE-flagged-errors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/data-types/figures/IDE-flagged-errors.png -------------------------------------------------------------------------------- /src/chapters/data-types/figures/TempConverter-class.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/data-types/figures/TempConverter-class.png -------------------------------------------------------------------------------- /src/chapters/exceptions/index.rst: -------------------------------------------------------------------------------- 1 | Rules to the Exceptions 2 | ======================= 3 | 4 | .. toctree:: 5 | :maxdepth: 1 6 | 7 | walkthrough 8 | exercises 9 | 10 | -------------------------------------------------------------------------------- /src/chapters/inheritance/figures/class-diagram-java.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/inheritance/figures/class-diagram-java.png -------------------------------------------------------------------------------- /src/chapters/inheritance/figures/inheritance-basic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/inheritance/figures/inheritance-basic.png -------------------------------------------------------------------------------- /src/chapters/orm-relationships/figures/find-usages.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/orm-relationships/figures/find-usages.png -------------------------------------------------------------------------------- /src/chapters/orm-relationships/figures/many-to-many.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/orm-relationships/figures/many-to-many.png -------------------------------------------------------------------------------- /src/chapters/orm-relationships/figures/many-to-one.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/orm-relationships/figures/many-to-one.png -------------------------------------------------------------------------------- /src/chapters/orm-relationships/figures/one-to-many.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/orm-relationships/figures/one-to-many.png -------------------------------------------------------------------------------- /src/chapters/spring-intro/figures/import-gradle-tip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/spring-intro/figures/import-gradle-tip.png -------------------------------------------------------------------------------- /src/chapters/thymeleaf-views/figures/completedform.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/thymeleaf-views/figures/completedform.png -------------------------------------------------------------------------------- /src/chapters/thymeleaf-views/figures/srcCcFileTree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/thymeleaf-views/figures/srcCcFileTree.png -------------------------------------------------------------------------------- /src/chapters/thymeleaf-views/figures/templatesFolder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/thymeleaf-views/figures/templatesFolder.png -------------------------------------------------------------------------------- /src/chapters/auth/figures/simplifiedsessionsandcookies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/auth/figures/simplifiedsessionsandcookies.png -------------------------------------------------------------------------------- /src/chapters/classes-part2/figures/selectEqualsOption.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/classes-part2/figures/selectEqualsOption.png -------------------------------------------------------------------------------- /src/chapters/enums/index.rst: -------------------------------------------------------------------------------- 1 | Enumeration Types 2 | ================= 3 | 4 | .. toctree:: 5 | :maxdepth: 3 6 | 7 | intro 8 | enums-in-models 9 | exercises 10 | 11 | -------------------------------------------------------------------------------- /src/chapters/spring-intro/figures/spring-initializr-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/spring-intro/figures/spring-initializr-11.png -------------------------------------------------------------------------------- /src/chapters/thymeleaf-views/figures/createNewTemplate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/thymeleaf-views/figures/createNewTemplate.png -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/figures/BuiltProject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/introduction-and-setup/figures/BuiltProject.png -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/figures/IntelliJVCS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/introduction-and-setup/figures/IntelliJVCS.png -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/figures/closeProject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/introduction-and-setup/figures/closeProject.png -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/figures/installJava.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/introduction-and-setup/figures/installJava.png -------------------------------------------------------------------------------- /src/chapters/orm-relationships/figures/events-by-category.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/orm-relationships/figures/events-by-category.png -------------------------------------------------------------------------------- /src/chapters/spring-controllers-and-routes/figures/form.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/spring-controllers-and-routes/figures/form.png -------------------------------------------------------------------------------- /src/chapters/thymeleaf-views/figures/buildGradleFileTree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/thymeleaf-views/figures/buildGradleFileTree.png -------------------------------------------------------------------------------- /src/chapters/thymeleaf-views/figures/endresultprofilepage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/thymeleaf-views/figures/endresultprofilepage.png -------------------------------------------------------------------------------- /src/chapters/thymeleaf-views/figures/htmlDefaultButtons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/thymeleaf-views/figures/htmlDefaultButtons.png -------------------------------------------------------------------------------- /src/chapters/thymeleaf-views/figures/selectTLdependency.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/thymeleaf-views/figures/selectTLdependency.png -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/figures/HelloWorldBuilt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/introduction-and-setup/figures/HelloWorldBuilt.png -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/figures/HelloWorldMaven.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/introduction-and-setup/figures/HelloWorldMaven.png -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/figures/IJ-github-login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/introduction-and-setup/figures/IJ-github-login.png -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/figures/IntelliJGithub.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/introduction-and-setup/figures/IntelliJGithub.png -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/figures/IntelliJRunFile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/introduction-and-setup/figures/IntelliJRunFile.png -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/figures/IntelliJWelcome.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/introduction-and-setup/figures/IntelliJWelcome.png -------------------------------------------------------------------------------- /src/chapters/spring-model-classes/figures/mvcOverviewDetail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/spring-model-classes/figures/mvcOverviewDetail.png -------------------------------------------------------------------------------- /src/chapters/thymeleaf-views/figures/bootstrapButtonOptions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/thymeleaf-views/figures/bootstrapButtonOptions.png -------------------------------------------------------------------------------- /src/chapters/thymeleaf-views/figures/thymeleafTemplateCode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/thymeleaf-views/figures/thymeleafTemplateCode.png -------------------------------------------------------------------------------- /src/chapters/tools-in-intelliJ/figures/gradle-refresh-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/tools-in-intelliJ/figures/gradle-refresh-icon.png -------------------------------------------------------------------------------- /src/chapters/tools-in-intelliJ/figures/gradle-refresh-note.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/tools-in-intelliJ/figures/gradle-refresh-note.png -------------------------------------------------------------------------------- /src/chapters/tools-in-intelliJ/figures/gradle-refresh-point.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/tools-in-intelliJ/figures/gradle-refresh-point.png -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/figures/HelloWorldProgram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/introduction-and-setup/figures/HelloWorldProgram.png -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/figures/IntelliJFileOutput.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/introduction-and-setup/figures/IntelliJFileOutput.png -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/figures/IntelliJNewProject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/introduction-and-setup/figures/IntelliJNewProject.png -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/figures/IntelliJOpenFile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/introduction-and-setup/figures/IntelliJOpenFile.png -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/figures/ij-install-options.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/introduction-and-setup/figures/ij-install-options.png -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/figures/startupWithProject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/introduction-and-setup/figures/startupWithProject.png -------------------------------------------------------------------------------- /src/chapters/orm-relationships/figures/event-table-with-data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/orm-relationships/figures/event-table-with-data.png -------------------------------------------------------------------------------- /src/chapters/spring-model-validation/figures/new-empty-event.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/spring-model-validation/figures/new-empty-event.png -------------------------------------------------------------------------------- /src/chapters/thymeleaf-views/figures/ThymeleafTemplateDiagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/thymeleaf-views/figures/ThymeleafTemplateDiagram.png -------------------------------------------------------------------------------- /src/chapters/thymeleaf-views/figures/resourcesFolderFileTree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/thymeleaf-views/figures/resourcesFolderFileTree.png -------------------------------------------------------------------------------- /src/chapters/thymeleaf-views/figures/selectThymeleafTemplate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/thymeleaf-views/figures/selectThymeleafTemplate.png -------------------------------------------------------------------------------- /src/chapters/tools-in-intelliJ/figures/gradle-refresh-corner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/tools-in-intelliJ/figures/gradle-refresh-corner.png -------------------------------------------------------------------------------- /src/chapters/interfaces-and-polymorphism/figures/compare-double.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/interfaces-and-polymorphism/figures/compare-double.png -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/figures/IntelliJAddFileToGit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/introduction-and-setup/figures/IntelliJAddFileToGit.png -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/figures/windowsjavafilepath.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/introduction-and-setup/figures/windowsjavafilepath.png -------------------------------------------------------------------------------- /src/chapters/orm-relationships/figures/event-table-after-update.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/orm-relationships/figures/event-table-after-update.png -------------------------------------------------------------------------------- /src/chapters/orm-relationships/figures/event-table-before-update.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/orm-relationships/figures/event-table-before-update.png -------------------------------------------------------------------------------- /src/chapters/interfaces-and-polymorphism/figures/implement-methods.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/interfaces-and-polymorphism/figures/implement-methods.png -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/figures/HelloWorldBuildProgram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/introduction-and-setup/figures/HelloWorldBuildProgram.png -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/figures/IntelliJProjectWindow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/introduction-and-setup/figures/IntelliJProjectWindow.png -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/figures/IntelliJRepoSelection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/introduction-and-setup/figures/IntelliJRepoSelection.png -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/figures/existingSourcesOption.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/introduction-and-setup/figures/existingSourcesOption.png -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/figures/startupWithoutProject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/introduction-and-setup/figures/startupWithoutProject.png -------------------------------------------------------------------------------- /src/chapters/spring-controllers-and-routes/figures/studio-home-page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/spring-controllers-and-routes/figures/studio-home-page.png -------------------------------------------------------------------------------- /src/chapters/spring-model-validation/figures/validation-exception.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/spring-model-validation/figures/validation-exception.png -------------------------------------------------------------------------------- /src/chapters/orm-relationships/figures/event-category-table-with-data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/orm-relationships/figures/event-category-table-with-data.png -------------------------------------------------------------------------------- /src/chapters/spring-controllers-and-routes/figures/blank-studio-form.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/spring-controllers-and-routes/figures/blank-studio-form.png -------------------------------------------------------------------------------- /src/chapters/spring-controllers-and-routes/figures/mvcOverviewDetail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/spring-controllers-and-routes/figures/mvcOverviewDetail.png -------------------------------------------------------------------------------- /src/chapters/tools-in-intelliJ/index.rst: -------------------------------------------------------------------------------- 1 | .. _tools-in-intelliJ: 2 | 3 | Tools in IntelliJ 4 | ================= 5 | 6 | .. toctree:: 7 | :maxdepth: 3 8 | 9 | gradle 10 | debugging 11 | studio 12 | -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/figures/HelloWorldBuildProgramConfig.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/introduction-and-setup/figures/HelloWorldBuildProgramConfig.png -------------------------------------------------------------------------------- /src/chapters/spring-controllers-and-routes/figures/completed-studio-form.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/spring-controllers-and-routes/figures/completed-studio-form.png -------------------------------------------------------------------------------- /src/chapters/spring-model-validation/figures/display-validation-errors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/java-web-development/HEAD/src/chapters/spring-model-validation/figures/display-validation-errors.png -------------------------------------------------------------------------------- /src/chapters/unit-testing/index.rst: -------------------------------------------------------------------------------- 1 | .. _unit-testing: 2 | 3 | Unit Testing 4 | ============ 5 | 6 | .. toctree:: 7 | :maxdepth: 3 8 | 9 | testing-in-java 10 | junit 11 | exercises 12 | studio 13 | -------------------------------------------------------------------------------- /src/appendices/software/intellij-install.rst: -------------------------------------------------------------------------------- 1 | Installing IntelliJ 2 | =================== 3 | 4 | The installation instructions for adding IntelliJ to your device can be found 5 | in ``IntelliJ`` section of :ref:`Chapter 1 `. 6 | -------------------------------------------------------------------------------- /src/chapters/data-types/index.rst: -------------------------------------------------------------------------------- 1 | .. _data-types: 2 | 3 | Data Types 4 | ========== 5 | 6 | .. toctree:: 7 | :maxdepth: 3 8 | 9 | data-types 10 | some-java-practice 11 | more-data-types 12 | exercises 13 | studio 14 | -------------------------------------------------------------------------------- /src/chapters/auth/index.rst: -------------------------------------------------------------------------------- 1 | Authentication 2 | ============== 3 | 4 | .. toctree:: 5 | :maxdepth: 3 6 | 7 | intro 8 | hashing-passwords 9 | user-model 10 | login-registration-forms 11 | request-filtering 12 | studio 13 | -------------------------------------------------------------------------------- /src/chapters/orm-part1/index.rst: -------------------------------------------------------------------------------- 1 | Introduction to Object-Relational Mapping 2 | ========================================= 3 | 4 | .. toctree:: 5 | :maxdepth: 3 6 | 7 | background 8 | accessing-data 9 | repositories 10 | exercises 11 | studio 12 | -------------------------------------------------------------------------------- /src/chapters/classes/index.rst: -------------------------------------------------------------------------------- 1 | .. _classes-part1: 2 | 3 | Classes in Java, Part 1 4 | ======================== 5 | 6 | .. toctree:: 7 | 8 | background 9 | modifiers 10 | encapsulation 11 | constructors 12 | methods 13 | srp 14 | exercises 15 | studio 16 | -------------------------------------------------------------------------------- /src/chapters/classes-part2/index.rst: -------------------------------------------------------------------------------- 1 | Classes and Objects, Part 2 2 | ============================ 3 | 4 | .. toctree:: 5 | :maxdepth: 3 6 | 7 | customize-fields 8 | instance-and-static-methods 9 | special-methods 10 | equals-shortcut 11 | exercises 12 | studio 13 | -------------------------------------------------------------------------------- /src/chapters/control-flow-and-collections/index.rst: -------------------------------------------------------------------------------- 1 | Control Flow and Collections 2 | ============================ 3 | 4 | .. toctree:: 5 | :maxdepth: 3 6 | 7 | conditionals 8 | loops 9 | collections 10 | arraylist 11 | array 12 | hashmap 13 | exercises 14 | studio 15 | -------------------------------------------------------------------------------- /src/chapters/spring-model-validation/index.rst: -------------------------------------------------------------------------------- 1 | Model Validation 2 | ================ 3 | 4 | .. toctree:: 5 | :maxdepth: 3 6 | 7 | server-side-validation 8 | validation-annotations 9 | validation-controller 10 | thymeleaf-form-tools 11 | exercises 12 | studio 13 | 14 | -------------------------------------------------------------------------------- /src/chapters/spring-model-classes/index.rst: -------------------------------------------------------------------------------- 1 | .. _models_in_MVC: 2 | 3 | Models and Model Binding 4 | ======================== 5 | 6 | .. toctree:: 7 | :maxdepth: 3 8 | 9 | model-intro 10 | model-class 11 | data-layer 12 | model-binding 13 | exercises 14 | studio 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/chapters/orm-relationships/index.rst: -------------------------------------------------------------------------------- 1 | Relationships in Object-Relational Mapping 2 | ========================================== 3 | 4 | .. toctree:: 5 | :maxdepth: 3 6 | 7 | types-of-relationships 8 | many-to-one 9 | one-to-many 10 | one-to-one 11 | many-to-many 12 | exercises 13 | -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/index.rst: -------------------------------------------------------------------------------- 1 | Introduction and Setup 2 | ====================== 3 | 4 | .. toctree:: 5 | :maxdepth: 3 6 | 7 | why-java 8 | setup 9 | java-terminal 10 | intellij 11 | first-java-project 12 | java-web-dev-exercises 13 | naming-conventions 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/chapters/interfaces-and-polymorphism/index.rst: -------------------------------------------------------------------------------- 1 | Interfaces and Polymorphism 2 | ============================ 3 | 4 | .. toctree:: 5 | :maxdepth: 3 6 | 7 | introduction 8 | interfaces 9 | interfaces-and-abstract-classes 10 | given-interfaces 11 | testing-interfaces 12 | exercises 13 | studio 14 | -------------------------------------------------------------------------------- /src/chapters/spring-controllers-and-routes/index.rst: -------------------------------------------------------------------------------- 1 | .. _controllers: 2 | 3 | Controllers and Routing 4 | ======================= 5 | 6 | .. toctree:: 7 | :maxdepth: 3 8 | 9 | controllers-simple 10 | controllers-parameters 11 | controllers-forms 12 | controllers-classes 13 | exercises 14 | studio 15 | 16 | -------------------------------------------------------------------------------- /src/chapters/inheritance/index.rst: -------------------------------------------------------------------------------- 1 | .. _inheritance: 2 | 3 | Inheritance 4 | =========== 5 | 6 | .. toctree:: 7 | :maxdepth: 3 8 | 9 | oop-inheritance 10 | java-inheritance 11 | cat-classes 12 | abstract-inheritance 13 | casting 14 | testing-inheritance 15 | class-diagrams 16 | exercises 17 | studio 18 | 19 | -------------------------------------------------------------------------------- /src/chapters/thymeleaf-views/index.rst: -------------------------------------------------------------------------------- 1 | .. _thymeleaf: 2 | 3 | Thymeleaf Views 4 | ================ 5 | 6 | .. toctree:: 7 | :maxdepth: 3 8 | 9 | why-templates 10 | create-template 11 | using-templates 12 | template-iteration 13 | template-conditionals 14 | template-forms 15 | template-fragments 16 | src&href 17 | bootstrap 18 | exercises 19 | studio 20 | -------------------------------------------------------------------------------- /src/appendices/exercise-solutions/index.rst: -------------------------------------------------------------------------------- 1 | Exercise Solutions 2 | ================== 3 | 4 | .. toctree:: 5 | :maxdepth: 1 6 | 7 | data-types 8 | control-flow-and-collections 9 | classes 10 | classes-part2 11 | unit-testing 12 | inheritance 13 | interfaces-and-polymorphism 14 | spring-controllers-and-routes 15 | thymeleaf-views 16 | spring-model-classes 17 | spring-model-validation 18 | enums 19 | orm-part1 20 | orm-relationships 21 | 22 | -------------------------------------------------------------------------------- /exts/external_links.py: -------------------------------------------------------------------------------- 1 | from docutils.nodes import reference, raw 2 | 3 | 4 | def setup(app): 5 | app.connect('doctree-resolved', doctree_resolved) 6 | return {'version': '0.1'} 7 | 8 | 9 | def doctree_resolved(app, doctree, document): 10 | for node in doctree.traverse(reference): 11 | if not node.get('internal'): 12 | node['target'] = '_blank' 13 | text = '' 14 | node += raw(text, text, format='html') 15 | -------------------------------------------------------------------------------- /src/chapters/inheritance/oop-inheritance.rst: -------------------------------------------------------------------------------- 1 | Inheritance in OOP 2 | ================== 3 | 4 | .. index:: ! inheritance, ! subtyping 5 | 6 | **Inheritance** is the second of the **Four Pillars of Object-Oriented 7 | Programming** that we encounter. 8 | 9 | Here’s a definition: inheritance is a mechanism within object-oriented programming that 10 | allows one class to be based on another class, thus receiving its 11 | properties and behaviors. 12 | 13 | .. note:: 14 | 15 | Inheritance is also sometimes referred to as **subtyping**. -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | alabaster==0.7.12 2 | Babel==2.9.1 3 | certifi==2022.12.7 4 | chardet==3.0.4 5 | commonmark==0.9.1 6 | docutils==0.16 7 | idna==2.8 8 | imagesize==1.2.0 9 | Jinja2==2.11.3 10 | MarkupSafe==1.1.1 11 | packaging==20.1 12 | Pygments==2.7.4 13 | pypandoc==1.4 14 | pyparsing==2.4.6 15 | pytz==2019.3 16 | recommonmark==0.6.0 17 | requests==2.22.0 18 | six==1.14.0 19 | snowballstemmer==2.0.0 20 | Sphinx==3.3.1 21 | git+https://github.com/LaunchCodeEducation/sphinx-bootstrap-theme.git@master 22 | sphinxcontrib-websupport==1.1.2 23 | urllib3 24 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: true 2 | cache: pip 3 | python: "3.9" 4 | language: python 5 | 6 | if: type = push AND branch = master 7 | 8 | install: # install dependencies (cached) 9 | - pip install -r requirements.txt 10 | 11 | script: 12 | - ./build -c # run clean build 13 | - mv docs/ gh-pages/ 14 | 15 | deploy: 16 | provider: pages # github pages provider 17 | skip_cleanup: true # save the build output (artifact) 18 | local_dir: gh-pages # the directory to deploy to GH pages 19 | target_branch: gh-pages # branch to push to 20 | github_token: $GITHUB_ACCESS_TOKEN # access token with repo:public scope 21 | -------------------------------------------------------------------------------- /src/_static/fa/css/brands.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Font Awesome Free 5.8.2 by @fontawesome - https://fontawesome.com 3 | * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) 4 | */ 5 | @font-face{font-family:"Font Awesome 5 Brands";font-style:normal;font-weight:normal;font-display:auto;src:url(../webfonts/fa-brands-400.eot);src:url(../webfonts/fa-brands-400.eot?#iefix) format("embedded-opentype"),url(../webfonts/fa-brands-400.woff2) format("woff2"),url(../webfonts/fa-brands-400.woff) format("woff"),url(../webfonts/fa-brands-400.ttf) format("truetype"),url(../webfonts/fa-brands-400.svg#fontawesome) format("svg")}.fab{font-family:"Font Awesome 5 Brands"} -------------------------------------------------------------------------------- /src/_static/fa/css/solid.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Font Awesome Free 5.8.2 by @fontawesome - https://fontawesome.com 3 | * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) 4 | */ 5 | @font-face{font-family:"Font Awesome 5 Free";font-style:normal;font-weight:900;font-display:auto;src:url(../webfonts/fa-solid-900.eot);src:url(../webfonts/fa-solid-900.eot?#iefix) format("embedded-opentype"),url(../webfonts/fa-solid-900.woff2) format("woff2"),url(../webfonts/fa-solid-900.woff) format("woff"),url(../webfonts/fa-solid-900.ttf) format("truetype"),url(../webfonts/fa-solid-900.svg#fontawesome) format("svg")}.fa,.fas{font-family:"Font Awesome 5 Free";font-weight:900} -------------------------------------------------------------------------------- /src/_static/fa/css/regular.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Font Awesome Free 5.8.2 by @fontawesome - https://fontawesome.com 3 | * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) 4 | */ 5 | @font-face{font-family:"Font Awesome 5 Free";font-style:normal;font-weight:400;font-display:auto;src:url(../webfonts/fa-regular-400.eot);src:url(../webfonts/fa-regular-400.eot?#iefix) format("embedded-opentype"),url(../webfonts/fa-regular-400.woff2) format("woff2"),url(../webfonts/fa-regular-400.woff) format("woff"),url(../webfonts/fa-regular-400.ttf) format("truetype"),url(../webfonts/fa-regular-400.svg#fontawesome) format("svg")}.far{font-family:"Font Awesome 5 Free";font-weight:400} -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Introduction to Professional Web Development in Java 2 | 3 | Creative Commons License
Introduction to Professional Web Development in Java by The LaunchCode Foundation is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. 4 | -------------------------------------------------------------------------------- /src/_static/fa/css/brands.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Font Awesome Free 5.8.2 by @fontawesome - https://fontawesome.com 3 | * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) 4 | */ 5 | @font-face { 6 | font-family: 'Font Awesome 5 Brands'; 7 | font-style: normal; 8 | font-weight: normal; 9 | font-display: auto; 10 | src: url("../webfonts/fa-brands-400.eot"); 11 | src: url("../webfonts/fa-brands-400.eot?#iefix") format("embedded-opentype"), url("../webfonts/fa-brands-400.woff2") format("woff2"), url("../webfonts/fa-brands-400.woff") format("woff"), url("../webfonts/fa-brands-400.ttf") format("truetype"), url("../webfonts/fa-brands-400.svg#fontawesome") format("svg"); } 12 | 13 | .fab { 14 | font-family: 'Font Awesome 5 Brands'; } 15 | -------------------------------------------------------------------------------- /src/_static/fa/css/regular.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Font Awesome Free 5.8.2 by @fontawesome - https://fontawesome.com 3 | * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) 4 | */ 5 | @font-face { 6 | font-family: 'Font Awesome 5 Free'; 7 | font-style: normal; 8 | font-weight: 400; 9 | font-display: auto; 10 | src: url("../webfonts/fa-regular-400.eot"); 11 | src: url("../webfonts/fa-regular-400.eot?#iefix") format("embedded-opentype"), url("../webfonts/fa-regular-400.woff2") format("woff2"), url("../webfonts/fa-regular-400.woff") format("woff"), url("../webfonts/fa-regular-400.ttf") format("truetype"), url("../webfonts/fa-regular-400.svg#fontawesome") format("svg"); } 12 | 13 | .far { 14 | font-family: 'Font Awesome 5 Free'; 15 | font-weight: 400; } 16 | -------------------------------------------------------------------------------- /src/_static/fa/css/solid.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Font Awesome Free 5.8.2 by @fontawesome - https://fontawesome.com 3 | * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) 4 | */ 5 | @font-face { 6 | font-family: 'Font Awesome 5 Free'; 7 | font-style: normal; 8 | font-weight: 900; 9 | font-display: auto; 10 | src: url("../webfonts/fa-solid-900.eot"); 11 | src: url("../webfonts/fa-solid-900.eot?#iefix") format("embedded-opentype"), url("../webfonts/fa-solid-900.woff2") format("woff2"), url("../webfonts/fa-solid-900.woff") format("woff"), url("../webfonts/fa-solid-900.ttf") format("truetype"), url("../webfonts/fa-solid-900.svg#fontawesome") format("svg"); } 12 | 13 | .fa, 14 | .fas { 15 | font-family: 'Font Awesome 5 Free'; 16 | font-weight: 900; } 17 | -------------------------------------------------------------------------------- /exts/replit.py: -------------------------------------------------------------------------------- 1 | from docutils import nodes 2 | from docutils.parsers.rst import directives, Directive 3 | from sphinx.directives.code import CodeBlock 4 | 5 | 6 | def setup(app): 7 | app.add_config_value('replit_user', '', 'html') 8 | app.add_directive('replit', ReplIt) 9 | return {'version': '0.1'} 10 | 11 | 12 | class ReplIt(CodeBlock): 13 | 14 | option_spec = { 15 | 'linenos': directives.flag, 16 | 'slug': directives.unchanged 17 | } 18 | 19 | url_template = "https://repl.it/@%s/%s" 20 | 21 | def run(self): 22 | replit_user = self.state.document.settings.env.app.config['replit_user'] 23 | code_node = super(ReplIt, self).run()[0] 24 | ref_node = nodes.reference('', '') 25 | ref_node['refuri'] = self.url_template % (replit_user, self.options['slug']) 26 | ref_node += nodes.Text('repl.it', 'repl.it') 27 | para_nodes = nodes.paragraph() 28 | para_nodes += ref_node 29 | para_nodes['classes'] = ['repl-link'] 30 | return [code_node, para_nodes] 31 | -------------------------------------------------------------------------------- /src/appendices/exercise-solutions/spring-model-validation.rst: -------------------------------------------------------------------------------- 1 | .. _model-validation-exercise-solutions: 2 | 3 | Exercise Solutions: Model Validation 4 | ==================================== 5 | 6 | Event information to add: 7 | 8 | .. _model-validation-exercise-solutions1: 9 | 10 | #. Add a field to collect information about where the event will take place. This field should not be 11 | null or blank. 12 | 13 | .. sourcecode:: java 14 | 15 | @NotBlank(message="Location cannot be left blank.") 16 | private String location; 17 | 18 | :ref:`Back to the exercises ` 19 | 20 | .. _model-validation-exercise-solutions3: 21 | 22 | 3. Add a field to collect information about the number of attendees for the event. Valid values for this 23 | field should be any number over zero. 24 | 25 | .. sourcecode:: java 26 | 27 | @Positive(message="Number of attendees must be one or more.") 28 | private int numberOfAttendees; 29 | 30 | :ref:`Back to the exercises ` 31 | 32 | -------------------------------------------------------------------------------- /src/_static/css/site.css: -------------------------------------------------------------------------------- 1 | /* BEGIN styles related to inclusion of breadcrumb nav */ 2 | 3 | .breadcrumb { 4 | width: 100%; 5 | position: fixed; 6 | top: 60px; 7 | z-index: 99; 8 | border-bottom: 1px solid #dbdbdb; 9 | } 10 | 11 | body.body-bc { 12 | padding-top: 98px; 13 | } 14 | 15 | .body-bc .section { 16 | margin-top: -98px; 17 | padding-top: 98px; 18 | } 19 | 20 | .body-bc p[id]:before { 21 | display: block; 22 | content: " "; 23 | margin-top: -105px; 24 | height: 105px; 25 | visibility: hidden; 26 | } 27 | 28 | /* END styles related to inclusion of breadcrumb nav */ 29 | 30 | /* BEGIN jumbotron styles */ 31 | 32 | .jumbotron { 33 | text-align: center; 34 | padding: 0; 35 | margin: 0; 36 | } 37 | 38 | .jumbotron h1 { 39 | font-size: 42px; 40 | } 41 | 42 | .jumbotron .content > * { 43 | margin: 40px 0; 44 | } 45 | 46 | .jumbotron .pagination { 47 | margin: 0; 48 | } 49 | 50 | /* END jumbotron styles */ 51 | 52 | .toctree-wrapper ol { 53 | list-style: none; 54 | padding-left: 20px; 55 | } 56 | 57 | .fas.fa-external-link-alt { 58 | color: inherit; 59 | font-size: 10px; 60 | padding-left: 4px; 61 | } 62 | -------------------------------------------------------------------------------- /.github/workflows/deploy-lc.yml: -------------------------------------------------------------------------------- 1 | name: LC GitHub Pages 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | deploy: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@master 13 | 14 | - name: Setup Python 15 | uses: actions/setup-python@master 16 | with: 17 | python-version: '3.9' 18 | 19 | - name: Upgrade pip 20 | run: | 21 | # install pip=>20.1 to use "pip cache dir" 22 | python3 -m pip install --upgrade pip 23 | 24 | - name: Get pip cache dir 25 | id: pip-cache 26 | run: | 27 | echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT 28 | 29 | - name: Cache dependencies 30 | uses: actions/cache@master 31 | with: 32 | path: ${{ steps.pip-cache.outputs.dir }} 33 | key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} 34 | restore-keys: | 35 | ${{ runner.os }}-pip- 36 | 37 | - name: Build Project Artifacts 38 | run: python3 -m pip install -r ./requirements.txt 39 | - run: sphinx-build src docs 40 | 41 | - name: Deploy to GitHub Pages 42 | uses: peaceiris/actions-gh-pages@v3 43 | with: 44 | github_token: ${{ secrets.GITHUB_TOKEN }} 45 | publish_dir: ./docs 46 | -------------------------------------------------------------------------------- /src/appendices/about-this-book.rst: -------------------------------------------------------------------------------- 1 | About This Book 2 | =============== 3 | 4 | License 5 | ------- 6 | 7 | .. image:: https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png 8 | :alt: Creative Commons License 9 | 10 | Java Web Development by `The LaunchCode Foundation`_ is licensed under a `Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License`_. 11 | 12 | 13 | .. _The LaunchCode Foundation: https://www.launchcode.org/ 14 | .. _Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License: https://creativecommons.org/licenses/by-nc-sa/4.0/ 15 | 16 | Contributors 17 | ------------ 18 | 19 | .. list-table:: 20 | 21 | * - .. figure:: ./figures/Staff_Chris_Bay.png 22 | :alt: Chris Bay 23 | 24 | `Chris Bay`_ 25 | - .. figure:: ./figures/Staff_Jim_Flores.png 26 | :alt: Jim Flores 27 | 28 | `Jim Flores`_ 29 | * - .. figure:: ./figures/Staff_Carly_Langlois.png 30 | :alt: Carly Langlois 31 | 32 | `Carly Langlois`_ 33 | - .. figure:: ./figures/Staff_Sally_Steuterman.png 34 | :alt: Sally Steuterman 35 | 36 | `Sally Steuterman`_ 37 | 38 | 39 | 40 | 41 | .. _Chris Bay: https://github.com/chrisbay 42 | .. _Jim Flores: https://github.com/jimflores5 43 | .. _Sally Steuterman: https://github.com/gildedgardenia 44 | .. _Carly Langlois: https://github.com/carlylanglois 45 | -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/why-java.rst: -------------------------------------------------------------------------------- 1 | Why Learn Java? 2 | =============== 3 | 4 | .. index:: ! Java 5 | 6 | This course is an introduction to **Java** and the Spring Boot framework. Java is a 7 | powerful programming language and one of the most widely used across the globe. 8 | This course is designed for learners who are already familiar with at least one 9 | programming language. Thus, we'll move quickly through the syntax rules and 10 | procedural basics of the language (ie, how does one write a for loop in Java? a 11 | conditional statement?). 12 | 13 | As you've likely heard before, once you grasp the fundamentals of programming in 14 | one language, learning another becomes much easier. Professional software 15 | developers often work in environments involving several programming languages so 16 | it's wise to start learning new ones early on in your career. 17 | 18 | .. index:: IntelliJ IDE, Spring Boot 19 | 20 | Beyond the basics of programming in Java, you'll learn some key *object oriented* 21 | concepts to enhance the capabilities of your programs. You'll also download a 22 | program called **IntelliJ IDE** to get familiar with the tools of the Java developer. 23 | In the final lessons of this course, you will use a Java framework called **Spring Boot**. 24 | This framework gives us the scaffolding necessary to create *MVC* programs, another 25 | concept we'll cover, effectively and efficiently. 26 | -------------------------------------------------------------------------------- /src/appendices/exercise-solutions/orm-relationships.rst: -------------------------------------------------------------------------------- 1 | .. _orm-relationships-exercise-solutions: 2 | 3 | Exercise Solutions: The Early Bird gets the ORM! 4 | ================================================ 5 | 6 | Here is an example of how the README may turn out: 7 | 8 | 1. Our ``Person`` class might hold the following fields: 9 | 10 | a. ``id`` (``int``) - the unique user ID 11 | 12 | b. ``firstName`` (``String``) - the user's first name 13 | 14 | c. ``lastName`` (``String``) - the user's last name 15 | 16 | d. ``email`` (``String``) - the user's email, which will also function as their username 17 | 18 | e. ``password`` (``String``) - the user's password 19 | 20 | The class would need getters for all of these fields. It could have setters for all fields except id (since it shouldn't change). 21 | 22 | 2. The ``Person`` class might also have the following references: 23 | 24 | a. ``PersonProfile`` - a class to gather up all of the profile information about the user 25 | 26 | b. ``List eventsAttending`` - to store events the user wants to attend 27 | 28 | c. ``List eventsOwned`` - a different list, to store the events the user has created 29 | 30 | ``Person`` would have a many-to-many relationship with ``Event`` via ``List eventsAttending``. 31 | It would have a one-to-many relationship with ``Event`` via ``List eventsOwned``. 32 | 33 | :ref:`Back to the exercises ` -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/intellij.rst: -------------------------------------------------------------------------------- 1 | .. index:: ! integrated development environment, IDE 2 | 3 | IntelliJ 4 | ======== 5 | 6 | IntelliJ is an **integrated development environment (IDE)**. An IDE is like a text 7 | editor on steroids. It not only allows you to write and edit code, but also contains many 8 | features that enhance the coding experience. IntelliJ offers 9 | code completion hints, debugging, and even it's own compiler. We'll be using it throughout 10 | this course, so it's time to get familiar with some of the basics. 11 | 12 | .. _install-intellij: 13 | 14 | Install IntelliJ 15 | ---------------- 16 | 17 | Visit the `IntelliJ download site `__. 18 | Select your operating system and the Community version. Follow the installation 19 | prompts to select your settings. 20 | 21 | When you reach the window asking for *Installation Options*, select the 22 | *Add "bin" folder to the PATH* box. Click *Next*. If 23 | you are asked for any other input, accept the default options. 24 | 25 | .. figure:: figures/ij-install-options.png 26 | :scale: 90% 27 | :alt: Welcome window for IntelliJ 28 | 29 | IntelliJ installation options 30 | 31 | You will finish on an IntelliJ welcome panel listing options to create a 32 | *New Project*, *Open* a project, or *Get from VCS* (a.k.a Version Control 33 | System). 34 | 35 | .. figure:: figures/IntelliJWelcome.png 36 | :scale: 80% 37 | :alt: Welcome window for IntelliJ 38 | 39 | IntelliJ welcome window 40 | 41 | You've installed IntelliJ, and you're ready to start exploring its many features. 42 | 43 | -------------------------------------------------------------------------------- /src/chapters/inheritance/exercises.rst: -------------------------------------------------------------------------------- 1 | .. _inheritance-exercises: 2 | 3 | Exercises: Inheritance 4 | ====================== 5 | 6 | Work on these exercises in the IntelliJ ``java-web-dev-exercises`` project. Add a new package called ``technology`` to your ``exercises`` directory. 7 | 8 | 1. **Class design:** Create a new class called ``Computer``. Before you add any more code, know that you will need to add two additional classes: ``Laptop`` and ``SmartPhone``. 9 | Before you start coding anything inside these classes, diagram how the three classes are going to be related to each other. 10 | Remember to add properties and methods to your diagram! 11 | 12 | 1. For a parent class add 3 properties, 2 methods, and a constructor. 13 | 2. For a child class add *at least* 1 additional property and 1 additional method. 14 | 15 | 2. **Class implementation:** Implement your design and test it in a ``Program.java`` class. 16 | 17 | 1. Try to add three JUnit tests per class! 18 | 19 | :ref:`Check your solution ` 20 | 21 | 3. **Abstract class design:** Consider the group of classes that you designed. Suppose you had a web program that used these classes, and you needed to assign a unique ID to every object created from one of these classes within the application. Therefore, each such class should have an ``Id`` property, and no two objects created from any of the classes may have the same value for ``Id``. Create an abstract class, ``AbstractEntity``, that contains the behavior for assigning and accessing such a unique ID for each class that extends it. Add this class to your program above, and add ``AbstractEntity`` to the class hierarchy in the correct place. 22 | 23 | -------------------------------------------------------------------------------- /src/appendices/exercise-solutions/thymeleaf-views.rst: -------------------------------------------------------------------------------- 1 | .. _thymeleaf-views-exercise-solutions: 2 | 3 | Exercise Solutions: Thymeleaf Views 4 | =================================== 5 | 6 | Expanding our Events Schedule 7 | ----------------------------- 8 | 9 | .. _thymeleaf-views-exercise-solutions1: 10 | 11 | #. Comment out your previous code in the ``displayAllEvents`` method. 12 | 13 | .. sourcecode:: java 14 | 15 | // List events = new ArrayList<>(); 16 | // events.add("Code With Pride"); 17 | // events.add("Strange Loop"); 18 | // events.add("Apple WWDC"); 19 | // events.add("SpringOne Platform"); 20 | 21 | :ref:`Back to the exercises ` 22 | 23 | .. _thymeleaf-views-exercise-solutions3: 24 | 25 | 3. Fill your ``events`` HashMap with the names and descriptions of 3 coding 26 | events around town. 27 | 28 | .. sourcecode:: java 29 | 30 | events.put("Menteaship","A fun meetup for connecting with mentors"); 31 | events.put("Code With Pride","A fun meetup sponsored by LaunchCode"); 32 | events.put("Javascripty", "An imaginary meetup for Javascript developers"); 33 | 34 | :ref:`Back to the exercises ` 35 | 36 | .. _thymeleaf-views-exercise-solutions5: 37 | 38 | 5. Use fragments to store the address of the new tech hub where all of the 39 | programmers are hanging out. Use ``th:replace`` in your main template to 40 | bring in the address as a third column in your table. 41 | You may need to create a new ``fragments.html``. 42 | 43 | .. sourcecode:: guess 44 | 45 | 1234 5th Street 46 | 47 | :ref:`Back to the exercises ` -------------------------------------------------------------------------------- /src/chapters/classes/srp.rst: -------------------------------------------------------------------------------- 1 | Single Responsibility Principle 2 | =============================== 3 | 4 | As we wrap up our whirlwind tour of classes, we want you think a 5 | bit about how to go about building good classes. Doing so is more of an 6 | art than a science, and it will take you lots of practice and time. 7 | However, there are a few rules that we’ve pointed out to help guide you. 8 | Here’s one more. 9 | 10 | From 11 | `Wikipedia `__: 12 | 13 | The **single responsibility principle** states that every module or 14 | class should have responsibility over a single part of the functionality 15 | provided by the software, and that responsibility should be entirely 16 | encapsulated by the class. 17 | 18 | It isn’t always clear what “responsibility over a single part of the 19 | functionality” means. However, it is often very clear what it doesn’t 20 | mean. For example, we wouldn’t think of adding functionality to the 21 | ``Student`` class that tracked all of the data for each of the student’s 22 | classes, such as catalog number, instructor, and so on. Those are 23 | clearly different areas of responsibility. One way to interpret the 24 | single responsibility principle is to say that “classes should be 25 | small.” 26 | 27 | As you go forth and create classes, the main thing to keep in mind is 28 | that your skill and judgement in creating Java classes will improve over 29 | time. The best way to improve is to write lots of code, ask lots of 30 | questions, and continue learning! 31 | 32 | If you are interested in learning more about `Single Responsibility Principle `_, you can check out the entry on Wikipedia. 33 | 34 | -------------------------------------------------------------------------------- /exts/admonition_icons.py: -------------------------------------------------------------------------------- 1 | import re 2 | from docutils.nodes import Admonition, admonition, raw, title, warning, note, tip 3 | 4 | 5 | def setup(app): 6 | app.connect('doctree-resolved', doctree_resolved) 7 | app.connect('doctree-read', doctree_read) 8 | return {'version': '0.1'} 9 | 10 | 11 | ICONS_CLASSES = { 12 | "note": "sticky-note", 13 | "warning": "exclamation-triangle", 14 | "tip": "lightbulb", 15 | "example": "binoculars", 16 | "examples": "binoculars", 17 | "question": "question", 18 | "try-it": "puzzle-piece", 19 | "fun-fact": "rocket" 20 | } 21 | 22 | TEMPLATE = '' 23 | 24 | 25 | # Convert builtin admonitions to generic ones, for easier icon insertion 26 | def doctree_read(app, doctree): 27 | for node in doctree.traverse(is_builtin_admonition): 28 | new_node = admonition() 29 | name = node.__class__.__name__.title() 30 | title_node = title(name, name) 31 | new_node += title_node 32 | for child in node.children: 33 | new_node += child 34 | node.remove(child) 35 | node.replace_self(new_node) 36 | 37 | 38 | def is_builtin_admonition(node): 39 | return node.__class__ in [warning, note, tip] 40 | 41 | 42 | # insert icons 43 | def doctree_resolved(app, doctree, document): 44 | for node in doctree.traverse(title): 45 | if isinstance(node.parent, Admonition): 46 | node_title = node.children[0].astext() 47 | slug = node_title.lower().replace(' ', '-') 48 | slug = re.sub(r'[^a-z\-]', '', slug) 49 | if slug in ICONS_CLASSES: 50 | icon = TEMPLATE % ICONS_CLASSES[slug] 51 | node.insert(0, raw(icon, icon, format='html')) 52 | -------------------------------------------------------------------------------- /src/chapters/classes/exercises.rst: -------------------------------------------------------------------------------- 1 | .. _classes-exercises-part1: 2 | 3 | Exercises: Classes and Objects 4 | ============================== 5 | 6 | Work on these exercises in the IntelliJ ``java-web-dev-exercises`` project. 7 | 8 | #. Open up the file, ``Student.java``, and add all of the necessary getters and 9 | setters. Think about the access level each field and method should have, and 10 | try reducing the access level of at least one setter to less than public. 11 | 12 | :ref:`Check your solution ` 13 | 14 | #. Instantiate the ``Student`` class using yourself as the student. For the 15 | ``numberOfCredits`` give yourself ``1`` for this class and a GPA of ``4.0`` 16 | because you are a Java superstar! 17 | #. In the ``school`` package, create a class ``Course`` with at least three 18 | fields. Before diving into IntelliJ, try using pen and paper to work through 19 | what these might be. At least one of your fields should be an ``ArrayList`` 20 | or ``HashMap``, and you should use your ``Student`` class. 21 | 22 | :ref:`Check your solution ` 23 | 24 | #. In the ``school`` package, create a class ``Teacher`` with four fields: 25 | ``firstName``, ``lastName``, ``subject``, and ``yearsTeaching``. Add getters 26 | and setters to the class and add the access level to each field and method 27 | in the class. When adding your getters and setters, think about what we read 28 | about in the section on Encapsulation. 29 | 30 | a. What access modifier restricts access the most for what we need? 31 | b. If it is a field, could we restrict the access to ``private`` and use 32 | getters and setters? 33 | c. If we do set fields to ``private``, what access level do we have to give 34 | our getters and setters? 35 | -------------------------------------------------------------------------------- /src/chapters/spring-model-validation/exercises.rst: -------------------------------------------------------------------------------- 1 | .. _model-validation-exercises: 2 | 3 | Exercises: Model Validation 4 | =========================== 5 | 6 | Let’s practice adding more fields onto our event objects and 7 | validating them. Create a new branch from your own ``display-errors`` branch. Here's the ``display-errors`` branch on 8 | `coding-events-demo `__ if you need to get up to speed. 9 | 10 | Below, we describe some new fields for you to add to the ``Event`` class. 11 | For each field, consider the following factors: 12 | 13 | a. What will you call your field? 14 | #. Will you need accessors for this field? 15 | #. What type of input should be added to capture the field's information from the user? 16 | #. Refer to the documentation page to find an appropriate annotation to fit the constraints. 17 | #. What should the error message convey to the user? 18 | #. What, if anything, will you need to update on the controller to account for the new field? 19 | 20 | Event information to add: 21 | 22 | #. Add a field to collect information about where the event will take place. This field should not be 23 | null or blank. 24 | 25 | :ref:`Check your solution ` 26 | 27 | #. Add a field to collect information about whether an attendee must register for the event or not. For 28 | the purposes of validation practice, make this field only able to be marked as true. 29 | 30 | #. Add a field to collect information about the number of attendees for the event. Valid values for this 31 | field should be any number over zero. 32 | 33 | :ref:`Check your solution ` 34 | 35 | #. Browse the validation annotations to find one to use on another new field of your choosing. 36 | 37 | 38 | -------------------------------------------------------------------------------- /exts/ordered_toctree.py: -------------------------------------------------------------------------------- 1 | from docutils import nodes 2 | from sphinx.addnodes import toctree 3 | from sphinx.builders.html import StandaloneHTMLBuilder 4 | from sphinx.writers.html import HTMLWriter, HTMLTranslator 5 | 6 | 7 | class AccessibleHTMLBuilder(StandaloneHTMLBuilder): 8 | 9 | name = 'html-a11y' 10 | 11 | @property 12 | def default_translator_class(self): 13 | return AccessibleHTMLTranslator 14 | 15 | 16 | def is_toctree_node(node): 17 | if len(node.children) < 1: 18 | return False 19 | child_classes = node.children[0].attributes['classes'] 20 | toctree_classes = list(filter(lambda x: 'toctree' in x, child_classes)) 21 | return len(toctree_classes) > 0 22 | 23 | 24 | class AccessibleHTMLTranslator(HTMLTranslator): 25 | 26 | def visit_bullet_list(self, node): 27 | # type: (nodes.Node) -> None 28 | if len(node) == 1 and node[0].tagname == 'toctree': 29 | # avoid emitting empty
    30 | raise nodes.SkipNode 31 | atts = {} 32 | old_compact_simple = self.compact_simple 33 | self.context.append((self.compact_simple, self.compact_p)) 34 | self.compact_p = None 35 | self.compact_simple = self.is_compactable(node) 36 | if self.compact_simple and not old_compact_simple: 37 | atts['class'] = 'simple' 38 | if is_toctree_node(node): 39 | self.body.append(self.starttag(node, 'ol', **atts)) 40 | else: 41 | self.body.append(self.starttag(node, 'ul', **atts)) 42 | 43 | def depart_bullet_list(self, node): 44 | self.compact_simple, self.compact_p = self.context.pop() 45 | if is_toctree_node(node): 46 | self.body.append('\n') 47 | else: 48 | self.body.append('\n') 49 | 50 | 51 | def setup(app): 52 | app.add_builder(AccessibleHTMLBuilder) 53 | -------------------------------------------------------------------------------- /src/appendices/exercise-solutions/classes.rst: -------------------------------------------------------------------------------- 1 | .. _classes-exercise-solutions: 2 | 3 | Exercise Solutions: Classes and Objects 4 | ======================================= 5 | 6 | .. _classes-exercise-solutions1: 7 | 8 | #. Open up the file, ``Student.java``, and add all of the necessary getters and 9 | setters. Think about the access level each field and method should have, and 10 | try reducing the access level of at least one setter to less than public. 11 | 12 | .. sourcecode:: java 13 | :linenos: 14 | 15 | public void setName(String name) { 16 | this.name = name; 17 | } 18 | 19 | public void setStudentId(int studentId) { 20 | this.studentId = studentId; 21 | } 22 | 23 | public void setGpa(double gpa) { 24 | this.gpa = gpa; 25 | } 26 | 27 | private void setNumberOfCredits(int numberOfCredits) { 28 | this.numberOfCredits = numberOfCredits; 29 | } 30 | 31 | public String getName() { 32 | return name; 33 | } 34 | 35 | public int getStudentId() { 36 | return studentId; 37 | } 38 | 39 | public int getNumberOfCredits() { 40 | return numberOfCredits; 41 | } 42 | 43 | public double getGpa() { 44 | return gpa; 45 | } 46 | 47 | :ref:`Back to the exercises ` 48 | 49 | .. _classes-exercise-solutions3: 50 | 51 | 3. In the ``school`` package, create a class ``Course`` with at least three fields. Before diving into IntelliJ, try using pen and paper to work through what these might be. At least one of your fields should be an ``ArrayList`` or ``HashMap``, and you should use your ``Student`` class. 52 | 53 | .. sourcecode:: java 54 | :linenos: 55 | 56 | public class Course { 57 | private String topic; 58 | private Teacher instructor; 59 | private ArrayList enrolledStudents; 60 | } 61 | 62 | :ref:`Back to the exercises ` 63 | -------------------------------------------------------------------------------- /src/appendices/exercise-solutions/spring-controllers-and-routes.rst: -------------------------------------------------------------------------------- 1 | .. _controllers-exercise-solutions: 2 | 3 | Exercise Solutions: Controllers and Routing 4 | =========================================== 5 | 6 | When the user submits the form (via a ``POST`` request), they should be 7 | greeted in the selected language. Your new feature should: 8 | 9 | #. Include at least 5 languages, with English being the default. If you don’t speak 5 languages yourself, ask your friend `the Internet `__. 10 | #. Include a new ``public static`` method, ``createMessage``, in the ``HelloController`` that takes a name as well as a language string. Based on the language string, you’ll display the proper greeting. 11 | 12 | .. sourcecode:: java 13 | 14 | @RequestMapping(value="hello", method = RequestMethod.POST) 15 | @ResponseBody 16 | public String helloPost(@RequestParam String name, @RequestParam String language) { 17 | if (name == null) { 18 | name = "World"; 19 | } 20 | 21 | return createMessage(name, language); 22 | 23 | // For a bonus mission, students can change this response text to look nicer. 24 | // This is subjective, but students should be modifying the HTML of the response string. 25 | } 26 | 27 | public static String createMessage(String n, String l) { 28 | String greeting = ""; 29 | 30 | if (l.equals("english")) { 31 | greeting = "Hello"; 32 | } 33 | else if (l.equals("french")) { 34 | greeting = "Bonjour"; 35 | } 36 | else if (l.equals("italian")) { 37 | greeting = "Bonjourno"; 38 | } 39 | else if (l.equals("spanish")) { 40 | greeting = "Hola"; 41 | } 42 | else if (l.equals("german")) { 43 | greeting = "Hallo"; 44 | } 45 | 46 | return greeting + " " + n; 47 | } 48 | 49 | :ref:`Back to the exercises ` -------------------------------------------------------------------------------- /src/appendices/exercise-solutions/unit-testing.rst: -------------------------------------------------------------------------------- 1 | .. _unit-testing-exercise-solutions: 2 | 3 | Exercise Solutions: Unit Testing 4 | ================================ 5 | 6 | .. _unit-testing-exercise-solutions1: 7 | 8 | ``testGasTankAfterDriving()`` 9 | ----------------------------- 10 | 11 | Add a test for the third TODO, "gasTankLevel is accurate after driving within tank range". 12 | 13 | After following the steps, your test should look like the following: 14 | 15 | .. sourcecode:: java 16 | 17 | @Test 18 | public void testGasTankAfterDriving() { 19 | test_car.drive(50); 20 | assertEquals(9, test_car.getGasTankLevel(),.001); 21 | } 22 | 23 | :ref:`Back to the exercises ` 24 | 25 | .. _unit-testing-exercise-solutions2: 26 | 27 | ``testGasTankAfterExceedingTankRange()`` 28 | ---------------------------------------- 29 | 30 | Add a test for the fourth TODO, "gasTankLevel is accurate after attempting to drive past tank range". 31 | 32 | .. sourcecode:: java 33 | 34 | @Test 35 | public void testGasTankAfterExceedingTankRange() { 36 | test_car.drive(501); 37 | assertEquals(test_car.getGasTankLevel(), 0, .001); 38 | } 39 | 40 | :ref:`Back to the exercises ` 41 | 42 | .. _unit-testing-exercise-solutions3: 43 | 44 | ``testGasOverfillException()`` 45 | ------------------------------ 46 | 47 | The test for our last TODO is a little different. We are going to 48 | perform an action on our car object, and we are expecting the object 49 | to throw an error. In this case, we are going to attempt to add gas 50 | to our car that exceeds the gas tank size. 51 | 52 | After following the steps, your test should look like the following: 53 | 54 | .. sourcecode:: java 55 | 56 | @Test(expected = IllegalArgumentException.class) 57 | public void testGasOverfillException() { 58 | test_car.addGas(5); 59 | fail("Shouldn't get here, car cannot have more gas in tank than the size of the tank"); 60 | } 61 | 62 | :ref:`Back to the exercises ` 63 | -------------------------------------------------------------------------------- /src/chapters/interfaces-and-polymorphism/introduction.rst: -------------------------------------------------------------------------------- 1 | Introduction 2 | ============= 3 | 4 | .. index:: ! polymorphism 5 | 6 | The third pillar of Object-Oriented Programming that we’ll 7 | explore is polymorphism. 8 | 9 | Polymorphism 10 | ------------ 11 | 12 | **Polymorphism** is an object-oriented mechanism that allows for objects 13 | of different types to be used in the same way. 14 | 15 | We’ve already encountered polymorphism made possible by inheritance when talking about :ref:`casting ` with our ``Cat`` and ``HouseCat`` classes. 16 | In that case, we stored an object of type ``HouseCat`` in its compatible type, ``Cat``. 17 | 18 | Let's take a closer look at how polymorphism might work in our cat-centric application. 19 | 20 | .. admonition:: Example 21 | 22 | Suppose we had a ``CatOwner`` class like the one below: 23 | 24 | .. sourcecode:: java 25 | :linenos: 26 | 27 | public class CatOwner 28 | { 29 | private Cat pet; 30 | 31 | public CatOwner(Cat pet) { 32 | this.pet = pet; 33 | } 34 | 35 | public void feedTheCat() { 36 | 37 | // ...code to prepare the cat's meal... 38 | 39 | pet.eat(); 40 | } 41 | } 42 | 43 | The method ``feedTheCat`` uses the field ``pet``, which is of type ``Cat``. 44 | Since a ``HouseCat`` *is a* ``Cat`` via inheritance, it is perfectly 45 | acceptable to use an instance of ``HouseCat`` to fill the ``pet`` field. 46 | 47 | .. sourcecode:: java 48 | :linenos: 49 | 50 | HouseCat suki = new HouseCat("Suki", 12); 51 | CatOwner Annie = new CatOwner (suki); 52 | 53 | Annie.feedTheCat(); 54 | 55 | Similarly, ``feedTheCat`` can accept ``Tiger`` instances as well. This 56 | is because the only thing that the method requires is that the input 57 | parameter has the methods defined within ``Cat``, and via inheritance, 58 | both of the subclasses satisfy this requirement. 59 | 60 | In addition to using classes to code in a polymorphic way, we can use *interfaces*. 61 | -------------------------------------------------------------------------------- /src/chapters/interfaces-and-polymorphism/testing-interfaces.rst: -------------------------------------------------------------------------------- 1 | Unit Testing and Interfaces 2 | =========================== 3 | 4 | After all that we have learned about interfaces, you are probably wondering, *how do I write my unit tests with interfaces?* 5 | 6 | The best practices to testing interfaces are very similar to those of :ref:`testing inheritance `. You want to focus on testing the contract that the interface is supposed to be upholding as opposed to the interface itself. 7 | 8 | .. admonition:: Example 9 | 10 | We have a ``Temperature`` interface, a ``Celsius`` class, and a ``Fahrenheit`` class. 11 | 12 | .. sourcecode:: java 13 | :linenos: 14 | 15 | public interface Temperature { 16 | double static final ABS_ZERO = -273.15; 17 | 18 | double convertTemp(); 19 | } 20 | 21 | public class Celsius implements Temperature { 22 | 23 | private double currentTemp; 24 | 25 | @Overrides 26 | public double convertTemp() { 27 | return this.currentTemp * 9 / 5 + 32; 28 | } 29 | } 30 | 31 | public class Fahrenheit implements Temperature { 32 | 33 | private double currentTemp; 34 | 35 | @Overrides 36 | public double convertTemp() { 37 | return (this.currentTemp - 32) * 5 / 9; 38 | } 39 | } 40 | 41 | In this situation, we can test the contract that the interface is supposed to be upholding, but not the interface itself. 42 | We may choose to test that ``ABS_ZERO`` is ``-273.15`` for both ``Fahrenheit`` and ``Celsius``. 43 | We may also want to test that the ``convertTemp`` function works as expected, however, since ``convertTemp`` has a different method body depending on whether it is in ``Fahrenheit`` or ``Celsius``, we cannot define the as expected behavior with a test on our interface, ``Temperature``. 44 | 45 | Check Your Understanding 46 | ------------------------ 47 | 48 | .. admonition:: Question 49 | 50 | True or False: You should test the interface itself. 51 | 52 | .. ans: False 53 | -------------------------------------------------------------------------------- /src/index-full.rst: -------------------------------------------------------------------------------- 1 | Chapters 2 | ======== 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | :name: chapterstoc 7 | 8 | chapters/introduction-and-setup/index 9 | chapters/data-types/index 10 | chapters/control-flow-and-collections/index 11 | chapters/classes/index 12 | chapters/classes-part2/index 13 | chapters/unit-testing/index 14 | chapters/inheritance/index 15 | chapters/interfaces-and-polymorphism/index 16 | chapters/spring-intro/index 17 | chapters/spring-controllers-and-routes/index 18 | chapters/exceptions/index 19 | chapters/thymeleaf-views/index 20 | chapters/spring-model-classes/index 21 | chapters/spring-model-validation/index 22 | chapters/enums/index 23 | chapters/orm-part1/index 24 | chapters/orm-relationships/index 25 | chapters/auth/index 26 | 27 | .. toctree:: 28 | 29 | genindex 30 | 31 | Studios 32 | ------- 33 | 34 | .. toctree:: 35 | :maxdepth: 1 36 | :name: studiostoc 37 | 38 | chapters/data-types/studio 39 | chapters/control-flow-and-collections/studio 40 | chapters/classes/studio 41 | chapters/classes-part2/studio 42 | chapters/unit-testing/studio 43 | chapters/inheritance/studio 44 | chapters/interfaces-and-polymorphism/studio 45 | chapters/spring-controllers-and-routes/studio 46 | chapters/tools-in-intelliJ/studio 47 | chapters/thymeleaf-views/studio 48 | chapters/spring-model-classes/studio 49 | chapters/orm-part1/studio 50 | chapters/auth/studio 51 | 52 | Assignments 53 | ----------- 54 | 55 | .. toctree:: 56 | :maxdepth: 1 57 | :name: assignmentstoc 58 | 59 | assignments/hello-world 60 | assignments/tech-jobs-console 61 | assignments/tech-jobs-oo 62 | assignments/tech-jobs-mvc 63 | assignments/tech-jobs-persistent 64 | 65 | Appendices 66 | ---------- 67 | 68 | .. toctree:: 69 | :maxdepth: 1 70 | :name: appendicestoc 71 | 72 | appendices/about-this-book 73 | appendices/spring/thymeleaf 74 | appendices/software/index 75 | appendices/exercise-solutions/index 76 | 77 | .. toctree:: 78 | :hidden: 79 | 80 | todos 81 | glossary 82 | -------------------------------------------------------------------------------- /src/_templates/navbar.html: -------------------------------------------------------------------------------- 1 | 48 | -------------------------------------------------------------------------------- /src/chapters/unit-testing/studio.rst: -------------------------------------------------------------------------------- 1 | .. _unit-testing-studio: 2 | 3 | Studio: Unit Testing 4 | ==================== 5 | 6 | For this studio, you will be writing unit tests to help you find 7 | errors in provided code. 8 | 9 | Getting Started 10 | --------------- 11 | 12 | #. Fork the `studio repository `__. 13 | #. In IntelliJ, check out your forked repository from Version Control. 14 | #. Write unit tests to find the errors in ``BalancedBrackets``. 15 | 16 | a. The tests you write should guide how you revise the sourcecode. Use TDD to 17 | first write tests that will work for the desired behavior of ``BalancedBrackets``. 18 | When your tests fail, correct the class to pass your tests. 19 | b. The content of your tests is up to you, but you should write at least 12 tests. 20 | 21 | .. admonition:: Tip 22 | 23 | Here's a first test to help get you started: 24 | 25 | Assert that brackets in the correct order, ``"[]"``, return true. 26 | 27 | .. sourcecode:: java 28 | 29 | @Test 30 | public void onlyBracketsReturnsTrue() { 31 | assertTrue(BalancedBrackets.hasBalancedBrackets("[]")); 32 | } 33 | 34 | .. note:: 35 | 36 | ``BalancedBrackets`` is essentially a wrapper class for a method. And 37 | because it's only method is static, we don't need to create an instance 38 | to test ``hasBalancedBrackets()``. 39 | 40 | .. tip:: 41 | 42 | Discuss with your fellow students and TA how the 43 | class should behave. What are some examples of input, and 44 | what would the desired output be for each input? 45 | 46 | Uploading Your Work 47 | ------------------- 48 | 49 | Push your work to save your solution in your remote repository. 50 | 51 | Bonus Mission 52 | ------------- 53 | 54 | The repository contains an additional branch called ``bonus_mission`` 55 | with a new class called ``BonusBinarySearch``. Create a new test file 56 | and write tests that pass the written description of how this class 57 | should behave. There will be errors in the class that need to be corrected. 58 | -------------------------------------------------------------------------------- /src/chapters/orm-relationships/exercises.rst: -------------------------------------------------------------------------------- 1 | .. _orm-relationships-exercises: 2 | 3 | Exercises: The Early Bird Gets the ORM! 4 | ======================================= 5 | 6 | Now that we have gotten very familiar with our ``coding-events`` application, let's design some additional features. 7 | As you work on your ``coding-events`` application, you may have been inspired by `Meetup `_! 8 | One of the cool features that Meetup has is that people can sign up for accounts. 9 | They can use their Meetup accounts to follow the events they are most interested in and keep track of their calendar of events. 10 | To add similar features to ``coding-events``, you need to add a ``Person`` class. 11 | For the exercises, answer the following questions about what your ``Person`` class would look like. 12 | 13 | .. admonition:: Note 14 | 15 | You do not have to code anything to complete these exercises! 16 | This is mainly focused on using our design skills to add a new feature to your application. 17 | 18 | #. You need to add a ``Person`` class to hold necessary info about users of our app. What fields and methods would this class hold? 19 | #. Would you need to add any additional classes to ``Person`` to make the app work? If so, what classes would be necessary? 20 | #. What kinds of relationships would ``Person`` have to the other classes you already created, such as the ``Event`` class? 21 | 22 | As you dream up answers to these questions, write the answers down in a note or piece of paper. You are now going to write up some documentation for your app! 23 | 24 | #. Add a ``README.md`` to your repository by navigating to the repository page on your GitHub profile. 25 | At the bottom of the page, there is a blue banner asking you to add a ``README.md``. Click the button to do so! 26 | #. You should write three sections. The first should describe the purpose of the app. The second should describe the current state of the app. 27 | The third and final section should describe the future improvements you want to make to the app including your notes about the ``Person`` class. 28 | 29 | :ref:`Check your solution ` 30 | 31 | -------------------------------------------------------------------------------- /src/chapters/spring-model-validation/server-side-validation.rst: -------------------------------------------------------------------------------- 1 | Server-Side Validation 2 | ====================== 3 | 4 | .. index:: ! validation 5 | 6 | Web applications work under the client-server model. We have been focusing on the server portion, using Spring Boot and Java to create server-side application code. A critical component of any well-made web application is **validation**, which is the process of checking that data conforms to certain criteria. Validation ensures that the application only stores meaningful data. 7 | 8 | .. _validation-example: 9 | 10 | .. admonition:: Example 11 | 12 | Consider a user registration form on a web site. Effective validation rules might require that: 13 | 14 | - The username is between 3 and 12 characters long, and 15 | - The password is at least 6 characters long. 16 | 17 | .. index:: 18 | single: validation, server-side 19 | single: validation, client-side 20 | 21 | Web applications should validate *all* data submitted by users. This ensures that data remains well-structured and unexpected errors don't occur. Validation that occurs in the browser---using JavaScript or HTML attributes---is **client-side validation**. Validation that occurs on the web server is **server-side validation**. 22 | 23 | Even if client-side validation is done, it is still critical to validate data on the server. This is because client-side validation can often be bypassed by a savvy user. For example, such a user might modify HTML using a browser's developer tools, or disable JavaScript. 24 | 25 | Server-side validation involves both the model and controller. The model is responsible for *defining* validation rules, while the controller is responsible for *checking* validation rules when data is submitted to the server. 26 | 27 | Check Your Understanding 28 | ------------------------ 29 | 30 | .. admonition:: Question 31 | 32 | The best practice for validating data in a web app is to: 33 | 34 | #. Use client-side validation 35 | #. Use server-side validation 36 | #. Use both client-side and server-side validation 37 | #. Don't validate incoming data 38 | 39 | .. ans: c, Use both client-side and server-side validation 40 | -------------------------------------------------------------------------------- /src/chapters/control-flow-and-collections/collections.rst: -------------------------------------------------------------------------------- 1 | .. index:: ! data structure 2 | 3 | Collections 4 | =========== 5 | 6 | Data Structures 7 | --------------- 8 | 9 | A **data structure** lets us hold on to lots of data in a single place. It 10 | is a programming construct to aggregate lots of values into one value. Many 11 | types of data structures exist in various languages. A few examples are 12 | lists, dictionaries, arrays, tuples, etc. 13 | 14 | .. index:: ! collections, ! Java Collections Framework 15 | 16 | Java Collections Framework 17 | --------------------------- 18 | 19 | Java provides powerful and flexible structures to store data, known as 20 | **collections**. The **Java collections framework** refers to the various interfaces 21 | the language provides for implementing collection types. 22 | 23 | Here, we'll discuss a collection called ``ArrayList`` and compare it to the 24 | ``Array`` class. We'll then introduce a third collection type called ``HashMap``. 25 | These three collection types will be sufficient for our basic Java needs. 26 | For more, refer to the official Java documentation on `collections `__. 27 | 28 | Gradebook, Three Ways 29 | --------------------- 30 | 31 | We’ll explore collections in Java by looking at different versions of 32 | the same program. The program functions as a gradebook, allowing a 33 | user (a professor or teacher) to enter the class roster for a course, 34 | along with each student’s grade. It then prints the class roster along 35 | with the average grade. In each variation of this program, the grading 36 | system could be anything numeric, such as a 0.0-4.0 point scale, or a 37 | 0-100 percentage scale. 38 | 39 | A test run of the program might yield the following: 40 | 41 | .. sourcecode:: bash 42 | 43 | Enter your students (or ENTER to finish): 44 | Chris 45 | Jesse 46 | Sally 47 | 48 | Grade for Chris: 3.0 49 | Grade for Jesse: 4.0 50 | Grade for Sally: 3.5 51 | 52 | Class roster: 53 | Chris (3.0) 54 | Jesse (4.0) 55 | Sally (3.5) 56 | 57 | Average grade: 3.5 58 | 59 | We’ll look at the gradebook using an ``Arraylist`` first. 60 | 61 | -------------------------------------------------------------------------------- /src/index.rst: -------------------------------------------------------------------------------- 1 | Chapters 2 | ======== 3 | 4 | .. toctree:: 5 | :numbered: 6 | :maxdepth: 1 7 | :name: chapterstoc 8 | 9 | chapters/introduction-and-setup/index 10 | chapters/data-types/index 11 | chapters/control-flow-and-collections/index 12 | chapters/classes/index 13 | chapters/classes-part2/index 14 | chapters/unit-testing/index 15 | chapters/inheritance/index 16 | chapters/interfaces-and-polymorphism/index 17 | chapters/spring-intro/index 18 | chapters/spring-controllers-and-routes/index 19 | chapters/exceptions/index 20 | chapters/tools-in-intelliJ/index 21 | chapters/thymeleaf-views/index 22 | chapters/spring-model-classes/index 23 | chapters/spring-model-validation/index 24 | chapters/enums/index 25 | chapters/orm-part1/index 26 | chapters/orm-relationships/index 27 | chapters/auth/index 28 | 29 | .. toctree:: 30 | 31 | genindex 32 | 33 | Studios 34 | ------- 35 | 36 | .. toctree:: 37 | :maxdepth: 1 38 | :name: studiostoc 39 | 40 | chapters/data-types/studio 41 | chapters/control-flow-and-collections/studio 42 | chapters/classes/studio 43 | chapters/classes-part2/studio 44 | chapters/unit-testing/studio 45 | chapters/inheritance/studio 46 | chapters/interfaces-and-polymorphism/studio 47 | chapters/spring-controllers-and-routes/studio 48 | chapters/tools-in-intelliJ/studio 49 | chapters/thymeleaf-views/studio 50 | chapters/spring-model-classes/studio 51 | chapters/spring-model-validation/studio 52 | chapters/orm-part1/studio 53 | chapters/auth/studio 54 | 55 | Assignments 56 | ------------ 57 | 58 | .. toctree:: 59 | :maxdepth: 1 60 | :name: assignmentstoc 61 | 62 | assignments/hello-world 63 | assignments/tech-jobs-console 64 | assignments/tech-jobs-oo 65 | assignments/tech-jobs-mvc 66 | assignments/tech-jobs-persistent 67 | 68 | Appendices 69 | ----------- 70 | 71 | .. toctree:: 72 | :maxdepth: 1 73 | :name: appendicestoc 74 | 75 | appendices/about-this-book 76 | appendices/spring/thymeleaf 77 | appendices/software/index 78 | appendices/exercise-solutions/index 79 | 80 | .. toctree:: 81 | :hidden: 82 | 83 | todos 84 | index-full 85 | glossary 86 | -------------------------------------------------------------------------------- /src/appendices/exercise-solutions/enums.rst: -------------------------------------------------------------------------------- 1 | .. _enums-exercise-solutions: 2 | 3 | Exercise Solutions: Enum Practice 4 | ================================= 5 | 6 | .. _enums-exercise-solutions5: 7 | 8 | 5. Before adding any other fields to ``Planets``, go to ``PlanetController`` 9 | and update the index handler to pass in a ``Model`` class argument (eg. ``Model model``). 10 | 11 | .. sourcecode:: java 12 | 13 | @GetMapping() 14 | public String displayIndex(Model model) { 15 | model.addAttribute("planets", Planets.values()); 16 | return "index"; 17 | } 18 | 19 | :ref:`Back to the exercises ` 20 | 21 | .. _enums-exercise-solutions7: 22 | 23 | 7. In ``templates/index``, create a list element and use the template 24 | variable you have just defined in the controller to list all of the 25 | planet values on the page. 26 | 27 | .. sourcecode:: html 28 | 29 |
      30 |
    1. 31 |
    32 | 33 | :ref:`Back to the exercises ` 34 | 35 | .. _enums-exercise-solutions9: 36 | 37 | 9. Update the template to display the planet names. 38 | 39 | .. sourcecode:: html 40 | 41 |
      42 |
    1. 43 |
    44 | 45 | :ref:`Back to the exercises ` 46 | 47 | .. _enums-exercise-solutions11: 48 | 49 | 11. Change the index template to display a table of each planet name and its year in earth days. 50 | 51 | #. In ``templates/index``, create a table element and add the appropriate bootstrap class. 52 | #. The table can be styled to your liking. 53 | #. Add a message to let the users know what data you are displaying with the ``yearLength`` field. 54 | 55 | .. sourcecode:: html 56 | :linenos: 57 | 58 | 59 | 60 | 61 | 63 | 64 | 65 | 66 | 67 | 68 |
    62 |
    69 | 70 | :ref:`Back to the exercises ` 71 | -------------------------------------------------------------------------------- /src/appendices/exercise-solutions/inheritance.rst: -------------------------------------------------------------------------------- 1 | .. _inheritance-exercise-solutions: 2 | 3 | Exercise Solutions: Inheritance 4 | =============================== 5 | 6 | After working through the exercises, your ``Computer``, ``Laptop``, and ``Smartphone`` classes should look similar to the following examples. 7 | 8 | The ``Computer`` class: 9 | 10 | .. sourcecode:: java 11 | :linenos: 12 | 13 | public class Computer extends AbstractEntity{ 14 | // computer is my parent class 15 | 16 | private int ram; 17 | private int storage; 18 | private boolean hasKeyboard; 19 | 20 | public Computer(int storage, int ram, boolean hasKeyboard) { 21 | super(); 22 | this.ram = ram; 23 | this.storage = storage; 24 | this.hasKeyboard = hasKeyboard; 25 | } 26 | 27 | public void increaseRAM (int n) { 28 | this.ram = this.ram + n; 29 | } 30 | 31 | public void increaseStorage (int x) { 32 | this.storage = this.storage + x; 33 | } 34 | } 35 | 36 | The ``Laptop`` class: 37 | 38 | .. sourcecode:: java 39 | :linenos: 40 | 41 | public class Laptop extends Computer { 42 | 43 | private double weight; // laptop weight in pounds. 44 | 45 | public Laptop(int storage, int ram, boolean hasKeyboard, double weight) { 46 | super(storage, ram, hasKeyboard); 47 | this.weight = weight; 48 | } 49 | 50 | public boolean isClunky() { 51 | if (weight > 5.0) { 52 | return true; 53 | } 54 | else { 55 | return false; 56 | } 57 | } 58 | } 59 | 60 | The ``SmartPhone`` class: 61 | 62 | .. sourcecode:: java 63 | :linenos: 64 | 65 | public class SmartPhone extends Computer { 66 | 67 | private int numberOfSelfies; 68 | 69 | public SmartPhone(int storage, int ram, boolean hasKeyboard, int numberOfSelfies) { 70 | super(storage, ram, hasKeyboard); 71 | this.numberOfSelfies = numberOfSelfies; 72 | } 73 | 74 | public void takeSelfie() { 75 | this.numberOfSelfies = this.numberOfSelfies + 1; 76 | } 77 | 78 | public int getNumberOfSelfies() { 79 | return this.numberOfSelfies; 80 | } 81 | } 82 | 83 | :ref:`Back to the exercises ` -------------------------------------------------------------------------------- /src/chapters/spring-controllers-and-routes/exercises.rst: -------------------------------------------------------------------------------- 1 | .. _controllers-exercises: 2 | 3 | Exercises: Controllers and Routing 4 | ================================== 5 | 6 | While reading the chapter, you created a 7 | basic Hello, World application using Spring Boot called ``hello-spring``. Open that project up 8 | in IntelliJ, and get ready to add some features! 9 | 10 | .. admonition:: Note 11 | 12 | Before your start these exercises, take a look at the 13 | `hello-spring-demo class-annotations branch `__. 14 | to make sure your own application matches ours. 15 | 16 | Create and checkout a branch for your exercises solution. Name it something useful, such as ``controller-exercises``. 17 | 18 | Modify your ``HelloController`` class to display a form on a ``GET`` 19 | request that asks the user for both their name and the language they 20 | would like to be greeted in. It should look something like this: 21 | 22 | .. figure:: figures/form.png 23 | :alt: Greeting Form 24 | 25 | Greeting Form 26 | 27 | The resulting form submission should return and display the message, 28 | “Bonjour Chris”. 29 | 30 | .. admonition:: Note 31 | 32 | The language is presented in a dropdown, more formally known 33 | as a ``select`` element. For more information about the ``select`` element and how it works, read the `MDN documentation `__. 34 | 35 | When the user submits the form (via a ``POST`` request), they should be 36 | greeted in the selected language. Your new feature should: 37 | 38 | #. Include at least 5 languages, with English being the default. If you don’t speak 5 languages yourself, ask your friend `the Internet `__. 39 | #. Include a new ``public static`` method, ``createMessage``, in the ``HelloController`` that takes a name as well as a language string. Based on the language string, you’ll display the proper greeting. 40 | 41 | :ref:`Check your solution ` 42 | 43 | Commit your changes! 44 | 45 | Bonus Mission 46 | ------------- 47 | 48 | #. Instead of returning the greeting as plain text, add a bit of HTML to 49 | the response string so that the displayed message looks a bit nicer. -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/naming-conventions.rst: -------------------------------------------------------------------------------- 1 | .. _naming-conventions: 2 | 3 | Java Naming Conventions 4 | ======================= 5 | 6 | Java has some very straightforward naming conventions. These are 7 | universally used by Java programmers, and differ in some cases from 8 | conventions commonly used in other languages. 9 | 10 | Again, these are conventions. Ignoring them will not prevent your code from running, 11 | as long as you are following Java’s `naming 12 | rules `__. Java’s 13 | identifier naming rules are somewhat hard to parse, so a good 14 | rule-of-thumb is that you should use only letters, numbers, and the 15 | underscore character ``_``, and they should always start with a letter. 16 | 17 | The naming conventions are more like guidelines than rules and are what other Java coders 18 | expect to see when reading your code. 19 | 20 | .. list-table:: 21 | :header-rows: 1 22 | 23 | * - Identifier Type 24 | - Convention 25 | - Examples 26 | 27 | * - Package 28 | - All lowercase 29 | - ``demos.javawebdevelopment``, ``org.launchcode.utilities`` 30 | 31 | * - Class 32 | - Start with an uppercase letter 33 | - ``Scanner``, ``System``, ``Cello`` 34 | 35 | * - Method 36 | - Start with a lower case letter, and use camelCase to represent multi-word method names 37 | - ``nextInt()``, ``getId()`` 38 | 39 | * - Instance variable 40 | - Start with a lowercase letter and use camelCase 41 | - ``id``, ``firstName`` 42 | 43 | * - Constant 44 | - All uppercase letters, words separated by underscores 45 | - ``MAX_INT`` 46 | 47 | .. note:: 48 | 49 | Constants in Java are variables created using both ``static`` and 50 | ``final`` modifiers. For example: ``static final Double PI = 3.14159`` 51 | 52 | .. tip:: 53 | 54 | If you're not sure about all of these identifier types yet, that's ok. Keep 55 | this page in mind for future reference as you read through this book. 56 | 57 | Oracle, the company that develops the Java language, provides some `more 58 | detailed naming 59 | conventions `__. 60 | (From the date on this article, you’ll note that these have been 61 | relatively standard for a very long time!) 62 | -------------------------------------------------------------------------------- /src/chapters/thymeleaf-views/exercises.rst: -------------------------------------------------------------------------------- 1 | .. _thymeleaf-views-exercises: 2 | 3 | Exercises: Thymeleaf Views 4 | ========================== 5 | 6 | In the chapter, we started working on an application for tracking various 7 | coding events around town. 8 | 9 | Open up your ``coding-events`` project in IntelliJ. 10 | 11 | Getting Started 12 | --------------- 13 | 14 | From your own ``add-bootstrap`` branch, create and checkout a new branch called ``my-views-exercises-solution``. 15 | 16 | .. admonition:: Note 17 | 18 | If you need to make sure your code matches ours to start, look at the 19 | `add-bootstrap branch `__ on ``coding-events-demo``. 20 | 21 | Now, let's add descriptions to our events! 22 | 23 | Expanding our Events Schedule 24 | ----------------------------- 25 | 26 | #. Comment out your previous code in the ``displayAllEvents`` method. 27 | 28 | :ref:`Check your solution ` 29 | 30 | #. In the videos, we learned how to use templates to display the elements in a 31 | static list called ``events``. Let's make our ``events`` list a HashMap! 32 | This enables us to add descriptions to our events. 33 | #. Fill your ``events`` HashMap with the names and descriptions of 3 coding 34 | events around town. 35 | 36 | :ref:`Check your solution ` 37 | 38 | #. Using ``th:block`` and ``th:each``, put together the events and their 39 | descriptions in a table as opposed to an unordered list. 40 | #. Use fragments to store the address of the new tech hub where all of the 41 | programmers are hanging out. Use ``th:replace`` in your main template to 42 | bring in the address as a third column in your table. 43 | You may need to create a new ``fragments.html``. 44 | 45 | :ref:`Check your solution ` 46 | 47 | #. Add some CSS to style your table to make it easier to read and center it on 48 | the page. You may need to create a new ``styles.css`` as well. Make sure to 49 | connect ``styles.css`` to the appropriate template with ``th:href``. 50 | 51 | Bonus Mission 52 | ------------- 53 | 54 | Try to add one more column to the table with pictures for each coding event. 55 | You need to use ``th:href`` to pull in pictures in the appropriate template. 56 | -------------------------------------------------------------------------------- /src/chapters/exceptions/exercises.rst: -------------------------------------------------------------------------------- 1 | Exercises: Exceptions 2 | ===================== 3 | 4 | To get started, ensure that you have properly forked and cloned this `repo `_ from Github. 5 | The starter code is in the ``exercises`` package inside ``org.launchcode``. 6 | 7 | Divide By Zero! 8 | --------------- 9 | 10 | The professor you TA for, Professor Jackson, shared with you the code she uses to auto-grade students' work. 11 | She and the other TAs have encountered some problems with the code in the past when they enter the total possible point value for an assignment. 12 | Occasionally, they accidentally enter ``0`` for the total number of possible points and the program encounters a fatal error when trying to divide by 0. 13 | 14 | To help out with this issue, complete a function called ``Divide()`` in ``Main``. 15 | The ``Divide()`` method takes in two parameters: ``x`` and ``y``. 16 | 17 | Your function should return the result of ``x/y``. 18 | 19 | However, if ``y`` is zero, you should throw an exception. 20 | Try to use an ``ArithmeticException`` and put your ``try/catch`` block in ``Divide()`` to test out your error-handling skills. 21 | If an exception is caught, make sure to print out a helpful message. 22 | 23 | Test Student Labs 24 | ----------------- 25 | 26 | After mentioning to Professor Jackson that you would like to get some more practice with exceptions, she offered to let you write some grading software! 27 | Before she gives you full control over auto-grading students' work, she asked if you could write a function called ``CheckFileExtension()``. 28 | The ``CheckFileExtension()`` method takes in one parameter: ``fileName``. 29 | 30 | ``CheckFileExtension()`` should return an integer representing the number of points a student receives for properly submitting a file in Java. 31 | If a student's submitted file ends in ``.java``, they get 1 point. 32 | If a student's submitted file doesn't end in ``.java``, they get 0 points. 33 | If the file submitted is ``null`` or an empty string, an exception should be thrown and you should give the student -1 points. What kind of exception is up to you, including to a custom exception! 34 | 35 | In ``Main()``, Professor Jackson has provided a hashmap of students and the names of their submitted files for you to test out your work. 36 | If an exception is caught, make sure to print out the error message. -------------------------------------------------------------------------------- /exts/youtube.py: -------------------------------------------------------------------------------- 1 | from docutils import nodes 2 | from docutils.parsers.rst import directives, Directive 3 | 4 | 5 | def setup(app): 6 | app.add_config_value('youtube_user', '', 'html') 7 | app.add_directive('youtube', YouTube) 8 | return {'version': '0.1'} 9 | 10 | 11 | class YouTube(Directive): 12 | 13 | GITHUB_URL_TEMPLATE = "https://github.com/{github_user}/{repo}/tree/{branch}" 14 | YOUTUBE_EMBED_TEMPLATE = """ 15 |
    16 | """ 17 | 18 | required_arguments = 0 19 | final_argument_whitespace = True 20 | has_content = False 21 | 22 | option_spec = { 23 | 'video_id': directives.unchanged, 24 | 'gh_path': directives.unchanged, 25 | } 26 | 27 | url_template = "https://repl.it/@%s/%s" 28 | 29 | def run(self): 30 | 31 | vid_params = { 32 | 'video_id': self.options['video_id'], 33 | } 34 | 35 | if 'gh_path' in self.options and len(self.options['gh_path'].split('/')) == 3: 36 | parts = self.options['gh_path'].split('/') 37 | gh_params = { 38 | 'github_user': parts[0], 39 | 'repo': parts[1], 40 | 'branch': parts[2], 41 | } 42 | else: 43 | gh_params = {} 44 | 45 | params = {**vid_params, **gh_params} 46 | 47 | text = self.YOUTUBE_EMBED_TEMPLATE.format(**params) 48 | 49 | para_nodes = nodes.paragraph() 50 | 51 | if 'github_user' in params: 52 | ref_node = nodes.reference('', '') 53 | ref_node['refuri'] = self.GITHUB_URL_TEMPLATE.format(**params) 54 | ref_node_text = "{branch} branch".format(**params) 55 | ref_node += nodes.Text(ref_node_text, ref_node_text) 56 | para_nodes += nodes.Text("The final code from this video is in the ", "The final code from this video is in the ") 57 | para_nodes += ref_node 58 | para_nodes += nodes.Text(params['repo']) 59 | 60 | video_node = nodes.raw('', text, format='html') 61 | (video_node.source, 62 | video_node.line) = self.state_machine.get_source_and_line(self.lineno) 63 | return [video_node, para_nodes] 64 | -------------------------------------------------------------------------------- /src/chapters/classes-part2/exercises.rst: -------------------------------------------------------------------------------- 1 | .. _classes-exercises-part2: 2 | 3 | Exercises: Objects and Classes, Part 2 4 | ======================================= 5 | 6 | Work on these exercises in the IntelliJ ``java-web-dev-exercises`` project. 7 | You will update your ``Student.java`` file by implementing the ``addGrade`` and 8 | ``getGradeLevel`` methods that were sketched out in the 9 | :ref:`Instance Methods ` section. 10 | 11 | The ``getGradeLevel`` Method 12 | ----------------------------- 13 | 14 | This method returns the student's level based on the number of credits they 15 | have earned: Freshman (0-29 credits), Sophomore (30-59 credits), Junior (60-89 16 | credits), or Senior (90+ credits). 17 | 18 | :ref:`Check your solution ` 19 | 20 | The ``addGrade`` Method 21 | ------------------------ 22 | 23 | This method accepts two parameters---a number of course credits and a 24 | numerical grade (0.0-4.0). With this data, you need to update the student’s 25 | GPA. 26 | 27 | GPA Information 28 | ^^^^^^^^^^^^^^^^ 29 | 30 | GPA is computed via the formula: 31 | 32 | gpa = (total quality score) / (total number of credits) 33 | 34 | #. The *quality score* for a class is found by multiplying the letter grade 35 | score (0.0-4.0) by the number of credits. 36 | #. The *total quality score* is the sum of the quality scores for all classes. 37 | 38 | For example, if a student received an "A" (worth 4 points) in a 3-credit course 39 | and a "B" (worth 3 points) in a 4-credit course, their total quality score 40 | would be: 4.0 * 3 + 3.0 * 4 = 24. Their GPA would then be 24 / 7 = 3.43. 41 | 42 | Determine the New GPA 43 | ^^^^^^^^^^^^^^^^^^^^^^ 44 | 45 | To update the student's GPA: 46 | 47 | #. Calculate their *current* total quality score by using the formula 48 | ``gpa * numberOfCredits``. 49 | #. Use the new course grade and course credits to update their total quality 50 | score. 51 | #. Update the student's total ``numberOfCredits``. 52 | #. Compute their new GPA. 53 | 54 | :ref:`Check your solution ` 55 | 56 | ``toString`` and ``equals`` 57 | ---------------------------- 58 | 59 | #. Add custom ``equals()`` and ``toString()`` methods to the ``Student`` 60 | class. 61 | 62 | :ref:`Check your solution ` 63 | 64 | #. Add custom ``equals()`` and ``toString()`` methods to the ``Course`` 65 | class which you started in the exercises for the 66 | :ref:`previous chapter `. 67 | -------------------------------------------------------------------------------- /src/chapters/interfaces-and-polymorphism/interfaces-and-abstract-classes.rst: -------------------------------------------------------------------------------- 1 | Interfaces and Abstract Classes 2 | =============================== 3 | 4 | We mentioned previously that interfaces share some characteristics with 5 | abstract classes. Recall that an abstract class is one declared with the 6 | ``abstract`` keyword. You may not create an object from an abstract 7 | class, and like an interface, an abstract class is allowed to contain 8 | methods that only have signatures (that is, they don’t have 9 | implementation code). 10 | 11 | The main differences between interfaces and abstract classes are: 12 | 13 | #. You *implement* an interface, while you *extend* an abstract class. The net effect of this is that a class may implement interfaces while also extending a class. Note that while you can implement *more than one* interface, you can only extend *one* class. 14 | #. Abstract classes may contain non-constant fields, while interfaces can only contain constant fields. 15 | #. Interfaces may only contain implementation code inside of default or static methods. Therefore, interfaces can’t contain methods that need to be shared by class instances in the same way that abstract classes do. In particular, any method that needs to use an instance property may not be part of an interface, since interfaces don’t have instance properties. Unlike interfaces, abstract classes may have methods which are not static or default and which do have instance properties. 16 | 17 | *We should use abstract classes to collect and specify behavior by related classes, while we should use an interface to specify related behaviors that may be common across unrelated classes.* 18 | 19 | .. admonition:: Example 20 | 21 | Let's go back to our ``Feedable`` interface. If we want to add a ``Dog`` class to our application, we might implement the ``Feedable`` interface for our ``Dog`` class. 22 | This makes sense as dogs are creatures that we feed. However, as dogs and cats are so different, it is unlikely that they would share many behaviors through the ``Pet`` class. 23 | 24 | Check Your Understanding 25 | ------------------------ 26 | 27 | .. admonition:: Question 28 | 29 | Check all statements that are TRUE about the differences between interfaces and abstract classes. 30 | 31 | a. You extend an abstract class, but implement an interface. 32 | b. You can implement many interfaces and many classes. 33 | c. Interfaces cannot contain non-constant fields, but abstract classes can. 34 | d. Methods that use instance properties can be in both interfaces and abstract classes. 35 | 36 | .. ans: a,c 37 | -------------------------------------------------------------------------------- /src/appendices/exercise-solutions/interfaces-and-polymorphism.rst: -------------------------------------------------------------------------------- 1 | .. _interfaces-and-polymorphism-exercise-solutions: 2 | 3 | Exercise Solutions: Interfaces and Polymorphism 4 | =============================================== 5 | 6 | .. _interfaces-and-polymorphism-exercise-solutions1: 7 | 8 | Sorting Flavors by Name 9 | ----------------------- 10 | 11 | Create a Sorting Class 12 | ^^^^^^^^^^^^^^^^^^^^^^ 13 | 14 | #. Create a new class called ``FlavorComparator`` and have it implement the 15 | ``Comparator`` interface: 16 | 17 | .. sourcecode:: java 18 | 19 | public class FlavorComparator implements Comparator 20 | 21 | #. Always returning ``0`` results in no sorting, so replace line 8 with: 22 | 23 | .. sourcecode:: java 24 | 25 | return o1.getName().compareTo(o2.getName()); 26 | 27 | This returns an integer (negative, positive, or zero) depending on 28 | whether ``Flavor`` object ``o1`` or ``o2`` comes first, alphabetically. 29 | 30 | .. sourcecode:: java 31 | 32 | public class FlavorComparator implements Comparator { 33 | @Override 34 | public int compare(Flavor flavor1, Flavor flavor2) { 35 | return flavor1.getName().compareTo(flavor2.getName()); 36 | } 37 | } 38 | 39 | :ref:`Back to the exercises ` 40 | 41 | .. _interfaces-and-polymorphism-exercise-solutions3: 42 | 43 | Sorting Cones by Cost 44 | ---------------------- 45 | 46 | Now let's sort our ``cones`` list by cost, from least expensive to most 47 | expensive. 48 | 49 | #. Create the new class ``ConeComparator``. 50 | #. Follow the example above to implement the ``Comparator`` interface and 51 | evaluate ``Cone`` objects by cost. 52 | #. In ``Main``, sort the ``cones`` list, then print the elements to the screen 53 | to verify the results. 54 | 55 | .. sourcecode:: bash 56 | 57 | Before: After: 58 | 59 | Waffle: $1.25 Bowl: $0.05 60 | Sugar: $0.75 Wafer: $0.50 61 | Wafer: $0.50 Sugar: $0.75 62 | Bowl: $0.05 Waffle: $1.25 63 | 64 | .. sourcecode:: java 65 | 66 | public class ConeComparator implements Comparator { 67 | @Override 68 | public int compare(Cone cone1, Cone cone2) { 69 | if (cone1.getCost() - cone2.getCost() < 0){ 70 | return -1; 71 | } else if (cone1.getCost() - cone2.getCost() > 0) { 72 | return 1; 73 | } else { 74 | return 0; 75 | } 76 | } 77 | } 78 | 79 | :ref:`Back to the exercises ` -------------------------------------------------------------------------------- /src/chapters/tools-in-intelliJ/studio.rst: -------------------------------------------------------------------------------- 1 | Studio: If It Ain't Broke, Add a Breakpoint! 2 | ============================================ 3 | 4 | The purpose of this studio is to expand your current debugging strategies. 5 | First, as a group, you will discuss your current debugging strategies. 6 | Next, you will explore the debugger tools addressed in this chapter. 7 | 8 | This studio will use a previous studio assignment to explore IntelliJ's Debugger. 9 | On your machine, open up your copy of `java-web-dev-studio7 `_ in IntelliJ. 10 | 11 | 12 | 13 | Part One: Pre-Debugger Debugging 14 | -------------------------------- 15 | 16 | Review with the group one error you encountered when working on your version of lesson 7’s studio. 17 | This could be the result of a typo or a logical error. 18 | 19 | #. What was the error? 20 | #. How did you solve this error? 21 | #. What strategies and tools have you been using so far to debug your code? 22 | #. Could one of the debugging tools help you when addressing this error? 23 | 24 | 25 | Part Two: Debugger Debugging 26 | ---------------------------- 27 | 28 | Now, check out the ``debugging`` branch of the studio repo. 29 | Review the code and then practice using IntelliJ's debugging tools. 30 | To get started, try the following: 31 | 32 | #. Add a few breakpoints inside ``Main.java``. Make a note of where you expect the program to break in its execution. 33 | #. Add ``cd.name`` as a *Watch expression* in the *Variables Pane* of the Debugger. 34 | #. Add a breakpoint inside some of the methods in ``BaseDisc.java``. Anticipate what you expect to see as the last line in the *Variables Pane* when the debugger stops. 35 | 36 | 37 | Part Three: More Debugger Debugging 38 | ----------------------------------- 39 | 40 | Take your debugging skills one step further by answering these questions. 41 | 42 | #. When would use a *Watch expression*? If you run the app and it's already functioning, what shows up there? 43 | #. Would a conditional breakpoint make sense to use in the context of this app? Try adding a conditional breakpoint and then run your app. 44 | #. What does the *Frames Pane* tell you as you step through your code? 45 | #. Add ``dvd.aName`` as a *Watch expression* and add a breakpoint. Can you explain the output in the *Variables Pane*? 46 | 47 | 48 | Part Four: Debugging Beyond This Studio 49 | --------------------------------------- 50 | 51 | Once you have worked through the studio’s codebase, open up a piece of code you have been struggling with. 52 | In what ways, could the debugging tools help you figure out what is going on with the code? 53 | 54 | 55 | **Additional Resources for IntelliJ's Debugger** 56 | 57 | - `Debug code `_ 58 | - `Tutorial: Debug your first Java application `_ 59 | -------------------------------------------------------------------------------- /src/appendices/exercise-solutions/data-types.rst: -------------------------------------------------------------------------------- 1 | .. _data-types-exercise-solutions: 2 | 3 | Exercise Solutions: Data Types 4 | ============================== 5 | 6 | Part 2: Exercises 7 | ----------------- 8 | 9 | .. _data-types-exercise-solutions2a: 10 | 11 | #. **Input/output**: Write a new "Hello, World" program to prompt the 12 | user for their name and greet them by name. After the given steps, you should have a ``HelloWorld`` class that looks like the following: 13 | 14 | .. sourcecode:: java 15 | :linenos: 16 | 17 | package exercises.lsn1datatypes; 18 | import java.util.Scanner; 19 | 20 | public class HelloWorld { 21 | public static void main(String[] args) { 22 | Scanner input = new Scanner(System.in); 23 | System.out.println("Hello, what is your name:"); 24 | 25 | String name = input.nextLine(); 26 | System.out.println("Hello " + name); 27 | } 28 | } 29 | 30 | :ref:`Back to the exercises ` 31 | 32 | .. _data-types-exercise-solutions2b: 33 | 34 | 3. **Numeric types**: Write a program that asks a user for the number of miles they have driven and the amount of gas they’ve consumed (in gallons), and print their miles-per-gallon. 35 | 36 | .. sourcecode:: java 37 | :linenos: 38 | 39 | package exercises.lsn1datatypes; 40 | import java.util.Scanner; 41 | 42 | public class Miles { 43 | public static void main(String[] args) { 44 | Scanner input = new Scanner(System.in); 45 | 46 | System.out.println("How many miles have you driven?"); 47 | Double numMiles = input.nextDouble(); 48 | 49 | System.out.println("How much gas did you use? In gallons."); 50 | Double numGallons = input.nextDouble(); 51 | 52 | Double mpg = numMiles / numGallons; 53 | System.out.println("You are running on " + mpg + " mpg."); 54 | } 55 | } 56 | 57 | :ref:`Back to the exercises ` 58 | 59 | .. _data-types-exercise-solutions2c: 60 | 61 | 5. **Strings**: Extend the previous exercise. Assume the user enters a word that is in the sentence. Print out its index within the string and its length. Next, remove the word from the string and print the sentence again to confirm your code. Remember that strings are *immutable*, so you will need to reassign the old sentence variable or create a new one to store the updated phrase. 62 | 63 | .. sourcecode:: java 64 | :linenos: 65 | 66 | Integer index = firstSentence.indexOf(searchTerm); 67 | Integer length = searchTerm.length(); 68 | System.out.println("Your search term first appears at index " + index + ". Your term is " + length + " characters long."); 69 | String modifiedSentence = firstSentence.replace(searchTerm, ""); 70 | System.out.println(modifiedSentence); 71 | 72 | :ref:`Back to the exercises ` -------------------------------------------------------------------------------- /src/chapters/introduction-and-setup/setup.rst: -------------------------------------------------------------------------------- 1 | Setup For Java 2 | ============== 3 | 4 | For the entirety of this course, we will be coding in Java. Besides installing Java on your machine, you must also add some support technologies to 5 | allow you to run and edit Java code. 6 | 7 | .. index:: ! Java Development Kit, JDK, javac, Java Virtual Machine, JVM 8 | 9 | Java Development Kit 10 | -------------------- 11 | 12 | Installing Java means downloading a package of software called the **Java Development Kit**, 13 | or **JDK**, for short. The JDK contains software the tools needed to develop and 14 | run Java code, namely the the Java compiler, **javac**, and the 15 | **Java Virtual Machine (JVM)**. 16 | 17 | While the compiler is responsible for processing Java code into machine readable 18 | code, the JVM allows us to run that code on any computer. These tools 19 | together, downloaded as the JDK, give us the means to write, compile, and run Java 20 | on our machines. 21 | 22 | .. _compiling-java: 23 | 24 | A step-by-step walk-through of the process: 25 | 26 | .. index:: ! bytecode 27 | 28 | #. We write code in Java, 29 | #. The code is passed through the compiler program, 30 | #. The compiler translates Java into **bytecode**, a language readable by the JVM. 31 | #. In the JVM, bytecode is translated to machine code, 32 | #. Your computer then reads and executes the machine code. 33 | 34 | The JVM gives Java more flexibility than other compiled programming languages because 35 | it will translate bytecode into the appropriate machine code, depending on the 36 | operating environment. 37 | 38 | 39 | Install the JDK 40 | --------------- 41 | 42 | Open a terminal window on your machine and enter the following command: 43 | 44 | .. sourcecode:: bash 45 | 46 | java -version 47 | 48 | If the response returns a major version 11 (ie 11.0.0 or higher, but not as high as 12.0.0), you can move on to the section below, 49 | :ref:`terminal-java`. 50 | 51 | If you do not have Java 11, or the command does not work, you can download 52 | it `here `__. 53 | The relevant install link for your operating system is on the bottom of the page: 54 | 55 | .. figure:: figures/installJava.png 56 | :alt: Screenshot of different Java installation options on Oracle's website 57 | 58 | The figure above shows options for downloading Java 15. You should download Java 11 from the link above. 59 | 60 | - **Mac users**: we recommend the ``.dmg`` option 61 | - **Windows users**: we recommend the ``.exe`` option 62 | 63 | To install, you must first select *Accept License Agreement*. 64 | 65 | Make note of the location where the Java JDK has been installed on your computer. 66 | 67 | - **Mac users**: This should be ``/Library/Java/JavaVirtualMachines``. 68 | 69 | - **Windows users**: This should be in the C: Drive under ``Program Files`` 70 | 71 | Once you have completed the installation steps, move onto the next section. 72 | 73 | -------------------------------------------------------------------------------- /src/chapters/enums/exercises.rst: -------------------------------------------------------------------------------- 1 | .. _enums-exercises: 2 | 3 | Exercises: Enum Practice 4 | ======================== 5 | 6 | #. Fork and clone `enumerable-planets `__. 7 | 8 | #. Use the *Get from Version Control* option to open the project in IntelliJ. 9 | 10 | #. In the project, create a data package. 11 | 12 | #. Create a new public enum called ``Planets``. 13 | 14 | .. sourcecode:: java 15 | 16 | public enum Planets { 17 | // list the planets here. 18 | // Mercury, Venus, Earth, Mars, Jupiter, 19 | // Saturn, Uranus, Neptune 20 | // Don't forget to capitalization convention and enum 21 | // syntax to separate value and end the list 22 | } 23 | 24 | #. Before adding any other fields to ``Planets``, go to ``PlanetController`` 25 | and update the index handler to pass in a ``Model`` class argument (eg. ``Model model``). 26 | 27 | :ref:`Check your solution ` 28 | 29 | #. Use ``.addAttribute`` to add the planet values to the model. 30 | 31 | #. In ``templates/index``, create a list element and use the template 32 | variable you have just defined in the controller to list all of the 33 | planet values on the page. 34 | 35 | :ref:`Check your solution ` 36 | 37 | #. Add a ``name`` field to the planets. 38 | 39 | a. Create a name property to display a non-capitalized version of each of the planet names. 40 | #. Add a constructor with the name field and a getter for the field. 41 | 42 | #. Update the template to display the planet names. 43 | 44 | :ref:`Check your solution ` 45 | 46 | #. Back in the ``Planets`` enum, add a new field called ``yearLength``. 47 | 48 | #. The value of each ``yearLength`` should be the number of earth days of a year on the given planet. 49 | 50 | #. Number of earth days on each planet: 51 | 52 | #. Mercury: 88 53 | #. Venus: 225 54 | #. Earth: 365 55 | #. Mars: 687 56 | #. Jupiter: 4333 57 | #. Saturn: 10759 58 | #. Uranus: 30687 59 | #. Neptune: 60200 60 | 61 | #. Update the constructor and add a getter for this field. 62 | 63 | #. Change the index template to display a table of each planet name and its year in earth days. 64 | 65 | #. In ``templates/index``, create a table element and add the appropriate bootstrap class. 66 | #. The table can be styled to your liking. 67 | #. Add a message to let the users know what data you are displaying 68 | with the ``yearLength`` field. 69 | 70 | :ref:`Check your solution ` 71 | 72 | #. If you wish, add another field to ``Planets``. You can find plenty of information on `NASA's web site `__. 73 | 74 | #. Update the enum with the new field, including changing the constructor and adding a getter method. 75 | #. Add the field to display in the table, with a message if helpful to convey the information or units of measure. 76 | -------------------------------------------------------------------------------- /src/chapters/spring-intro/mvc.rst: -------------------------------------------------------------------------------- 1 | .. _mvc: 2 | 3 | Design Patterns, MVC, and Spring, Oh My! 4 | ======================================== 5 | 6 | .. index:: ! design pattern, ! Model-View-Controller, ! MVC, ! model, ! view, ! controller 7 | 8 | So far, we have been designing our applications by diagramming classes, drawing connections, and abstracting via interfaces. 9 | This practice benefits us because we can start seeing issues *before* we start coding. 10 | Many software developers start their applications with this process. 11 | Before we start diagramming our ``Cat`` class and our ``HouseCat`` class, we decide on the template for our design that we want to use. 12 | These design templates that are abstract solutions to common software architecture problems are called **design patterns**. 13 | Design patterns provide a set of conventions that we follow to build an application. 14 | 15 | **Model-View-Controller** (MVC) is a design pattern where the programming logic behind the application is broken down into 3 components: models, views, and controllers. 16 | A **model** handles the data and business logic of the application. A **view** handles the user interface elements. 17 | A **controller** passes information from the models to the views. Controllers are the traffic cops of the application, capable of passing data back and forth to the browser in MVC web applications. This process will be covered in depth later on in this chapter. 18 | 19 | .. figure:: figures/mvcOverview.png 20 | :alt: Figure showing that controllers handle traffic between models and views, but models do not interact with views. 21 | 22 | Because MVC breaks down all of the programming logic of an application into three digestable components, we can use this particular design pattern to make extensible applications. 23 | We also use MVC because it separates the components of the programs that the user interacts with from the underlying business logic. 24 | 25 | .. index:: ! Spring, ! Spring MVC, ! Spring Boot, ! Tomcat 26 | 27 | Spring 28 | ------ 29 | 30 | **Spring** is a Java framework with multiple different modules and extensions. 31 | For this class, we will be using **Spring Boot**, an extension of **Spring MVC** (a module of Spring) to build Java based web applications with the MVC design pattern. 32 | Spring Boot gives us easier configuration options than Spring MVC and is a framework that helps us write applications with the idea of convention over configuration. 33 | With Spring Boot's default settings and locations, we won't have to configure all of the paths and settings for our applications. 34 | We can also write and run apps quickly because of the embedded application server, **Tomcat**. 35 | 36 | How we Teach Spring 37 | ------------------- 38 | 39 | The following section is the first of many videos we will be using to demonstrate coding a Spring Boot application. The video below introduces the role of 40 | controllers. In subsequent videos, we ask you to code along for maximum absorption of the topics introduced. A summary of the content introduced will follow each video. 41 | 42 | Intro to Spring - Video 43 | ----------------------- 44 | 45 | .. youtube:: 46 | :video_id: V_yz_naA3_c 47 | -------------------------------------------------------------------------------- /src/chapters/inheritance/studio.rst: -------------------------------------------------------------------------------- 1 | .. _inheritance-studio: 2 | 3 | Studio: Fun with Quizzes 4 | ======================== 5 | 6 | For this studio, you will design and build a console program that allows 7 | the user to take a quiz. This means you will have to create some 8 | questions, and get some input from the user. 9 | 10 | First, the questions. We want to be able to handle multiple types of 11 | questions: 12 | 13 | #. **Multiple choice**: a question with a fixed set of possible answers, of which only one may be chosen and only one answer is correct 14 | #. **Checkbox**: a question with a fixed set of possible answers, of which any number may be chosen; there is one correct combination of choices 15 | #. **True/False**: a question that has a true/false answer 16 | 17 | Design 18 | ------ 19 | 20 | In order to design your program, consider: 21 | 22 | #. What do these types of questions have in common? 23 | #. What makes these question types different? 24 | 25 | First, design a base class (called ``Question``) that contains the common features, and 26 | design subclasses for each of the question types. For each question type 27 | be sure to include: 28 | 29 | #. Class name 30 | #. Fields and properties with access modifiers 31 | #. Methods with access modifiers 32 | #. Any inheritance relationship 33 | 34 | Should any of the question classes be abstract? If so, should any of its 35 | methods be abstract? 36 | 37 | Make sure that there is functionality included to display the questions, 38 | to display the possible answers, and to check to see if the answer(s) is 39 | correct. 40 | 41 | Then design the ``Quiz`` class. A quiz has a list of questions, and we 42 | should be able to: 43 | 44 | #. Add questions 45 | #. Run or carry out the quiz 46 | #. Grade the quiz 47 | 48 | Implementation 49 | -------------- 50 | 51 | Create a new IntelliJ project and implement the design that you created. 52 | If you are unsure about your design, get some feedback by talking through it with a classmate before you start coding. 53 | 54 | Putting it all together 55 | ----------------------- 56 | 57 | Create a class named ``QuizRunner`` with only a ``main`` method. The program should 58 | create several questions, present them to the user, accept the user’s 59 | responses, and then tell them whether their answers were correct or 60 | incorrect. 61 | 62 | How to Submit 63 | ------------- 64 | 65 | Push up your work to a new Github repository. Submit the link to your repository in the Lesson 6 Studio assignment in Canvas. 66 | 67 | Bonus Missions 68 | -------------- 69 | 70 | #. Add a short answer question type that includes validation behavior to 71 | only allow the user to enter text with less than 80 characters. 72 | #. Add a couple of more question types to your program: 73 | 74 | #. Linear scale: a question that allows the user to provide a numeric 75 | response within an integer scale, which may vary from question to 76 | question. For instance, it could be 1-3 for one linear scale 77 | question, and 1-5 for another. 78 | #. Paragraph: Similar to short answer but allows for responses of up 79 | to 500 characters. 80 | #. Add tests with JUnit to your classes. 81 | 82 | -------------------------------------------------------------------------------- /src/chapters/tools-in-intelliJ/debugging.rst: -------------------------------------------------------------------------------- 1 | Debugging in IntelliJ 2 | ===================== 3 | 4 | .. youtube:: 5 | :video_id: 1bCgzjatcr4 6 | 7 | Watch this video to learn the basics of the debugging tools available in IntelliJ. 8 | If you want to follow along, Chris is working with ``ArrayListGradebook`` 9 | from the :ref:`Control Flow and Collections ` chapter 10 | and the ``HelloMethods`` and ``Message`` from :ref:`Classes and Objects, Part 2 ` chapter. 11 | You should have already downloaded this code from the ``java-web-dev-exercises``. 12 | 13 | .. admonition:: Note 14 | 15 | The video is using an older version of IntelliJ. 16 | 17 | The overall functionality of the debugging pane is still there, however, 18 | you may have to explore the location of buttons. 19 | We recommend hovering over each icon and looking at the names of each. 20 | 21 | IntelliJ has `documentation and videos `_ exploring their debugger if you are curious. 22 | 23 | Steps to Find and Diagnose Logical Bugs 24 | --------------------------------------- 25 | 26 | - Set a **breakpoint** where you want to pause the execution of the code. This will provide a more detailed look at what the program is doing at this point. Right-click in the text editing window to add a breakpoint to your code. 27 | - Run your program in **Debug** mode 28 | - Inspect the values of your variables in the **Debugger Pane**. 29 | - If needed, use the **Add/Watch** button to watch a specific expression as your program executes. 30 | - You can also set a **conditional breakpoint** to pause the execution of the code when a certain condition is a method. 31 | 32 | Control the Flow of Execution 33 | ----------------------------- 34 | 35 | - **Step-over** button executes a given line then steps to the next executable line 36 | - **Step-into** button allows you to review a called method and see what is going to line within the method 37 | - **Step-out-of** button allows you to move out of the method you stepped into and resume stepping through the main code 38 | - **Variables Pane** allows you to examine how variables are manipulated within your code. Also allows you to identify specific *Watch expressions* 39 | - **Frames Pane** tracks any method calls and threads in your code line by line. Best used with breakpoints. 40 | 41 | 42 | Advantage of Debugger Over Printing to the Console 43 | -------------------------------------------------- 44 | 45 | - The debugger lets you look at **all** the values in your program instead of just guessing which values you want to track via logging to the console. 46 | 47 | 48 | Check Your Understanding 49 | ------------------------ 50 | 51 | .. admonition:: Question 52 | 53 | What is a breakpoint? 54 | 55 | a. A point in our code where the debugger will stop running and provide information about the current state. 56 | b. A point in our code that we anticipate will result in an exception or error. 57 | c. A point in our code where we include a print statement to see what’s going on. 58 | d. A point in our code where we want to throw the computer out of a window because nothing works. -------------------------------------------------------------------------------- /src/chapters/classes/studio.rst: -------------------------------------------------------------------------------- 1 | .. _classes-studio-part1: 2 | 3 | Studio: Restaurant Menu 4 | ======================== 5 | 6 | Let’s practice designing classes using the following scenario. You’ve 7 | been hired to create a web application for a local restaurant. 8 | They want to both display their current menu and edit it through an admin panel. 9 | 10 | You’re not going to build an actual application in this studio. Instead, 11 | you will focus on the *design* of a portion of this application. 12 | Object-oriented programming in Java requires intentional, up-front planning. 13 | While this may seem tedious, outlining your ideas before you code helps reduce the errors you need to fix later. 14 | 15 | Design 16 | ------ 17 | 18 | You know you’ll need to create classes within the web application to 19 | facilitate this behavior and represent the various components of the 20 | menu. After talking to the owner, you have these details: 21 | 22 | 1. The menu consists of several menu items 23 | 2. Each menu item has a price, description, and category (appetizer, main course, or dessert) 24 | 3. It should be possible to display whether a menu item is new or not 25 | 4. The app should know when the menu was last updated, so visitors can see that the restaurant is constantly changing and adding exciting new items 26 | 27 | Starting with pen and paper (or your favorite notes application on your 28 | laptop), sketch out the design for two classes, ``Menu`` and 29 | ``MenuItem``. List the fields that each should have, along with the data 30 | type and access level for each. Also consider what constructors the classes might need. 31 | 32 | .. note:: 33 | 34 | For this studio, we are focusing on class design for these two classes. 35 | You do not need to be concerned with how the classes would be used in an application. 36 | At this stage, don’t think about how the application will work or behave; you should focus on the way that data will be represented within these classes, and how they should relate to each other. 37 | 38 | You may find it useful to use one or more of the classes provided by 39 | Java, such as 40 | `Date `__. 41 | 42 | Presenting Your Design 43 | ---------------------- 44 | 45 | Once you have sketched out your fields and properties, pair with a classmate and take turns presenting your designs. 46 | Class design can be subjective, so it’s important to properly think and talk through your choices before coding. 47 | 48 | While your partner is presenting their design, ask questions about why they made the decisions they did. 49 | Consider other use cases that might come up, and see if their design fits with those. 50 | 51 | Implementation 52 | -------------- 53 | 54 | In IntelliJ, create a new project, ``Restaurant Menu``. 55 | Within the project, create a new package named 56 | ``restaurant``. Add the ``Menu`` and ``MenuItem`` classes and code the 57 | design that you created above. Be sure to add getters and setters as 58 | appropriate. 59 | 60 | Submitting Your Work 61 | -------------------- 62 | 63 | Create a repository on your Github account and push up your project. 64 | Submit the link to your repository on Canvas. 65 | -------------------------------------------------------------------------------- /src/chapters/orm-part1/repositories.rst: -------------------------------------------------------------------------------- 1 | Repositories 2 | ============ 3 | 4 | .. index:: ! @Autowired 5 | 6 | Now that we have a general idea of how to set up our entity classes and repositories, let's take a deeper dive into how repositories are used to perform CRUD operations on a database. 7 | 8 | CRUD Operations 9 | --------------- 10 | 11 | Previously, we learned that we can create a repository to fetch rows of a table in a database. 12 | To do so, we need to create a corresponding controller. 13 | When creating our controller, we add a variable of the repository type that has the annotation ``@Autowired``. 14 | 15 | Next, we will learn how to use some of the more common ``CrudRepository`` methods, such as ``delete(T entity)``, ``deleteById(ID id)``, ``findAll()``, ``findById(ID id)``, and ``save(S entity)``. 16 | 17 | Using Persistence in a Controller - Video 18 | ----------------------------------------- 19 | 20 | The following video explains how we can add a controller to manage persistence in our ``coding-events`` application. 21 | The accompanying text is a quick rundown of what happens in the video. To get started, create a branch off of your `persistent-model `_ branch. 22 | 23 | .. youtube:: 24 | :video_id: 0eug2HI7rbo 25 | 26 | .. admonition:: Note 27 | 28 | The starter code for this video is found at the `persistent-model branch `__ of the ``coding-events-demo`` repo. 29 | The final code presented in this video is found on the `persistent-controller branch `__. As always, code along to the 30 | videos on your own ``coding-events`` project. 31 | 32 | Using Persistence in a Controller - Text 33 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 34 | 35 | Inside of ``EventController``, we can add a variable of type ``EventRepository`` and give it an ``@Autowired`` annotation. 36 | For events, we want to be able to display all of the events in our database as well as add and delete events. 37 | 38 | When displaying the events in our database, we write a method, ``displayAllEvents``. 39 | We want to use ``displayAllEvents`` to display a table that contains all of our events. 40 | We did something similar to this before, but we used a list or iterable containing all of the objects we wanted to display. 41 | Since we have set up ORM between the MySQL database and our MVC application, we need to use the methods from ``CrudRepository`` to get all of the instances of the ``Event`` class. 42 | We can use the ``findAll()`` method to return an iterable containing all of the events in our database. 43 | 44 | As you write the methods necessary for ``EventController``, you might notice that this controller doesn't look too different from other controllers we previously created. 45 | Now we need to use the methods in ``CrudRepository`` to fetch the necessary information or update the correct table. 46 | 47 | Check Your Understanding 48 | ------------------------ 49 | 50 | .. admonition:: Question 51 | 52 | True or false: We add different methods directly to our repository. 53 | 54 | .. ans: False 55 | -------------------------------------------------------------------------------- /src/chapters/inheritance/testing-inheritance.rst: -------------------------------------------------------------------------------- 1 | .. _testinginheritance: 2 | 3 | Testing Inheritance 4 | =================== 5 | 6 | Not sure you get the whole inheritance idea? Still not sure which fields and methods get inherited and 7 | which are overridden? Looking to *test* your understanding? (wink) 8 | 9 | Knowing what we know now about :ref:`unit-testing` and :ref:`inheritance`, we can test that our 10 | subclasses extend their base classes. 11 | 12 | We can add a ``test`` folder to our ``inheritance`` package and write some code to ensure that 13 | ``HouseCat`` inherits what we expect it to. 14 | 15 | .. sourcecode:: java 16 | :linenos: 17 | 18 | @Test 19 | public void inheritsSuperInFirstConstructor() { 20 | HouseCat keyboardCat = new HouseCat("Keyboard Cat", 7); 21 | assertEquals(7, keyboardCat.getWeight(), .001); 22 | } 23 | 24 | Here, we're testing that one of our ``HouseCat`` constructors will call the ``Cat`` constructor 25 | and appropriately assign the ``HouseCat`` object's ``weight`` property. Remember, we don't need 26 | to write unit tests for getters or setters unless they do something extra in addition to getting 27 | or setting. The purpose of this test, though, is less to test getting ``keyboardCat.weight`` 28 | and more to validate that the subclass constructor has inherited the base class constructor. 29 | 30 | It's a good practice to test your subclasses to verify the items that they inherit or override. 31 | 32 | Check Your Understanding 33 | ------------------------ 34 | 35 | .. admonition:: Question 36 | 37 | 38 | Fill in the blank to test that the default constructor of ``Cat`` is called when the second 39 | constructor on ``HouseCat`` is used? 40 | 41 | Second ``HouseCat`` constructor: 42 | 43 | .. sourcecode:: java 44 | :lineno-start: 14 45 | 46 | public HouseCat(String aName) { 47 | name = aName; 48 | } 49 | 50 | .. sourcecode:: java 51 | :linenos: 52 | 53 | @Test 54 | public void inheritsDefaultCatInSecondConstructor() { 55 | HouseCat keyboardCat = new HouseCat("Keyboard Cat"); 56 | 57 | } 58 | 59 | a. ``assertEquals(13, keyboardCat.getWeight());`` 60 | 61 | b. ``assertNotNull(keyboardCat.getWeight());`` 62 | 63 | c. ``assertEquals(13, keyboardCat.getWeight(), .001);`` 64 | 65 | d. ``assertNotNull(keyboardCat.weight);`` 66 | 67 | .. ans c, ``assertEquals(13, keyboardCat.getWeight(), .001);`` 68 | 69 | .. admonition:: Question 70 | 71 | What additional assert method can we add to this test to properly verify that ``HouseCat`` 72 | inherits ``eat()``? 73 | 74 | .. sourcecode:: java 75 | :linenos: 76 | 77 | @Test 78 | public void isNotInitiallyTired() { 79 | HouseCat keyboardCat = new HouseCat("Keyboard Cat"); 80 | assertFalse(keyboardCat.isHungry()); 81 | assertFalse(keyboardCat.isTired()); 82 | keyboardCat.eat(); 83 | } 84 | 85 | a. ``assertFalse(keyboardCat.isTired());`` 86 | 87 | b. ``assertTrue(keyboardCat.isTired());`` 88 | 89 | c. ``assertTrue(keyboardCat.isHungry());`` 90 | 91 | d. ``assertFalse(keyboardCat.tired);`` 92 | 93 | .. ans b, ``assertTrue(keyboardCat.isTired());`` 94 | 95 | -------------------------------------------------------------------------------- /src/chapters/control-flow-and-collections/studio.rst: -------------------------------------------------------------------------------- 1 | Studio: Counting Characters 2 | =========================== 3 | 4 | In this studio, you will write a program to count the number of times each 5 | character occurs in a string and then print the results to the console. 6 | 7 | Feel free to prompt the user for a string. However, for the sake of simplicity, 8 | you might want to start by hard-coding some text and storing it in a variable. 9 | For your convenience, here is a quote from the movie *Hidden Figures*: 10 | 11 | If the product of two terms is zero then common sense says at least one of 12 | the two terms has to be zero to start with. So if you move all the terms 13 | over to one side, you can put the quadratics into a form that can be 14 | factored allowing that side of the equation to equal zero. Once you’ve done 15 | that, it’s pretty straightforward from there. 16 | 17 | .. admonition:: Tip 18 | 19 | Remember, you can turn a ``String`` object into an array of characters 20 | using: 21 | 22 | .. sourcecode:: java 23 | 24 | char[] charactersInString = myString.toCharArray(); 25 | 26 | Some Items to Ponder Before Starting 27 | ------------------------------------- 28 | 29 | #. There are multiple ways to approach this task, but one way involves the 30 | following steps: 31 | 32 | a. Loop through the string one character at a time, 33 | b. Store and/or update the count for a given character using an appropriate 34 | data structure. 35 | c. Loop through the data structure to print the results (one character and its 36 | count per line). 37 | 38 | #. Which type of data structure (``ArrayList``, ``HashMap``, or ``Array``) 39 | should you use to store character counts? Any can be made to work, but there 40 | is a BEST choice. 41 | #. You’ll need to *initialize* the counts for the characters in some fashion. 42 | It’s probably better to do this as you go through the string instead of 43 | doing so before you loop through it. (*WHY?*) 44 | #. If you need to review how to create a new class, revisit the instructions in 45 | :ref:`Studio: Area of a Circle `. 46 | #. Don’t forget to check out the *Bonus Missions* below. 47 | 48 | Sample Output 49 | -------------- 50 | 51 | For the example string above, your output should look something like: 52 | 53 | .. sourcecode:: bash 54 | 55 | I: 1 56 | O: 1 57 | S: 1 58 | ’: 2 59 | : 66 60 | a: 20 61 | b: 2 62 | c: 7 63 | d: 7 64 | e: 32 65 | f: 9 66 | g: 2 67 | h: 13 68 | i: 11 69 | l: 6 70 | ,: 2 71 | m: 8 72 | n: 12 73 | .: 3 74 | o: 31 75 | p: 3 76 | q: 3 77 | r: 18 78 | s: 16 79 | t: 38 80 | u: 8 81 | v: 3 82 | w: 5 83 | y: 5 84 | z: 3 85 | 86 | Bonus Missions 87 | --------------- 88 | 89 | Try these modifications on your code: 90 | 91 | #. Prompt the user to enter the string in the command line. 92 | #. Make the character counts case-insensitive. 93 | #. Exclude non-alphabetic characters. 94 | 95 | Super Bonus 96 | ^^^^^^^^^^^^ 97 | 98 | Read the string in from a file. 99 | 100 | .. admonition:: Note 101 | 102 | This is a hard one. We won’t talk about reading from files in Java in this 103 | course, so be ready for a tough challenge if you accept this mission. 104 | -------------------------------------------------------------------------------- /src/chapters/classes-part2/studio.rst: -------------------------------------------------------------------------------- 1 | Studio: Restaurant Menu Continued 2 | ================================== 3 | 4 | We began designing and implementing our ``Menu`` and ``MenuItem`` classes in 5 | the :ref:`last studio `. Let’s continue working on these 6 | classes by adding some methods. 7 | 8 | Design 9 | ------- 10 | 11 | To review, here are the details you have from the restaurant owner: 12 | 13 | #. The menu consists of several menu items. 14 | #. Each menu item has a price, description, and category (appetizer, 15 | main course, or dessert). 16 | #. It should be possible to display whether or not a menu item is new. 17 | #. The app should know when the menu was last updated, so visitors can 18 | see that the restaurant is constantly changing and adding exciting 19 | new items. 20 | 21 | Based on these details, you need to include some *instance* methods: 22 | 23 | #. A way to add and remove menu items from the menu. 24 | #. A way to tell if a menu item is new. 25 | #. A way to tell when the menu was last updated. 26 | #. A way to print out both a single menu item as well as the entire menu. 27 | #. A way to determine whether or not two menu items are equal. 28 | 29 | Starting with pen and paper (or your favorite notes application on your 30 | laptop), sketch out the methods that you need to add to these classes. List the 31 | method names and access levels, along with the types of all input and return 32 | parameters. Also, consider whether any methods should be ``static``. 33 | 34 | Share Your Design 35 | ------------------ 36 | 37 | Once you have sketched out your methods, pair with a classmate and take turns 38 | presenting your designs. Class design can be subjective, so it’s important to 39 | properly think and talk through your choices before coding. 40 | 41 | While your partner is presenting their design, ask questions about why they 42 | made the decisions they did. Consider other use cases that might come up, and 43 | see if their design fits with those. 44 | 45 | Implementation 46 | --------------- 47 | 48 | #. In IntelliJ, open your ``Restaurant Menu`` project. Open the terminal in IntelliJ and create a branch in your repository for your Lesson 4 Studio solution. For the studio, make sure all of your work is in that branch. 49 | #. Within the ``restaurant`` package, add the methods you designed to your ``Menu`` and 50 | ``MenuItem`` classes. 51 | #. Create a class called ``Restaurant``, and add a 52 | ``public static void main(String[] args)`` method. 53 | #. Use the ``main`` method to test your classes: 54 | 55 | a. Create several items and add them to a menu. 56 | b. Print the entire, updated menu to the screen. 57 | c. Print an individual menu item to the screen. 58 | d. Delete an item from a menu, then reprint the menu. 59 | 60 | Bonus Mission 61 | -------------- 62 | 63 | If a user tries to add an item that is already on the menu, print a message 64 | that warns the user about the duplicate. Also, prevent the duplicate from 65 | being added to the menu. 66 | 67 | Submitting Your Work 68 | --------------------- 69 | 70 | In the previous studio, you should have created a repository on GitHub for 71 | your restaurant project. 72 | 73 | Since you just modified that project in this studio, commit your changes and 74 | push them up to the same repository. However, you must still submit the URL 75 | for your repository on Canvas. 76 | -------------------------------------------------------------------------------- /src/chapters/control-flow-and-collections/exercises.rst: -------------------------------------------------------------------------------- 1 | .. _control-flow-and-collections-exercises: 2 | 3 | Exercises: Control Flow and Collections 4 | ======================================= 5 | 6 | Work on these exercises in the IntelliJ ``java-web-dev-exercises`` project, 7 | creating a new class for each item. You may call these classes whatever you 8 | like, but remember to use the proper 9 | :ref:`Java naming conventions `. 10 | 11 | Array Practice 12 | -------------- 13 | 14 | #. Create and initialize an array with the following values in a single line: 15 | ``1, 1, 2, 3, 5, 8``. 16 | 17 | :ref:`Check your solution ` 18 | 19 | #. Loop through the array and print out each value, then modify the loop to 20 | only print the odd numbers. 21 | #. For this exercise, use the string ``I would not, could not, in a box. I 22 | would not, could not with a fox. I will not eat them in a house. I will not 23 | eat them with a mouse.`` Use the ``split`` method to divide the string at 24 | each space and store the individual words in an array. If you need to review 25 | the method syntax, look back at the :ref:`String methods ` 26 | table. 27 | 28 | :ref:`Check your solution ` 29 | 30 | #. Print the array of words to verify that your code works. The syntax is: 31 | 32 | .. sourcecode:: java 33 | 34 | System.out.println(Arrays.toString(arrayName)); 35 | 36 | #. Repeat steps 3 and 4, but change the delimiter to split the string into 37 | separate sentences. 38 | 39 | .. admonition:: Note 40 | 41 | Some characters, like a period ``"."``, have special meanings when used with 42 | the ``split`` method. They cannot be used as-is for the deliminator. 43 | 44 | To use these characters as the deliminator, we must *escape* their special 45 | meanings. Instead of ``.split(".")``, we need to use ``.split("\\.")``. 46 | 47 | :ref:`Check your solution ` 48 | 49 | ArrayList Practice 50 | ------------------ 51 | 52 | #. Write a static method to find the sum of all the even numbers in an 53 | ArrayList. Within ``main``, create a list with at least 10 integers and call 54 | your method on the list. 55 | 56 | :ref:`Check your solution ` 57 | 58 | #. Write a static method to print out each word in a list that has exactly 5 59 | letters. 60 | #. Modify your code to prompt the user to enter the word length for the search. 61 | 62 | :ref:`Check your solution ` 63 | 64 | #. BONUS: Instead of creating our own list of words, what if we want to use the 65 | string from the *Array Practice* section? Search "Java convert String to 66 | ArrayList" online to see how to split a string into the more flexible 67 | ``ArrayList`` collection. 68 | 69 | HashMap Practice 70 | ---------------- 71 | 72 | Make a program similar to ``GradebookHashMap`` that does the following: 73 | 74 | #. It takes in student names and ID numbers (as integers) instead of names and 75 | grades. 76 | #. The keys should be the IDs and the values should be the names. 77 | #. Modify the roster printing code accordingly. 78 | 79 | :ref:`Check your solution ` 80 | -------------------------------------------------------------------------------- /src/_static/images/logos/lc-logo.svg: -------------------------------------------------------------------------------- 1 | LaunchCode_white -------------------------------------------------------------------------------- /src/chapters/spring-controllers-and-routes/studio.rst: -------------------------------------------------------------------------------- 1 | Studio: Skills Tracker 2 | ====================== 3 | 4 | Wouldn't it be nice to have a small tracker to show us what skills we have built and where we are at in learning them? 5 | Let's build something that would let us do just that! 6 | 7 | As always, read through the whole studio before starting! 8 | 9 | At the end of the studio, your final project should be able to take input from a user via a form and post the information in a way that is easy to read. 10 | 11 | Start up Spring 12 | --------------- 13 | 14 | Using the Spring Initializr 15 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | 17 | Head to the `Spring initializr `_ to initialize a new Spring project. 18 | 19 | #. For Project, select *Gradle Project*, for Language, select *Java*, and for Spring Boot, select *2.4.x* (whichever is the most recent release, that is NOT a snapshot). 20 | #. For Project Metadata, we can use *org.launchcode* as Group and *skills-tracker* as the artifact. Also, remember to expand *Options* so you can make sure that Java 11 is selected! 21 | #. Finally, we want to add *Spring Web* and *Spring DevTools* as our dependencies. 22 | 23 | Double check that everything is ready to go and click *Generate*! 24 | 25 | Launching IntelliJ 26 | ^^^^^^^^^^^^^^^^^^ 27 | 28 | Unzip the newly generated ``skills-tracker.zip`` and move the folder into the directory where you are keeping your homework for this class! 29 | 30 | Open IntelliJ and select *Import Project*. Double click *bootRun* and head to ``localhost:8080`` to make sure there is nothing there. 31 | 32 | Now you are ready to start coding! 33 | 34 | Creating Controllers 35 | -------------------- 36 | 37 | In your ``org.launchcode`` package, add another package called ``controllers`` and add a class called ``SkillsController``. 38 | Inside ``SkillsController``, you will add several methods to accomplish the following: 39 | 40 | #. At ``localhost:8080``, add text that states the three possible programming languages someone could be working on. 41 | You need to have an ``h1`` with the title "Skills Tracker", an ``h2``, and an ``ol`` containing three programming languages of your choosing. 42 | #. At ``localhost:8080/form``, add a form that lets the user enter their name and choose their favorite, second favorite, and third favorite programming languages on your list. 43 | Use ``select`` elements for each of the rankings. Just as with the exercises, we will use ``@GetMapping()``. 44 | #. Also at ``localhost:8080/form``, use ``@PostMapping`` and ``@RequestParam`` to update the HTML with an ``h1`` stating the user's name and an ``ol`` showing the three programming languages in the order they chose. 45 | 46 | End Result 47 | ---------- 48 | 49 | At the end of the studio, when you navigate to ``localhost:8080``, you should see the following: 50 | 51 | .. figure:: figures/studio-home-page.png 52 | :alt: Image showing functioning home page. 53 | 54 | When you navigate to ``localhost:8080/form``, you should see a blank form that looks something like: 55 | 56 | .. figure:: figures/blank-studio-form.png 57 | :alt: Image showing the blank form. 58 | 59 | If you fill out the form, your page may render like so: 60 | 61 | .. figure:: figures/completed-studio-form.png 62 | :alt: Image showing the web page with information from the completed form. 63 | 64 | Bonus Missions 65 | -------------- 66 | 67 | #. Reformat your ``form`` page to use a table instead of an ordered list. 68 | #. Add a new path to the site to display the information from the completed form. -------------------------------------------------------------------------------- /src/chapters/classes-part2/equals-shortcut.rst: -------------------------------------------------------------------------------- 1 | .. _equals-shortcut: 2 | 3 | IntelliJ Generator Shortcut 4 | ============================ 5 | 6 | Instead of cutting, pasting, and refactoring old code to ensure that you create 7 | a well-structured ``hashCode()`` method whenever you define your own 8 | ``equals()`` method, you can use IntelliJ’s code generation tool! Just 9 | right-click within your class file and select 10 | *Generate > equals and hashCode* and follow the prompts. 11 | 12 | Let's use a ``Course`` class to demonstrate: 13 | 14 | .. sourcecode:: java 15 | :linenos: 16 | 17 | public class Course { 18 | 19 | private String title; 20 | private int credits; 21 | private String instructor; 22 | 23 | public Course (String title, int credits, String instructor) { 24 | this.title = title; 25 | this.credits = credits; 26 | this.instructor = instructor; 27 | } 28 | } 29 | 30 | #. In the IntelliJ editor, right-click in the editor (or on the ``Course`` 31 | class name to be really deliberate), then select *Generate* from the menu. 32 | 33 | .. figure:: ./figures/IJgeneratemenu.png 34 | :scale: 80% 35 | :alt: Pop up menu for IntelliJ's generate option. 36 | 37 | #. Select the *equals() and hashCode()* option: 38 | 39 | .. figure:: ./figures/selectEqualsOption.png 40 | :scale: 80% 41 | :alt: Select ``equals`` option. 42 | 43 | #. Select the default options until you are asked to choose the fields you 44 | want ``equals`` to consider. Let's assume that two ``Course`` objects 45 | will be equal if they have the same ``title`` and ``instructor`` values. 46 | 47 | .. figure:: ./figures/chooseFields.png 48 | :alt: Select fields to compare. 49 | 50 | #. Repeat the selections in the next two prompts for the ``hashCode`` and 51 | ``null`` fields. 52 | 53 | #. Click *Finish*. IntelliJ generates the ``equals`` and ``hashCode`` methods: 54 | 55 | .. sourcecode:: java 56 | :linenos: 57 | 58 | import java.util.Objects; 59 | 60 | public class Course { 61 | 62 | private String title; 63 | private int credits; 64 | private String instructor; 65 | 66 | public Course (String title, int credits, String instructor) { 67 | this.title = title; 68 | this.credits = credits; 69 | this.instructor = instructor; 70 | } 71 | 72 | @Override 73 | public boolean equals(Object o) { 74 | if (this == o) return true; 75 | if (!(o instanceof Course)) return false; 76 | Course course = (Course) o; 77 | return title.equals(course.title) && 78 | instructor.equals(course.instructor); 79 | } 80 | 81 | @Override 82 | public int hashCode() { 83 | return Objects.hash(title, instructor); 84 | } 85 | } 86 | 87 | Looking at the new ``equals`` method shows that it includes all of the 88 | :ref:`best-practice components `: 89 | 90 | #. Line 17 performs the reference check on the object ``o``. 91 | #. Line 18 performs the ``null`` check and class check on ``o``. 92 | #. Line 19 casts ``o`` as a ``Course`` object. 93 | #. Line 20 compares the ``title`` and ``instructor`` fields of the two objects. 94 | 95 | Try It! 96 | -------- 97 | 98 | Use the *Generate* option to add getters, setters, and a ``toString`` method 99 | to the ``Course`` class. 100 | 101 | COOL!!!!! 102 | -------------------------------------------------------------------------------- /src/chapters/spring-controllers-and-routes/controllers-classes.rst: -------------------------------------------------------------------------------- 1 | .. _controllers-class-annotations: 2 | 3 | Class Level Controller Annotations 4 | ================================== 5 | 6 | Controller Classes - Video 7 | -------------------------- 8 | 9 | .. youtube:: 10 | :video_id: DvEvhB20e2s 11 | 12 | .. admonition:: Note 13 | 14 | The starter code for this video is found in the `forms branch `__ 15 | of the ``hello-spring-demo`` repo. The final code presented in this video is found on the `class-annotations branch `__. 16 | As always, code along to the videos on your own ``hello-spring`` project. 17 | 18 | Have you been tracking your app progress in your own 19 | `git branches `__? 20 | Saving your progress in branches for each video tutorial 21 | means you can always go back to a certain spot in the app development. 22 | We will be returning to the ``forms`` branch in the next lesson so track your ``class-annotations`` in a new branch with 23 | ``git checkout -b ``. 24 | 25 | 26 | 27 | Controller Classes - Text 28 | -------------------------- 29 | 30 | Once you have written several controller methods within a class, you may 31 | notice some similar behavior across handlers. This is an opportunity to 32 | DRY your code. Some of the annotations we use at the method level can also 33 | be used on whole controller classes. 34 | 35 | We mention this earlier. If all of the methods in a controller class begin 36 | with the same root path, ``@RequestMapping`` can be added above the class. 37 | 38 | .. sourcecode:: java 39 | 40 | @Controller 41 | @RequestMapping(value="hello") 42 | public class HelloController { 43 | 44 | // responds to /hello 45 | @GetMapping("") 46 | @ResponseBody 47 | public String hello() { 48 | return "Hello"; 49 | } 50 | 51 | // responds to /hello/goodbye 52 | @GetMapping("goodbye") 53 | @ResponseBody 54 | public String helloGoodbye() { 55 | return "Hello, Goodbye"; 56 | } 57 | } 58 | 59 | Note that we use ``@RequestMapping`` on the class. ``@GetMapping`` and ``@PostMapping`` 60 | cannot be applied at the class level. 61 | 62 | In a related fashion, if you find that each of your methods in a controller class 63 | use ``@ResponseBody`` to return plain text, this annotation may be added at the top 64 | of the class, rather than at each method declaration. 65 | 66 | Check Your Understanding 67 | ------------------------ 68 | 69 | .. admonition:: Question 70 | 71 | True/False: No one controller method can handle several request types. 72 | 73 | a. True 74 | 75 | b. False 76 | 77 | .. ans: b, A controller method annotated with ``@RequestMapping`` can handle multiple request types. 78 | 79 | .. admonition:: Question 80 | 81 | We want the method ``hello`` to take another parameter, ``@RequestParam String friend``, that will 82 | add a friend's name to the returned greeting. The use should also be able to enter this name via 83 | a text field. What needs to be added to the form? 84 | 85 | a. Another ``input`` tag with a ``friend`` attribute. 86 | 87 | b. Another ``input`` tag with a ``name`` attribute. 88 | 89 | c. Another ``form`` tag with a ``method`` attribute. 90 | 91 | d. Another ``submit`` tag with a ``friend`` value. 92 | 93 | .. ans: b, Another ``input`` tag with a ``name`` attribute. 94 | 95 | 96 | -------------------------------------------------------------------------------- /src/appendices/exercise-solutions/spring-model-classes.rst: -------------------------------------------------------------------------------- 1 | .. _model-classes-exercise-solutions: 2 | 3 | Exercise Solutions: Edit Model Classes 4 | ====================================== 5 | 6 | .. _model-classes-exercise-solutions1: 7 | 8 | #. Create the two handler methods listed below in ``EventController``. We’ll add code 9 | to these in a moment, so just put the method outline in place for 10 | now. 11 | 12 | .. sourcecode:: java 13 | :linenos: 14 | 15 | @Controller 16 | @RequestMapping("events") 17 | public class EventController { 18 | 19 | @GetMapping 20 | public String displayAllEvents(Model model) { 21 | model.addAttribute("title", "All Events"); 22 | model.addAttribute("events", EventData.getAll()); 23 | return "events/index"; 24 | } 25 | 26 | @GetMapping("create") 27 | public String displayCreateEventForm(Model model) { 28 | model.addAttribute("title", "Create Event"); 29 | return "events/create"; 30 | } 31 | 32 | @PostMapping("create") 33 | public String processCreateEventForm(@ModelAttribute Event newEvent) { 34 | EventData.add(newEvent); 35 | return "redirect:"; 36 | } 37 | 38 | @GetMapping("delete") 39 | public String displayDeleteEventForm(Model model) { 40 | model.addAttribute("title", "Delete Events"); 41 | model.addAttribute("events", EventData.getAll()); 42 | return "events/delete"; 43 | } 44 | 45 | @PostMapping("delete") 46 | public String processDeleteEventsForm(@RequestParam(required = false) int[] eventIds) { 47 | 48 | if (eventIds != null) { 49 | for (int id : eventIds) { 50 | EventData.remove(id); 51 | } 52 | } 53 | 54 | return "redirect:"; 55 | } 56 | 57 | @GetMapping("edit/{eventId}") 58 | public String displayEditForm(Model model, @PathVariable int eventId){ 59 | } 60 | 61 | @PostMapping("edit") 62 | public String processEditForm(int eventId, String name, String description) { 63 | } 64 | 65 | } 66 | 67 | :ref:`Back to the exercises ` 68 | 69 | .. _model-classes-exercise-solutions5: 70 | 71 | 5. Back in the ``displayEditForm`` handler, round out the controller method. 72 | 73 | .. sourcecode:: java 74 | 75 | @GetMapping("edit/{eventId}") 76 | public String displayEditForm(Model model, @PathVariable int eventId){ 77 | Event eventToEdit = EventData.getById(eventId); 78 | model.addAttribute("event", eventToEdit); 79 | String title = "Edit Event " + eventToEdit.getName() + " (id=" + eventToEdit.getId() + ")"; 80 | model.addAttribute("title", title ); 81 | return "events/edit"; 82 | } 83 | 84 | :ref:`Back to the exercises ` 85 | 86 | .. _model-classes-exercise-solutions9: 87 | 88 | 9. In ``processEditForm``, 89 | 90 | .. sourcecode:: java 91 | 92 | @PostMapping("edit") 93 | public String processEditForm(int eventId, String name, String description) { 94 | Event eventToEdit = EventData.getById(eventId); 95 | eventToEdit.setName(name); 96 | eventToEdit.setDescription(description); 97 | return "redirect:"; 98 | } 99 | 100 | :ref:`Back to the exercises ` 101 | 102 | -------------------------------------------------------------------------------- /src/chapters/data-types/studio.rst: -------------------------------------------------------------------------------- 1 | .. _area-of-a-circle-studio: 2 | 3 | Studio: Area of a Circle 4 | ======================== 5 | 6 | Get cosy with Java syntax by writing a console program that calculates the 7 | area of a circle based on input from the user. 8 | 9 | Creating your class 10 | ------------------- 11 | 12 | Since you’re still new to Java and IntelliJ, we’ll provide some extra 13 | direction the first few coding exercises. 14 | 15 | First, make a new folder, or package, to hold your studio exercises. Create a 16 | new package named ``org.launchcode.java.studios.areaofacircle`` by 17 | right-clicking (or ctrl-clicking for some Mac users) on the ``src`` directory 18 | in ``java-web-dev-exercises`` and selecting *New > Package*. Be sure to enter 19 | the full name, or your package won’t be created in the correct location. 20 | 21 | Create your class in the ``java-web-dev-exercises`` project within the 22 | package ``org.launchcode.java.studios.areaofacircle`` by 23 | right-clicking/ctrl-clicking on the ``studios.areaofacircle`` package/folder 24 | and selecting *New > Java Class*. Enter the name ``Area``. Select the option 25 | to add the file to Git when the window appears. 26 | 27 | Your first task 28 | --------------- 29 | 30 | Write a class, ``Area``, that prompts the user for the radius of a circle and 31 | then calculate its area and print the result. 32 | 33 | .. admonition:: Tip 34 | 35 | Recall that the area of a circle is ``A = pi * r * r`` where ``pi`` is 36 | 3.14 and ``r`` is the radius. 37 | 38 | .. note:: 39 | 40 | Unlike some other languages, Java does not have an exponent operator. 41 | 42 | 43 | Here’s an example of how your program should work: 44 | 45 | :: 46 | 47 | Enter a radius: 2.5 48 | The area of a circle of radius 2.5 is: 19.625 49 | 50 | Some questions to ask yourself: 51 | 52 | #. What data type should the radius be? 53 | #. What is the best way to get user input into a variable ``radius`` of 54 | that type? 55 | 56 | .. admonition:: Warning 57 | 58 | Be sure to create a ``main`` method to place your code within. It’s 59 | signature *must* be: 60 | 61 | .. sourcecode:: java 62 | 63 | public static void main(String[] args) 64 | 65 | Your next task 66 | -------------- 67 | 68 | Add a second Java file to your program to delegate the area calculation away 69 | from the printing task. 70 | 71 | #. Add a new class in your ``studios.areaofacircle`` package called ``Circle``. 72 | #. Create a method called ``getArea`` inside of ``Circle`` that takes a Double 73 | ``radius`` as its only parameter and returns another ``Double``, the result of 74 | the area calculation. 75 | 76 | .. sourcecode:: java 77 | 78 | public static Double getArea(Double radius) { 79 | return 3.14 * radius * radius; 80 | } 81 | 82 | #. Back in ``Area``, replace your area calculation line with a call to 83 | ``Circle.getArea()``. 84 | 85 | .. tip:: 86 | 87 | Check out the ``HelloMethods`` and ``Message`` example from 88 | :ref:`static-methods` for a reference on how to use a class from another 89 | file. 90 | 91 | Bonus Missions 92 | -------------- 93 | 94 | 1. Add validation to your program. If the user enters a negative number? a 95 | non-numeric character? the empty string? Print an error message and quit. 96 | You’ll need to peek ahead to learn 97 | about `conditional syntax in 98 | Java `__. 99 | 2. Extend your program further by using a `while or do-while 100 | loop `__, 101 | so that when the user enters a negative number they are re-prompted. 102 | -------------------------------------------------------------------------------- /src/appendices/exercise-solutions/classes-part2.rst: -------------------------------------------------------------------------------- 1 | .. _classes2-exercise-solutions: 2 | 3 | Exercise Solutions: Classes and Objects, Part 2 4 | =============================================== 5 | 6 | .. _classes2-exercise-solutions1: 7 | 8 | The ``getGradeLevel`` Method 9 | ----------------------------- 10 | 11 | This method returns the student's level based on the number of credits they 12 | have earned: Freshman (0-29 credits), Sophomore (30-59 credits), Junior (60-89 13 | credits), or Senior (90+ credits). 14 | 15 | .. sourcecode:: java 16 | :linenos: 17 | 18 | public static String getGradeLevel(int credits) { 19 | if (credits <= 29){ 20 | return "freshman"; 21 | } else if (credits <= 59){ 22 | return "sophomore"; 23 | } else if (credits <= 89) { 24 | return "junior"; 25 | } else { 26 | return "senior"; 27 | } 28 | } 29 | 30 | :ref:`Back to the exercises ` 31 | 32 | .. _classes2-exercise-solutions2: 33 | 34 | The ``addGrade`` Method 35 | ------------------------ 36 | 37 | This method accepts two parameters---a number of course credits and a 38 | numerical grade (0.0-4.0). With this data, you need to update the student’s 39 | GPA. 40 | 41 | GPA Information 42 | ^^^^^^^^^^^^^^^^ 43 | 44 | GPA is computed via the formula: 45 | 46 | gpa = (total quality score) / (total number of credits) 47 | 48 | #. The *quality score* for a class is found by multiplying the letter grade 49 | score (0.0-4.0) by the number of credits. 50 | #. The *total quality score* is the sum of the quality scores for all classes. 51 | 52 | For example, if a student received an "A" (worth 4 points) in a 3-credit course 53 | and a "B" (worth 3 points) in a 4-credit course, their total quality score 54 | would be: 4.0 * 3 + 3.0 * 4 = 24. Their GPA would then be 24 / 7 = 3.43. 55 | 56 | Determine the New GPA 57 | ^^^^^^^^^^^^^^^^^^^^^^ 58 | 59 | To update the student's GPA: 60 | 61 | #. Calculate their *current* total quality score by using the formula 62 | ``gpa * numberOfCredits``. 63 | #. Use the new course grade and course credits to update their total quality 64 | score. 65 | #. Update the student's total ``numberOfCredits``. 66 | #. Compute their new GPA. 67 | 68 | .. sourcecode:: java 69 | :linenos: 70 | 71 | public void addGrade(int courseCredits, double grade) { 72 | double totalQualityScore = this.gpa * this.numberOfCredits; 73 | totalQualityScore += courseCredits * grade; 74 | this.numberOfCredits += courseCredits; 75 | this.gpa = totalQualityScore/this.numberOfCredits; 76 | } 77 | 78 | :ref:`Back to the exercises ` 79 | 80 | .. _classes2-exercise-solutions3a: 81 | 82 | ``toString`` and ``equals`` 83 | --------------------------- 84 | 85 | #. Add custom ``equals()`` and ``toString()`` methods to the ``Student`` 86 | class. 87 | 88 | .. sourcecode:: java 89 | :linenos: 90 | 91 | public String toString() { 92 | String studentReport = String.format("%s is a %s with %d credits and a GPA of %.2f", this.name, this.getGradeLevel(this.numberOfCredits), this.getNumberOfCredits(), this.getGpa()); 93 | return studentReport; 94 | } 95 | 96 | public boolean equals(Object toBeCompared) { 97 | if (toBeCompared == this) { 98 | return true; 99 | } 100 | 101 | if (toBeCompared == null) { 102 | return false; 103 | } 104 | 105 | if (toBeCompared.getClass() != getClass()) { 106 | return false; 107 | } 108 | 109 | Student theStudent = (Student) toBeCompared; 110 | return theStudent.getStudentId() == getStudentId(); 111 | } 112 | 113 | :ref:`Back to the exercises ` 114 | 115 | -------------------------------------------------------------------------------- /src/chapters/thymeleaf-views/src&href.rst: -------------------------------------------------------------------------------- 1 | Static Resources 2 | ================= 3 | 4 | Up to now, we used templates to display controller data as text in the view. If 5 | we need to display an image or video, or if we want to create a link to a 6 | different file, then we need to move beyond a text output. 7 | 8 | With Thymeleaf, we can set values for the HTML ``src`` and ``href`` attributes. 9 | Instead of hard-coding a file path or external URL inside a tag, ``th:src`` and 10 | ``th:href`` take advantage of a simpler syntax. You did this near the end of 11 | the last video when you referenced information stored in files other than the 12 | controller or the template. 13 | 14 | Accessing Resources 15 | -------------------- 16 | 17 | Inside the ``resources`` folder, there is another directory called ``static``. 18 | By convention, this is the location where we store files that our project needs 19 | to access---like images, CSS stylesheets, JavaScript code, etc. 20 | 21 | .. figure:: ./figures/resourcesFolderFileTree.png 22 | :alt: Resources folder file tree. 23 | 24 | 25 | ``th:src`` and ``th:href`` - Video 26 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 27 | 28 | Code along with this final video to practice adding static resources to your 29 | ``coding-events`` project: 30 | 31 | .. youtube:: 32 | :video_id: syzOmHnTnmo 33 | 34 | .. admonition:: Note 35 | 36 | The starter code for this video is found at the `fragments branch `__. of the ``coding-events-demo`` repo. 37 | The final code presented in this video is found on the `static-resources branch `__. As always, code along to the 38 | videos on your own ``coding-events`` project. 39 | 40 | ``th:src`` 41 | ^^^^^^^^^^ 42 | 43 | To access a file with the standard HTML ``src`` attribute, we need to provide 44 | either a detailed or relative file path in order to establish a link. 45 | ``th:src`` shortens this process by filling in most of the file path 46 | automatically (``.../project-name/src/main/resources/static``). All we 47 | need to do is fill in the last portion of the file path---everything after 48 | ``/static``. 49 | 50 | The general syntax is: 51 | 52 | .. sourcecode:: groovy 53 | 54 | th:src = "@{/filePath}" 55 | 56 | .. admonition:: Examples 57 | 58 | If we have an image file called ``familyPhoto1.jpg`` stored in 59 | ``static``, then we can display it in the view with an ``img`` tag as follows: 60 | 61 | .. sourcecode:: HTML 62 | 63 | 64 | 65 | If the image is contained in an ``images`` folder inside ``static``, then the 66 | syntax is: 67 | 68 | .. sourcecode:: HTML 69 | 70 | 71 | 72 | Think of the ``@`` symbol as representing everything in the file path up to the 73 | ``static`` folder. 74 | 75 | ``th:href`` 76 | ^^^^^^^^^^^^ 77 | 78 | The syntax for ``th:href`` is the same as that for ``th:src``. For example, to 79 | link to a CSS stylesheet: 80 | 81 | .. sourcecode:: HTML 82 | 83 | 84 | 85 | Check Your Understanding 86 | ------------------------- 87 | 88 | .. admonition:: Question 89 | 90 | Given the file tree shown below, which option displays the correct syntax 91 | for finding the image ``fluffy.jpg``? 92 | 93 | .. figure:: ./figures/srcCcFileTree.png 94 | :alt: File tree for finding ``fluffy.jpg``. 95 | :scale: 90% 96 | 97 | #. ``th:src = "@{/pets/cats/fluffy.jpg}"`` 98 | #. ``th:src = "@{/static/pets/cats/fluffy.jpg}"`` 99 | #. ``th:src = "@{/static/pets/cats/images/fluffy.jpg}"`` 100 | #. ``th:src = "@{/pets/cats/images/fluffy.jpg}"`` 101 | 102 | .. Answer = (d) th:src = "@{/pets/cats/images/fluffy.jpg}" 103 | -------------------------------------------------------------------------------- /src/chapters/unit-testing/exercises.rst: -------------------------------------------------------------------------------- 1 | .. _unit-testing-exercises: 2 | 3 | Exercises: Unit Testing 4 | ======================= 5 | 6 | Work on these exercises in the IntelliJ ``java-web-dev-exercises`` 7 | project. You will update your ``CarTest.java`` file by adding 8 | more test cases. 9 | 10 | ``testGasTankAfterDriving()`` 11 | ----------------------------- 12 | 13 | Add a test for the third TODO, "gasTankLevel is accurate after driving within tank range". 14 | 15 | #. Your test must use the ``Car`` method ``drive()`` 16 | 17 | .. sourcecode:: java 18 | 19 | test_car.drive(50); 20 | 21 | #. With a value of ``50`` miles passed into ``drive()``, we expect 22 | ``test_car`` to have a ``gasTankLevel`` of ``9``. 23 | 24 | .. sourcecode:: java 25 | 26 | assertEquals(9, test_car.getGasTankLevel(), .001); 27 | 28 | :ref:`Check your solution ` 29 | 30 | ``testGasTankAfterExceedingTankRange()`` 31 | ---------------------------------------- 32 | 33 | Add a test for the fourth TODO, "gasTankLevel is accurate after attempting to drive past tank range". 34 | 35 | #. You're on your own for this one. You'll need to simulate the ``Car`` 36 | travelling farther than it's ``gasTankLevel`` allows. 37 | 38 | :ref:`Check your solution ` 39 | 40 | ``testGasOverfillException()`` 41 | ------------------------------ 42 | 43 | The test for our last TODO is a little different. We are going to 44 | perform an action on our car object, and we are expecting the object 45 | to throw an error. In this case, we are going to attempt to add gas 46 | to our car that exceeds the gas tank size. 47 | 48 | #. First, we'll add some text to our ``@Test`` annotation to tell JUnit 49 | to expect an exception. 50 | 51 | .. sourcecode:: java 52 | 53 | //TODO: can't have more gas than tank size, expect an exception 54 | @Test(expected = IllegalArgumentException.class) 55 | public void testGasOverfillException() { 56 | 57 | } 58 | 59 | This lets JUnit know that this test should pass if an 60 | ``IllegalArgumentException`` is thrown at any point during this test. 61 | 62 | #. Update the ``Car`` class to include an ``addGas()`` method. 63 | 64 | .. sourcecode:: java 65 | 66 | public void addGas(double gas) { 67 | this.setGasTankLevel(gas + this.getGasTankLevel()); 68 | } 69 | 70 | #. Back in ``CarTest``, implement the new ``addGas()`` method and a 71 | ``fail()`` scenario. 72 | 73 | .. sourcecode:: java 74 | 75 | test_car.addGas(5); 76 | fail("Shouldn't get here, car cannot have more gas in tank than the size of the tank"); 77 | 78 | 79 | The ``fail()`` message will be displayed if the test fails. 80 | We have to import ``fail`` into this class to use it. 81 | 82 | #. Run the test. It should fail! In the output is an unexpected 83 | exception. This test was expecting an ``IllegalArgumentException``, 84 | but it got an ``AssertionError`` exception. This caused the test 85 | to fail. Further down in the output log, we can see that our 86 | ``fail()`` statement printed out the statement about not being 87 | able to add more gas than is possible. 88 | 89 | #. We need to refactor ``Car`` to throw an exception when too much 90 | gas is added to the tank. Find the ``setGasTankLevel`` method and 91 | modify it: 92 | 93 | .. sourcecode:: java 94 | 95 | public void setGasTankLevel(double gasTankLevel) { 96 | if (gasTankLevel > this.getGasTankSize()) { 97 | throw new IllegalArgumentException("Can't exceed tank size"); 98 | } 99 | this.gasTankLevel = gasTankLevel; 100 | } 101 | 102 | #. Now, run the test - it should pass! 103 | 104 | :ref:`Check your solution ` 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | --------------------------------------------------------------------------------