├── ApplicationLayers.png ├── AutomationReview.md ├── BDD ├── Homepage.png ├── bdd.md ├── bdd.xlsx ├── reviewpage.png └── wikiautomation2 │ ├── environment.py │ ├── languages.feature │ ├── poms │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-39.pyc │ │ └── wiki_home_page.cpython-39.pyc │ └── wiki_home_page.py │ ├── search.feature │ └── steps │ ├── __init__.py │ └── language_steps.py ├── CommunityLibrariAPI ├── pom.xml └── src │ ├── main │ └── java │ │ └── dev │ │ └── ranieri │ │ ├── app │ │ └── App.java │ │ ├── controllers │ │ └── BookController.java │ │ ├── daos │ │ ├── BookDAO.java │ │ ├── BookDaoLocal.java │ │ └── BookDaoPostgres.java │ │ ├── entities │ │ └── Book.java │ │ ├── exceptions │ │ └── ResourceNotFound.java │ │ ├── services │ │ ├── BookService.java │ │ └── BookServiceImpl.java │ │ └── utils │ │ └── ConnectionUtil.java │ └── test │ ├── java │ └── dev │ │ └── ranieri │ │ ├── daotests │ │ └── BookDaoTests.java │ │ ├── servicetests │ │ └── BookServiceTests.java │ │ └── testngbasics │ │ └── TestNgBasics.java │ └── resources │ ├── alltests.xml │ └── daotests.xml ├── DOM ├── domintro.html ├── eventlistener.html ├── inputs.html ├── notetracker.html └── outside.js ├── Day1Python ├── controlflow.py ├── datatypes.py ├── forloopsranges.py ├── functions.py ├── hello.py ├── operators.py └── userinput.py ├── Day2Python ├── closures.py ├── collections_dictionaries.py ├── collections_list.py ├── collections_sets.py ├── collections_tuples.py ├── enclosing.py ├── example.py ├── fancyfunctions.py ├── namespaces.py ├── objects101.py ├── objects202.py └── strings.py ├── Day3Python ├── calculator_app.py ├── errors101.py ├── inheritance.py ├── lambda.py ├── list_comprehension.py ├── mini_app.py └── raising_errors.py ├── HelloWorld2 ├── HelloWorld2.iml ├── pom.xml ├── src │ └── main │ │ └── java │ │ └── dev │ │ └── ranieri │ │ └── app │ │ ├── App.java │ │ └── Person.java └── target │ └── classes │ └── dev │ └── ranieri │ └── app │ ├── App.class │ └── Person.class ├── HelloWorldServer ├── .idea │ ├── .gitignore │ ├── compiler.xml │ ├── jarRepositories.xml │ └── misc.xml ├── HelloWorldServer.iml ├── pom.xml ├── src │ └── main │ │ └── java │ │ └── dev │ │ └── ranieri │ │ └── app │ │ └── App.java └── target │ └── classes │ └── dev │ └── ranieri │ └── app │ └── App.class ├── HelloWorldWebServer └── main.py ├── IntroToTDD ├── calculators │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-39.pyc │ │ └── temperature_calculator.cpython-39.pyc │ └── temperature_calculator.py ├── demo │ ├── __init__.py │ └── four_functions.py ├── main.py └── tests │ ├── __init__.py │ ├── __pycache__ │ ├── __init__.cpython-39.pyc │ └── temp_calculator_tests.cpython-39-pytest-6.2.4.pyc │ └── temp_calculator_tests.py ├── JSON.docx ├── Java101.md ├── JavaCollections.md ├── JavaDay2 ├── JavaDay2.iml ├── pom.xml └── src │ └── main │ └── java │ └── dev │ └── ranieri │ ├── constructors │ ├── ConstructorPlayground.java │ ├── Dwelling.java │ ├── Estate.java │ └── House.java │ ├── overloading │ └── OverloadPlayground.java │ ├── overriding │ ├── Child.java │ ├── OverridePlayground.java │ └── Parent.java │ ├── strings │ └── StringPlayground.java │ └── wrappers │ ├── EsotericJava.java │ └── WrapperPlayground.java ├── JavaDay3 ├── .idea │ ├── .gitignore │ ├── compiler.xml │ ├── jarRepositories.xml │ └── misc.xml ├── JavaDay3.iml ├── pom.xml ├── src │ └── main │ │ └── java │ │ └── dev │ │ └── ranieri │ │ ├── colllectionsframework │ │ ├── ArrayFactory.java │ │ ├── CollectionPlayground.java │ │ ├── ListPlayground.java │ │ ├── MyAwesomeList.java │ │ └── Player.java │ │ └── polymorphism │ │ ├── CashBackCard.java │ │ ├── CreditCard.java │ │ ├── CreditPlayground.java │ │ ├── DiamondPlusRewardCard.java │ │ ├── Expandable.java │ │ ├── Freezable.java │ │ └── RewardCard.java └── target │ └── classes │ └── dev │ └── ranieri │ ├── colllectionsframework │ ├── ArrayFactory.class │ ├── CollectionPlayground.class │ ├── ListPlayground.class │ ├── MyAwesomeList.class │ └── Player.class │ └── polymorphism │ ├── CashBackCard.class │ ├── CreditCard.class │ ├── CreditPlayground.class │ ├── DiamondPlusRewardCard.class │ ├── Expandable.class │ ├── Freezable.class │ └── RewardCard.class ├── JavaDay4 ├── .idea │ ├── .gitignore │ ├── compiler.xml │ ├── jarRepositories.xml │ └── misc.xml ├── JavaDay4.iml ├── pom.xml ├── src │ └── main │ │ └── java │ │ └── dev │ │ └── ranieri │ │ ├── exceptions │ │ ├── ErrorPlayground.java │ │ ├── InvalidUsernameException.java │ │ └── UsernameValidationApp.java │ │ ├── lambdas │ │ ├── Calculate.java │ │ └── LambdaPlayground.java │ │ └── object101 │ │ └── ObjectPlayground.java └── target │ └── classes │ └── dev │ └── ranieri │ ├── exceptions │ ├── ErrorPlayground.class │ ├── InvalidUsernameException.class │ └── UsernameValidationApp.class │ ├── lambdas │ ├── Calculate.class │ └── LambdaPlayground.class │ └── object101 │ └── ObjectPlayground.class ├── LibraryAPI ├── daos │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-39.pyc │ │ ├── book_dao.cpython-39.pyc │ │ ├── book_dao_local.cpython-39.pyc │ │ └── book_dao_postgres.cpython-39.pyc │ ├── book_dao.py │ ├── book_dao_local.py │ └── book_dao_postgres.py ├── entities │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-39.pyc │ │ └── book.cpython-39.pyc │ └── book.py ├── exceptions │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-39.pyc │ │ ├── book_unavailable_error.cpython-39.pyc │ │ └── not_found_exception.cpython-39.pyc │ ├── book_unavailable_error.py │ └── not_found_exception.py ├── main.py ├── records.log ├── services │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-39.pyc │ │ ├── book_service.cpython-39.pyc │ │ └── book_service_impl.cpython-39.pyc │ ├── book_service.py │ └── book_service_impl.py ├── tests │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-39.pyc │ │ ├── test_book_dao.cpython-39-pytest-6.2.4.pyc │ │ └── test_book_service.cpython-39-pytest-6.2.4.pyc │ ├── test_book_dao.py │ └── test_book_service.py └── utils │ ├── __init__.py │ ├── __pycache__ │ ├── __init__.cpython-39.pyc │ └── connection_util.cpython-39.pyc │ └── connection_util.py ├── PyBookFrontend ├── bookadder.html ├── bookviewer.html └── checkout.html ├── PythonImporting ├── __pycache__ │ ├── english.cpython-39.pyc │ └── spanish.cpython-39.pyc ├── app.py ├── english.py ├── foreign_imports.py ├── germanic_languages │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-39.pyc │ │ └── german.cpython-39.pyc │ └── german.py ├── paradigms.py └── spanish.py ├── PythonNotesDay1.docx ├── Question Bank (Pre-panel).docx ├── README.md ├── RequirementsTraceabilityMatrix.xlsx ├── Reviews ├── ApplicationLayers.png ├── BankingAPI.md ├── InterviewQuestions.md ├── JavaReview.md ├── LifeCycles.md ├── PythonReview.md ├── Ranieri Corp Test Strategy.docx ├── RestReview.md ├── SqlReview.md ├── TestPlan.docx ├── TestTerminolgy.md ├── TypesOfTesting.md ├── Week6Leftovers.md ├── arrays.png ├── aws.md ├── clientsidereview.md ├── defectlifecycle.png ├── httpReview.md ├── java-collection-framework-hierarchy.jpg ├── javaquestions │ ├── java-questions.md │ └── moar-java-questions.md ├── jvm.png ├── pipelinesetup.md ├── scrum.md ├── stlc.png ├── testquestions.txt ├── usecases.png └── waterfall-model.png ├── Seleniumwaits ├── 1000th.html ├── 100_automate.py ├── automate.py └── slowpage.html ├── TDD.txt ├── TestTypes.md ├── WikiAutomationJava ├── .idea │ ├── .gitignore │ ├── compiler.xml │ ├── jarRepositories.xml │ └── misc.xml ├── WikiAutomationJava.iml ├── pom.xml ├── src │ └── test │ │ ├── java │ │ └── dev │ │ │ └── ranieri │ │ │ ├── pages │ │ │ └── WikiHomePage.java │ │ │ ├── runners │ │ │ └── BasicRunner.java │ │ │ └── steps │ │ │ ├── BabySteps.java │ │ │ └── LanguageSteps.java │ │ └── resources │ │ ├── chromedriver.exe │ │ └── features │ │ ├── languages.feature │ │ └── sample.feature └── target │ └── test-classes │ ├── chromedriver.exe │ ├── dev │ └── ranieri │ │ ├── pages │ │ └── WikiHomePage.class │ │ ├── runners │ │ └── BasicRunner.class │ │ └── steps │ │ ├── BabySteps.class │ │ └── LanguageSteps.class │ └── features │ ├── languages.feature │ └── sample.feature ├── arrays.png ├── asyncjs ├── asyncd.md ├── eventqueue.html ├── pokeviewer.html └── simplerequest.html ├── branching.txt ├── clientsidereview.md ├── clientsidetech ├── JavaScript.md ├── arrays.js ├── clientside.md ├── datatypes.js ├── football.jpg ├── functions.js ├── gatorfanpage.html ├── gatorfanpage2.html ├── hello.txt ├── helloworld.js ├── runner.html ├── scopes.js ├── styles.css └── truthyfalsy.js ├── collectionsframework.png ├── deliverable.txt ├── encapsulation ├── .idea │ ├── .gitignore │ ├── compiler.xml │ ├── jarRepositories.xml │ └── misc.xml ├── encapsulation.iml ├── pom.xml ├── src │ └── main │ │ └── java │ │ ├── a │ │ ├── APlayground.java │ │ └── Shape.java │ │ ├── b │ │ ├── BPlayground.java │ │ └── Rectangle.java │ │ └── practical │ │ ├── Car.java │ │ ├── CarPlayground.java │ │ └── Person.java └── target │ └── classes │ ├── a │ ├── APlayground.class │ └── Shape.class │ ├── b │ ├── BPlayground.class │ └── Rectangle.class │ └── practical │ ├── Car.class │ └── CarPlayground.class ├── java-collection-framework-hierarchy.jpg ├── javaquestions ├── java-questions.md └── moar-java-questions.md ├── obj.js ├── project1.md ├── sdlc.md ├── seleniumbasics ├── helloselenium.py └── selenium.md ├── sql ├── basketball.sql ├── intro.sql ├── library.sql └── sql.md ├── urlrewrite ├── end.html └── start.html ├── waterfall-model.png ├── webbasics.docx ├── webservicecreation.txt ├── week1interviews.txt └── week1python.txt /ApplicationLayers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/ApplicationLayers.png -------------------------------------------------------------------------------- /BDD/Homepage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/BDD/Homepage.png -------------------------------------------------------------------------------- /BDD/bdd.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/BDD/bdd.xlsx -------------------------------------------------------------------------------- /BDD/reviewpage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/BDD/reviewpage.png -------------------------------------------------------------------------------- /BDD/wikiautomation2/environment.py: -------------------------------------------------------------------------------- 1 | from behave.runner import Context 2 | from selenium import webdriver 3 | from selenium.webdriver.chrome.webdriver import WebDriver 4 | from poms.wiki_home_page import WikiHomePage 5 | # Environment is like a configuration for your cucumber tests 6 | # it is actual python code 7 | 8 | # the context object passed into our step implementations and environment set up and tear down functions 9 | # is SHARED between every function 10 | # context is a singleton (there is only ONE context object for the entirety of the program) 11 | # context is the primary way to share information or objects in you code 12 | def before_all(context: Context): 13 | ## ideally you attach the web driver for the applicaiton to the context object 14 | context.driver = webdriver.Chrome('C:\\Users\\AdamRanieri\\Desktop\\drivers\\chromedriver.exe') 15 | context.wiki_home_page = WikiHomePage(context.driver) 16 | print("I run before ANY scenarios") 17 | 18 | def after_all(context): 19 | print("I run after all scenarios") 20 | context.driver.quit() 21 | -------------------------------------------------------------------------------- /BDD/wikiautomation2/languages.feature: -------------------------------------------------------------------------------- 1 | Feature: Multiple Languages should be supported 2 | 3 | Scenario: Navigate to English Wikipedia 4 | Given The Guest is on the Wikipedia Home Page 5 | When The Guest clicks on English 6 | Then The Guest should be on the English Home Page 7 | 8 | Scenario: Navigate to Spanish Wikipedia 9 | Given The Guest is on the Wikipedia Home Page 10 | When The Guest clicks on Spanish 11 | Then The Guest should be on the Spanish Home Page 12 | 13 | Scenario: Navigate to Italian Wikipedia 14 | Given The Guest is on the Wikipedia Home Page 15 | When The Guest clicks on Italian 16 | Then The Guest should be on the Italian Home Page 17 | 18 | Scenario: Person Loves to quickly navigate between pages 19 | Given The Guest is on the Wikipedia Home Page 20 | When The Guest clicks on Italian 21 | Given The Guest is on the Wikipedia Home Page 22 | When The Guest clicks on Spanish 23 | Given The Guest is on the Wikipedia Home Page 24 | When The Guest clicks on English 25 | Given The Guest is on the Wikipedia Home Page 26 | When The Guest clicks on Spanish -------------------------------------------------------------------------------- /BDD/wikiautomation2/poms/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/BDD/wikiautomation2/poms/__init__.py -------------------------------------------------------------------------------- /BDD/wikiautomation2/poms/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/BDD/wikiautomation2/poms/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /BDD/wikiautomation2/poms/__pycache__/wiki_home_page.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/BDD/wikiautomation2/poms/__pycache__/wiki_home_page.cpython-39.pyc -------------------------------------------------------------------------------- /BDD/wikiautomation2/poms/wiki_home_page.py: -------------------------------------------------------------------------------- 1 | from selenium.webdriver.chrome.webdriver import WebDriver 2 | 3 | # Page Object Model 4 | # A class that will contain the important elements on a web page 5 | from selenium.webdriver.remote.webelement import WebElement 6 | 7 | 8 | class WikiHomePage: 9 | 10 | def __init__(self, driver: WebDriver): 11 | self.driver = driver #Dependency injection of a driver into the web page 12 | 13 | # Selectors are the different ways to get elements in selenium 14 | def english(self): 15 | element: WebElement = self.driver.find_element_by_id("js-link-box-en") # get element by id 16 | return element 17 | 18 | def spanish(self): 19 | # CSS selector is a great choice if name or id is unavailbe 20 | element: WebElement = self.driver.find_element_by_css_selector('div[lang="es"]') 21 | return element 22 | 23 | def italian(self): 24 | # xpath should a more last resort way of getting elements 25 | # xpath is the HTML directions to a element 26 | # relative xpaths are better //*[@id="www-wikipedia-org"]/div[2]/div[8] 27 | # absolute xpath /html/body/div[2]/div[8] 28 | element: WebElement = self.driver.find_element_by_xpath('//*[@id="www-wikipedia-org"]/div[2]/div[8]') 29 | return element 30 | 31 | def search_bar(self): 32 | element: WebElement = self.driver.find_element_by_name("search") 33 | return element 34 | 35 | def search_button(self): 36 | element: WebElement = self.driver.find_element_by_class_name("pure-button-primary-progressive") 37 | return element 38 | 39 | -------------------------------------------------------------------------------- /BDD/wikiautomation2/search.feature: -------------------------------------------------------------------------------- 1 | Feature: Search for articles 2 | 3 | 4 | Scenario Outline: Search for US States 5 | Given The Guest is on the Wikipedia Home Page 6 | When The Guest types into the search bar 7 | When The Guest clicks on the search button 8 | Then The title should be 9 | 10 | Examples: 11 | | word | title | 12 | | Florida | Florida - Wikipedia | 13 | | florida | Florida - Wikipedia | 14 | | Oregon | Oregon - Wikipedia | 15 | | California | California - Wikipedia | -------------------------------------------------------------------------------- /BDD/wikiautomation2/steps/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/BDD/wikiautomation2/steps/__init__.py -------------------------------------------------------------------------------- /BDD/wikiautomation2/steps/language_steps.py: -------------------------------------------------------------------------------- 1 | from behave import given, when, then 2 | from selenium.webdriver.chrome.webdriver import WebDriver 3 | 4 | @given('The Guest is on the Wikipedia Home Page') 5 | def open_up_wiki_home_page(context): 6 | context.driver.get('https://www.wikipedia.org/') 7 | 8 | 9 | @when('The Guest clicks on English') 10 | def click_on_engnlish(context): 11 | context.wiki_home_page.english().click() 12 | 13 | 14 | @then('The Guest should be on the English Home Page') 15 | def verify_on_enlish_page(context): 16 | title = context.driver.title # returns the title of the web page 17 | assert title == 'Wikipedia, the free encyclopedia' 18 | 19 | 20 | @when('The Guest clicks on Spanish') 21 | def step_impl(context): 22 | context.wiki_home_page.spanish().click() 23 | 24 | 25 | @then('The Guest should be on the Spanish Home Page') 26 | def step_impl(context): 27 | driver: WebDriver = context.driver # create a type annotation for the intellisense 28 | title = driver.title # returns the title of the web page 29 | assert title == 'Wikipedia, la enciclopedia libre' 30 | 31 | 32 | @when('The Guest clicks on Italian') 33 | def step_impl(context): 34 | context.wiki_home_page.italian().click() 35 | 36 | 37 | @then('The Guest should be on the Italian Home Page') 38 | def step_impl(context): 39 | title = context.driver.title # returns the title of the web page 40 | assert title == "Wikipedia, l'enciclopedia libera" 41 | 42 | 43 | @when('The Guest clicks on the search button') 44 | def step_impl(context): 45 | context.wiki_home_page.search_button().click() 46 | 47 | 48 | @when('The Guest types {word} into the search bar') 49 | def step_impl(context, word: str): 50 | context.wiki_home_page.search_bar().send_keys(word) 51 | 52 | 53 | @then(u'The title should be {title}') 54 | def step_impl(context, title: str): 55 | assert context.driver.title == title 56 | -------------------------------------------------------------------------------- /CommunityLibrariAPI/pom.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <project xmlns="http://maven.apache.org/POM/4.0.0" 3 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 5 | <modelVersion>4.0.0</modelVersion> 6 | 7 | <groupId>dev.ranieri</groupId> 8 | <artifactId>CommunityLibrariAPI</artifactId> 9 | <version>1.0-SNAPSHOT</version> 10 | <dependencies> 11 | <dependency> 12 | <groupId>org.testng</groupId> 13 | <artifactId>testng</artifactId> 14 | <version>RELEASE</version> 15 | <scope>test</scope> 16 | </dependency> 17 | 18 | <!-- https://mvnrepository.com/artifact/org.mockito/mockito-core --> 19 | <dependency> 20 | <groupId>org.mockito</groupId> 21 | <artifactId>mockito-core</artifactId> 22 | <version>3.11.2</version> 23 | <scope>test</scope> 24 | </dependency> 25 | 26 | <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson --> 27 | <dependency> 28 | <groupId>com.google.code.gson</groupId> 29 | <artifactId>gson</artifactId> 30 | <version>2.8.7</version> 31 | </dependency> 32 | 33 | <dependency> 34 | <groupId>io.javalin</groupId> 35 | <artifactId>javalin</artifactId> 36 | <version>3.13.7</version> 37 | </dependency> 38 | 39 | <dependency> 40 | <groupId>org.slf4j</groupId> 41 | <artifactId>slf4j-simple</artifactId> 42 | <version>1.7.30</version> 43 | </dependency> 44 | 45 | <!-- https://mvnrepository.com/artifact/org.postgresql/postgresql --> 46 | <dependency> 47 | <groupId>org.postgresql</groupId> 48 | <artifactId>postgresql</artifactId> 49 | <version>42.2.22</version> 50 | </dependency> 51 | 52 | 53 | 54 | </dependencies> 55 | 56 | <properties> 57 | <maven.compiler.source>14</maven.compiler.source> 58 | <maven.compiler.target>14</maven.compiler.target> 59 | <sonar.projectKey>adamranieri_CommunityLibrary</sonar.projectKey> 60 | <sonar.organization>adamranieri-github</sonar.organization> 61 | <sonar.host.url>https://sonarcloud.io</sonar.host.url> 62 | </properties> 63 | 64 | </project> -------------------------------------------------------------------------------- /CommunityLibrariAPI/src/main/java/dev/ranieri/app/App.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.app; 2 | 3 | import dev.ranieri.controllers.BookController; 4 | import dev.ranieri.daos.BookDAO; 5 | import dev.ranieri.daos.BookDaoPostgres; 6 | import dev.ranieri.services.BookService; 7 | import dev.ranieri.services.BookServiceImpl; 8 | import io.javalin.Javalin; 9 | 10 | public class App { 11 | 12 | public static void main(String[] args) { 13 | Javalin app = Javalin.create(config -> { 14 | // optionaally you can pass in a lambda into the create method for extra steps in creating your 15 | // Javalin app 16 | config.enableCorsForAllOrigins(); 17 | config.enableDevLogging(); 18 | 19 | }); 20 | 21 | BookDAO bookDAO = new BookDaoPostgres(); 22 | BookService bookService = new BookServiceImpl(bookDAO); 23 | BookController bookController = new BookController(bookService); 24 | 25 | // get /books 26 | app.get("/books", bookController.getAllBooks); // The handler is the function to be executed when a get request is sent to that URI 27 | // you are passing in the funciton DEFINITION not invoking the function 28 | 29 | // get /books/5 30 | app.get("/books/:id", bookController.getBookById); 31 | 32 | // post /books 33 | app.post("/books",bookController.createBook); 34 | 35 | // put /books/15 36 | //app.put("/books/:id",null); 37 | 38 | // delete /books/4 39 | //app.delete("/books/:id",null); 40 | 41 | // patch checkin/19 42 | //app.patch("/checkin/:id", null); 43 | 44 | // patch checkout/20 45 | //app.patch("/checkout/:id",null); 46 | 47 | app.start(); // defaults to port 7000 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /CommunityLibrariAPI/src/main/java/dev/ranieri/daos/BookDAO.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.daos; 2 | 3 | import dev.ranieri.entities.Book; 4 | import dev.ranieri.exceptions.ResourceNotFound; 5 | 6 | import java.util.List; 7 | 8 | // Proper Interface for our DAO 9 | public interface BookDAO { 10 | 11 | //CREATE 12 | Book createBook(Book book); 13 | 14 | //READ 15 | Book getBookById(int id); 16 | List<Book> getAllBooks(); // You should ALWAYS be using the interfaces 17 | 18 | //UPDATE 19 | Book updateBook(Book book); 20 | 21 | //DELETE 22 | boolean deleteBookById(int id); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /CommunityLibrariAPI/src/main/java/dev/ranieri/daos/BookDaoLocal.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.daos; 2 | 3 | import dev.ranieri.entities.Book; 4 | 5 | import java.util.ArrayList; 6 | import java.util.HashMap; 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | // This type of class is sometimes called a stub 11 | // A stub is an implemented class that you use for testing or developing another piece of code (often removed 12 | // once a real implementation comes along) 13 | // similar to mocking except a mock HAS NO underlying logic 14 | public class BookDaoLocal implements BookDAO{ 15 | 16 | private static Map<Integer,Book> bookTable = new HashMap<>(); 17 | private static int idMaker = 0; 18 | 19 | @Override 20 | public Book createBook(Book book) { 21 | int key = ++BookDaoLocal.idMaker; 22 | book.setBookId(key); 23 | BookDaoLocal.bookTable.put(key,book); 24 | return book; 25 | } 26 | 27 | @Override 28 | public Book getBookById(int id) { 29 | return BookDaoLocal.bookTable.get(id); // autoboxing 30 | } 31 | 32 | @Override 33 | public List<Book> getAllBooks() { 34 | List<Book> books = new ArrayList<>(BookDaoLocal.bookTable.values()); 35 | return books; 36 | } 37 | 38 | @Override 39 | public Book updateBook(Book book) { 40 | BookDaoLocal.bookTable.put(book.getBookId(),book); 41 | return book; 42 | } 43 | 44 | @Override 45 | public boolean deleteBookById(int id) { 46 | Book book = BookDaoLocal.bookTable.remove(id); 47 | if(book == null){ 48 | return false; 49 | }else{ 50 | return true; 51 | } 52 | 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /CommunityLibrariAPI/src/main/java/dev/ranieri/exceptions/ResourceNotFound.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.exceptions; 2 | 3 | // if this is a runtime exception there is no guarantee that it is caught and handled somewhere 4 | // if this is a checked exception it MUST be handled before leaving java 5 | public class ResourceNotFound extends RuntimeException{ 6 | 7 | public ResourceNotFound(String message){ 8 | super(message); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /CommunityLibrariAPI/src/main/java/dev/ranieri/services/BookService.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.services; 2 | 3 | import dev.ranieri.entities.Book; 4 | import dev.ranieri.exceptions.ResourceNotFound; 5 | 6 | import java.util.List; 7 | 8 | public interface BookService { 9 | 10 | Book registerBook(Book book); 11 | 12 | List<Book> retrieveAllBooks(); 13 | 14 | Book retrieveBookById(int id); 15 | 16 | List<Book> getBooksByTitle(String title); 17 | 18 | Book updateBook(Book book); 19 | 20 | boolean decommissionBookById(int id); 21 | 22 | Book checkinById(int id); 23 | 24 | Book checkoutById(int id); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /CommunityLibrariAPI/src/main/java/dev/ranieri/services/BookServiceImpl.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.services; 2 | 3 | import dev.ranieri.daos.BookDAO; 4 | import dev.ranieri.entities.Book; 5 | import dev.ranieri.exceptions.ResourceNotFound; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | public class BookServiceImpl implements BookService { 11 | 12 | private BookDAO bookDAO = null; // dependencies are usually private 13 | 14 | public BookServiceImpl(BookDAO bookDAO){ 15 | this.bookDAO = bookDAO; // dependency injection 16 | } 17 | 18 | @Override 19 | public Book registerBook(Book book) { 20 | return this.bookDAO.createBook(book); 21 | } 22 | 23 | @Override 24 | public List<Book> retrieveAllBooks() { 25 | return this.bookDAO.getAllBooks(); 26 | } 27 | 28 | @Override 29 | public Book retrieveBookById(int id) throws ResourceNotFound { 30 | return this.bookDAO.getBookById(id); 31 | } 32 | 33 | @Override 34 | public List<Book> getBooksByTitle(String title) { 35 | List<Book> books = this.bookDAO.getAllBooks(); 36 | List<Book> filteredBooks = new ArrayList<>(); 37 | 38 | for(Book b : books){ 39 | if(b.getTitle().contains(title)){ 40 | filteredBooks.add(b); 41 | } 42 | } 43 | 44 | return filteredBooks; 45 | } 46 | 47 | @Override 48 | public Book updateBook(Book book) { 49 | return this.bookDAO.updateBook(book); 50 | } 51 | 52 | @Override 53 | public boolean decommissionBookById(int id) { 54 | return this.bookDAO.deleteBookById(id); 55 | } 56 | 57 | @Override 58 | public Book checkinById(int id) throws ResourceNotFound { 59 | Book book = this.bookDAO.getBookById(id); 60 | book.setAvailable(true);; 61 | book.setReturnDate(0); 62 | this.bookDAO.updateBook(book); 63 | return book; 64 | } 65 | 66 | @Override 67 | public Book checkoutById(int id) throws ResourceNotFound { 68 | Book book = this.bookDAO.getBookById(id); 69 | book.setAvailable(false); 70 | book.setReturnDate(System.currentTimeMillis() + 1_209_600); 71 | this.bookDAO.updateBook(book); 72 | return book; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /CommunityLibrariAPI/src/main/java/dev/ranieri/utils/ConnectionUtil.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.utils; 2 | 3 | import java.sql.Connection; 4 | import java.sql.DriverManager; 5 | import java.sql.SQLException; 6 | 7 | public class ConnectionUtil { 8 | 9 | public static Connection createConnection(){ 10 | // jdbc:postgresql://ranieridb.cyysbedq8cqc.us-east-1.rds.amazonaws.com:5432/postgres?user=adam&password=gatorfan1 11 | try { 12 | Connection connection = DriverManager.getConnection("jdbc:postgresql://ranieridb.cyysbedq8cqc.us-east-1.rds.amazonaws.com:5432/postgres?user=adam&password=gatorfan1"); 13 | return connection; 14 | } catch (SQLException sqlException) { 15 | sqlException.printStackTrace(); 16 | return null; 17 | } 18 | } 19 | 20 | // quick way to test if successful 21 | public static void main(String[] args) { 22 | System.out.println(createConnection()); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /CommunityLibrariAPI/src/test/java/dev/ranieri/servicetests/BookServiceTests.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.servicetests; 2 | 3 | import dev.ranieri.daos.BookDAO; 4 | import dev.ranieri.entities.Book; 5 | import dev.ranieri.services.BookService; 6 | import dev.ranieri.services.BookServiceImpl; 7 | import org.mockito.Mockito; 8 | import org.testng.Assert; 9 | import org.testng.annotations.BeforeMethod; 10 | import org.testng.annotations.Test; 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | public class BookServiceTests { 15 | 16 | BookDAO bookDAO = Mockito.mock(BookDAO.class); // create a mock instance 17 | BookService bookService = new BookServiceImpl(bookDAO); 18 | 19 | @BeforeMethod // before each test reset anything on our mock object 20 | void init() { 21 | List<Book> testBooks = new ArrayList<>(); 22 | Book book1 = new Book(0,"A stitch in time","",true,1,0); 23 | Book book2 = new Book(0,"Z is for zebra","",true,1,0); 24 | Book book3 = new Book(0,"Crime and Punishment","",true,1,0); 25 | testBooks.add(book1); 26 | testBooks.add(book2); 27 | testBooks.add(book3); 28 | Mockito.when(this.bookDAO.getAllBooks()).thenReturn(testBooks); 29 | } 30 | 31 | @Test 32 | void find_by_title(){ 33 | List<Book> books = this.bookService.getBooksByTitle("zebra"); 34 | Assert.assertEquals(books.size(),1); 35 | Assert.assertEquals(books.get(0).getTitle(),"Z is for zebra"); 36 | } 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /CommunityLibrariAPI/src/test/java/dev/ranieri/testngbasics/TestNgBasics.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.testngbasics; 2 | 3 | import org.testng.annotations.AfterClass; 4 | import org.testng.annotations.BeforeClass; 5 | import org.testng.annotations.BeforeMethod; 6 | import org.testng.annotations.Test; 7 | 8 | // We will be using TestNG for Java testing Test Next Generation 9 | // it is second to JUnit in popularity but it's VERY similar 10 | // all test methods @Test or the @Before @After are all void return types 11 | public class TestNgBasics { 12 | 13 | // In Java any test that executes PASSES so long as as it does not throw an error 14 | 15 | @BeforeClass // will execute this setup method before any of the tests 16 | static void setup(){ 17 | System.out.println("BEFORE CLASS"); 18 | } 19 | 20 | @BeforeMethod 21 | void smallerSetup(){ 22 | System.out.println("BEFORE EVERY TEST METHOD"); 23 | } 24 | 25 | @Test(priority = 1)// priority is the way to run your tests in order // by default alpha-numeric 26 | void c(){ 27 | System.out.println("Hello"); 28 | } 29 | 30 | // @Test(priority = 2) 31 | // void a(){ 32 | // System.out.println("Will fail"); 33 | // throw new RuntimeException("EpicFail"); 34 | // } 35 | 36 | @Test(priority = 3) 37 | void b(){ 38 | System.out.println("Will pass"); 39 | } 40 | 41 | @AfterClass 42 | static void teardown(){ 43 | System.out.println("AFTER CLASS"); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /CommunityLibrariAPI/src/test/resources/alltests.xml: -------------------------------------------------------------------------------- 1 | <!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd" > 2 | 3 | <suite name="AllTests" verbose="1" > 4 | <test name="dao tests"> 5 | <classes> 6 | <class name="dev.ranieri.daotests.BookDaoTests"></class> 7 | </classes> 8 | </test> 9 | <test name="service tests"> 10 | <classes> 11 | <class name="dev.ranieri.servicetests.BookServiceTests"></class> 12 | </classes> 13 | </test> 14 | </suite> 15 | -------------------------------------------------------------------------------- /CommunityLibrariAPI/src/test/resources/daotests.xml: -------------------------------------------------------------------------------- 1 | <!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd" > 2 | 3 | <suite name="DAO tests" verbose="1" > 4 | 5 | <test name="Book DAO"> 6 | <classes> 7 | <class name="dev.ranieri.daotests.BookDaoTests"></class> 8 | </classes> 9 | </test> 10 | 11 | </suite> -------------------------------------------------------------------------------- /DOM/domintro.html: -------------------------------------------------------------------------------- 1 | <!DOCTYPE html> 2 | <html lang="en"> 3 | <head> 4 | <title>Dom Intro 5 | 6 | 11 | 12 | 13 |

Inline JS

14 |

Internal JS

15 |

external JS

16 | 17 | 18 | 19 | 24 | 25 | -------------------------------------------------------------------------------- /DOM/eventlistener.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Events 5 | 6 | 7 | 8 |

You have not clicked on hello

9 | 10 | 11 | 23 | -------------------------------------------------------------------------------- /DOM/inputs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Greeter 5 | 6 | 7 | 8 | 9 |

Hello Random person

10 | 11 | 12 | 24 | -------------------------------------------------------------------------------- /DOM/notetracker.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Document 5 | 6 | 7 |

Super Awesome Note Tracker

8 | 9 | 10 | 11 | 12 |

Tasks

13 | 16 | 17 | 18 | 31 | -------------------------------------------------------------------------------- /DOM/outside.js: -------------------------------------------------------------------------------- 1 | function external(){ 2 | alert("External JS") 3 | } -------------------------------------------------------------------------------- /Day1Python/controlflow.py: -------------------------------------------------------------------------------- 1 | # Python has your typical if else while for as most programming languages 2 | 3 | x = 1 4 | # Python does NOT use curly brackets 5 | # It uses colons, new lines and indenting to create 'blocks' of code 6 | if x < 10: 7 | print("The value is less than 10") 8 | elif x==10: # else if 9 | print("The value is 10") 10 | else: 11 | print("The Value is 10 or greater") 12 | 13 | i = 0 14 | while i<100: 15 | 16 | if i % 2 == 0: 17 | print("even" + str(i)) 18 | else: 19 | print("odd" + str(i)) 20 | 21 | if i == 50: 22 | break 23 | 24 | i = i + 1 25 | # identical to 26 | # i += 1 27 | print(i)# 100 28 | 29 | -------------------------------------------------------------------------------- /Day1Python/datatypes.py: -------------------------------------------------------------------------------- 1 | # Python has quite a few data types. It considers it's collections (think list or array or dicitonary) as a datatype 2 | 3 | # numeric types 4 | i = 100 # of type int (integer type) 5 | ii: int = 100 6 | 7 | f = 100.7 # of type float (decimal values) 8 | ff: float = 1986.5 9 | 10 | # text types 11 | s = "Hello Everyone" # of type str (strings and text) there is NO character type 12 | ss: str = "Hello Everyone" 13 | 14 | # Boolean type 15 | t = True # boolean values are True or False 16 | f = False 17 | tt: bool = True 18 | 19 | # NoneType 20 | # Python does not have null instead it has None 21 | # very similar to null and functionally identical in most ways 22 | n = None 23 | 24 | # to find the type of something there is an in built type function 25 | print(type(i)) 26 | 27 | -------------------------------------------------------------------------------- /Day1Python/forloopsranges.py: -------------------------------------------------------------------------------- 1 | 2 | # Java for loop: for(int i =0;i<100;i++){code} 3 | 4 | # Python uses ranges for iterating a piece of code a fixed amount of times 5 | 6 | #range(startnumber, targetnumber(exclusive)) 7 | # for i in range(0,10): 8 | # print(i) 9 | 10 | # the third parameter is the step (how much to increment or decrement if negative) 11 | # for j in range(10,0,-1): 12 | # print(j) 13 | 14 | # for x in range(100,1000,3): 15 | # print(x) 16 | 17 | 18 | 19 | names = ["Adam","Bob","Alice","Tim"] 20 | 21 | #YOU SHOULD ALMOST NEVER be creating a range to iterate over a list 22 | for x in names: # iterate over a list 23 | print(x) 24 | 25 | # Strings are iterable 26 | hello = "Hello" 27 | 28 | for c in hello: 29 | print(c) # print out each character 30 | 31 | # Technically the same but do not do. Looks way worse and harder to read 32 | for i in range(0,len(hello)): 33 | print(hello[i]) 34 | 35 | # iterate 12 times 36 | for l in range(12): 37 | print(l) 38 | 39 | # print(hello[1]) # prints outs just e 40 | 41 | for i,c in enumerate(hello): 42 | if i == 1: 43 | print(c) 44 | 45 | x = 909 46 | 47 | for x in range(0,19): # x will initalize to 0 at the start of the for 48 | print(x) 49 | 50 | print(x) # 18 -------------------------------------------------------------------------------- /Day1Python/functions.py: -------------------------------------------------------------------------------- 1 | 2 | # function is a a reusable chunk of code 3 | # they can have parameters where you pass in arguments 4 | 5 | # def for define 6 | # void functions do not return anything (if you do not return something from a function is returns the None object) 7 | def hello(): 8 | print("This is a simple function") 9 | print("It just says Hello!!") 10 | 11 | def greet_person(name: str): 12 | print("Hello" + name) 13 | 14 | # x = hello() 15 | # print(x) 16 | # I HIGHLY reccomend using type annotaions for your functions 17 | def greater_number(num1:float, num2:float) -> float: 18 | if num1 > num2: 19 | return num1 20 | else: 21 | return num2 22 | 23 | i= greater_number(90.1, 154.2) 24 | print(i) 25 | 26 | # takes in a string and returns how many vowels it has 27 | def num_caps(phrase: str) -> int: 28 | counter = 0 29 | 30 | for c in phrase: 31 | if c.isupper(): 32 | counter +=1 33 | 34 | return counter 35 | 36 | 37 | ups = num_caps("sldnDALKfsdfknweoiDDS") 38 | print(ups) 39 | 40 | def multi_print(phrase: str, times: int) -> None: 41 | for i in range(times): 42 | print(phrase) 43 | 44 | # in python you can pass arguments in positionally like, Java or JS 45 | multi_print("Hello Everyone",10) 46 | 47 | #you can pass in functions using the named variables 48 | # identical to the previous function call 49 | multi_print(times = 10, phrase="Hello Everyone") 50 | multi_print(phrase ="Hello Everyone", times=10) -------------------------------------------------------------------------------- /Day1Python/hello.py: -------------------------------------------------------------------------------- 1 | print("Hello World") 2 | -------------------------------------------------------------------------------- /Day1Python/operators.py: -------------------------------------------------------------------------------- 1 | # Python operators work like most programming languages 2 | 3 | # arithmetic operators 4 | a = 10 + 10 # add 5 | b = 100 - 40 # subtract 6 | c = 5 * 4 # multiply 7 | d = 10/2 # divide 8 | e = 4**3 # 4 to the power of 3 9 | f = 10//3 # floor division operator output is 20 the division rounded down 10 | g = 10%3 # modulous gets the remainder 11 | 12 | # comparison operators 13 | 14 | x = 100 15 | y = 100 16 | 17 | 18 | x == y # is equal to (different than) the "value" is the same 19 | x != y # not equal to 20 | x > y # greater than 21 | y < x # less than 22 | x >= y # greater than or equal to 23 | x <= y # less than or equal to 24 | 25 | # logical operators 26 | x == y and y < 1000 or y ==9 27 | 28 | 29 | # is the letter g not in a string 30 | print("g" not in "lskdfldsknflnk") 31 | 32 | # python has a really weird ternary that I am not a huge fan of 33 | x = "Hello" if 4<5 else "World" -------------------------------------------------------------------------------- /Day1Python/userinput.py: -------------------------------------------------------------------------------- 1 | name = input("Please enter your name") 2 | print("Hello" + name) -------------------------------------------------------------------------------- /Day2Python/closures.py: -------------------------------------------------------------------------------- 1 | 2 | def outer(name): 3 | 4 | greeting ="How are you " + name 5 | 6 | def innner(): 7 | print(greeting) 8 | 9 | return innner 10 | 11 | adam_greeter = outer("Adam") 12 | bill_greeter =outer("Bill") 13 | adam_greeter() 14 | bill_greeter() 15 | 16 | 17 | def is_palindrome(phrase: str): 18 | 19 | def reverse(word): 20 | return word[::-1] 21 | 22 | if phrase == reverse(phrase): 23 | return True 24 | else: 25 | False 26 | -------------------------------------------------------------------------------- /Day2Python/collections_dictionaries.py: -------------------------------------------------------------------------------- 1 | # Dictionaries 2 | 3 | # Data structurs that store things as key value pairs 4 | # Key : value 5 | # Dictionaries DO NOT ALLOW duplicate keys 6 | # You can add or remove KV pairs from a dictionary or edit the values inside of it 7 | 8 | def welcome(): 9 | print("Welcome") 10 | 11 | emails = { 12 | "Adam":{"phone number": "555-555-5555", "email":"adam.ranieri@revature.com"}, 13 | "Richard":"leetsnipz@hotmail.com", 14 | "Sierra": "hikerwoman96@gmail.com", 15 | "func": welcome, 16 | "Nichols": "hikerwoman96@gmail.com", 17 | 965: "Hello World", # you can have , 18 | None: 1000 19 | } 20 | 21 | emails["func"]() -------------------------------------------------------------------------------- /Day2Python/collections_list.py: -------------------------------------------------------------------------------- 1 | # Python common data structures 2 | # data structures are just ways for us to store information for easy access and use 3 | names = ["Adam", "Bill", "Steve"] 4 | 5 | # lists will reisize as needed and can store any type 6 | # lists are MUTABLE always add or remove elements 7 | # lists can contain duplicates 8 | 9 | stuff = ["Apple", 4, [[],1], 9.8, 4 ,4 ,4 ,4] 10 | print(stuff) 11 | stuff2 = stuff # points to the same list 12 | print(stuff2 is stuff) # NOT THE EQUALITY operator. Are they the same EXACT OBJECT IN MEMORY 13 | # to create a list 14 | my_list = [] 15 | print(my_list) 16 | my_list.append("Hello") 17 | print(my_list) 18 | my_list.append("World") # always adds at the end of the list 19 | print(my_list) 20 | # delete an item from a list 21 | del my_list[1] 22 | print(my_list) 23 | my_list.insert(1,"!") 24 | 25 | stuff2.append("Added just random string") 26 | print(stuff) 27 | -------------------------------------------------------------------------------- /Day2Python/collections_sets.py: -------------------------------------------------------------------------------- 1 | # Sets 2 | # Sets are MUTABLE add, remove, edit 3 | # Sets do NOT allow duplicates 4 | # Sets can store any types 5 | # Sets will increase and descrease dynamiclly in size 6 | # Sets DO NOT MAINTAIN THE INSERTION ORDER of elements inside of them 7 | # Sets are NOT INDEXABLE 8 | 9 | wvu_eployees = {"Adam", "Richard", "Sierra", "Dan", "Ryan"} 10 | wvu_eployees.add("Steven") 11 | 12 | # print(wvu_eployees[2]) # ERROR cannot get by index 13 | 14 | wvu_eployees.add("Steven") 15 | wvu_eployees.add("Steven") 16 | wvu_eployees.add("Steven") 17 | for employee in wvu_eployees: 18 | print(employee) 19 | 20 | print("Adam" in wvu_eployees) 21 | -------------------------------------------------------------------------------- /Day2Python/collections_tuples.py: -------------------------------------------------------------------------------- 1 | # Tuples 2 | # Tuples are immutable 3 | # Tuples can be of any size when first created 4 | # Tuples can have duplicate 5 | # Tuples can have values of any type 6 | 7 | # Tuples are created much like lists except with paranthesis 8 | ssbu_fighters = ("Peach","Zelda","Little Mac", "Samus", 4, 6, 2, 3, 4) 9 | 10 | print(ssbu_fighters[2]) 11 | 12 | print(ssbu_fighters[0:2]) 13 | 14 | # code to the principle of least privellage 15 | # if the values do not need to be altered then do not make it mutable -------------------------------------------------------------------------------- /Day2Python/enclosing.py: -------------------------------------------------------------------------------- 1 | welcome = "Global welcome variable" 2 | 3 | def greet(): 4 | welcome = "local welomce variable" # creates a brand new variable also called welcome 5 | print(welcome) # LEGB to deterime what this welcome variable refers to 6 | # the nearest namespace is the local one defined on like 5 7 | 8 | name = "Globy McGlobeFace" 9 | # if python cannot find an enclosing one it will check the global namespace for a variable named name 10 | if True: 11 | name = "Enclosing McEnclose" #if python cannot find a local variable named name it see if 12 | # there are enclosing variables of that name 13 | if True: 14 | name = "Enclosing McEnlose Junior " 15 | if True: 16 | name = "Local McLocal" 17 | print(name) # python will look for a local variable named name 18 | #print(noexist) 19 | # python 20 | # checked local: not found: 21 | # check enclosing: not found, 22 | # checked global: not found 23 | # checked built in: not found 24 | # NameError 25 | 26 | -------------------------------------------------------------------------------- /Day2Python/example.py: -------------------------------------------------------------------------------- 1 | import namespaces # think of an import as a shortand for copy and pasting your code 2 | 3 | x = "Alternate x" 4 | 5 | print(x) 6 | -------------------------------------------------------------------------------- /Day2Python/fancyfunctions.py: -------------------------------------------------------------------------------- 1 | # Python is a dyanmic language that does NOT support function overloading 2 | # this is a problem for develpers because renaming essentially the same function for all the types of 3 | # parameters would be a mess 4 | def say_hello(): 5 | print("Hello Person") 6 | 7 | def say_hello(name: str): # this line will REPLACE the function defined on line 3 8 | print(f"Hello {name}") 9 | 10 | # default arguments 11 | def hola(name: str = None): 12 | if name is None: 13 | print("Hola random person") 14 | else: 15 | print(f"Hola {name}") 16 | 17 | hola() 18 | hola("Adam") 19 | 20 | def greet_many(*names): # var args essentially a tuple 21 | for n in names: 22 | print("Hello" + n) 23 | 24 | # greet_many("Adam","Bill","Steve","Joseph") 25 | 26 | def super_greet(**kwargs): # Key Word arguments essentially made your argumenst a dictionary 27 | print(kwargs["adam"]) 28 | 29 | super_greet(adam="Adam Ranieri", richard = "Richard Orr", sierra = "Sierra Nichols") 30 | 31 | # kwargs are really popular for configuration function 32 | # creating a conneciton to a database 33 | 34 | def connect_to_datbase(**kwargs): 35 | username = kwargs["username"] 36 | password = kwargs["password"] 37 | print(username) 38 | print(password) 39 | 40 | connect_to_datbase(username="adamgator",password="123pass") 41 | 42 | credentials = {"username":"adamgator","password":"123pass"} 43 | connect_to_datbase(**credentials) -------------------------------------------------------------------------------- /Day2Python/namespaces.py: -------------------------------------------------------------------------------- 1 | # LEGB namespaces 2 | # Local 3 | # Enclosing 4 | # Global 5 | # Built - in 6 | # When you define a variable the namespace determines where you access it 7 | # what variable you are referring to 8 | 9 | # Highest level name space 10 | # built in namespace the variables and functions that are built- in to the language 11 | # print(id) 12 | 13 | # global name space is any variable or funciton defined at the TOP-level of a python file 14 | x = 100 # this is a global variable 15 | # it can be used anywhere in this file or used in another file 16 | 17 | 18 | 19 | 20 | # local variables are defined WITHIN a function or a code block 21 | def say_hello(): 22 | greeting = "Hello everyone" # greeting is a local variable it is NOT global 23 | # you cannot use it outside of this function 24 | # you cannot get it another file 25 | print(greeting) 26 | 27 | say_hello() 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Day2Python/objects202.py: -------------------------------------------------------------------------------- 1 | class Car: 2 | 3 | total_cars = 0 4 | 5 | def __init__(self, make: str, model: str, year: int, owner: str, mileage: int = 0) -> None: 6 | self.make = make 7 | self.model = model 8 | self.year = year 9 | self.owner = owner 10 | self.mileage = mileage 11 | Car.total_cars += 1 12 | 13 | def __str__(self): 14 | return f"Make: {self.make}, Model: {self.model}, Year: {self.year}, Owner: {self.owner}, Miles: {self.mileage}" 15 | 16 | def drive_car(self, distance: int): 17 | print(f"Driving the car {distance} miles") 18 | self.mileage += distance 19 | 20 | #class method. A method that is attached to the class 21 | #it does not pass in self as the first argument because it does not need a car instance 22 | # for it to work. Think static in Java 23 | def miles_to_kilos(miles: int): 24 | kilos = miles*1.6 25 | return kilos 26 | 27 | # Objects are mutable and you can always attached new properties to the instance 28 | def paint_car(self, color: str): 29 | self.color = color 30 | 31 | 32 | 33 | 34 | crosstrek = Car("Subaru","Crosstrek",2018,"Adam Ranieri") 35 | print(crosstrek) 36 | 37 | crosstrek.drive_car(100) 38 | print(crosstrek) 39 | crosstrek.drive_car(50) 40 | print(crosstrek) 41 | kilometers = Car.miles_to_kilos(87) 42 | print(kilometers) 43 | # crosstrek.miles_to_kilos(100) 44 | # Car.miles_to_kilos(crosstrek,100) 45 | # crosstrek.paint_car("White") 46 | # print(crosstrek.color) 47 | 48 | -------------------------------------------------------------------------------- /Day2Python/strings.py: -------------------------------------------------------------------------------- 1 | # Strings are one f the most common data types in any programming lanugage 2 | 3 | # A string literal is just defining a string as such 4 | name = "Adam" 5 | 6 | # String interpolation putting variables into a string 7 | greeeting = "Hello " + name + " it is great to meet you!" 8 | # f is format interpolate values into your string using {} 9 | greeeting = f"Hello {name} it is awesome to see you! {7<8}" 10 | # format method of strings 11 | greeeting = "Hello {} is is great to see you! Also something else {}".format(name, "Wassup") 12 | 13 | print(greeeting) 14 | 15 | # string slicing is being able to take substrings out of a larget string 16 | 17 | alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 18 | 19 | # start at 0 go the the 4th character. That is exclusive 20 | abc = alphabet[0:3] 21 | jk = alphabet[9:11] 22 | 23 | # negative index 24 | # print(alphabet[len(alphabet)-1]) 25 | 26 | # -1 is the last element -2 second to last etc 27 | # print(alphabet[-1]) 28 | 29 | # the last argument is the step 30 | everyother = alphabet[0::-2] 31 | # print(everyother) 32 | 33 | # reverse a string in python 34 | zyx = alphabet[::-1] 35 | print(zyx) 36 | l = list(alphabet) # generates a brand new list 37 | del l[2] 38 | print("".join(l))# brand new string 39 | 40 | # you can make anything a string by using the str function 41 | 42 | x = 100 43 | y = str(x) 44 | print(type(y)) 45 | 46 | # strings are immutable 47 | # cannot be altered once created 48 | 49 | phrase = "hello everyone" 50 | # phrase[8] = "A" # throws an error becuase strings CANNOT be altered once created 51 | 52 | -------------------------------------------------------------------------------- /Day3Python/calculator_app.py: -------------------------------------------------------------------------------- 1 | # This console application allows you to add two numbers together 2 | # Exceptions and try excepts add resiliency to your code 3 | # If all inputs are correct and everything is how it is supposed to be (Happy Path Execution) 4 | # Exceptions are for when code does not follow happy path execution 5 | print("Awesome adding app") 6 | in1 = input("Enter your first number") 7 | in2 = input("Enter your second number") 8 | 9 | try: 10 | num1 = float(in1) 11 | num2 = float(in2) 12 | sum = num1 + num2 13 | print("The sum is {}".format(sum)) 14 | except ValueError: 15 | print("That was an invalid number :[") 16 | finally: 17 | print("I print at the end") 18 | 19 | -------------------------------------------------------------------------------- /Day3Python/errors101.py: -------------------------------------------------------------------------------- 1 | # Python has errors and execptions. The exceptions usally have error in the name 2 | # The only REAL error is a syntax error. Exceptions are all LOGIC based. 3 | 4 | # Why do programs have exceptions at ALL? 5 | # if an error manages to avoid being caught by an except block all the way up the program 6 | # your application may crash 7 | def celcius_to_farenheit(c): 8 | try: 9 | f = c*9/5 +32 10 | return f 11 | except TypeError : # this except block will only catch TypeErrors 12 | print("Input must be an int or float") 13 | except: 14 | print("Some other error must have occured") 15 | finally: 16 | print("This code WILL always execute if there is an error or NOT") 17 | 18 | 19 | x = celcius_to_farenheit(8) 20 | print(x) 21 | print("last bit of code") 22 | 23 | # whenever you write code that has a possiblity of FAILING 24 | # you can surround the code in a try: except block 25 | # in the except clause you can OPTIONALLY put a type of error to check for 26 | # putting NOTHING is a catch ALL 27 | # the catch all blank except should ALWAYS go last 28 | # ONLY ONE except block is executed when an exception is caught 29 | -------------------------------------------------------------------------------- /Day3Python/inheritance.py: -------------------------------------------------------------------------------- 1 | # Inheritance in Python 2 | # Inheritance is the ability of one class to recieve attributes from another class 3 | # attributes are instance variables self.something and the methods def m(self) 4 | # Python DOES have multiple inheritence (It is very rare to actually have to use multiple inheritence) 5 | 6 | class Employee: 7 | 8 | 9 | def __init__(self, e_id:int, f_name: str, l_name: str) -> None: 10 | self.e_id = e_id 11 | self.f_name = f_name 12 | self.l_name = l_name 13 | 14 | def __str__(self) -> str: 15 | return f"The employee is {self.f_name} {self.l_name}" 16 | 17 | 18 | 19 | # you pass in the parent class Trainer inherits Employee 20 | class Trainer(Employee): 21 | 22 | def __init__(self, e_id: int, f_name: str, l_name: str, favorite_language: str) -> None: 23 | print("In trainer contstrutor") 24 | super().__init__(e_id, f_name, l_name) # IN PYTHON 25 | # EXPLICITY create your PARENT user the Parent class init dunder method 26 | self.favorite_language = favorite_language 27 | 28 | ## the double underscores are the DUNDER methods aka Magic Methods 29 | def __str__(self) -> str: 30 | return f"Trainer is {self.f_name} {self.l_name} and favorite language is {self.favorite_language}" 31 | 32 | 33 | adam = Trainer(202,"Adam","Ranieri", "TypeScript") 34 | print(adam) 35 | 36 | # Duck typing if it looks like a duck and quacks like a duck it is a duck 37 | # duck.quack() and it give you he output you want you might as well treat it like a duck -------------------------------------------------------------------------------- /Day3Python/lambda.py: -------------------------------------------------------------------------------- 1 | # a lambda is an anonymous function 2 | # () =>{} 3 | # popular in funcitonal programming 4 | 5 | 6 | nums = [1,2,3,4,5,6] 7 | result = map(lambda n : n*10,nums) 8 | # Lambdas are NOWHERE near as common or useful in python as in other languages JS 9 | for r in result: 10 | print(r) -------------------------------------------------------------------------------- /Day3Python/list_comprehension.py: -------------------------------------------------------------------------------- 1 | # A lot of times you want to generate a list based of a range or another list 2 | # A list comprehension is a really compact syntax 3 | 4 | # create a list of negative numbers 5 | nums = [1,2,-5,6,-6,10,12,-13] 6 | 7 | # negs = [] 8 | 9 | # for n in nums: 10 | # if n < 0: 11 | # negs.append(n) 12 | # print(negs) 13 | 14 | # nums2 = [element for element in iterable if boolean_condition ] 15 | nums2 = [n *-1 for n in nums if n < 0] 16 | print(nums2) 17 | 18 | nums2 =[] 19 | for n in nums: 20 | if n < 0: 21 | nums.append(n*-1) 22 | 23 | names = ["tim", "Adam", "steve"] 24 | 25 | # [map(x) for iterable if filter(x) ] 26 | super_names = [name for name in names] 27 | 28 | print(super_names) 29 | 30 | -------------------------------------------------------------------------------- /Day3Python/mini_app.py: -------------------------------------------------------------------------------- 1 | # We have been tasked with writing a short console applicaiton 2 | # to see if a person's username is valid 3 | # username has to be at least 6 character long 4 | # it must contain at least one number 5 | 6 | # one is that the construtor is already set up take take in message and disply the message when printed 7 | # second you cannot raise an object that is not an excpetion 8 | class InvalidUsernameError(Exception): 9 | 10 | error_description = "This error occurs when a username has improper values" 11 | 12 | def __init__(self, *args: object) -> None: 13 | super().__init__(*args) 14 | 15 | # def __str__(self) -> str: 16 | # return "You done goofed" 17 | 18 | 19 | 20 | def validate_username(username: str): 21 | 22 | if len(username)<6: 23 | raise InvalidUsernameError(f"usernme must be at least 6 character was: {len(username)}") 24 | 25 | contains_number: bool = False 26 | for c in username: 27 | if c.isnumeric(): 28 | contains_number = True 29 | 30 | if contains_number: 31 | return True 32 | else: 33 | raise InvalidUsernameError("username must include at least one number") 34 | 35 | # All errors in Python are Runtime. There are no checked exceptions 36 | # There is no way to know if a function raises an error until you actually call it 37 | try: 38 | validate_username("a123") 39 | except InvalidUsernameError as e: 40 | print(e.error_description) 41 | print(e) 42 | -------------------------------------------------------------------------------- /Day3Python/raising_errors.py: -------------------------------------------------------------------------------- 1 | # Common Errors in Python 2 | # LookUpError: get an index that does not exist from a list or tuple or use dictionary key that does not exist 3 | # TypeError: when you pass in a variable that is of the wrong type (pass in a str instead of int/float) 4 | # ValueError: when the type is right but the value of that variable is wrong 5 | # NameError: you reference a variable that does not exist 6 | 7 | # OFTEN functions will raise errors and NOT handle them 8 | # For functions that might be used throughout the program you can handle the errors 9 | # differently / most appropriately 10 | def celcius_to_farenheit(c): 11 | 12 | # Exceptions give you information on WHY something failed 13 | # And you might want to address them different 14 | if type(c) != int and type(c) != float: 15 | raise TypeError("Temperature must be a numeric type") # all errors are objects 16 | if c < -273: 17 | raise ValueError(f"Input Temperature {c} is below absoulate zero -273 C") 18 | 19 | f = c*9/5 +32 20 | return f 21 | 22 | try: 23 | result = celcius_to_farenheit(-400) 24 | except TypeError as e: # if you want the object put 25 | print(e) # prints out the message you passed when you created the Error 26 | # the __str__ for errors is to return the message it was created with 27 | except ValueError as e: 28 | print(e) 29 | except Exception as e: 30 | print(type(e)) # is a value error 31 | 32 | 33 | -------------------------------------------------------------------------------- /HelloWorld2/HelloWorld2.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /HelloWorld2/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | HelloWorld2 9 | 1.0-SNAPSHOT 10 | 11 | 12 | 14 13 | 14 14 | 15 | 16 | -------------------------------------------------------------------------------- /HelloWorld2/src/main/java/dev/ranieri/app/App.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.app; 2 | 3 | public class App { 4 | 5 | // main method. Entry point of every Java Application 6 | // string [] args is how you would pass in command line arguments to a Java application 7 | public static void main(String [] args) { 8 | System.out.println("Hello World"); 9 | sayHola();// Java is a compiled language. All code is read before the main method runs 10 | // you can define methods anywhere 11 | 12 | // Java has primitives. Values that are not connected to a class. ARE NOT OBJECTS 13 | // 8 primitives 14 | boolean b = true; // N/A 15 | byte y = 120;// 1 byte 16 | char c = 'm'; // 2 bytes support a single character are actually numbers 17 | short s = 50;// 2 bytes 18 | int i = 100000;// 4 bytes 19 | float f = 100.9f; // 4 bytes decimal 20 | long l = 88888888; // 8 bytes 21 | double d = 99.572; // 8 bytes decimal 22 | 23 | char cc = 100 + 2; // no problem 24 | System.out.println(cc); // ascii value 25 | 26 | // Java DOES have object versions of primitives they are called wrappers (wrapper classes) 27 | Integer j = 90; 28 | Short k = 8; 29 | // Encouraged to use Primitives as your default and use wrapper classes only when applicable 30 | // 31 | // long start = System.nanoTime(); 32 | // for(int g =0;g<100_000;g++){ 33 | // // adding 1 to g 100,000 times 34 | // } 35 | // long end = System.nanoTime(); 36 | // System.out.println((end-start)/1000); 37 | 38 | Person adam = new Person("Adam Ranieri", 19); 39 | System.out.println(adam); 40 | 41 | // new means allocate memory for an object 42 | // UNLESS you use the word new to create an object you cannot be 100% that you acutally created 43 | // a new object in memory 44 | Person tim = new Person("Tim", 30); 45 | System.out.println(tim); 46 | adam.introduceSelf(); 47 | 48 | 49 | } 50 | 51 | static void sayHola(){ // void is the return type means the method does not return anything 52 | System.out.println("Hola Mundo"); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /HelloWorld2/src/main/java/dev/ranieri/app/Person.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.app; 2 | 3 | public class Person { 4 | 5 | // static variables and methods belong to the class itself 6 | // Essentially class variables in Python 7 | static int counter = 0; 8 | 9 | // instance variables 10 | String name; 11 | int age; 12 | 13 | 14 | // Constructors in Java are not __init__ or a specific keyword 15 | // A method with the SAME EXACT name as the class 16 | // Constructors are the ONLY methods in Java to NOT have a return Type 17 | Person(String name, int age){ 18 | this.name = name; 19 | this.age = age; 20 | Person.counter += 1; // You can access class variables just like in Python 21 | // counter += 1; // You can omit the class name so long as it is unambiguous in the code 22 | } 23 | 24 | public void introduceSelf(){ 25 | System.out.println("Hi my name is " + this.name); 26 | } 27 | 28 | //toString is like __str__ in Python. 29 | // String representation of an abject 30 | @Override // Annotation. Annotations cannnot directly impact code 31 | // @Override is optional 32 | // throws an error if the method is NOT overriding something 33 | // but is not needed to actually override something 34 | // @ in python vs Java are VERY DIFFERENT in functionality 35 | public String toString(){ 36 | return "Name: " + this.name +" Age: " + this.age; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /HelloWorld2/target/classes/dev/ranieri/app/App.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/HelloWorld2/target/classes/dev/ranieri/app/App.class -------------------------------------------------------------------------------- /HelloWorld2/target/classes/dev/ranieri/app/Person.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/HelloWorld2/target/classes/dev/ranieri/app/Person.class -------------------------------------------------------------------------------- /HelloWorldServer/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /HelloWorldServer/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /HelloWorldServer/.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | -------------------------------------------------------------------------------- /HelloWorldServer/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /HelloWorldServer/HelloWorldServer.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /HelloWorldServer/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | HelloWorldServer 9 | 1.0-SNAPSHOT 10 | 11 | 12 | 14 13 | 14 14 | 15 | 16 | 17 | 18 | 19 | io.javalin 20 | javalin 21 | 3.13.7 22 | 23 | 24 | 25 | org.slf4j 26 | slf4j-simple 27 | 1.7.30 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /HelloWorldServer/src/main/java/dev/ranieri/app/App.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.app; 2 | 3 | import io.javalin.Javalin; 4 | import io.javalin.http.Handler; 5 | 6 | public class App { 7 | 8 | public static void main(String[] args) { 9 | // Javalin is a micro framework for making web servers in Java 10 | // Java version of Flask. It functions VERY similarly. Just slight differences 11 | Javalin app = Javalin.create(); 12 | 13 | // first param is the route, second param is a lambda/function to execute when that route is activated 14 | // similar to an event listener in JS 15 | app.get("/hello/:name", ctx ->{ 16 | String name = ctx.pathParam("name"); 17 | ctx.result("Hi you hit the hello end point =) " + name); 18 | }); 19 | 20 | // define the function elsewhere 21 | Handler sayHola = ctx ->{ 22 | ctx.result("Hola todos"); 23 | }; 24 | 25 | // pass the function as a callback 26 | app.get("/hola", sayHola); 27 | 28 | 29 | 30 | 31 | app.start(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /HelloWorldServer/target/classes/dev/ranieri/app/App.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/HelloWorldServer/target/classes/dev/ranieri/app/App.class -------------------------------------------------------------------------------- /HelloWorldWebServer/main.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, request 2 | 3 | app:Flask = Flask(__name__) 4 | 5 | # @ is called a decorator in Python. It is actually a type of enclosed function 6 | # defines a route ("URI", methods = ["http request verbs you are listening for"]) 7 | # routes are also called endpoints 8 | 9 | @app.route("/hello/", methods = ["GET"]) 10 | def hello_world(name: str): 11 | return "Hello " + name 12 | 13 | @app.route("/hola", methods = ["GET"]) 14 | def hola_mundo(): 15 | return "Hola Mundo" 16 | # none of these functions are called immediately 17 | # Flask will call that function when it a request of that verb to that uri 18 | 19 | @app.route("/calculate//add/", methods = ["GET"]) 20 | def add(num1: str, num2: str ): 21 | sum = int(num1) + int(num2) 22 | return str(sum) 23 | # Get requests CANNOT have a body 24 | 25 | 26 | @app.route("/iseven", methods = ["POST"]) # POST requests CAN have a body 27 | def is_even(): 28 | body = request.get_json() # flask will auto convert jsons into Python dictionaries 29 | # it does this just as a helpful utility 30 | num = body["number"] 31 | if num % 2 == 0: 32 | return "It is even" 33 | else: 34 | return "odd" 35 | 36 | @app.route("/calcarea", methods = ["POST"]) 37 | def calculate_area(): 38 | body = request.json 39 | x = body["side1"] 40 | y = body["side2"] 41 | area = x * y 42 | return "the area of the rectangle is" + str(area) 43 | 44 | 45 | 46 | app.run() 47 | -------------------------------------------------------------------------------- /IntroToTDD/calculators/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/IntroToTDD/calculators/__init__.py -------------------------------------------------------------------------------- /IntroToTDD/calculators/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/IntroToTDD/calculators/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /IntroToTDD/calculators/__pycache__/temperature_calculator.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/IntroToTDD/calculators/__pycache__/temperature_calculator.cpython-39.pyc -------------------------------------------------------------------------------- /IntroToTDD/calculators/temperature_calculator.py: -------------------------------------------------------------------------------- 1 | 2 | # the science lab was some functions for converting between temperatures 3 | 4 | # 1. write the interface (Python does not have an interface keyword) 5 | from abc import ABC, abstractmethod 6 | 7 | 8 | # ABC is ABstract Class. An abstract Class is a class you cannot directly create 9 | class TemperatureCalculator(ABC): 10 | 11 | @abstractmethod 12 | def celcius_to_farenheit(self, temp: float) -> float: 13 | pass 14 | 15 | @abstractmethod 16 | def farenheit_to_celcius(self, temp: float) -> float: 17 | pass 18 | 19 | # converts from betwetween temps convert_temp(100,"C","F") 20 | @abstractmethod 21 | def convert_temp(self, temp: float, initial: str, target: str) -> float: 22 | pass 23 | 24 | 25 | 26 | 27 | class TemperatureCalculatorImpl(TemperatureCalculator): 28 | 29 | def celcius_to_farenheit(self, temp: float) -> float: 30 | f = (temp * 9/5) + 32 31 | return f 32 | 33 | 34 | def farenheit_to_celcius(self, temp: float) -> float: 35 | c = (temp-32) * 5/9 36 | return c 37 | 38 | 39 | def convert_temp(self, temp: float, initial: str, target: str) -> float: 40 | initial = initial.upper() 41 | target = target.upper() 42 | 43 | if initial not in ["C","F"] or target not in ["C","F"]: 44 | raise ValueError("Only the values f,F or c,C are acceptable ") 45 | 46 | if initial == "C" and target == "F": 47 | return self.celcius_to_farenheit(temp) 48 | elif initial == "F" and target == "C" : 49 | return self.farenheit_to_celcius(temp) 50 | 51 | -------------------------------------------------------------------------------- /IntroToTDD/demo/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/IntroToTDD/demo/__init__.py -------------------------------------------------------------------------------- /IntroToTDD/demo/four_functions.py: -------------------------------------------------------------------------------- 1 | 2 | def add(num1: float, num2: float) -> float: 3 | return num1 + num2 4 | 5 | 6 | def subtract(num1: float, num2: float) -> float: 7 | return num1-num2 8 | -------------------------------------------------------------------------------- /IntroToTDD/main.py: -------------------------------------------------------------------------------- 1 | 2 | from chart import bar 3 | 4 | from demo.four_functions import add, subtract 5 | 6 | x = [500, 200, 900, 400] 7 | y = ['marc', 'mummify', 'chart', 'sausagelink'] 8 | 9 | bar(x, y) 10 | x = add(10,9) 11 | y = add(7,4) 12 | subtract(x,y) 13 | 14 | 15 | -------------------------------------------------------------------------------- /IntroToTDD/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/IntroToTDD/tests/__init__.py -------------------------------------------------------------------------------- /IntroToTDD/tests/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/IntroToTDD/tests/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /IntroToTDD/tests/__pycache__/temp_calculator_tests.cpython-39-pytest-6.2.4.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/IntroToTDD/tests/__pycache__/temp_calculator_tests.cpython-39-pytest-6.2.4.pyc -------------------------------------------------------------------------------- /IntroToTDD/tests/temp_calculator_tests.py: -------------------------------------------------------------------------------- 1 | 2 | # tests are considered passing so long as no error escapes the function 3 | # def test_1(): 4 | # print("Hello test 1 ") 5 | # 6 | # def test_2(): 7 | # print("Hello test 2") 8 | # x = 90/0 9 | # 10 | # def test_3(): 11 | # print("Hello test 3") 12 | # assert False # the ONLY thing the assert key woud does is check that some value is True 13 | # # if not it raises an error 14 | 15 | # pytest -s for output of all tests 16 | from calculators.temperature_calculator import TemperatureCalculator, TemperatureCalculatorImpl 17 | 18 | # Reaplce the oringinal None with a proper implementation 19 | temp_calculator: TemperatureCalculator = TemperatureCalculatorImpl() 20 | 21 | 22 | def test_convert_F_C(): 23 | temp = temp_calculator.farenheit_to_celcius(212) 24 | assert temp == 100 25 | 26 | def test_convert_C_F(): 27 | temp = temp_calculator.celcius_to_farenheit(100) 28 | assert temp == 212 29 | 30 | def test_flexible_convert(): 31 | temp = temp_calculator.convert_temp(100,"C","F") 32 | assert temp == 212 33 | 34 | def test_flexible_convert2(): 35 | temp = temp_calculator.convert_temp(100,"c","f") 36 | assert temp == 212 37 | 38 | # This is a NEGATIVE test 39 | # Testing that a funciton FAILS or creates an error the way it is supposed to 40 | def test_flexible_convert3(): 41 | try: 42 | temp_calculator.convert_temp(245,"f","v") 43 | assert False # if that error was not thrown this 44 | except ValueError as e: 45 | assert str(e) =="Only the values f,F or c,C are acceptable " 46 | -------------------------------------------------------------------------------- /JSON.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/JSON.docx -------------------------------------------------------------------------------- /JavaCollections.md: -------------------------------------------------------------------------------- 1 | 2 | # Java Collections Framework 3 | ![Java Collections Framework](java-collection-framework-hierarchy.jpg) 4 | - A conglomeration of interfaces and classes for storing objects 5 | 6 | ## Key Interfaces 7 | - Iterable 8 | - Root Interface of the collections framework 9 | - Collection 10 | - Contains very generic methods that we associate with all collections 11 | - size() 12 | - add() 13 | - Queue 14 | - Store objects in a FIFO (First in first out fashion) 15 | - Dynamically resizes 16 | - List 17 | - Dynamically resizes as you add elements 18 | - Can contain duplicates 19 | - Does maintain the order of insertion 20 | - Set 21 | - Dynamically resizes as you add elements 22 | - Cannot contain duplicates 23 | - Do not maintain the order of insertion 24 | - Map 25 | - NOT ITERABLE 26 | - YOU CANNOT LOOP THROUGH A MAP 27 | - You can get the values of a map then iterate through the values but not the map itself 28 | - Store objects as key value pairs 29 | - Technically not a Collection but is part of the collections framework 30 | 31 | ### Python Cheatsheet 32 | - Python List = Java List 33 | - Python Set = Java Set 34 | - Python Dictionary = Java Map 35 | - Python Tuple = There is not a good Java corrallary 36 | 37 | ### Collections Framework vs Collection Interface vs Collections class 38 | - Collections Framework 39 | - group of interaces and classes for storing objects 40 | - Collection interface 41 | - Primariy interface used by many interfaces in the framework 42 | - Collections 43 | - A utilty class with static methods for working with collections 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /JavaDay2/JavaDay2.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /JavaDay2/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | JavaDay2 9 | 1.0-SNAPSHOT 10 | 11 | 12 | 14 13 | 14 14 | 15 | 16 | -------------------------------------------------------------------------------- /JavaDay2/src/main/java/dev/ranieri/constructors/ConstructorPlayground.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.constructors; 2 | 3 | public class ConstructorPlayground { 4 | 5 | public static void main(String[] args) { 6 | // You only get that no args default constructor if there are NO constructors defined 7 | // Dwelling dwelling = new Dwelling(); 8 | // System.out.println(dwelling); 9 | // 10 | // Dwelling dwelling2 = new Dwelling("Frodo Baggins", 200); 11 | // System.out.println(dwelling2); 12 | 13 | // House h1 = new House("Gandalf",700,12); 14 | // House h2 = new House(); 15 | 16 | Estate estate = new Estate("Adam",1400,50,"Manor du Ranieri"); 17 | 18 | 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /JavaDay2/src/main/java/dev/ranieri/constructors/Dwelling.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.constructors; 2 | 3 | // if you have NO constructors in a class you get a DEFAULT constructor 4 | // The default constructor takes in NO arguments 5 | public class Dwelling { 6 | 7 | String owner; // objects with no value are null 8 | int area; // primitives with no value are 0 9 | 10 | // // __str__ 11 | // public String toString(){ 12 | // return "Owner :" +this.owner +" Area: " + this.area; 13 | // } 14 | // Constructors must be named the same as the class and have no return type 15 | // Constructors CAN be overloaded 16 | Dwelling(String owner, int area){ 17 | System.out.println("Building a dwelling to your specifications"); 18 | this.owner = owner; 19 | this.area = area; 20 | } 21 | 22 | Dwelling(){ 23 | System.out.println("Building a generic dwelling"); 24 | this.owner = "Jason McDeveloper"; 25 | this.area = 100; 26 | } 27 | 28 | 29 | @Override 30 | public String toString() { 31 | return "Dwelling{" + 32 | "owner='" + owner + '\'' + 33 | ", area=" + area + 34 | '}'; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /JavaDay2/src/main/java/dev/ranieri/constructors/Estate.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.constructors; 2 | 3 | public class Estate extends House{ 4 | 5 | String fancyName; 6 | 7 | // the process is called constructor chaining where a child must call the parent as the first line of the constructor 8 | // Since Java DOES NOT support multiple inheritance there is no grandfather problem 9 | Estate(String owner, int area, int walls, String fancyName){ 10 | super(owner, area, walls); 11 | this.fancyName = fancyName; 12 | System.out.println("Built the luxious fancy manor called "+this.fancyName); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /JavaDay2/src/main/java/dev/ranieri/constructors/House.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.constructors; 2 | 3 | // House inherits from Dwelling 4 | public class House extends Dwelling{ 5 | 6 | int walls; 7 | 8 | House(String owner, int area, int walls){ 9 | super(owner,area);// super can be used to build the Parent class first!!! 10 | // super MUST be the VERY FIRST LINE OF CODE in any constructor 11 | this.walls = walls; 12 | System.out.println("Built a house to your specifications"); 13 | } 14 | 15 | House(){ 16 | super();// super() will be automatically called by Java if not written 17 | System.out.println("Built a house with no arguments"); 18 | } 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /JavaDay2/src/main/java/dev/ranieri/overloading/OverloadPlayground.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.overloading; 2 | 3 | public class OverloadPlayground { 4 | 5 | public static void main(String[] args) { 6 | int result1 = OverloadPlayground.add(90,75); 7 | int result2 = OverloadPlayground.add("75","54"); 8 | System.out.println(result1); 9 | System.out.println(result2); 10 | 11 | int [] nums = {12,34,65,12,35,10}; // Array literal syntax. This is a fixed size 12 | System.out.println(OverloadPlayground.add(nums)); 13 | OverloadPlayground.add(90,23,1,32,5,123,12332,123); 14 | 15 | } 16 | // Java DOES support Overloading methods unlike Python 17 | // Overloading is when you have a method with the SAME name but different parameters 18 | // different parameter types or lengths 19 | 20 | // Overloaded 21 | static int add(int num1, int num2){ 22 | return num1 + num2; 23 | } 24 | 25 | // Overloaded 26 | static int add(int num1, int num2, int num3){ 27 | return num1 + num2 + num3; 28 | } 29 | // For instance a method that takes in two strings turns them into numbers and then adds them 30 | // Overloaded 31 | static int add(String word1, String word2){ 32 | int num1 = Integer.parseInt(word1); 33 | int num2 = Integer.parseInt(word2); 34 | return num1 + num2; 35 | } 36 | 37 | // static int add(int [] ray){ 38 | // int sum = 0; 39 | // // enhanced for loop 40 | // // Python for i in ray: 41 | // for(int i : ray){ 42 | // sum += i; 43 | // } 44 | // return sum; 45 | // } 46 | 47 | // Var args syntax *nums in python 48 | // In Java the inputs turn into an array 49 | static int add(int... nums){ 50 | int sum = 0; 51 | // enhanced for loop 52 | // Python for i in ray: 53 | for(int i : nums){ 54 | sum += i; 55 | } 56 | return sum; 57 | 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /JavaDay2/src/main/java/dev/ranieri/overriding/Child.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.overriding; 2 | 3 | // by using extends our Child class will inherit all methods and fields from the Parent class 4 | public class Child extends Parent{ 5 | 6 | // Overidden method 7 | // SAME EXACT METHOD signature as the parent's method 8 | // Same name, same return type, same parameters 9 | @Override // Optional annotation that will give you an error if the method IS NOT overrding something 10 | void sayHello(){ 11 | System.out.println("I am the Child Implementation of the sayHello method"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /JavaDay2/src/main/java/dev/ranieri/overriding/OverridePlayground.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.overriding; 2 | 3 | public class OverridePlayground { 4 | 5 | public static void main(String[] args) { 6 | // Overriding is a process where a method Inherited from a parent has its implementation changed 7 | Parent p = new Parent(); 8 | p.sayHello(); 9 | 10 | Child child = new Child(); 11 | child.sayHello(); // child implementation is used 12 | 13 | Parent child2 = new Child(); // Valid assignment becuase a child object CAN be labeled under the parent class 14 | child2.sayHello(); // Whenever you call a method on an object. The actual object's method is what is used 15 | // Not what you labelled it as. 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /JavaDay2/src/main/java/dev/ranieri/overriding/Parent.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.overriding; 2 | 3 | public class Parent { 4 | 5 | //instance method 6 | // You need an instance of parent to call this method 7 | //def say_hello(self) -> None in python 8 | void sayHello(){ 9 | System.out.println("Hello I am the Parent implementaion of the sayHello method!!!"); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /JavaDay2/src/main/java/dev/ranieri/wrappers/EsotericJava.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.wrappers; 2 | 3 | public class EsotericJava { 4 | 5 | public static void main(String[] args) { 6 | 7 | // Java has an Integer Pool for values LESS THAN a byte 8 | Integer i = 128; 9 | Integer j = 128; 10 | System.out.println(i == j); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /JavaDay2/src/main/java/dev/ranieri/wrappers/WrapperPlayground.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.wrappers; 2 | 3 | public class WrapperPlayground { 4 | 5 | public static void main(String[] args) { 6 | // Wrapper classes are object version of primitives 7 | 8 | Integer i = 100; 9 | Character c = 'c'; 10 | Double d = 1000.675; 11 | 12 | int j = 100; 13 | int k = 9; 14 | 15 | WrapperPlayground.multiply(j,k);// Autoboxing. A primtive will be turned into the wrapper 16 | WrapperPlayground.printChar(c); // Unboxing. A wrapper class can be turned into the primitive 17 | String value = String.valueOf(i);// Unboxing 18 | 19 | } 20 | 21 | public static Integer multiply(Integer num1, Integer num2){ 22 | return num1 * num2; 23 | } 24 | 25 | public static void printChar(char c){ 26 | System.out.println(c); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /JavaDay3/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /JavaDay3/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /JavaDay3/.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | -------------------------------------------------------------------------------- /JavaDay3/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /JavaDay3/JavaDay3.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /JavaDay3/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | JavaDay3 9 | 1.0-SNAPSHOT 10 | 11 | 12 | 14 13 | 14 14 | 15 | 16 | -------------------------------------------------------------------------------- /JavaDay3/src/main/java/dev/ranieri/colllectionsframework/ArrayFactory.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.colllectionsframework; 2 | 3 | import java.util.ArrayList; 4 | import java.util.LinkedList; 5 | import java.util.List; 6 | 7 | public class ArrayFactory { 8 | 9 | // Factory Design pattern. 10 | // A method that returns an IMPLEMENTATION of an interface based on certain inputs 11 | // Often a developer does not need to know or care what the implementation is just that methods are supported 12 | /** insert a 1 for a list that optimizes read efficiency. insert anything else for a list that optimizes write efficiency */ 13 | static List createList(int choice){ 14 | if(choice == 1){ 15 | return new ArrayList(); 16 | }else { 17 | return new LinkedList(); 18 | } 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /JavaDay3/src/main/java/dev/ranieri/colllectionsframework/ListPlayground.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.colllectionsframework; 2 | 3 | import java.util.ArrayList; 4 | import java.util.LinkedList; 5 | import java.util.List; 6 | 7 | public class ListPlayground { 8 | 9 | public static void main(String[] args) { 10 | 11 | List myList = ArrayFactory.createList(1); 12 | // ArrayList and LinkedList can do the same things when treated as a List 13 | // But the implementation is different 14 | 15 | long start = System.nanoTime(); 16 | for(int i =0; i<100_000; i++){ 17 | myList.add(new Object()); // adding 100,000 objects to the END of the list 18 | } 19 | long end = System.nanoTime(); 20 | System.out.println("Time to add 100,000 objects to the end " + (end-start)/1000000000.0); 21 | 22 | start = System.nanoTime(); 23 | for(int i =0; i<100_000; i++){ 24 | myList.get(50_000); // get object at middle of list 25 | } 26 | end = System.nanoTime(); 27 | System.out.println("Time to get object 100_000 in the middle of the list " + (end-start)/1000000000.0); 28 | 29 | start = System.nanoTime(); 30 | for(int i =0; i<100_000; i++){ 31 | myList.add(1, new Object()); // add to the begining of the list 100_000 times 32 | } 33 | end = System.nanoTime(); 34 | System.out.println("Time to add object 100_000 to the beginning of the list " + (end-start)/1000000000.0); 35 | 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /JavaDay3/src/main/java/dev/ranieri/colllectionsframework/Player.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.colllectionsframework; 2 | 3 | // Interfaces add methods which abilites to a class 4 | // Comparable interface provided a method stub that you must implement 5 | // tell Java how to sort this class in a collection 6 | public class Player implements Comparable { 7 | String name; 8 | int age; 9 | int height; 10 | 11 | public Player(String name, int age, int height) { 12 | this.name = name; 13 | this.age = age; 14 | this.height = height; 15 | } 16 | 17 | @Override 18 | public String toString() { 19 | return "Player{" + 20 | "name='" + name + '\'' + 21 | ", age=" + age + 22 | ", height=" + height + 23 | '}'; 24 | } 25 | 26 | @Override // this instance vs another instance of this class 27 | // if this instance is "smaller" return -1 28 | // if this instance is "larger" return 1 29 | // if same return 0 30 | public int compareTo(Player player) { 31 | if(this.age< player.age){ 32 | return -1; 33 | } 34 | if(this.age> player.age){ 35 | return 1; 36 | } 37 | return 0; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /JavaDay3/src/main/java/dev/ranieri/polymorphism/CashBackCard.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.polymorphism; 2 | 3 | public class CashBackCard extends CreditCard { 4 | 5 | public CashBackCard(String owner, double balance, double creditLimit) { 6 | super(owner, balance, creditLimit); 7 | } 8 | 9 | @Override 10 | void makePurchase(double amount){ 11 | if((this.balance + amount)< this.creditLimit){ 12 | this.balance += amount; 13 | this.balance -= amount*0.01;// give 1% cash back 14 | }else{ 15 | System.out.println("Insufficient Credit"); 16 | } 17 | 18 | } 19 | 20 | @Override 21 | public String toString() { 22 | return "CashBackCard{" + 23 | "owner='" + owner + '\'' + 24 | ", balance=" + balance + 25 | ", creditLimit=" + creditLimit + 26 | '}'; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /JavaDay3/src/main/java/dev/ranieri/polymorphism/CreditCard.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.polymorphism; 2 | 3 | // The ONLY thing putting abstract a class does is make it impossible to directly instantiate this class 4 | public abstract class CreditCard { 5 | 6 | String owner; 7 | // Amount of money charged on the card 8 | double balance; 9 | //maximum balance you can have on a credit card 10 | double creditLimit; 11 | 12 | public CreditCard(String owner, double balance, double creditLimit) { 13 | this.owner = owner; 14 | this.balance = balance; 15 | this.creditLimit = creditLimit; 16 | } 17 | 18 | //IF and OPTIONALLY you can make abstract methods which are method signatures lacking implementations 19 | // The child classes have their own implementations of this method. 20 | // There is NEVER a situation you can construct in your code where you call a method that does not exist 21 | abstract void makePurchase(double amount); 22 | 23 | @Override 24 | public String toString() { 25 | return "CreditCard{" + 26 | "owner='" + owner + '\'' + 27 | ", balance=" + balance + 28 | ", creditLimit=" + creditLimit + 29 | '}'; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /JavaDay3/src/main/java/dev/ranieri/polymorphism/DiamondPlusRewardCard.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.polymorphism; 2 | 3 | // All the functionalitu of a the reward PLUS any methods provided by the interface 4 | public class DiamondPlusRewardCard extends RewardCard implements Expandable, Freezable{ 5 | 6 | boolean isFrozen = false; 7 | 8 | public DiamondPlusRewardCard(String owner, double balance, double creditLimit, int rewardPoints) { 9 | super(owner, balance, creditLimit, rewardPoints); 10 | } 11 | 12 | @Override 13 | public void expandCreditLimit(double amount) { 14 | this.creditLimit += amount; 15 | System.out.println("expanded credit limit"); 16 | } 17 | 18 | @Override 19 | void makePurchase(double amount){ 20 | if(isFrozen){ 21 | System.out.println("Card is frozen cannot make purchase"); 22 | }else{ 23 | super.makePurchase(amount);// calls the parent implentation 24 | } 25 | } 26 | 27 | @Override 28 | public void freeze() { 29 | this.isFrozen = true; 30 | } 31 | 32 | @Override 33 | public void unfreeze() { 34 | this.isFrozen = false; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /JavaDay3/src/main/java/dev/ranieri/polymorphism/Expandable.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.polymorphism; 2 | 3 | // Interface vs Abastract class 4 | // ALL methods in an interface are abstract 5 | // Interfaces do not have constructors 6 | // Interfaces cannot have instance varaibles // public static final variables 7 | // A single class can implement MANY interfaces 8 | // A single class can only inherit/extend a single class (abstract or otherwise) 9 | // Interfaces tend to be more flexible 10 | public interface Expandable { 11 | 12 | void expandCreditLimit(double amount); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /JavaDay3/src/main/java/dev/ranieri/polymorphism/Freezable.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.polymorphism; 2 | 3 | public interface Freezable { 4 | /** 5 | * Makes a card unable to make Purchase 6 | * */ 7 | void freeze(); 8 | 9 | /** 10 | * Makes a card able to make Purchase 11 | * */ 12 | void unfreeze(); 13 | } 14 | -------------------------------------------------------------------------------- /JavaDay3/src/main/java/dev/ranieri/polymorphism/RewardCard.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.polymorphism; 2 | 3 | public class RewardCard extends CreditCard{ 4 | // the owner, balance, creditLimit are all inherited and usable even though they are not seen visibliy in the source code 5 | 6 | int rewardPoints; 7 | 8 | public RewardCard(String owner, double balance, double creditLimit, int rewardPoints) { 9 | super(owner, balance, creditLimit); 10 | this.rewardPoints = rewardPoints; 11 | } 12 | 13 | @Override // an overridden method re implements a method in the parent class 14 | void makePurchase(double amount){ 15 | if((amount+this.balance) < creditLimit){ 16 | this.balance += amount; 17 | this.rewardPoints += Math.floor(amount*0.01); 18 | }else{ 19 | System.out.println("Credit Limit Exceeded"); 20 | } 21 | } 22 | 23 | void showRewardPoints(){ 24 | System.out.println("Your current reward points are " + this.rewardPoints); 25 | } 26 | 27 | @Override 28 | public String toString() { 29 | return "RewardCard{" + 30 | "owner='" + owner + '\'' + 31 | ", balance=" + balance + 32 | ", creditLimit=" + creditLimit + 33 | ", rewardPoints=" + rewardPoints + 34 | '}'; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /JavaDay3/target/classes/dev/ranieri/colllectionsframework/ArrayFactory.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/JavaDay3/target/classes/dev/ranieri/colllectionsframework/ArrayFactory.class -------------------------------------------------------------------------------- /JavaDay3/target/classes/dev/ranieri/colllectionsframework/CollectionPlayground.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/JavaDay3/target/classes/dev/ranieri/colllectionsframework/CollectionPlayground.class -------------------------------------------------------------------------------- /JavaDay3/target/classes/dev/ranieri/colllectionsframework/ListPlayground.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/JavaDay3/target/classes/dev/ranieri/colllectionsframework/ListPlayground.class -------------------------------------------------------------------------------- /JavaDay3/target/classes/dev/ranieri/colllectionsframework/MyAwesomeList.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/JavaDay3/target/classes/dev/ranieri/colllectionsframework/MyAwesomeList.class -------------------------------------------------------------------------------- /JavaDay3/target/classes/dev/ranieri/colllectionsframework/Player.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/JavaDay3/target/classes/dev/ranieri/colllectionsframework/Player.class -------------------------------------------------------------------------------- /JavaDay3/target/classes/dev/ranieri/polymorphism/CashBackCard.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/JavaDay3/target/classes/dev/ranieri/polymorphism/CashBackCard.class -------------------------------------------------------------------------------- /JavaDay3/target/classes/dev/ranieri/polymorphism/CreditCard.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/JavaDay3/target/classes/dev/ranieri/polymorphism/CreditCard.class -------------------------------------------------------------------------------- /JavaDay3/target/classes/dev/ranieri/polymorphism/CreditPlayground.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/JavaDay3/target/classes/dev/ranieri/polymorphism/CreditPlayground.class -------------------------------------------------------------------------------- /JavaDay3/target/classes/dev/ranieri/polymorphism/DiamondPlusRewardCard.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/JavaDay3/target/classes/dev/ranieri/polymorphism/DiamondPlusRewardCard.class -------------------------------------------------------------------------------- /JavaDay3/target/classes/dev/ranieri/polymorphism/Expandable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/JavaDay3/target/classes/dev/ranieri/polymorphism/Expandable.class -------------------------------------------------------------------------------- /JavaDay3/target/classes/dev/ranieri/polymorphism/Freezable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/JavaDay3/target/classes/dev/ranieri/polymorphism/Freezable.class -------------------------------------------------------------------------------- /JavaDay3/target/classes/dev/ranieri/polymorphism/RewardCard.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/JavaDay3/target/classes/dev/ranieri/polymorphism/RewardCard.class -------------------------------------------------------------------------------- /JavaDay4/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /JavaDay4/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /JavaDay4/.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | -------------------------------------------------------------------------------- /JavaDay4/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /JavaDay4/JavaDay4.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /JavaDay4/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | JavaDay4 9 | 1.0-SNAPSHOT 10 | 11 | 12 | 14 13 | 14 14 | 15 | 16 | -------------------------------------------------------------------------------- /JavaDay4/src/main/java/dev/ranieri/exceptions/ErrorPlayground.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.exceptions; 2 | 3 | public class ErrorPlayground { 4 | 5 | // Exceptions and Errors are similar but mean different things in Java 6 | // Exceptions and Errors are both children of throwable which is the top of the exception hierarchy 7 | // Exceptions are for when things go wrong that your program should be able to handle 8 | // Errors are for catastrophic fundamental failures that you shoould not catch or handle 9 | // If you are reciving errors. You need to rewrite the code or the problem is not solveable via a programming 10 | // Errors OutOfMemoryError 11 | // StackOverflowError 12 | public static void main(String[] args) { 13 | try { 14 | recursive(); 15 | }catch (StackOverflowError error){ 16 | System.out.println("You can catch errors but it is INCREDIBLY BAD PRACTICE"); 17 | } 18 | 19 | try { 20 | terrible(); 21 | }catch (Throwable e){ 22 | System.out.println("YOU CAN CATCH COMPILER ERRORS IN JAVA"); 23 | } 24 | 25 | } 26 | 27 | public static void recursive(){ 28 | recursive(); 29 | } 30 | 31 | public static void terrible(){ 32 | // askdjlfnawefnjawnlffnwluefnaw laksjjdnflwenfoawefunaowefunf 33 | // fauywefiuaywbefiauwb uneifunwiefunewwef 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /JavaDay4/src/main/java/dev/ranieri/exceptions/InvalidUsernameException.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.exceptions; 2 | 3 | // Any class that inherits from Exception is a checked excption 4 | public class InvalidUsernameException extends Exception{ 5 | 6 | InvalidUsernameException(String message){ 7 | super(message); // the RuntimeException class have a single argument string constructor we can use 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /JavaDay4/src/main/java/dev/ranieri/lambdas/Calculate.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.lambdas; 2 | 3 | // Steps to create a custom lambda 4 | // 1. make a functional interface (an interface with one and ONLY one method) 5 | @FunctionalInterface// does not do anything other than throw an error if you add another method 6 | public interface Calculate { 7 | 8 | double calc(double num1, double num2); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /JavaDay4/src/main/java/dev/ranieri/lambdas/LambdaPlayground.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.lambdas; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.function.Consumer; 6 | import java.util.stream.Collectors; 7 | 8 | public class LambdaPlayground { 9 | 10 | public static void main(String[] args) { 11 | // Java is a VERY OOP language. 12 | // Java 8 added lambdas which allow you to create first order functions 13 | // a function that is an object!!!! 14 | // Callback functions are not a possiblity in Java which did NOT previously exist 15 | 16 | List nums = new ArrayList(); 17 | nums.add(1); 18 | nums.add(2); 19 | nums.add(3); 20 | nums.add(4); 21 | nums.add(10); 22 | nums.add(20); 23 | nums.add(30); 24 | nums.add(40); 25 | 26 | // imperative approach 27 | for(int i : nums){ 28 | System.out.println(i); 29 | } 30 | 31 | // You have to be very explicit about the type of function you are creating 32 | // A consumer function is a function that takes in one argument and does NOT return anything 33 | // the lets you define what the type of the argument is 34 | Consumer print = i -> {System.out.println(i);}; 35 | 36 | nums.forEach(print); 37 | 38 | // List names = new ArrayList(); 39 | // names.forEach(print); error because print lambda takes in strings 40 | // print.accept(1900); // 41 | 42 | List filteredNums = nums.stream().filter(num -> num <10).collect(Collectors.toList()); 43 | System.out.println(filteredNums); 44 | 45 | Calculate add = (n1, n2) -> { return n1 +n2;}; 46 | // alternate syntax 47 | // if a lambda is just ONE statement that is a value then it has an implicit return 48 | Calculate subtract = (n1, n2) -> n1 -n2; 49 | 50 | System.out.println(add.calc(50,70)); 51 | System.out.println(subtract.calc(50,70)); 52 | 53 | 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /JavaDay4/src/main/java/dev/ranieri/object101/ObjectPlayground.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.object101; 2 | 3 | import dev.ranieri.exceptions.InvalidUsernameException; 4 | 5 | public class ObjectPlayground { 6 | 7 | public static void main(String[] args) { 8 | // The Object Class is the grandfather root class of EVERYTHING in Java 9 | // Every Object is of type Object 10 | 11 | Object s = "Hello"; 12 | Integer i = 19; 13 | 14 | // few key methods on the Object class 15 | // toString() returns the string representation of an object 16 | // probably the most overridden method in all of Java. Return the memory address by default 17 | Object o= new Object(); 18 | 19 | // equals() a method that returns trye or false if one the implementation says so 20 | // by default it compares memeory addresses 21 | String s1 = new String("Hello"); 22 | String s2 = new String("Hello"); 23 | System.out.println(s1.equals(s2)); 24 | 25 | // hashcode() a method that returns a number generated from the fields in a class 26 | // It is used to identify the state of an object but is one way operations 27 | // you cannot reconstruct the intial values based off of a hashcode 28 | String s3 = "Wasssup"; 29 | System.out.println(s3.hashCode()); 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /JavaDay4/target/classes/dev/ranieri/exceptions/ErrorPlayground.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/JavaDay4/target/classes/dev/ranieri/exceptions/ErrorPlayground.class -------------------------------------------------------------------------------- /JavaDay4/target/classes/dev/ranieri/exceptions/InvalidUsernameException.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/JavaDay4/target/classes/dev/ranieri/exceptions/InvalidUsernameException.class -------------------------------------------------------------------------------- /JavaDay4/target/classes/dev/ranieri/exceptions/UsernameValidationApp.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/JavaDay4/target/classes/dev/ranieri/exceptions/UsernameValidationApp.class -------------------------------------------------------------------------------- /JavaDay4/target/classes/dev/ranieri/lambdas/Calculate.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/JavaDay4/target/classes/dev/ranieri/lambdas/Calculate.class -------------------------------------------------------------------------------- /JavaDay4/target/classes/dev/ranieri/lambdas/LambdaPlayground.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/JavaDay4/target/classes/dev/ranieri/lambdas/LambdaPlayground.class -------------------------------------------------------------------------------- /JavaDay4/target/classes/dev/ranieri/object101/ObjectPlayground.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/JavaDay4/target/classes/dev/ranieri/object101/ObjectPlayground.class -------------------------------------------------------------------------------- /LibraryAPI/daos/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/LibraryAPI/daos/__init__.py -------------------------------------------------------------------------------- /LibraryAPI/daos/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/LibraryAPI/daos/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /LibraryAPI/daos/__pycache__/book_dao.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/LibraryAPI/daos/__pycache__/book_dao.cpython-39.pyc -------------------------------------------------------------------------------- /LibraryAPI/daos/__pycache__/book_dao_local.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/LibraryAPI/daos/__pycache__/book_dao_local.cpython-39.pyc -------------------------------------------------------------------------------- /LibraryAPI/daos/__pycache__/book_dao_postgres.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/LibraryAPI/daos/__pycache__/book_dao_postgres.cpython-39.pyc -------------------------------------------------------------------------------- /LibraryAPI/daos/book_dao.py: -------------------------------------------------------------------------------- 1 | from abc import ABC, abstractmethod 2 | from typing import List 3 | 4 | from entities.book import Book 5 | 6 | 7 | class BookDAO(ABC): 8 | 9 | # CRUD 10 | # CREATE 11 | # create method SAVES a new book to a database or some other location 12 | @abstractmethod 13 | def create_book(self, book: Book) -> Book: 14 | pass 15 | 16 | # READ 17 | @abstractmethod 18 | def get_book_by_id(self, book_id: int) -> Book: 19 | pass 20 | 21 | @abstractmethod # List[Book] is the type annotation for saying a list of books 22 | def get_all_books(self) -> List[Book]: 23 | pass 24 | 25 | #UPDATE 26 | @abstractmethod 27 | def update_book(self, book: Book) -> Book: 28 | pass 29 | 30 | #DELETE 31 | @abstractmethod 32 | def delete_book(self, book_id: int) -> bool: 33 | pass -------------------------------------------------------------------------------- /LibraryAPI/daos/book_dao_local.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | from daos.book_dao import BookDAO 3 | from entities.book import Book 4 | 5 | 6 | # BookDAO that saves objects in local memory 7 | from exceptions.not_found_exception import ResourceNotFoundError 8 | 9 | 10 | class BookDaoLocal(BookDAO): 11 | id_maker = 0 # mimic a primary key generator in a database 12 | book_table = {} # mimicing a table in a database 13 | 14 | def create_book(self, book: Book) -> Book: 15 | BookDaoLocal.id_maker += 1 16 | book.book_id = BookDaoLocal.id_maker 17 | # adding a new item to a dictionary 18 | BookDaoLocal.book_table[BookDaoLocal.id_maker] = book 19 | return book 20 | 21 | def get_book_by_id(self, book_id: int) -> Book: 22 | try: 23 | book = BookDaoLocal.book_table[book_id] 24 | return book 25 | except KeyError: 26 | raise ResourceNotFoundError(f"Could not find book of id {book_id}") 27 | 28 | def get_all_books(self) -> List[Book]: 29 | book_list = list(BookDaoLocal.book_table.values()) 30 | return book_list 31 | 32 | def update_book(self, book: Book) -> Book: 33 | BookDaoLocal.book_table[book.book_id] = book 34 | return book 35 | 36 | def delete_book(self, book_id: int) -> bool: 37 | try: 38 | del BookDaoLocal.book_table[book_id] 39 | return True 40 | except KeyError: 41 | return False 42 | -------------------------------------------------------------------------------- /LibraryAPI/daos/book_dao_postgres.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | from daos.book_dao import BookDAO 3 | from entities.book import Book 4 | from utils.connection_util import connection 5 | 6 | 7 | class BookDaoPostgres(BookDAO): 8 | 9 | def create_book(self, book: Book) -> Book: 10 | # returning book_id it will return the value of the newly generated key in the database 11 | sql = """insert into book (title,author,available,quality,return_date) values (%s,%s,%s,%s,%s) returning book_id""" 12 | cursor = connection.cursor() 13 | cursor.execute(sql, (book.title, book.author, book.available, book.quality, book.return_date)) 14 | connection.commit() # make permaent the SQL statements that were executed 15 | b_id = cursor.fetchone()[0] 16 | book.book_id = b_id 17 | return book 18 | 19 | def get_book_by_id(self, book_id: int) -> Book: 20 | sql = """select * from book where book_id = %s""" 21 | cursor = connection.cursor() 22 | cursor.execute(sql, [book_id]) 23 | record = cursor.fetchone() 24 | # book = Book(record[0],record[1],record[2],record[3],record[4],record[5]) 25 | book = Book(*record) 26 | return book 27 | 28 | def get_all_books(self) -> List[Book]: 29 | sql = """select * from book""" 30 | cursor = connection.cursor() 31 | cursor.execute(sql) 32 | records = cursor.fetchall() 33 | # books = [Book(*record) for record in records] 34 | book_list = [] 35 | for record in records: 36 | book_list.append(Book(*record)) 37 | 38 | return book_list 39 | 40 | def update_book(self, book: Book) -> Book: 41 | sql = """update book set title=%s, author=%s, available=%s, quality=%s ,return_date=%s where book_id =%s""" 42 | cursor = connection.cursor() 43 | cursor.execute(sql, [book.title, book.author, book.available, book.quality, book.return_date, book.book_id]) 44 | connection.commit() 45 | return book 46 | 47 | def delete_book(self, book_id: int) -> bool: 48 | sql = """delete from book where book_id =%s""" 49 | cursor = connection.cursor() 50 | cursor.execute(sql, [book_id]) 51 | connection.commit() 52 | return True 53 | -------------------------------------------------------------------------------- /LibraryAPI/entities/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/LibraryAPI/entities/__init__.py -------------------------------------------------------------------------------- /LibraryAPI/entities/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/LibraryAPI/entities/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /LibraryAPI/entities/__pycache__/book.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/LibraryAPI/entities/__pycache__/book.cpython-39.pyc -------------------------------------------------------------------------------- /LibraryAPI/entities/book.py: -------------------------------------------------------------------------------- 1 | # Entity classes are used for storing information 2 | # they will have minimal logic. usually do not have a lot of methods in them 3 | 4 | class Book: 5 | 6 | def __init__(self, book_id : int, title: str, author: str, available: bool, quaility: int, return_date: int ): 7 | self.book_id = book_id # ID should different for every book in our library 8 | # the book_id will become primary key 9 | self.title = title 10 | self.author = author 11 | self.available = available 12 | self.quality = quaility 13 | self.return_date = return_date 14 | 15 | def __str__(self): 16 | return f"id={self.book_id}, title={self.title}, author={self.author}" 17 | 18 | def as_json_dict(self): 19 | return { 20 | "bookId":self.book_id, 21 | "title":self.title, 22 | "author":self.author, 23 | "available":self.available, 24 | "quality":self.quality, 25 | "returnDate":self.return_date 26 | } 27 | 28 | -------------------------------------------------------------------------------- /LibraryAPI/exceptions/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/LibraryAPI/exceptions/__init__.py -------------------------------------------------------------------------------- /LibraryAPI/exceptions/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/LibraryAPI/exceptions/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /LibraryAPI/exceptions/__pycache__/book_unavailable_error.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/LibraryAPI/exceptions/__pycache__/book_unavailable_error.cpython-39.pyc -------------------------------------------------------------------------------- /LibraryAPI/exceptions/__pycache__/not_found_exception.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/LibraryAPI/exceptions/__pycache__/not_found_exception.cpython-39.pyc -------------------------------------------------------------------------------- /LibraryAPI/exceptions/book_unavailable_error.py: -------------------------------------------------------------------------------- 1 | 2 | class BookUnavailableError(Exception): 3 | pass -------------------------------------------------------------------------------- /LibraryAPI/exceptions/not_found_exception.py: -------------------------------------------------------------------------------- 1 | class ResourceNotFoundError(Exception): 2 | description = "This exception arises when a resource cannot be found" -------------------------------------------------------------------------------- /LibraryAPI/services/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/LibraryAPI/services/__init__.py -------------------------------------------------------------------------------- /LibraryAPI/services/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/LibraryAPI/services/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /LibraryAPI/services/__pycache__/book_service.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/LibraryAPI/services/__pycache__/book_service.cpython-39.pyc -------------------------------------------------------------------------------- /LibraryAPI/services/__pycache__/book_service_impl.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/LibraryAPI/services/__pycache__/book_service_impl.cpython-39.pyc -------------------------------------------------------------------------------- /LibraryAPI/services/book_service.py: -------------------------------------------------------------------------------- 1 | from abc import ABC, abstractmethod 2 | from typing import List 3 | 4 | from entities.book import Book 5 | 6 | 7 | class BookService(ABC): 8 | 9 | # general CRUD functionality 10 | @abstractmethod 11 | def add_book(self, book: Book): 12 | pass 13 | 14 | @abstractmethod 15 | def retrieve_all_books(self): 16 | pass 17 | 18 | @abstractmethod 19 | def retrieve_book_by_id(self, book_id: int): 20 | pass 21 | 22 | @abstractmethod 23 | def update_book(self, book: Book): 24 | pass 25 | 26 | @abstractmethod 27 | def remove_book(self, book_id: int): 28 | pass 29 | 30 | @abstractmethod 31 | def find_books_by_tile_containing(self, phrase: str) -> List[Book]: 32 | pass 33 | 34 | @abstractmethod 35 | def checkout_book(self, book_id: int) -> bool: 36 | pass 37 | -------------------------------------------------------------------------------- /LibraryAPI/services/book_service_impl.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | 3 | from daos.book_dao import BookDAO 4 | from entities.book import Book 5 | from exceptions.book_unavailable_error import BookUnavailableError 6 | from exceptions.not_found_exception import ResourceNotFoundError 7 | from services.book_service import BookService 8 | import time 9 | 10 | 11 | class BookServiceImpl(BookService): 12 | 13 | # Compisition 14 | def __init__(self, book_dao: BookDAO): 15 | self.book_dao = book_dao 16 | # Dependency injection 17 | # The service needs a BOOK DAO to perform crud operations 18 | # When creating a service we will INJECT a BookDAO into it 19 | # Deoupling. Makes our code more modular and independent 20 | # Easier to test and easier to refactor 21 | 22 | def add_book(self, book: Book): 23 | return self.book_dao.create_book(book) 24 | 25 | def retrieve_all_books(self): 26 | return self.book_dao.get_all_books() 27 | 28 | def retrieve_book_by_id(self, book_id: int): 29 | return self.book_dao.get_book_by_id(book_id) 30 | 31 | def update_book(self, book: Book): 32 | return self.book_dao.update_book(book) 33 | 34 | def remove_book(self, book_id: int): 35 | result = self.book_dao.delete_book(book_id) 36 | if result: 37 | return result 38 | else: 39 | raise ResourceNotFoundError(f"book with the id of {book_id} could not be found") 40 | 41 | def find_books_by_tile_containing(self, phrase: str) -> List[Book]: 42 | books = self.book_dao.get_all_books() 43 | filtered_books = [] 44 | 45 | for book in books: 46 | if phrase in book.title: 47 | filtered_books.append(book) 48 | 49 | return filtered_books 50 | 51 | def checkout_book(self, book_id: int) -> bool: 52 | book = self.book_dao.get_book_by_id(book_id) 53 | if book.available == False: 54 | raise BookUnavailableError(f"the book with id {book_id} is currently unavailable") 55 | 56 | book.available = False 57 | book.return_date = time.time() + 1_209_600 58 | self.book_dao.update_book(book) 59 | return True 60 | -------------------------------------------------------------------------------- /LibraryAPI/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/LibraryAPI/tests/__init__.py -------------------------------------------------------------------------------- /LibraryAPI/tests/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/LibraryAPI/tests/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /LibraryAPI/tests/__pycache__/test_book_dao.cpython-39-pytest-6.2.4.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/LibraryAPI/tests/__pycache__/test_book_dao.cpython-39-pytest-6.2.4.pyc -------------------------------------------------------------------------------- /LibraryAPI/tests/__pycache__/test_book_service.cpython-39-pytest-6.2.4.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/LibraryAPI/tests/__pycache__/test_book_service.cpython-39-pytest-6.2.4.pyc -------------------------------------------------------------------------------- /LibraryAPI/tests/test_book_dao.py: -------------------------------------------------------------------------------- 1 | from daos.book_dao import BookDAO 2 | from daos.book_dao_local import BookDaoLocal 3 | from daos.book_dao_postgres import BookDaoPostgres 4 | from entities.book import Book 5 | 6 | book_dao: BookDAO = BookDaoPostgres() 7 | # An entity that HAS NOT BEEN SAVED should have an ID of 0 8 | # this is a well established convention in every tech stack 9 | # Many application store date information as the unix epoch 10 | # seconds from Jan 1st midnight 1970 11 | test_book = Book(0,"Fellowship of the Ring", "Tolkien",True, 2, 0) 12 | 13 | #PyTest runs tests in order top to bottom 14 | 15 | def test_create_book(): 16 | book_dao.create_book(test_book) # create_book should save the object 17 | assert test_book.book_id != 0 # the book should no longer have 0 as an id 18 | 19 | def test_get_book_by_id(): 20 | book = book_dao.get_book_by_id(test_book.book_id) 21 | assert test_book.title == book.title # assert that the book object we got from the DAO has same title 22 | 23 | def test_update_book(): 24 | test_book.available = False 25 | updated_book = book_dao.update_book(test_book) 26 | assert updated_book.available == test_book.available 27 | 28 | def test_delete_book(): 29 | result = book_dao.delete_book(test_book.book_id) 30 | assert result 31 | 32 | # Integrated test. Requires that other methods work in order for it to pass 33 | def test_get_all_books(): 34 | book1 = Book(0,"1984","George Orwell",True,1,0) 35 | book2 = Book(0, "1985", "George Orwell", True, 1, 0) 36 | book3 = Book(0, "1985: Reloaded", "George Orwell", True, 1, 0) 37 | book_dao.create_book(book1) 38 | book_dao.create_book(book2) 39 | book_dao.create_book(book3) 40 | books = book_dao.get_all_books() 41 | assert len(books) >= 3 42 | -------------------------------------------------------------------------------- /LibraryAPI/tests/test_book_service.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | # mocking is a very common testing practice 4 | # faking the output of a function with predefined values 5 | # allows us to write test in a consistent fashion without worrying if an underlying works correctly 6 | from unittest.mock import MagicMock 7 | 8 | from daos.book_dao_postgres import BookDaoPostgres 9 | from entities.book import Book 10 | from services.book_service import BookService 11 | 12 | # imgaine these are the only three books in my database 13 | from services.book_service_impl import BookServiceImpl 14 | 15 | books = [Book(0,'The Lion the Witch and the Wardrobe','doesnt matter',True,0,0), 16 | Book(0,'War and Peace','doesnt matter',True,0,0), 17 | Book(0,'Frankenstein','doesnt matter',True,0,0)] 18 | 19 | # the book service cannot work unless the BookDAO also works correclty 20 | mock_dao = BookDaoPostgres() 21 | mock_dao.get_all_books = MagicMock(return_value = books) 22 | books = mock_dao.get_all_books() # if you call this function that I magic mocked at line 21 return those defined 3 books 23 | 24 | book_service: BookService = BookServiceImpl(mock_dao) 25 | 26 | def test_get_by_title_1(): 27 | result = book_service.find_books_by_tile_containing("War") 28 | assert len(result) == 2 29 | 30 | -------------------------------------------------------------------------------- /LibraryAPI/utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/LibraryAPI/utils/__init__.py -------------------------------------------------------------------------------- /LibraryAPI/utils/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/LibraryAPI/utils/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /LibraryAPI/utils/__pycache__/connection_util.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/LibraryAPI/utils/__pycache__/connection_util.cpython-39.pyc -------------------------------------------------------------------------------- /LibraryAPI/utils/connection_util.py: -------------------------------------------------------------------------------- 1 | from psycopg2 import connect 2 | from psycopg2._psycopg import OperationalError 3 | import os 4 | 5 | 6 | def create_connection(): 7 | try: 8 | conn = connect( 9 | host= 'ranieridb.cyysbedq8cqc.us-east-1.rds.amazonaws.com', 10 | database='postgres', 11 | user= 'adam', 12 | password='gatorfan1', 13 | port='5432' 14 | ) 15 | return conn 16 | except OperationalError as e: 17 | print(e) 18 | 19 | 20 | connection = create_connection() 21 | -------------------------------------------------------------------------------- /PyBookFrontend/bookadder.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | New Book 5 | 6 | 7 |

New Book Registration

8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 57 | -------------------------------------------------------------------------------- /PyBookFrontend/checkout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Document 5 | 6 | 7 | 8 | 9 |
Books
10 | 11 | 12 | 13 | 14 |
TitleAuthorCondition
15 | 16 | 17 | 62 | -------------------------------------------------------------------------------- /PythonImporting/__pycache__/english.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/PythonImporting/__pycache__/english.cpython-39.pyc -------------------------------------------------------------------------------- /PythonImporting/__pycache__/spanish.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/PythonImporting/__pycache__/spanish.cpython-39.pyc -------------------------------------------------------------------------------- /PythonImporting/app.py: -------------------------------------------------------------------------------- 1 | # a simple greeting app that supports saying hello in many different languages 2 | import english # import the python file (A python file is called a module) 3 | 4 | from spanish import hola 5 | from germanic_languages.german import gutentag 6 | 7 | name = "Adam" 8 | 9 | english.hello(name) # if you import just the module 10 | # you have to use the module name to access the global funcitons anvariables 11 | 12 | # if you use from you can specify what functions you want it particular and do not need to 13 | # prefix with the module name 14 | hola(name) 15 | 16 | gutentag(name) 17 | 18 | 19 | # Python is an interpreted language that executes line by line 20 | # Most python interpreters (the software that reads you python code and executes it) 21 | # will (compile imported files into lower level code native the the computer) 22 | # by default .pyc C implemention of your python code 23 | 24 | # A python file is a module 25 | # A folder that contains one or many python modules is called a package 26 | # __init__.py file in a package Older versions of python required this exact file name 27 | # to be in a package otherwise it would not import the modules correctly 28 | 29 | # every module has a built-in variable called __name__ 30 | # the value of that variable is the name of the module 31 | # UNLESS you are running that module directly 32 | 33 | # the __name__ value is "__main__" if it is the file you are DIRECTLY executing otherwise it 34 | # is the name of the file 35 | print(__name__) 36 | 37 | # Essentially python's way of creating a entrypoint main method that you might see in 38 | # other programming languages 39 | if __name__ == "__main__": 40 | print("I can only run if you direclty execute this file") -------------------------------------------------------------------------------- /PythonImporting/english.py: -------------------------------------------------------------------------------- 1 | 2 | def hello(name:str): 3 | print("Hello " + name) 4 | 5 | print(__name__) -------------------------------------------------------------------------------- /PythonImporting/foreign_imports.py: -------------------------------------------------------------------------------- 1 | # How do you get a python module that someone else wrote 2 | # PyPi massive python repository for python module 3 | # if you can imagine a piece of software PyPi has it 4 | # PyPi an app store but for python modules 5 | 6 | # npm in JS 7 | # maven central repo for Java 8 | # PyPi for Python 9 | 10 | # pip is a dependenecy management tool that will install depenendenices 11 | # it also keeps track of dependencies in an application 12 | 13 | from chart import bar 14 | 15 | x = [500, 200, 900, 400] 16 | y = ['marc', 'mummify', 'chart', 'sausagelink'] 17 | 18 | bar(x, y) 19 | -------------------------------------------------------------------------------- /PythonImporting/germanic_languages/__init__.py: -------------------------------------------------------------------------------- 1 | # You can use this file to execute any code to be run when importing a module 2 | # in the package for the first time 3 | print("Hello from the init.py") -------------------------------------------------------------------------------- /PythonImporting/germanic_languages/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/PythonImporting/germanic_languages/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /PythonImporting/germanic_languages/__pycache__/german.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/PythonImporting/germanic_languages/__pycache__/german.cpython-39.pyc -------------------------------------------------------------------------------- /PythonImporting/germanic_languages/german.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | def gutentag(name: str): 4 | print("Gutentag " + name) -------------------------------------------------------------------------------- /PythonImporting/paradigms.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | #recursive 4 | def count_numbers(phrase: str, tot =0) -> int: 5 | if len(phrase) == 0: 6 | return tot 7 | else: 8 | return count_numbers(phrase[1:], tot:= tot +1 if phrase[0].isnumeric() else tot) 9 | 10 | #functional 11 | def count_numbers2(phrase: str): 12 | chars = list(filter(lambda c : c.isnumeric(), phrase)) 13 | return len(chars) 14 | 15 | 16 | #imperative 17 | def count_numbers3(phrase: str): 18 | count = 0 19 | 20 | for c in phrase: 21 | if c.isnumeric(): 22 | count += 1 23 | 24 | return count 25 | 26 | #list comprehension 27 | def count_numbers4(phrase: str): 28 | return len([c for c in phrase if c.isnumeric()]) 29 | 30 | start = time.perf_counter_ns() 31 | amount = count_numbers("123abc123") 32 | end = time.perf_counter_ns() 33 | print(f"RECURSIVE nanoseconds: {end-start}") 34 | 35 | start = time.perf_counter_ns() 36 | amount = count_numbers2("123abc123") 37 | end = time.perf_counter_ns() 38 | print(f"FUNCTIONAL nanoseconds: {end-start}") 39 | 40 | start = time.perf_counter_ns() 41 | amount = count_numbers3("123abc123") 42 | end = time.perf_counter_ns() 43 | print(f"IMPERATIVE nanoseconds: {end-start}") 44 | 45 | start = time.perf_counter_ns() 46 | amount = count_numbers4("123abc123") 47 | end = time.perf_counter_ns() 48 | print(f"LIST COMPREHENSION nanoseconds: {end-start}") -------------------------------------------------------------------------------- /PythonImporting/spanish.py: -------------------------------------------------------------------------------- 1 | 2 | def hola(name: str): 3 | print("Hola " + name) 4 | 5 | print(__name__) 6 | 7 | if __name__ =="__main__": 8 | print("I can only run if you direclty execute this file") -------------------------------------------------------------------------------- /PythonNotesDay1.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/PythonNotesDay1.docx -------------------------------------------------------------------------------- /Question Bank (Pre-panel).docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/Question Bank (Pre-panel).docx -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 2105PythonBatch -------------------------------------------------------------------------------- /RequirementsTraceabilityMatrix.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/RequirementsTraceabilityMatrix.xlsx -------------------------------------------------------------------------------- /Reviews/ApplicationLayers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/Reviews/ApplicationLayers.png -------------------------------------------------------------------------------- /Reviews/LifeCycles.md: -------------------------------------------------------------------------------- 1 | # SDLC 2 | ![Defect Lifecycle](https://upload.wikimedia.org/wikipedia/commons/1/19/SDLC_-_Software_Development_Life_Cycle.jpg) 3 | - Ranieri SDLC basics 4 | 1. Requirement analysis/planning 5 | - What are the most important things to get done? 6 | - Are there any current issues that need to be addressed? 7 | - What have we learned previously that might help us. 8 | 2. Design 9 | - Technologies 10 | - Arhcitecture 11 | - Create teams and workflows 12 | 3. Implement 13 | - Creating the application 14 | 4. Testing 15 | - verify everything workd 16 | 5. Deploy 17 | - make availabe to end users 18 | 6. Maitnenece/ Survailence 19 | - Making sure that the applicaiton has not crashed 20 | - Are there any problems reported by users. 21 | 22 | # STLC 23 | - A life cycle for testing 24 | - Kind of a sub set of the SDLC 25 | - A lot like the SDLCE 26 | ![STLC ](stlc.png) 27 | 28 | 29 | # Defect Lifecycle 30 | ![Defect Lifecycle](defectlifecycle.png) -------------------------------------------------------------------------------- /Reviews/Ranieri Corp Test Strategy.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/Reviews/Ranieri Corp Test Strategy.docx -------------------------------------------------------------------------------- /Reviews/TestPlan.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/Reviews/TestPlan.docx -------------------------------------------------------------------------------- /Reviews/TestTerminolgy.md: -------------------------------------------------------------------------------- 1 | # Testing Terminology 2 | - **Testing** validating that an application works 3 | - **Test Case** singlular test. A single comprehensive unit. @Test 4 | - **Test Suite** a collection of test cases that are related to each other 5 | - **defect/bug** Anything in an application that does not work as intended. 6 | - Priority 7 | - how urgent a bug is that this bug gets fixed. 8 | - Severity 9 | - How much a affects a feature. 10 | - Usually go hand in hand but not always 11 | - High Priority/ Low Severity 12 | - The logo on the homepage is for the wrong company 13 | - Low Priority/ High Severity 14 | - The ability to edit employees' names is just completely broken 15 | - **Test Strategy** 16 | - High Level Document 17 | - Company wide documents 18 | - Explains how developers report bugs and make test reports 19 | - Roles and responsibilities 20 | - All API endpoints must documented 21 | - Workflow for fixing bugs 22 | - make a branch called "something-bug" 23 | - **Test Plan** 24 | - Lower level Document 25 | - It is for a single project 26 | - Technolgies to be used 27 | - ex Behave and Python 28 | - pytest 29 | - Schedules containing deadlines/ important dates 30 | - What is being tested 31 | - what is going to be tested and what is not 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Reviews/arrays.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/Reviews/arrays.png -------------------------------------------------------------------------------- /Reviews/defectlifecycle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/Reviews/defectlifecycle.png -------------------------------------------------------------------------------- /Reviews/httpReview.md: -------------------------------------------------------------------------------- 1 | # HTTP Review 2 | ### Hyper Text Transfer Protocol 3 | - http is the main form of communication on the internet 4 | - Request reponse based system 5 | - you will always get back a response saying how your request was processed 6 | 7 | ### HTTP Request 8 | - HTTP Version 9 | - URL 10 | - where it is going 11 | - Verb 12 | - What type of request it is 13 | - Headers 14 | - meta infomation about the request 15 | - Body 16 | - the main content you are sending 17 | 18 | ### Verbs 19 | - GET 20 | - Cannot have a body 21 | - POST 22 | - PUT 23 | - DELETE 24 | - PATCH 25 | 26 | ### HTTP Response 27 | - HTTP Version 28 | - Headers 29 | - Body 30 | - Status code (How it was processed) 31 | - 100s 32 | - information 33 | - 200s 34 | - successes 35 | - 300s 36 | - redirects 37 | - 400s 38 | - client errors 39 | - 500s 40 | - web server error (very bad) 41 | 42 | ### JSON 43 | - JavaScript Object Notation 44 | - IT IS JUST A FORMATTED STRING 45 | - Primary way of sending information around the web 46 | - every programming languages can use strings 47 | - Very easy for machines to parse 48 | - Rules of JSON 49 | - Naming SHOULD follow JS naming conventions 50 | - camelCase 51 | - firstName 52 | - JSON only has three data types for values 53 | - string 54 | - number 55 | - boolean 56 | - "KEY":value 57 | - if value is string "KEY": "value" 58 | - if value is number no quoutes 59 | - if values is boolean no quotes 60 | 61 | ```json 62 | { 63 | "name":"Adam", 64 | "age":20, 65 | "profession": "Trainer", 66 | "languages":["Java", "JS", "Python"] 67 | } 68 | ``` 69 | 70 | -------------------------------------------------------------------------------- /Reviews/java-collection-framework-hierarchy.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/Reviews/java-collection-framework-hierarchy.jpg -------------------------------------------------------------------------------- /Reviews/javaquestions/moar-java-questions.md: -------------------------------------------------------------------------------- 1 | What is Encapsulation? 2 | What is Abstraction? 3 | What is Inheritance? 4 | What is Polymorphism? 5 | What is an Interface? 6 | Can I instantiate an Abstract class? Constructor? 7 | Why would you use an Abstract class over an Interface? 8 | equals() vs ==? 9 | Can I force garbage collection? 10 | Which method does the garbage collector call? 11 | What is the finally block? 12 | Is a catch block needed? 13 | What are Generics for? 14 | Comparable vs Comparator 15 | Hashtable vs Hashmap 16 | What is a deadlock? 17 | Which are the scopes of a variable? 18 | Can you override static methods? 19 | What are Wrapper classes? 20 | What is Varargs used for? 21 | What is the difference between protected and default? 22 | What is the final keyword used for? 23 | What is the difference between StringBuilder and Buffer? 24 | What is synchronization? 25 | How do you go about starting a thread? 26 | What is the difference between a List and a Set? 27 | Some concrete implementations of Set. 28 | LinkedList vs ArrayList 29 | How do you insert elements in a Map? 30 | Difference between Exception and Error? 31 | What is a Singleton? 32 | What is the IS-A rule? 33 | Where are variable references stored? 34 | When is an object ready for garbage collection? 35 | What is reflection? 36 | What makes the String class special? 37 | Exception vs RuntimeException 38 | Rules of the catch block? 39 | What does the Iterable interface do? 40 | HashSet vs TreeSet 41 | What is a Map? 42 | Can I sort a Map? 43 | Can an Interface have variables? What are they? 44 | What is an Abstract class? 45 | What are default methods in an interface? 46 | What's the first line in a constructor? 47 | What is constructor chaining? 48 | What is a short circuit operator? 49 | Where are Strings stored in memory? 50 | What is hashCode() for? 51 | What's the parent of all exceptions? 52 | Can I catch an error? Does it make sense? 53 | Is there any case the finally block won't execute? 54 | Array vs ArrayList 55 | What is a Thread? 56 | What is a Factory? 57 | -------------------------------------------------------------------------------- /Reviews/jvm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/Reviews/jvm.png -------------------------------------------------------------------------------- /Reviews/pipelinesetup.md: -------------------------------------------------------------------------------- 1 | 1. Create a linux micro ec2 2 | 2. run this script 3 | ```bat 4 | sudo yum install -y git 5 | sudo yum install -y maven 6 | wget https://downloads.apache.org/tomcat/tomcat-9/v9.0.48/bin/apache-tomcat-9.0.48.tar.gz 7 | tar -xf apache-tomcat-9.0.48.tar.gz 8 | rm apache-tomcat-9.0.48.tar.gz 9 | cd apache-tomcat-9.0.48/webapps 10 | wget https://get.jenkins.io/war-stable/2.289.1/jenkins.war 11 | cd ../bin 12 | ./startup.sh 13 | ``` 14 | 3. give a minute or two to wait for jenkins to start 15 | 4. access Jenkins via http://ipaddress:8080/jenkins 16 | 5. insert the admin password which can be found by doing 17 | ```bat 18 | cat /home/ec2-user/.jenkins/secrets/initialAdminPassword 19 | ``` 20 | 6. install suggested plugins 21 | 7. create a new free style project 22 | 8. Select github project and add project url 23 | 9. select git for version control 24 | 10. make blank the build branch 25 | 11. run build now to see that it clones the directory correctly 26 | 12. add build step, execute shell 27 | ```bat 28 | cd /home/ec2-user/.jenkins/workspace/{myproject} 29 | mvn package 30 | ``` 31 | 13. go to configure jenkins 32 | 14. go to github advanced options 33 | 15. find the github webhook url 34 | 16. on github go to settings->webhooks 35 | 17. add webhook and put that url 36 | -------------------------------------------------------------------------------- /Reviews/scrum.md: -------------------------------------------------------------------------------- 1 | # Scrum 2 | - Agile is just developement mindset. It does not tell you how to do anything 3 | - Scrum is a popular way of promoting Agile development 4 | - An iterative way of creating software 5 | - **Sprint** 6 | - A single iteration on a software project 7 | - 2-3 weeks in length 8 | - **Roles** 9 | - Stakeholder 10 | - Who the application is being built for 11 | - Bank of America Accountind Division etc... 12 | - Product Owner 13 | - Represents the stakeholder and is ultimately responsible for the success or failure of the project. 14 | - Key person to talk to regarding requirements and themes(acessiblity) 15 | - Scrum Master 16 | - Person in charge of a scrum team 17 | - Usually a technical person (lead or senior devloper) 18 | - Doing what they can to remove any blockers and help perform at their highest 19 | - Cheerleader 20 | - Help debug 21 | - Talk to clients 22 | - Team members (Scrumlings) 23 | - developers 24 | - DevOps IT 25 | - Bussiness Analysts(talk with clients and help create user stoires) 26 | - **Ceremonies** 27 | - User Story Grooming 28 | - Done at the begining of a sprint 29 | - Create user stories and acceptance criteria 30 | - Story Pointing 31 | - Process of assiging difficulty to a user story 32 | - Assign user stories to different teams 33 | - Daily Standup 34 | - Each day every team member will say what they are working on 35 | - Talk about progress 36 | - If they have any blockers or need help 37 | - Offer 38 | - Sprint Retrospective 39 | - Done at the end of a sprint 40 | - reflect on what went well and what did not 41 | - Use the lessons learned for the planning the next iteration 42 | 43 | -------------------------------------------------------------------------------- /Reviews/stlc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/Reviews/stlc.png -------------------------------------------------------------------------------- /Reviews/testquestions.txt: -------------------------------------------------------------------------------- 1 | Positive and negative tests for a form? 2 | Most common test? 3 | What type are are test are unit tests? 4 | White box versus black box testing? 5 | Examples of black box? 6 | High Priortity vs High Severity? 7 | What is quality assurance? 8 | Automated vs manual test? 9 | Alpha vs Beta testing? 10 | Functional testing vs Performance testing? 11 | Types of Performance testing? 12 | Regression testing vs Retesting? 13 | Defect lifecycle? 14 | reasons to reject working on a bug? 15 | Behavior vs state verification? 16 | Set up Selenium and cucumber in Java? 17 | Why use runner files? 18 | Constraints of REST? 19 | STLC? 20 | Test plan vs Test Strategy? 21 | SDLC? 22 | Waterfall vs agile? 23 | Can you do agile? 24 | Can do to be agile? 25 | roles in scrum? 26 | sprints in Scrum? 27 | Test strategy vs Test plan -------------------------------------------------------------------------------- /Reviews/usecases.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/Reviews/usecases.png -------------------------------------------------------------------------------- /Reviews/waterfall-model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/Reviews/waterfall-model.png -------------------------------------------------------------------------------- /Seleniumwaits/1000th.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 | 12 | 13 | 20 | 21 | -------------------------------------------------------------------------------- /Seleniumwaits/100_automate.py: -------------------------------------------------------------------------------- 1 | from selenium import webdriver # module 2 | from selenium.webdriver.chrome.webdriver import WebDriver 3 | from selenium.webdriver.remote.webelement import WebElement # WebDriver class 4 | from selenium.webdriver.support.ui import WebDriverWait 5 | from selenium.webdriver.support import expected_conditions as EC 6 | from selenium.webdriver.common.by import By 7 | from selenium.webdriver.common.alert import Alert 8 | 9 | driver: WebDriver = webdriver.Chrome('C:\\Users\\AdamRanieri\\Desktop\\drivers\\chromedriver.exe') 10 | driver.implicitly_wait(10) 11 | 12 | try: 13 | driver.get("file:///C:/Users/AdamRanieri/Desktop/Seleniumwaits/1000th.html") 14 | button: WebElement = driver.find_element_by_id("winBtn") 15 | button.click() 16 | alert = Alert(driver) 17 | print(alert.text) 18 | alert.accept() 19 | 20 | finally: 21 | driver.quit() -------------------------------------------------------------------------------- /Seleniumwaits/automate.py: -------------------------------------------------------------------------------- 1 | from selenium import webdriver # module 2 | from selenium.webdriver.chrome.webdriver import WebDriver 3 | from selenium.webdriver.remote.webelement import WebElement # WebDriver class 4 | from selenium.webdriver.support.ui import WebDriverWait 5 | from selenium.webdriver.support import expected_conditions as EC 6 | from selenium.webdriver.common.by import By 7 | 8 | import time 9 | driver: WebDriver = webdriver.Chrome('C:\\Users\\AdamRanieri\\Desktop\\drivers\\chromedriver.exe') 10 | driver.implicitly_wait(10) # wait 10 seconds before throwing an error 11 | # A MAXIUM WAIT time. if the element is found then it is not going to wait the full 10 seonds 12 | # implicit waits are set once per driver 13 | 14 | # waits are ways of telling selenium to wait on throwing an ERROR if it cannot find an element 15 | # for a specific amount of time 16 | 17 | try: 18 | driver.get("file:///C:/Users/AdamRanieri/Desktop/Seleniumwaits/slowpage.html") 19 | 20 | # worst way (sadly unavoidable or seen in bad code) 21 | # time.sleep(5) # makes your python code halt for 5 seconds 22 | #name_input: WebElement = driver.find_element_by_id("nameInput") 23 | 24 | #Explicit waits are used for specific elements 25 | # explicit waits are usually in your step implementations 26 | name_input: WebElement = WebDriverWait(driver,5).until(EC.presence_of_element_located((By.ID,"nameInput"))) 27 | name_input.send_keys("Adam Ranieri") 28 | 29 | finally: 30 | driver.quit() -------------------------------------------------------------------------------- /Seleniumwaits/slowpage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 |
11 | 12 |
13 | 14 | 23 | -------------------------------------------------------------------------------- /TDD.txt: -------------------------------------------------------------------------------- 1 | TDD Done the right way 2 | 3 | 1. design an interface with many functions 4 | Craft method signtures 5 | name of the method, the types it takes in, the order the parameters, what it returns 6 | 7 | 2. Write tests that would prove those functions work as intended 8 | a. They serve as a way to test functionality 9 | b. Making you use the functions to see if they are intuitive to use as designed 10 | c. Are there any edge cases or weird inputs you might not have considered 11 | edge cases are inputs that are uncommon or might be troublesome 12 | a good example is 0. 13 | 14 | 3. Write the implementation 15 | fill out the funcitons 16 | 17 | 4. Keep refining your code until you pass all the test cases 18 | 19 | I GUARANTEE YOU THIS WILL APPROACH WILL SAVE YOU TIME!!!!!!!!! 20 | I WILL NOT HELP YOU DEBUG YOUR PROJECTS UNLESS YOU HAVE TESTS!!!!! 21 | ONE OF THE BIGGEST PROBLEMS IS NOT FIXING BUGS. IT IS FINDING WHERE THEY COME FROM!!!! 22 | -------------------------------------------------------------------------------- /TestTypes.md: -------------------------------------------------------------------------------- 1 | # Types of Test 2 | - Unit Test 3 | - An atomic test 4 | - A test the checks functionality of a SINGLE FUNCTION 5 | - That function SHOULD NOT rely on outside functionality 6 | - A service test that uses mocked dependency is a unit test 7 | - Integration Test 8 | - A composite test 9 | - A test that requires multiple pieces of functionality to work correctly to pass 10 | - A serivce test that is not mocked requires a DAO that works 11 | - A function that has to call other other functions that you have written 12 | - End to End Test E2E 13 | - Test an application as an end user 14 | - They require the ENTIRE feature to be working in order for the test to pass 15 | - Create a book on my web page and see that the book is given an ID and added to my view all books table. 16 | - The front-end and the back-end had to be working 17 | - Automated Test 18 | - Any test executed by a machine 19 | - Often used in reference to selenium 20 | - But applies to any testing framework 21 | - JUnit 22 | - pytest 23 | - goal as a developer is to automate everything you can 24 | - Manual Test 25 | - A test performed directly by a human -------------------------------------------------------------------------------- /WikiAutomationJava/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /WikiAutomationJava/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /WikiAutomationJava/.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | -------------------------------------------------------------------------------- /WikiAutomationJava/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /WikiAutomationJava/WikiAutomationJava.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /WikiAutomationJava/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | WikiAutomationJava 9 | 1.0-SNAPSHOT 10 | 11 | 12 | 14 13 | 14 14 | 15 | 16 | 17 | 18 | io.cucumber 19 | cucumber-java 20 | 6.1.1 21 | test 22 | 23 | 24 | 25 | 26 | io.cucumber 27 | cucumber-junit 28 | 6.1.1 29 | test 30 | 31 | 32 | 33 | 34 | org.seleniumhq.selenium 35 | selenium-java 36 | 3.141.59 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /WikiAutomationJava/src/test/java/dev/ranieri/pages/WikiHomePage.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.pages; 2 | 3 | import org.openqa.selenium.WebDriver; 4 | import org.openqa.selenium.WebElement; 5 | import org.openqa.selenium.support.FindBy; 6 | import org.openqa.selenium.support.PageFactory; 7 | 8 | public class WikiHomePage { 9 | 10 | private WebDriver driver; 11 | 12 | public WikiHomePage(WebDriver driver){ 13 | this.driver = driver; 14 | PageFactory.initElements(driver,this); // this line will read the FindBy Anotations 15 | // and automatically get the elements for you 16 | } 17 | 18 | @FindBy(id = "js-link-box-en") 19 | public WebElement english; 20 | 21 | @FindBy(css = "div[lang='es']") 22 | public WebElement spanish; 23 | 24 | @FindBy(className = "lang8") 25 | public WebElement italian; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /WikiAutomationJava/src/test/java/dev/ranieri/runners/BasicRunner.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.runners; 2 | 3 | import dev.ranieri.pages.WikiHomePage; 4 | import io.cucumber.junit.Cucumber; 5 | import io.cucumber.junit.CucumberOptions; 6 | import org.junit.AfterClass; 7 | import org.junit.BeforeClass; 8 | import org.junit.runner.RunWith; 9 | import org.openqa.selenium.WebDriver; 10 | import org.openqa.selenium.chrome.ChromeDriver; 11 | 12 | import java.io.File; 13 | 14 | @RunWith(Cucumber.class) 15 | @CucumberOptions(features = "classpath:features", glue = "dev.ranieri.steps") 16 | public class BasicRunner { 17 | 18 | public static WebDriver driver = null; 19 | public static WikiHomePage wikiHomePage = null; 20 | 21 | @BeforeClass 22 | public static void setup() { 23 | File file = new File("src/test/resources/chromedriver.exe"); 24 | System.setProperty("webdriver.chrome.driver", file.getAbsolutePath()); 25 | driver = new ChromeDriver();// ChomeDriver is an implementation of a web driver interface 26 | wikiHomePage = new WikiHomePage(driver);// pass the driver into any poms that you need 27 | } 28 | 29 | @AfterClass 30 | public static void teardown(){ 31 | driver.quit(); 32 | } 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /WikiAutomationJava/src/test/java/dev/ranieri/steps/BabySteps.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.steps; 2 | 3 | import io.cucumber.java.en.Given; 4 | import io.cucumber.java.en.Then; 5 | import io.cucumber.java.en.When; 6 | 7 | public class BabySteps { 8 | 9 | @Given("I am somewhere") 10 | public void i_am_somewhere() { 11 | System.out.println("I am somewhere"); 12 | } 13 | 14 | @When("I do something") 15 | public void i_do_something() { 16 | System.out.println("I did something"); 17 | } 18 | 19 | @Then("Something should appear") 20 | public void something_should_appear() { 21 | System.out.println("Something done did happened"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /WikiAutomationJava/src/test/java/dev/ranieri/steps/LanguageSteps.java: -------------------------------------------------------------------------------- 1 | package dev.ranieri.steps; 2 | 3 | import dev.ranieri.runners.BasicRunner; 4 | import io.cucumber.java.en.Given; 5 | import io.cucumber.java.en.Then; 6 | import io.cucumber.java.en.When; 7 | import org.junit.Assert; 8 | 9 | public class LanguageSteps { 10 | 11 | @Given("The Guest is on the Wikipedia Home Page") 12 | public void the_Guest_is_on_the_Wikipedia_Home_Page() { 13 | BasicRunner.driver.get("https://www.wikipedia.org/"); 14 | } 15 | 16 | @When("The Guest clicks on English") 17 | public void the_Guest_clicks_on_English() { 18 | BasicRunner.wikiHomePage.english.click(); 19 | } 20 | 21 | @Then("The Guest should be on the English Home Page") 22 | public void the_Guest_should_be_on_the_English_Home_Page() { 23 | String title = BasicRunner.driver.getTitle(); 24 | Assert.assertEquals(title,"Wikipedia, the free encyclopedia"); 25 | } 26 | 27 | @When("The Guest clicks on Spanish") 28 | public void the_Guest_clicks_on_Spanish() { 29 | BasicRunner.wikiHomePage.spanish.click(); 30 | } 31 | 32 | @Then("The Guest should be on the Spanish Home Page") 33 | public void the_Guest_should_be_on_the_Spanish_Home_Page() { 34 | String title = BasicRunner.driver.getTitle(); 35 | Assert.assertEquals(title,"Wikipedia, la enciclopedia libre"); 36 | } 37 | 38 | @When("The Guest clicks on Italian") 39 | public void the_Guest_clicks_on_Italian() { 40 | BasicRunner.wikiHomePage.italian.click(); 41 | } 42 | 43 | @Then("The Guest should be on the Italian Home Page") 44 | public void the_Guest_should_be_on_the_Italian_Home_Page() { 45 | String title = BasicRunner.driver.getTitle(); 46 | Assert.assertEquals(title,"Wikipedia, l'enciclopedia libera"); 47 | } 48 | 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /WikiAutomationJava/src/test/resources/chromedriver.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/WikiAutomationJava/src/test/resources/chromedriver.exe -------------------------------------------------------------------------------- /WikiAutomationJava/src/test/resources/features/languages.feature: -------------------------------------------------------------------------------- 1 | Feature: Multiple Languages should be supported 2 | 3 | Scenario: Navigate to English Wikipedia 4 | Given The Guest is on the Wikipedia Home Page 5 | When The Guest clicks on English 6 | Then The Guest should be on the English Home Page 7 | 8 | Scenario: Navigate to Spanish Wikipedia 9 | Given The Guest is on the Wikipedia Home Page 10 | When The Guest clicks on Spanish 11 | Then The Guest should be on the Spanish Home Page 12 | 13 | Scenario: Navigate to Italian Wikipedia 14 | Given The Guest is on the Wikipedia Home Page 15 | When The Guest clicks on Italian 16 | Then The Guest should be on the Italian Home Page 17 | 18 | Scenario: Person Loves to quickly navigate between pages 19 | Given The Guest is on the Wikipedia Home Page 20 | When The Guest clicks on Italian 21 | Given The Guest is on the Wikipedia Home Page 22 | When The Guest clicks on Spanish 23 | Given The Guest is on the Wikipedia Home Page 24 | When The Guest clicks on English 25 | Given The Guest is on the Wikipedia Home Page 26 | When The Guest clicks on Spanish -------------------------------------------------------------------------------- /WikiAutomationJava/src/test/resources/features/sample.feature: -------------------------------------------------------------------------------- 1 | Feature: Sample feature file 2 | 3 | Scenario: Show that cucumber works 4 | Given I am somewhere 5 | When I do something 6 | Then Something should appear -------------------------------------------------------------------------------- /WikiAutomationJava/target/test-classes/chromedriver.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/WikiAutomationJava/target/test-classes/chromedriver.exe -------------------------------------------------------------------------------- /WikiAutomationJava/target/test-classes/dev/ranieri/pages/WikiHomePage.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/WikiAutomationJava/target/test-classes/dev/ranieri/pages/WikiHomePage.class -------------------------------------------------------------------------------- /WikiAutomationJava/target/test-classes/dev/ranieri/runners/BasicRunner.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/WikiAutomationJava/target/test-classes/dev/ranieri/runners/BasicRunner.class -------------------------------------------------------------------------------- /WikiAutomationJava/target/test-classes/dev/ranieri/steps/BabySteps.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/WikiAutomationJava/target/test-classes/dev/ranieri/steps/BabySteps.class -------------------------------------------------------------------------------- /WikiAutomationJava/target/test-classes/dev/ranieri/steps/LanguageSteps.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/WikiAutomationJava/target/test-classes/dev/ranieri/steps/LanguageSteps.class -------------------------------------------------------------------------------- /WikiAutomationJava/target/test-classes/features/languages.feature: -------------------------------------------------------------------------------- 1 | Feature: Multiple Languages should be supported 2 | 3 | Scenario: Navigate to English Wikipedia 4 | Given The Guest is on the Wikipedia Home Page 5 | When The Guest clicks on English 6 | Then The Guest should be on the English Home Page 7 | 8 | Scenario: Navigate to Spanish Wikipedia 9 | Given The Guest is on the Wikipedia Home Page 10 | When The Guest clicks on Spanish 11 | Then The Guest should be on the Spanish Home Page 12 | 13 | Scenario: Navigate to Italian Wikipedia 14 | Given The Guest is on the Wikipedia Home Page 15 | When The Guest clicks on Italian 16 | Then The Guest should be on the Italian Home Page 17 | 18 | Scenario: Person Loves to quickly navigate between pages 19 | Given The Guest is on the Wikipedia Home Page 20 | When The Guest clicks on Italian 21 | Given The Guest is on the Wikipedia Home Page 22 | When The Guest clicks on Spanish 23 | Given The Guest is on the Wikipedia Home Page 24 | When The Guest clicks on English 25 | Given The Guest is on the Wikipedia Home Page 26 | When The Guest clicks on Spanish -------------------------------------------------------------------------------- /WikiAutomationJava/target/test-classes/features/sample.feature: -------------------------------------------------------------------------------- 1 | Feature: Sample feature file 2 | 3 | Scenario: Show that cucumber works 4 | Given I am somewhere 5 | When I do something 6 | Then Something should appear -------------------------------------------------------------------------------- /arrays.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/arrays.png -------------------------------------------------------------------------------- /asyncjs/asyncd.md: -------------------------------------------------------------------------------- 1 | # Asynchronous 2 | - JavaScript is a single threaded language 3 | - It can only EVER do one thing at a time 4 | - other langugaes can make multiple threads and do several operations simulataneously 5 | - If you have some infinite JS loop your web page breaks 6 | - JavaScript cannot make threads but IS asynchronous and event driven 7 | ### CORS 8 | - Cross Origin Resource Sharing 9 | - CORS is a security protocol of browsers 10 | - JavaScript is not allowed to make HTTP requests to servers unless that server 11 | has specifically allowed it 12 | - By default JS can only make requests to webservers on the same domain 13 | - If you web application hosts its own html -------------------------------------------------------------------------------- /asyncjs/eventqueue.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Document 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 29 | -------------------------------------------------------------------------------- /asyncjs/pokeviewer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Pokedex viewer 5 | 6 | 7 |

My Pokedex Viewer

8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
NameHeightWeight
17 | 18 | poke image 19 | 20 | 21 | 35 | -------------------------------------------------------------------------------- /branching.txt: -------------------------------------------------------------------------------- 1 | 2 | 1. Create a skeleton project on the main branch 3 | 2. to add a feature make a new branch off of main for that feature 4 | 3. add your code and tests to that branch 5 | - git checkout scorehandlers 6 | 4. push your code up to github 7 | 5. request a merge 8 | 6. Have someone else look over the merge request 9 | 7a. It looks good and the code is merged into the main branch 10 | 7b. Deficient and rejected 11 | if it is rejected you should close the merge request.make the edits 12 | and then make another merge request 13 | 14 | pull request merge request are synonymous terms -------------------------------------------------------------------------------- /clientsidetech/JavaScript.md: -------------------------------------------------------------------------------- 1 | # JavaScript 2 | ### Background 3 | - 1995 Brendan Eich was tasked with making a programming languuage to make web pages dynamic 4 | - Designed JS by himself in about 9 days 5 | - JS is filled with quirky features 6 | - Has almost NOTHING to do with Java 7 | - JavaScript was entirely chosen as a marketing ploy because Java was the hip new language 8 | 9 | ### Main Features of JS 10 | - Found in the Web Broswer 11 | - client-side language 12 | - dynamically typed 13 | - do not have to declare variable types 14 | - Loosely typed 15 | - JS wil implicitly coerce values into other types 16 | - Python throws you an error 17 | - Multi-paradigmed 18 | - CakeSalad (little rules and mix matched features) 19 | - People kept adding features to it until it didn't really fit any one style 20 | - Old school JS and a good portion of modern JS is still very functional in nature 21 | - heavy emphasis on functions and callbacks 22 | - High Level programming lanugage 23 | - automatic memory management 24 | - Garbage Collection 25 | - JS was devloped with flexiblity in mind 26 | - Python was readability 27 | - Java was scalability 28 | - ES6 (EcmaScript6) 29 | - the latest version of JS 30 | - added helpful features like classes and async await 31 | - JS is a single threaded language 32 | - You CANNOT run code in parallel in JS 33 | - Event driven lanuguage 34 | -------------------------------------------------------------------------------- /clientsidetech/arrays.js: -------------------------------------------------------------------------------- 1 | // arrays are very similar to arrays in python 2 | // you can define them using array literal syntax. 3 | // they can hold anything. they dynamically size. 4 | 5 | let nums = [10,20,30,40,50] 6 | let stuff = ["asdf",null,9,"g",90.4,["a","b","c"],"end"] 7 | 8 | for(const num of nums){ 9 | console.log(num) // iterate over an array 10 | } 11 | 12 | stuff[3]// retrieve 4th element from the array 13 | 14 | -------------------------------------------------------------------------------- /clientsidetech/datatypes.js: -------------------------------------------------------------------------------- 1 | // JS has primtives and objects 2 | // JS 'primitives' do have methods 3 | // boolean 4 | // number 5 | // string 6 | // null 7 | // undefined 8 | // symbol (will not cover) 9 | b = true 10 | n = 100 11 | tim = "Tim" 12 | // null is a value that must explicitly assigned by a program j = null 13 | y = null 14 | // undefined is the default value of everything in JS 15 | x = undefined -------------------------------------------------------------------------------- /clientsidetech/football.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/clientsidetech/football.jpg -------------------------------------------------------------------------------- /clientsidetech/functions.js: -------------------------------------------------------------------------------- 1 | // Like every programming language JS has functions 2 | // there are a few ways to define functions 3 | // Good JS should have semicolons 4 | // JS will auto insert ; to it's best ability 5 | // works 99% of time and the other 1% will cost you hours of debugging 6 | 7 | // function keyword 8 | function hello(name){ 9 | 10 | console.log("Hello " + name); 11 | } 12 | 13 | hello("Adam") 14 | 15 | // storing the function in a variable 16 | const hola = function(nombre){ 17 | console.log("Hola " + nombre); 18 | } 19 | 20 | hola("Tim") 21 | 22 | // arrow notation DOES NOT use the function keyword 23 | // there are minor differences between function and arrow notation 24 | const gutentag = (name) => { 25 | console.log("Gutentag " + name); 26 | } 27 | 28 | // functions in JS can be invoked with ANY number of arguments 29 | 30 | function add(num1, num2){ 31 | return num1+num2; 32 | } 33 | 34 | // ALL of this is valid JS. It will NOT throw an error 35 | let sum = add() // calling a function with too few parameters will give the parameters a 36 | // default value of undefined 37 | console.log(sum) 38 | 39 | sum = add(100) 40 | console.log(sum) 41 | 42 | sum = add(100,200) 43 | console.log(sum) 44 | 45 | sum = add(100,200,300) // any excess parameters are ignored 46 | console.log(sum) 47 | 48 | // JS DOES NOT have type annotations BUT it default arguments 49 | // that can give your functions intellisense and be a bit more robust 50 | function bonjour(napel = "Jacque"){ 51 | console.log("Bonjour " + napel) 52 | } -------------------------------------------------------------------------------- /clientsidetech/gatorfanpage.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 10 | Gator Football 11 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |

Gator Football

25 |

The Gators are the football for the University of Florida. They play in the SEC (South Eastern Conference) 26 | There biggest rivals are FSU, UGA and LSU. The university is known for Inventing the drink 27 | Gatorade. 28 |

29 |
30 | 31 |

Heisman Winners

32 |
    33 |
  • Steve Spurrier
  • 34 |
  • Danny Wuerffel
  • 35 |
  • Tim Tebow
  • 36 |
37 | 38 |

National Championships

39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
OpponentYear
FSU1996
Oklahoma2006
Ohio State2008
47 | 48 | 49 | Gator football player running 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /clientsidetech/hello.txt: -------------------------------------------------------------------------------- 1 | 2 |

Hello

3 | -------------------------------------------------------------------------------- /clientsidetech/helloworld.js: -------------------------------------------------------------------------------- 1 | console.log("Hello World") -------------------------------------------------------------------------------- /clientsidetech/runner.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Runner 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /clientsidetech/scopes.js: -------------------------------------------------------------------------------- 1 | // JS does NOT have the same scoping as Python 2 | // JS scopes are defined via KEYWORDS rather than location 3 | 4 | // if you put NOTHING in front of a variable. the variable is of GLOBAL scope 5 | function hello(){ 6 | // name = "Adam" // name is a global variable!!!!!! 7 | var name = "Adam" // var makes the variable FUNCTION scope 8 | console.log(name) 9 | } 10 | 11 | hello() 12 | console.log(name) 13 | 14 | function hola(){ 15 | console.log(nombre) 16 | var nombre = "James" // hoisting is a 'feature of JS' 17 | // BEFORE a function executes the var variables in it are given the value of undefined 18 | console.log(nombre) 19 | } 20 | 21 | hola() 22 | 23 | // let and const keywords 24 | // they are used to make variables BLOCK scoped 25 | // CANNOT be hoisted 26 | 27 | function bonjour(){ 28 | { 29 | let napel = "Jaxon" 30 | // block scoped 31 | // name is only in the scope of the curly bracket 32 | } 33 | 34 | console.log("bonjour "+ napel) 35 | } 36 | 37 | //bonjour() 38 | 39 | // use let and const. NEVER NEVER use var 40 | // avoid global variables whenever possible 41 | 42 | let x = 100 43 | x = 90 44 | 45 | // constant variables CANNOT be changed once assigned 46 | // have the same scoping rules as let 47 | const y = 1000 48 | y = 900 49 | 50 | 51 | -------------------------------------------------------------------------------- /clientsidetech/styles.css: -------------------------------------------------------------------------------- 1 | td { 2 | color: orange; 3 | } 4 | 5 | .champ { 6 | color: orchid; 7 | } 8 | thead.champ{ 9 | color: seagreen; 10 | } -------------------------------------------------------------------------------- /clientsidetech/truthyfalsy.js: -------------------------------------------------------------------------------- 1 | // JS has EXTREMELY aggressive type coercion 2 | // JS will compare apple to oranges even if they are both bananas 3 | 4 | console.log(100 == 100)// true 5 | console.log(100 == "100")// true JS will coerce the string into a number then compare the values 6 | console.log(10 == false)// false 7 | console.log(10 == true)// true 8 | console.log("" == false * 1)// true 9 | console.log(90/"hello" == false/true)// false 10 | let a = 90/"hello" 11 | console.log(a) // NaN not a number 12 | console.log(typeof(a))// not a number is of type number 13 | let b = 90/"hello" 14 | console.log(a == b)// false 15 | console.log(a == a)// false NaN is always FALSE in an evaluation 16 | console.log(a != a)// true 17 | 18 | // There are some inherent falsy values 19 | // values that coerce to false 20 | console.log(Boolean("")) 21 | console.log(Boolean(0)) 22 | console.log(Boolean(null)) 23 | console.log(Boolean(undefined)) 24 | console.log(Boolean(NaN)) 25 | // every other value in JS will be TRUE in a comparsion 26 | console.log(Boolean("0")) // true 27 | console.log(Boolean("0"- 0)) // false 28 | 29 | console.log("100"-0 + ("100"- 0))// JS level 99999 30 | // == loose equality operator 31 | // you should not use. it will coerce values before checking equality 32 | // === strict equality will also check to see of same type 33 | console.log(100 === "100")// false 34 | console.log(100 == "100")// true 35 | 36 | // there is no transitive property of type coercion 37 | console.log("0"==0)// true 38 | console.log(0 == false) // true 39 | console.log("0" == false) // false -------------------------------------------------------------------------------- /collectionsframework.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/collectionsframework.png -------------------------------------------------------------------------------- /deliverable.txt: -------------------------------------------------------------------------------- 1 | Start a dialogue 2 | - about people who we did not want to sign 3 | - Very obvious people 4 | - Like 90% certain they will not make 5 | 6 | what are deliverables? 7 | After week 1 evaluations 8 | name|rating|notes| -------------------------------------------------------------------------------- /encapsulation/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /encapsulation/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /encapsulation/.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | -------------------------------------------------------------------------------- /encapsulation/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /encapsulation/encapsulation.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /encapsulation/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | encapsulation 9 | 1.0-SNAPSHOT 10 | 11 | 12 | 14 13 | 14 14 | 15 | 16 | -------------------------------------------------------------------------------- /encapsulation/src/main/java/a/APlayground.java: -------------------------------------------------------------------------------- 1 | package a; 2 | 3 | import practical.Car; 4 | 5 | public class APlayground { 6 | 7 | 8 | public static void main(String[] args) { 9 | Shape shape = new Shape(); 10 | 11 | shape.pubMethod(); 12 | shape.proMethod(); 13 | shape.defMethod(); 14 | //shape.privMethod(); 15 | shape.otherPubMethod(); 16 | System.out.println(Car.description); 17 | } 18 | 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /encapsulation/src/main/java/a/Shape.java: -------------------------------------------------------------------------------- 1 | package a; 2 | 3 | // Encapsualtion is how we protect data an methods from other parts of the code 4 | // why bother? In large applications you want to make sure that other developers use the code as intended. 5 | // if you have a variable that if edited broke the application why allow other parts of the code to access it 6 | 7 | // Java achieves encapsulation through access modifiers 8 | // these are keyword which limit the visibility of a method or variable 9 | // ACCESS MODIFIERS ARE NOT SCOPES!!!!!!!!!!! 10 | public class Shape { 11 | 12 | // Least restrictive 13 | // You can use public methods anywhere 14 | public void pubMethod(){ 15 | System.out.println("Hi I am a Public method you can use me anywhere!!!!!"); 16 | } 17 | 18 | // protected = default + child classes 19 | protected void proMethod(){ 20 | System.out.println("I am the protected method. I can be used anywhere in the package AND in child classes anywhere"); 21 | } 22 | 23 | // you can use default methods if in the same package 24 | void defMethod(){ 25 | System.out.println("I am the default method you can use me in this package only"); 26 | } 27 | 28 | // most restrictive 29 | // you can only call me in this class 30 | private void privMethod(){ 31 | System.out.println("Hi I am the private method. You can only call me within this class"); 32 | } 33 | 34 | public void otherPubMethod(){ 35 | System.out.println("I can call the private method in my code block"); 36 | this.privMethod(); 37 | } 38 | 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /encapsulation/src/main/java/b/BPlayground.java: -------------------------------------------------------------------------------- 1 | package b; 2 | 3 | import a.Shape; 4 | 5 | public class BPlayground { 6 | 7 | public static void main(String[] args) { 8 | Shape shape = new Shape(); 9 | 10 | shape.pubMethod(); 11 | // shape.proMethod(); 12 | // shape.defMethod(); 13 | shape.otherPubMethod(); 14 | 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /encapsulation/src/main/java/b/Rectangle.java: -------------------------------------------------------------------------------- 1 | package b; 2 | 3 | import a.Shape; 4 | 5 | public class Rectangle extends Shape { 6 | 7 | public void rectPubMethod(){ 8 | System.out.println("The child class has access to the protected method"); 9 | this.proMethod();// 10 | //this.privMethod();// Not even the child can access a private method defined in the parent. Even though 11 | // it is inherited it cannot access it. 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /encapsulation/src/main/java/practical/Car.java: -------------------------------------------------------------------------------- 1 | package practical; 2 | 3 | public class Car { 4 | 5 | // static HAS NOTHING to do with access modifiers it is a Class variable 6 | public static String description = "A Car is a self powered vehicle"; 7 | 8 | String make; 9 | String model; 10 | private int mileage; 11 | 12 | public Car(String make, String model, int mileage) { 13 | this.make = make; 14 | this.model = model; 15 | this.mileage = mileage; 16 | } 17 | 18 | public void driveCar(int miles){ 19 | if(miles <= 0){ 20 | return;// empty return in a void method to end execution immediately 21 | } 22 | this.mileage += miles; 23 | } 24 | 25 | // Static methods CANNOT and should not use the this keyword 26 | // They tend to be helpful methods that make sense even if no instance of the class exists 27 | static double convertMilesToKilometers(int miles){ 28 | return miles*1.6; 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return "Car{" + 34 | "make='" + make + '\'' + 35 | ", model='" + model + '\'' + 36 | ", mileage=" + mileage + 37 | '}'; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /encapsulation/src/main/java/practical/CarPlayground.java: -------------------------------------------------------------------------------- 1 | package practical; 2 | 3 | 4 | public class CarPlayground { 5 | 6 | public static void main(String[] args) { 7 | System.out.println(Car.description); 8 | 9 | Car car = new Car("Subaru", "Crosstrek", 40000); 10 | 11 | System.out.println(car); 12 | car.driveCar(-2000); 13 | System.out.println(car); 14 | car.driveCar(600); 15 | System.out.println(car); 16 | 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /encapsulation/src/main/java/practical/Person.java: -------------------------------------------------------------------------------- 1 | package practical; 2 | 3 | // A Java Bean is a specific type of Java class 4 | // 1. All fields must be private 5 | // 2. All fields should be access via a public getter and setter 6 | // 3. There MUST be a no args constructor (you can have more constructor) 7 | // 4. (optional) implement serializable. Serializable is not deprecated in Java so...... 8 | 9 | // A POJO Plain Old Java Object is any class that is NOT a bean 10 | public class Person { 11 | 12 | private int personId; 13 | private String fname; 14 | private String lname; 15 | 16 | // A lot of Java best practice guidelines say to write a no args constructor even if it does nothing 17 | // rather than use the implicit one 18 | public Person() { 19 | } 20 | 21 | public int getPersonId() { 22 | return personId; 23 | } 24 | 25 | public void setPersonId(int personId) { 26 | this.personId = personId; 27 | } 28 | 29 | public String getFname() { 30 | return fname; 31 | } 32 | 33 | public void setFname(String fname) { 34 | this.fname = fname; 35 | } 36 | 37 | public String getLname() { 38 | return lname; 39 | } 40 | 41 | public void setLname(String lname) { 42 | this.lname = lname; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /encapsulation/target/classes/a/APlayground.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/encapsulation/target/classes/a/APlayground.class -------------------------------------------------------------------------------- /encapsulation/target/classes/a/Shape.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/encapsulation/target/classes/a/Shape.class -------------------------------------------------------------------------------- /encapsulation/target/classes/b/BPlayground.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/encapsulation/target/classes/b/BPlayground.class -------------------------------------------------------------------------------- /encapsulation/target/classes/b/Rectangle.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/encapsulation/target/classes/b/Rectangle.class -------------------------------------------------------------------------------- /encapsulation/target/classes/practical/Car.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/encapsulation/target/classes/practical/Car.class -------------------------------------------------------------------------------- /encapsulation/target/classes/practical/CarPlayground.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/encapsulation/target/classes/practical/CarPlayground.class -------------------------------------------------------------------------------- /java-collection-framework-hierarchy.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/java-collection-framework-hierarchy.jpg -------------------------------------------------------------------------------- /javaquestions/moar-java-questions.md: -------------------------------------------------------------------------------- 1 | What is Encapsulation? 2 | What is Abstraction? 3 | What is Inheritance? 4 | What is Polymorphism? 5 | What is an Interface? 6 | Can I instantiate an Abstract class? Constructor? 7 | Why would you use an Abstract class over an Interface? 8 | equals() vs ==? 9 | Can I force garbage collection? 10 | Which method does the garbage collector call? 11 | What is the finally block? 12 | Is a catch block needed? 13 | What are Generics for? 14 | Comparable vs Comparator 15 | Hashtable vs Hashmap 16 | What is a deadlock? 17 | Which are the scopes of a variable? 18 | Can you override static methods? 19 | What are Wrapper classes? 20 | What is Varargs used for? 21 | What is the difference between protected and default? 22 | What is the final keyword used for? 23 | What is the difference between StringBuilder and Buffer? 24 | What is synchronization? 25 | How do you go about starting a thread? 26 | What is the difference between a List and a Set? 27 | Some concrete implementations of Set. 28 | LinkedList vs ArrayList 29 | How do you insert elements in a Map? 30 | Difference between Exception and Error? 31 | What is a Singleton? 32 | What is the IS-A rule? 33 | Where are variable references stored? 34 | When is an object ready for garbage collection? 35 | What is reflection? 36 | What makes the String class special? 37 | Exception vs RuntimeException 38 | Rules of the catch block? 39 | What does the Iterable interface do? 40 | HashSet vs TreeSet 41 | What is a Map? 42 | Can I sort a Map? 43 | Can an Interface have variables? What are they? 44 | What is an Abstract class? 45 | What are default methods in an interface? 46 | What's the first line in a constructor? 47 | What is constructor chaining? 48 | What is a short circuit operator? 49 | Where are Strings stored in memory? 50 | What is hashCode() for? 51 | What's the parent of all exceptions? 52 | Can I catch an error? Does it make sense? 53 | Is there any case the finally block won't execute? 54 | Array vs ArrayList 55 | What is a Thread? 56 | What is a Factory? 57 | -------------------------------------------------------------------------------- /obj.js: -------------------------------------------------------------------------------- 1 | 2 | something = "Global" 3 | 4 | let obj = { 5 | something:"inside the object", 6 | wasssup: function(){ 7 | console.log(this.something) 8 | function inner(){ 9 | console.log(this.something) 10 | } 11 | inner() 12 | } 13 | } 14 | 15 | obj.wasssup() -------------------------------------------------------------------------------- /project1.md: -------------------------------------------------------------------------------- 1 | # Project 1 2 | 3 | ## Expense Reimbursement System 4 | You are tasked with creating an expense reimbursement system. For a small company/group. This program will allow employees to create reimbursement requests.All Managers can view these requests and approve or deny them. When they approve/deny they 5 | can optionally leave a message. 6 | 7 | ### key features 8 | - Employee 9 | - An employee can login to see their own reimbursements, past and pending 10 | - An employee can submit a reimbursement with an amount and a reason 11 | - Bonus allow for file upload 12 | - Manager 13 | - A Manager can view all reimbursements past and pending 14 | - A Manager can appove or deny any reimbursement 15 | - Managers can view a 'statistics' page. That includes information like what employee spends the most money, mean expenditure cost etc... 16 | 17 | ### Key Notes 18 | - you do not have to allow for the creation of employees or managers. 19 | - You can have these already in the database. 20 | - You do not need to have implement security for application. You can assume that a later security team is responsible for making the applicaiton secure. 21 | - API routes do not need to be protected 22 | - Passwords do not have to be encrpted 23 | 24 | ### Technical and testing requirements 25 | - Backend developed in Javalin 26 | - Backend should be a RESTful web service 27 | - You may have to a make a non-REST compliant endpoint for login. This is normal. 28 | - AWS postgres RDS used to persist information 29 | - All DAO methods should have a test 30 | - All Service methods with logic should have a test 31 | - use mocking when applicable 32 | - There should be logging in the application 33 | - All user stories and acceptance criteria must be written out 34 | - completed E2E tests using gherkin and selnium for all user stories. 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /seleniumbasics/helloselenium.py: -------------------------------------------------------------------------------- 1 | from selenium import webdriver # module 2 | from selenium.webdriver.chrome.webdriver import WebDriver 3 | from selenium.webdriver.remote.webelement import WebElement # WebDriver class 4 | 5 | driver: WebDriver = webdriver.Chrome('C:\\Users\\AdamRanieri\\Desktop\\drivers\\chromedriver.exe') 6 | driver.implicitly_wait(1) 7 | 8 | # driver.get("https://www.google.com/") 9 | # search_bar: WebElement = driver.find_element_by_name("q") 10 | # search_bar.send_keys("Gears of War 3") 11 | # search_button: WebElement = driver.find_element_by_name("btnK") 12 | # search_button.click() 13 | 14 | driver.get("https://orteil.dashnet.org/cookieclicker/") 15 | cookie: WebElement = driver.find_element_by_id("bigCookie") 16 | 17 | for x in range(1000): 18 | cookie.click() 19 | 20 | driver.quit() # close the browser and shutdown the chromedriver -------------------------------------------------------------------------------- /seleniumbasics/selenium.md: -------------------------------------------------------------------------------- 1 | # Selenium 2 | - Automation software for web browsers 3 | - It automates human actions on a web page 4 | - you can automate super human things like clicking 10 times a second 5 | - think of it as a bot 6 | - IS NOT A TESTING FRAMEWORK 7 | - Web Driver 8 | - the main object in selenium 9 | - you need a specific web driver for each browser 10 | - you will need to install one for chrome, one for firefox, for edge etc 11 | - Responsible for 12 | - getting web pages 13 | - grabbing html elements 14 | -------------------------------------------------------------------------------- /sql/library.sql: -------------------------------------------------------------------------------- 1 | 2 | -- Tables should be named in singular. a table name should represent what a single record in the table is 3 | create table book( 4 | book_id int primary key generated always as identity, 5 | title varchar(50), 6 | author varchar(50), 7 | available bool, 8 | quality int, 9 | return_date bigint -- timestamp might end up very large 10 | ) 11 | 12 | insert into book (title,author,available,quality,return_date) values ('It','Stephen King',true,1,0) 13 | select * from book; 14 | 15 | select * from book where book_id = 5 16 | 17 | update book set title='', author='', available=false, quality=1,return_date=0 where book_id =1 18 | 19 | delete from book where book_id =3 -------------------------------------------------------------------------------- /sql/sql.md: -------------------------------------------------------------------------------- 1 | # Database 2 | - It stores infomation in a PERMANENT physical way 3 | - Storing information in disk drive 4 | - magnetic tap 5 | - cuneiform tablets 6 | - If you turn of the power information is still there 7 | - Types of databases 8 | - relational databases 9 | - store infomation in tables and connect those tables to each other 10 | - ex 11 | - postgres 12 | - MariaDB 13 | - Oracle (yuck) 14 | - Microsoft SQL Server 15 | - MySQL 16 | - NoSQL databases 17 | - store information in documents 18 | - sometimes as just massive JSONs 19 | - REDIS 20 | - Key value pair 21 | 22 | # SQL Structured Query Language 23 | - Is a programming language for working with databases 24 | - DSL (Domain Specific Language) fancy term for saying that the lanugage was written to do a specific thing. 25 | - For SQL that was querying and working with databases 26 | - Very old for langauges, it came out in the 70s 27 | - There are many dialects of SQL 28 | 29 | # Relational Database structure 30 | - Information is stored in **tables** 31 | - Tables are comprised of rows(records) and columns(attributes) 32 | - You can connect these tables together using a foreign key 33 | - The tables and rules regarding those tables are called the **schema** 34 | 35 | # Normalization 36 | - The process by which we eliminate redundancy in our relation database 37 | - Normalized does NOT mean better 38 | - 1NF 39 | - Each record has to be unqiuely identifiable 40 | - unique unchanging primary key 41 | - The attributes should contain atomic information 42 | - Cannot be broken down into more meaningiful columns 43 | - Do not store array-like information in a column 44 | - DO NOT store string containing 5 phone numbers 45 | - 2NF 46 | - You 1NF 47 | - No Functional dependencies 48 | - You cannot create a column that could computed using other columns 49 | |player_id|attempted|made|shooting_percentage| 50 | |---------|---------|----|-------------------| 51 | |101 |200 |50 | 25 | 52 | 53 | - 3NF 54 | - In 2NF 55 | - No Transitive depenedencies 56 | - You cannot find the data elsewhere in the database -------------------------------------------------------------------------------- /urlrewrite/end.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | End 5 | 6 | 7 |

The end page

8 | 9 | 10 | 16 | -------------------------------------------------------------------------------- /urlrewrite/start.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Start 6 | 7 | 8 |

The start page

9 | Go to the end page 10 | 11 | 12 | 13 | 14 | 32 | -------------------------------------------------------------------------------- /waterfall-model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/waterfall-model.png -------------------------------------------------------------------------------- /webbasics.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamranieri/2105PythonBatch/5d6ecbc6e9a4212e86a532dd749dbe79669f6931/webbasics.docx -------------------------------------------------------------------------------- /webservicecreation.txt: -------------------------------------------------------------------------------- 1 | We have been hired to create a RESTful web service to keep track of books in a local community library. 2 | - The library works on an honor system (We are not keeping track of who checked out what or handing out late fines etc...) 3 | - Anyone can donate a book 4 | - Anyone can check out a book 5 | 6 | General tips 7 | 1. Use type annotations anytime you define a function 8 | 2. Use objects and classes whenever you can. (code is more readable and easier to refactor) 9 | 10 | YOU WILL BE USING TDD to develop every part of this applicaiton 11 | 1. Interface 12 | 2. Tests 13 | 3. Implementation 14 | 15 | 16 | 1. Identify what Resources you are keeping track/ managing 17 | - In this case it is books 18 | 2. Create an ENTITY class 19 | - An entity is an object that is designed to be saved somewhere 20 | - These classes rarely contain complex logic 21 | - The fields of the class are a convienient way of storing and moving information in our project 22 | - AN ENTITY MUST have some field that serves as an ID 23 | 24 | 3. Create A DAO for EACH entity class. 25 | - DAO (Data Access Object) 26 | - A class that is responsible for peristing information on that entity 27 | - How that information gets persisted is up to the developers 28 | - Normally database but could be anythinig 29 | - Text file, NoSQL database, JPEG, 30 | - We are using an python dictionary in memory to persist information 31 | - Very common when developing applications but in not in finished applications 32 | - A DAO should support the basic CRUD operation 33 | - CREATE 34 | - READ 35 | - UPDATE 36 | - DELETE 37 | 4. Create Services. Services do NOT have to be a perfect 1 to 1 with an entity 38 | - Services are responsible for Business logic 39 | - Application specific rules 40 | ex - Books are checked out with a 2 week return date 41 | - One copy of a book has to always be in the library 42 | - Generally two types of methods in your service 43 | - Wrapper methods (contain little logic and just call your DAO) 44 | - In general these wrapper methods do not need to be tested 45 | - Business logic methods which DO have logic - 46 | 47 | -------------------------------------------------------------------------------- /week1interviews.txt: -------------------------------------------------------------------------------- 1 | 2 | Adam 3 | ================================================= 4 | Carlos 2:00 5 | Jamal 2:15 6 | Boston 2:30 7 | Amin 2:45 8 | Areesh 3:00 9 | Sayed 3:15 10 | Mohammad 3:30 11 | Rob 3:45 12 | Weston 4:00 13 | 14 | 15 | Ryan 16 | ================================================= 17 | Anthony 2:00 18 | Basiru 2:15 19 | Bishwo 2:30 20 | Dominick 2:45 21 | Jonathan 3:00 22 | Jordan 3:15 23 | Joseph 3:30 24 | Maria 3:45 25 | 26 | 27 | Christina 28 | ================================================= 29 | Wolf 2:00 30 | Irina 2:15 31 | Eric 2:30 32 | Isaac 2:45 33 | Dan 3:00 34 | David 3:15 35 | Mason 3:30 36 | Robert 3:45 37 | --------------------------------------------------------------------------------