├── .gitignore ├── AvengersHoursPractice ├── week01 │ ├── CastingPractices.java │ ├── Notes.txt │ ├── StringManipulator.java │ ├── StringManipulatorTest.java │ └── StringPractice01.java ├── week02 │ ├── AnimalSpecies.java │ ├── ArrayListExamplesWithMethods.java │ ├── CustomMethodsExample.java │ ├── NoahsArk.java │ └── Notes.txt ├── week03 │ ├── GroceryList.java │ ├── GroceryListMain.java │ ├── GroceryListMainStatic.java │ └── Notes.txt ├── week04 │ ├── Item.java │ ├── Notes.txt │ ├── OnSaleItem.java │ └── TJMaxx.java ├── week05 │ ├── Chrome.java │ ├── ElementaryStudent.java │ ├── ElementaryStudentTests.java │ ├── Locators.java │ ├── UsingThrowKeyword.java │ ├── WebDriver.java │ └── WebTestExample.java ├── week06 │ ├── Calculator.java │ ├── CalculatorTest.java │ ├── Carpet.java │ ├── Floor.java │ ├── LoopWithCollections.java │ ├── Product.java │ ├── SetOfProducts.java │ └── TaskNotes.txt └── weekUnknown │ ├── PracticeTasks.java │ └── Tests.java ├── liveReview ├── extraPackageToShowImport │ └── CalculatorTest2.java ├── week01 │ ├── DateExample.java │ ├── EscapeSquences.java │ ├── PrintVsPrintln.java │ └── SomeImportantRules.java ├── week02 │ ├── ArithmeticOperators.java │ ├── CarInfo.java │ ├── EmployeeInfo.java │ ├── Naming_Convention.java │ ├── PrimitivesExample.java │ └── UserInputIntro.java ├── week03 │ ├── AddNumbers.java │ ├── DifferenceBetweenAndOrBitwiseOperators.java │ ├── DivisionAndRemainderPractice.java │ ├── EvenOrOdd.java │ ├── Grader.java │ ├── NotesWeek03 │ ├── Questions.java │ ├── RelationalOperatorExample.java │ ├── SomeExtraTasks.java │ └── UnaryReview.java ├── week04 │ ├── AdaireApartments.java │ ├── AmazonFreeShipping.java │ ├── NestedIfExample.java │ ├── Notes.txt │ ├── TernaryExample.java │ ├── TrafficLightSelector.java │ └── VendingNestedIF.java ├── week05 │ ├── DynamicSubstring.java │ ├── EmailExampleFromReplit.java │ ├── Notes.txt │ ├── ReplacePractice.java │ ├── Replit_Quiz_Question.java │ ├── ReverseUsingCharATMethod.java │ ├── StringReview01.java │ ├── StringReview02.java │ └── emailCheckInterview.java ├── week06 │ ├── BasicLoopExamples.java │ ├── EncryptPassword.java │ ├── Fibonacci.java │ ├── InfiniteLoop.java │ ├── Notes.txt │ ├── PrintAllLetters.java │ └── UpperBound.java ├── week07 │ ├── FrequencyOfCharacters.java │ ├── Notes.txt │ ├── RandomPassword.java │ ├── ShoppingList2ReplitTask.java │ ├── Task01.java │ ├── Task02.java │ └── WhileHungary.java ├── week08 │ ├── A01_ArrayExample.java │ ├── ArraLoopWithConditions.java │ ├── ArraysUtilityExamples.java │ ├── CharArray.java │ ├── CharArrayTwo.java │ ├── Notes.txt │ ├── ReportMaxPricedItem.java │ ├── ReverseArray.java │ ├── SentenceSplit.java │ ├── ShoppingAppTest.java │ └── ZombieAttack2.java ├── week09 │ ├── Calculator.java │ ├── CalculatorTest.java │ ├── CombineStrings.java │ ├── CustomMethodsPractice01.java │ ├── EtsySearch.java │ ├── Notes.txt │ ├── R01_ArraysBinarySearchExample.java │ └── R02_BiggestIn2DArray.java ├── week10 │ ├── ArrayListExample01.java │ ├── Notes.txt │ ├── R01_CountOfEven.java │ ├── R02_DifferenceBetween.java │ ├── R03_CalculateRetirement.java │ ├── R04_HighScore.java │ ├── R05_MethodOverloading.java │ └── WrapperClassExamples.java ├── week11 │ ├── A01_AddElementToArray.java │ ├── A02_DistinctNumbers.java │ ├── Atts.java │ ├── AttsTest.java │ ├── LocalVSInstance.java │ ├── LocalVSInstanceTest.java │ ├── Notes.txt │ ├── ParkingMeter.java │ ├── SomeUsefulMethods.java │ ├── TV.java │ └── TestTV.java ├── week12 │ ├── Employee.java │ ├── Microsoft.java │ ├── Notes.txt │ ├── Telephone.java │ ├── TelephoneTest.java │ ├── Value.java │ ├── ValueTest.java │ └── static_examples │ │ ├── StaticMethods.java │ │ └── StaticTest.java ├── week13 │ ├── CameraPhone.java │ ├── Credentials.java │ ├── Db.java │ ├── Login.java │ ├── Notes.txt │ ├── Password.java │ ├── PasswordTest.java │ ├── Person.java │ ├── PersonTest.java │ ├── Phone.java │ ├── README.md │ └── inheritance │ │ ├── AudioBook.java │ │ ├── Book.java │ │ ├── BookShop.java │ │ └── Ebook.java ├── week14 │ ├── FinalKeyword.java │ ├── Notes.txt │ └── browserPagesInheritance │ │ ├── AmazonHomePage.java │ │ ├── Browser.java │ │ ├── CartPage.java │ │ ├── ProductPage.java │ │ └── TestCase.java ├── week15 │ ├── ErrorExamples.java │ ├── FinallyBlock.java │ ├── MultiCatchExamples.java │ ├── RuntimeErrorExample.java │ ├── TryCatchExamples.java │ ├── checkedExceptions │ │ ├── CheckedExceptionDemo.java │ │ ├── ReadFromFile.java │ │ └── data.txt │ └── customExceptions │ │ ├── BreakTimeException.java │ │ ├── CustomExceptionTest.java │ │ └── InsufficientBalanceException.java ├── week16 │ ├── AtTheGym.java │ ├── Exercise.java │ ├── FreeWeight.java │ ├── Lifting.java │ ├── Running.java │ └── Swimming.java ├── week17 │ ├── TestEdible.java │ └── interface_demo │ │ ├── ChromeDriver.java │ │ ├── DriverObjects.java │ │ ├── FirefoxDriver.java │ │ └── WebDriver.java ├── week18 │ ├── poly_demo │ │ ├── Father.java │ │ ├── Parent.java │ │ ├── SuperManTest.java │ │ └── Worker.java │ └── poly_demo2 │ │ ├── ElementsTest.java │ │ ├── InputField.java │ │ ├── Links.java │ │ ├── WebElement.java │ │ └── WebElementUtility.java ├── week19 │ ├── IteratorExample.java │ ├── ListExamples.java │ ├── Notes.txt │ ├── QueueExamples.java │ └── SetExamples.java └── week20 │ ├── BalancedBrackets.java │ ├── Day.java │ ├── Employee.java │ ├── EnumTest.java │ ├── MapExampleWithClassObject.java │ ├── MapsExample.java │ └── Notes.txt ├── replitTaksSolutions ├── _0_001_Basics_HelloWorld1.java ├── _0_002_Basics_HelloWorld2.java ├── _0_003_Basics_PrintName.java ├── _0_004_Basics_PrintNumbers.java ├── _0_005_Basics_FixPrint.java ├── _0_006_Basics_Cool.java ├── _0_010_Basics_PrintVariable1.java ├── _0_011_Basics_PrintVariable2.java ├── _0_012_Basics_PrintVariable3.java ├── _0_013_Basics_PrintVariable4.java ├── _0_014_Basics_PrintVariable5.java ├── _0_016_Basics_PrintVariable6.java ├── _0_017_Basics_PrintVariable7.java ├── _1_001_Variables_Primitives1.java ├── _1_002_Variables_Primitives2.java ├── _1_003_Variables_ShoppingList1.java ├── _1_004_Variables_Time.java ├── _1_005_Variables_PhoneNumber.java ├── _1_006_Variables_AddNumbers.java ├── _1_007_Variables_PatientInformation.java ├── _1_010_Variables_SecondsConverter.java ├── _1_011_Variables_CaffeineOverDose.java ├── _1_012_Variables_SchoolGrades.java ├── _2_001_Statements_GreaterNumber.java ├── _2_002_Statements_NumsGreaterEqual.java ├── _2_003_Statements_OddOrEven.java ├── _2_004_Statements_QuizQuestion.java ├── _2_005_Statements_ConditionalStatementPractice3.java ├── _2_006_Statements_VendingMachine.java ├── _2_007_Statements_GiftCard.java ├── _2_008_Statements_AndroidVersions.java ├── _2_008_Statements_Citizens.java ├── _2_008_Statements_PositiveNegativeOrZero.java ├── _2_009_Statements_VideoGameCoupons.java ├── _2_011_Statements_ApartmentLeasing1.java ├── _2_014_Statements_FindMidNumber.java ├── _2_016_Statements_BlackjackKeepHand.java ├── _2_017_Statements_HappyValleySchoolSystem.java ├── _2_018_Statements_VehicleRecall.java ├── _2_021_Statements_RealEstateCalculator.java ├── _2_023_Statements_ThreeNumsBigger.java ├── _2_024_Statements_IfStatementGrades.java ├── _2_025_Statements_BurgerOrChicken.java ├── _2_030_Statements_HttpStatusCodes.java ├── _2_031_Statements_LaptopConfigurator.java ├── _2_032_Statements_SwitchChar.java ├── _2_033_Statements_WeekDays.java ├── _2_034_Statements_Calendar.java ├── _2_035_Statements_TernaryOperator1.java ├── _2_036_Statements_TernaryOperator2.java ├── _2_037_Statements_ConsoleMenu.java ├── _3_001_String_VerifyContains.java ├── _3_002_String_FindAUser.java ├── _3_003_String_FindTheLength.java ├── _3_004_String_PrintFirstCharacter.java ├── _3_005_String_PrintLastCharacter.java ├── _3_006_String_PrintFirstAndLastLetters.java ├── _3_007_String_MiddleOne.java ├── _3_008_String_DuplicateIt.java ├── _3_009_String_MergeThem.java ├── _3_010_String_ReverseIt.java ├── _3_011_String_Words.java ├── _3_012_String_PrintHalfTwice.java ├── _3_013_String_PrintTheLongestWord.java ├── _3_015_String_StringNoEnd.java ├── _3_016_String_MiddleThree.java ├── _3_017_String_Alejandro1.java ├── _3_018_String_Alejandro2.java ├── _3_019_String_Email1.java ├── _3_020_String_Email2.java ├── _3_021_String_CarInsuranceQuote.java ├── _3_022_String_SMSMessage.java ├── _3_023_String_Without_Xx.java ├── _3_027_String_HasAJava.java ├── _3_028_String_GetSandwich.java ├── _3_029_String_PrefixAgain.java ├── _4_001_Loops_ShoppingList2.java ├── _4_002_Loops_Party.java ├── _4_003_Loops_ZombieAttack1.java ├── _4_004_Loops_CatsAndDogs.java ├── _4_005_Loops_PrintLettersCombinations.java ├── _4_006_Loops_Factorial.java ├── _4_007_Loops_CountHi.java ├── _4_008_Loops_CountJava.java ├── _4_009_Loops_CountTriples.java ├── _4_010_Loops_EachLetter.java ├── _4_011_Loops_EqualsJavaPython.java ├── _4_012_Loops_PrintNTimes.java ├── _4_013_Loops_PrintEvenFrom80To20.java ├── _4_014_Loops_PrintLetters.java ├── _4_015_Loops_PrintTriangle.java ├── _4_016_Loops_PrintVowels.java ├── _4_017_Loops_RepeatSeparator.java ├── _4_018_Loops_UtopianTree.java ├── _5_002_Arrays_FrontPiece.java ├── _5_003_Arrays_AverageTemperature.java ├── _5_004_Arrays_CountEvens.java ├── _5_005_Arrays_FindMax.java ├── _5_006_Arrays_FindNonDuplicate.java ├── _5_007_Arrays_FindSum.java ├── _5_013_Arrays_FindingMaxLengthInStringArray.java ├── _5_014_Arrays_PrintFirstAndLastChar2.java ├── _5_015_Arrays_PrintShortestWord.java ├── _5_023_Arrays_SplitEmail.java ├── _5_024_Arrays_SplitSentence.java ├── _6_001_Methods_HelloWorld.java ├── _6_002_Methods_PicturePrinterForFunNoTestCases.java ├── _6_002_Methods_SimpleCalculator.java ├── _6_002_Methods_SimpleCalculator48.java ├── _6_003_Methods_FindCube.java ├── _6_003_Methods_FindCube43.java ├── _6_004_Methods_Signum.java ├── _6_008_Methods_PrintNext3Numbers.java ├── _6_008_Methods_SplitPersonInfo.java ├── _6_009_Methods_FibonacciNumbers.java ├── _6_009_Methods_PalindromeNumber.java ├── _6_010_Methods_PopulateArray.java ├── _6_010_Methods_SwitchElements.java ├── _6_011_Methods_AddToArray.java ├── _6_014_Methods_PrintUniqueNumbers.java ├── _6_019_Methods_MethodsWithReturnMax.java ├── _6_020_Methods_MethodsWithReturnIsEven.java ├── _6_021_Methods_MethodsWithReturnProfitOrLoss.java ├── _6_022_Methods_MethodsWithReturnHamletLogic.java ├── _6_023_Methods_MethodsWithReturnWaterTax.java ├── _6_024_Methods_MethodsWithReturn3Locks.java ├── _6_025_Methods_MethodsWithReturnValidateTask.java ├── _6_026_Methods_MethodsWithReturnSimpleRoomBooking.java ├── _6_027_Methods_MethodsWithReturnThunderBlazz.java ├── _6_028_Methods_MethodsWithStringMergeThem.java ├── _6_029_Methods_MethodsWithStringRemoveDuplicates.java ├── _6_031_Methods_MethodsWithStringWordCount.java ├── _6_032_Methods_MethodsWithStringCleanString.java ├── _6_033_Methods_MethodsWithStringLimitString.java ├── _6_034_Methods_MethodsWithStringAt3rdChar.java ├── _6_035_Methods_MethodsWithStringBiggerString.java ├── _6_036_Methods_MethodsWithStringRemoveFirstChar.java ├── _6_037_Methods_MethodsWithStringLameDB.java ├── _6_038_Methods_MethodsWithStringCover.java ├── _6_039_Methods_MethodsWithStringReverseString.java ├── _6_040_Methods_MethodsWithStringFindErrorString.java ├── _6_042_Methods_MethodsWithStringCountLetters.java ├── _6_043_Methods_Palindrome.java ├── _6_045_Methods_Anagram.java ├── _6_046_Methods_CopyCertainValuesArray.java ├── _6_047_Methods_MethodOverloading1.java ├── _6_048_Methods_MethodsWithArraysMergeArrays.java ├── _6_049_Methods_MethodsWithArraysTicTacToe.java ├── _6_050_Methods_MethodsWithArrays3GetDuplicates.java ├── _6_051_Methods_MethodsWithArraysAddElements.java ├── _6_052_Methods_ReverseLetters.java ├── _6_053_Methods_StringExtractNumberFromString.java ├── _7_002_ArrayList_Add.java ├── _7_003_ArrayList_Set.java ├── _7_006_ArrayList_Remove.java ├── _7_007_ArrayList_AddInsert.java ├── _7_007_ArrayList_RemoveAll.java ├── _7_008_ArrayList_CombineAll.java ├── _7_009_ArrayList_CombineArrays.java ├── _7_010_ArrayList_AppendPosSum.java ├── _7_011_ArrayList_TimesTwo.java └── _7_012_ArrayList_RepeatAll.java ├── src ├── day01_JavaIntro │ ├── Test.java │ └── day01 class notes.txt ├── day02_HelloWorld │ ├── HelloCydeo.java │ ├── HelloWorld.java │ ├── PrintExecution.java │ └── day02 class notes.txt ├── day03_EscapeSequences │ ├── AboutMe.java │ ├── Err_VS_Out.java │ ├── EscapeSequences.java │ ├── GasReceipt.java │ ├── PersonalInfo.java │ ├── Println_VS_Print.java │ ├── Println_VS_Print2.java │ ├── RightTriangle.java │ ├── Triangle.java │ └── day03 class notes.txt ├── day04_Variables │ ├── Circle.java │ ├── Currencies.java │ ├── EmployeeInfo.java │ ├── GallonsToLitters.java │ ├── KgToPounds.java │ ├── PrimitivesIntro.java │ ├── Rectangle.java │ ├── SalaryCalculator.java │ ├── Square.java │ └── day04 class notes.txt ├── day05_Concatenation │ ├── Calculator.java │ ├── FullName.java │ ├── Introduction.java │ ├── ShippingAddress.java │ ├── StudentInfo.java │ ├── Variables_Practice.java │ └── day05 class notes.txt ├── day06_PrimitiveTypeCastings │ ├── ArithmeticOperators.java │ ├── BirthDay.java │ ├── HappyBirthDay.java │ ├── PrimitiveCastings.java │ └── day06 class notes.txt ├── day07_Operators │ ├── ArithmeticOperators.java │ ├── Castings.java │ ├── RelationalOperators.java │ ├── ShortHandOperators.java │ ├── UnaryOperators.java │ └── day07 class notes.txt ├── day08_IfStatements │ ├── EligibleToVote.java │ ├── EvenlyDivisible.java │ ├── GradeReport.java │ ├── IdentifyNumber.java │ ├── LogicalOperators.java │ ├── NumberOfDays.java │ ├── SalaryCalculator.java │ ├── SingleIfStatementIntro.java │ ├── SwapTwoVariables_WithTemporaryVariable.java │ └── day08 class notes.txt ├── day09_IfStatements │ ├── LeapYear.java │ ├── MedianNumber.java │ ├── MinNumber.java │ ├── NameOfDay.java │ ├── NumberToWord.java │ ├── PassOrFail.java │ ├── PosNegZero.java │ └── day09 class notes.txt ├── day10_NestedIf │ ├── CharacterIdentity.java │ ├── DaysInWeek.java │ ├── FieldTrip.java │ ├── GradeReport.java │ ├── GradeReport2.java │ ├── IfStatementsWithoutCurlyBraces.java │ ├── NameOfMonth.java │ ├── NameOfMonth2.java │ ├── NestedIfIntro.java │ ├── TernariesIntro.java │ ├── TernariesWithNestedIf.java │ └── day10 class notes.txt ├── day11_Switch_Scanner │ ├── Browsers.java │ ├── Calculator.java │ ├── DaysInWeek.java │ ├── Grade.java │ ├── Grade2.java │ ├── NumberOfDays.java │ ├── NumberToWords.java │ ├── ScannerIntro.java │ └── day11 class notes.txt ├── day12_Scanner │ ├── Circle.java │ ├── GradeLevel.java │ ├── NextLinePractice.java │ ├── ScannerPractice.java │ ├── ScannerPractice2.java │ ├── ScannerPractice3_NextLine.java │ ├── ShippingAddress.java │ └── day12 class notes.txt ├── day13_String │ ├── Initials.java │ ├── MyInfo.java │ ├── StringIntro.java │ ├── StringMethods.java │ └── day13 class notes.txt ├── day14_String │ ├── EmailDomain_Substring.java │ ├── StringMethod2.java │ ├── StringMethod4.java │ ├── StringMethods1.java │ ├── StringMethods3_Substring.java │ └── day14 class notes.txt ├── day15_ForLoop │ ├── Alphabet.java │ ├── FINRA.java │ ├── ForLoopIntro.java │ ├── ForLoopPractices.java │ ├── FormatFullName.java │ ├── MaximumNumber.java │ ├── MinimumNumber.java │ ├── ReplaceX.java │ ├── StringMethods.java │ ├── SumOfNumbers.java │ ├── day15 class notes.txt │ └── startsWithX.java ├── day16_ForLoopStringPractice │ ├── DigitsLettersSpecialChars.java │ ├── Palindrome.java │ ├── RemoveDuplicates.java │ ├── Reverse.java │ ├── UniqueCharacters.java │ └── day16 class notes.txt ├── day17_While_DoWhile │ ├── BranchingStatements.java │ ├── BranchingStatements2.java │ ├── Calculator.java │ ├── DoWhileLoopIntro.java │ ├── EligibleToVote.java │ ├── FrequencyOfCharacter.java │ ├── FrequencyOfWord.java │ ├── FrequencyOfWord2.java │ ├── FrequencyOfWord_WhileLoop.java │ ├── LogIn.java │ ├── LoopPractices.java │ ├── MarriageProposal.java │ ├── RemoveDuplicates.java │ ├── WhileLoopIntro.java │ └── day17 class notes.txt ├── day18_NestedLoop │ ├── AdditionOfTwoNumbers.java │ ├── DivideTwoNumbers.java │ ├── LogIn.java │ ├── NestedLoop.java │ ├── NestedLoopPractice.java │ ├── NestedLoopPractice2.java │ ├── OddOrEven.java │ └── day18 class notes.txt ├── day19_LoopPractices │ ├── Calculator.java │ ├── ExitMethod.java │ ├── FrequencyOfCharacters.java │ ├── LoopsWithoutCurlyBraces.java │ ├── OddOrEVen.java │ ├── UniqueCharacters.java │ └── day19 class notes.txt ├── day20_Arrays │ ├── Alphabet.java │ ├── AppearedTwice.java │ ├── ArrayPractice2.java │ ├── ArrayPractice3.java │ ├── ArraysIntro.java │ ├── ArraysPractice.java │ ├── ArraysUtility.java │ ├── AverageNumbers.java │ ├── MaxNumberOfArray.java │ ├── MinMaxNumbers.java │ ├── MinNumberOfArray.java │ ├── UniqueElements.java │ └── day20 class notes.txt ├── day21_ForEachLoop │ ├── Anagram.java │ ├── ArraysUtility.java │ ├── ArraysUtility2.java │ ├── AverageNumber.java │ ├── ForEachLoopIntro.java │ ├── ForEachLoopPractice.java │ ├── Initials.java │ ├── Items.java │ ├── MaxNumber.java │ ├── MergeTwoArrays.java │ ├── ReverseArray.java │ ├── ReverseNames.java │ ├── StringMethods.java │ ├── UniqueElements.java │ └── day21 class notes.txt ├── day22_MultiDimensionalArray │ ├── ForEachLoop.java │ ├── IteratingMultiDimensionalArray.java │ ├── IteratingMultiDimensionalArray2.java │ ├── MultiDimensionalArray2.java │ ├── MultiDimensionalArrayIntro.java │ ├── ReverseSecondWord.java │ ├── ReverseSentence.java │ └── day22 class notes.txt ├── day23_CustomMethods_Void │ ├── CustomMethodsIntro.java │ ├── CustomMethodsPractice.java │ ├── CustomMethodsWIthParameters.java │ └── day23 class notes.txt ├── day24_CustomMethods_Return │ ├── BreakfastTasks.java │ ├── ReturnMethodIntro.java │ ├── ReturnMethodPractice.java │ ├── ReturnMethodPractice4.java │ ├── ReturnMethodsPractice2.java │ ├── ReturnMethodsPractice3.java │ ├── ReturnStatement.java │ ├── ReturnStatement2.java │ ├── Return_vs_ExitMethod.java │ └── day24 class notes.txt ├── day25_CustomMethods_Overloading │ ├── AddElementsToArray.java │ ├── AddElementsToArray_Overloading.java │ ├── MainMethodOverloading.java │ ├── MethodOverloading.java │ ├── SumOfNumbers.java │ ├── Test.java │ ├── Test2.java │ └── day25 class notes.txt ├── day26_CustomMethodsPractice │ ├── FrequencyOfElement.java │ ├── MergeTwoArrays.java │ ├── MergeTwoArrays2.java │ ├── RemoveElements1.java │ ├── RemoveElements2.java │ ├── ReverseArray.java │ ├── ReverseArray2.java │ ├── UniqueElements.java │ └── day26 class notes.txt ├── day27_WrapperClasses │ ├── RemoveDuplicates.java │ ├── Replace.java │ ├── ReplaceAll.java │ ├── WrapperClassMethods.java │ ├── WrapperClassesIntro.java │ └── day27 class notes.txt ├── day28_ArrayList │ ├── ArrayListIntro.java │ ├── ArrayListMethods1.java │ ├── ArrayListMethods2.java │ ├── ArrayListPractice.java │ ├── RemoveDuplicates.java │ ├── StrongPassword.java │ ├── StrongPassword2.java │ ├── UniqueElements.java │ └── day28 class notes.txt ├── day29_ArrayList │ ├── ArrayListPractice1.java │ ├── ArrayListPractice2.java │ ├── BulkOperations.java │ ├── CollectionsUtility.java │ ├── FirstUniqueElements.java │ ├── GradeCalculator.java │ ├── MaxMinAverage.java │ ├── NthLargestNumber.java │ ├── RemoveIfMethod.java │ ├── ReverseArrayAndArrayList.java │ ├── UniqueCharacters.java │ ├── UniqueElements.java │ └── day29 class notes.txt ├── day30_CustomClass │ ├── CapitalOne.java │ ├── Car.java │ ├── CarObjects.java │ ├── Dog.java │ ├── DogObjects.java │ ├── Employee.java │ ├── Student.java │ ├── StudentObjects.java │ ├── WarmupTasks.java │ └── day30 class notes.txt ├── day31_Constructors │ ├── BankAccount.java │ ├── CapitalOne.java │ ├── MyOffers.java │ ├── Offer.java │ ├── Person.java │ ├── PersonObjects.java │ ├── Pizza.java │ ├── PizzaOrdering.java │ ├── Rectangle.java │ ├── RectangleObjects.java │ ├── Student.java │ ├── StudentObjects.java │ ├── day31 class notes.txt │ └── scrumTask │ │ ├── Developer.java │ │ ├── MyScrumTeam.java │ │ ├── ScrumTeam.java │ │ └── Tester.java ├── day32_Constructors │ ├── Car.java │ ├── CarObjects.java │ ├── Carpet.java │ ├── CarpetObjects.java │ ├── ConstructorCalls.java │ ├── Employee.java │ ├── EmployeeObjects.java │ ├── Test.java │ └── day32 class notes.txt ├── day33_Statics │ ├── Employee.java │ ├── EmployeeObjects.java │ ├── Iphone.java │ ├── Student.java │ ├── StudentObjects.java │ ├── StudentTask.java │ ├── TestIphone.java │ └── day33 class notes.txt ├── day34_GarbageCollection_AccessModifiers │ ├── AccessModifiers.java │ ├── AccessModifiers_Test.java │ ├── Circle.java │ ├── Constructor_vs_StaticBlock.java │ ├── CydeoStudent.java │ ├── GarbageCollection.java │ ├── StaticBlock.java │ ├── StaticImport.java │ ├── StaticMembers.java │ ├── Test.java │ └── day34 class notes.txt ├── day35_Encapsulation │ ├── CydeoStudent.java │ ├── Person.java │ ├── day35 class notes.txt │ └── encapsulation │ │ ├── Employee.java │ │ ├── EmployeeObject.java │ │ ├── Person.java │ │ └── PersonObjects.java ├── day36_Inheritance │ ├── animalTask │ │ ├── Animal.java │ │ ├── Cat.java │ │ ├── Dog.java │ │ ├── Tiger.java │ │ └── Zoo.java │ ├── day36 class notes.txt │ └── encapsulation │ │ ├── Student.java │ │ └── StudentObject.java ├── day37_Inheritance │ ├── ConstructorPractice.java │ ├── animalTask │ │ ├── Animal.java │ │ ├── AnimalObjects.java │ │ ├── Cat.java │ │ ├── Dog.java │ │ └── Parrot.java │ ├── day37 class notes.txt │ ├── phoneTask │ │ ├── Iphone.java │ │ ├── Nokia.java │ │ ├── Phone.java │ │ ├── PhoneShop.java │ │ └── Samsung.java │ └── scrumTask │ │ ├── AmazonInc.java │ │ ├── BusinessAnalyst.java │ │ ├── Developer.java │ │ ├── Employee.java │ │ ├── Person.java │ │ ├── ProductOwner.java │ │ ├── ScrumMaster.java │ │ ├── ScrumTeam.java │ │ └── Tester.java ├── day38_Inheritance │ ├── carTask │ │ ├── BMW.java │ │ ├── Car.java │ │ ├── ParkingLot.java │ │ ├── Tesla.java │ │ └── Toyota.java │ └── day38 class notes.txt ├── day39_Recap │ ├── MethodOverloading.java │ ├── cydeoTask │ │ ├── Cydeo.java │ │ ├── Developer.java │ │ ├── Employee.java │ │ ├── Person.java │ │ ├── Student.java │ │ ├── Teacher.java │ │ └── Tester.java │ ├── day39 class notes.txt │ └── shapeTask │ │ ├── Circle.java │ │ ├── Rectangle.java │ │ ├── Shape.java │ │ ├── ShapeObjects.java │ │ └── Square.java ├── day40_FinalKeyword │ ├── Animal.java │ ├── Cat.java │ ├── Dog.java │ ├── EncapsulationReview.java │ ├── FinalVariable.java │ ├── ProtectedAccessModifier.java │ ├── Zoo.java │ └── day40 clas notes.txt ├── day41_Exceptions │ ├── Checked_vs_Unchecked.java │ ├── FinallyBlock.java │ ├── MultiCatchBlocks.java │ ├── TryCatchBlocks.java │ └── day41 class notes.txt ├── day42_Exceptions │ ├── CustomExceptions.java │ ├── DisadvantageOfThrowsKeyword.java │ ├── DisadvantageOfThrowsKeyword2.java │ ├── MorningWorkOut.java │ ├── ThrowKeyword.java │ ├── ThrowKeyword2.java │ ├── ThrowsKeyword.java │ ├── ThrowsKeyword2.java │ └── day42 class notes.txt ├── day43_Abstraction │ ├── Throw_vs_Throws.java │ ├── car │ │ ├── Audi.java │ │ ├── Car.java │ │ ├── CarShop.java │ │ ├── Honda.java │ │ └── Tesla.java │ ├── day43 class notes.txt │ └── employeeTask │ │ ├── Developer.java │ │ ├── Driver.java │ │ ├── Employee.java │ │ ├── EmployeeObjects.java │ │ ├── Person.java │ │ ├── Teacher.java │ │ └── Tester.java ├── day44_Abstraction │ ├── animalTask │ │ ├── Animal.java │ │ ├── Cat.java │ │ ├── Dog.java │ │ ├── Eagle.java │ │ ├── Flyable.java │ │ ├── Parrot.java │ │ ├── Playable.java │ │ ├── Tiger.java │ │ └── WildAnimal.java │ └── day44 class notes.txt ├── day45_Abstraction │ ├── Extends_vs_Implements.java │ ├── PropertiesOfInterface.java │ ├── day45 class notes.txt │ └── shape │ │ ├── Circle.java │ │ ├── Cube.java │ │ ├── Cylinder.java │ │ ├── Pentagon.java │ │ ├── Rectangle.java │ │ ├── Shape.java │ │ ├── Sphere.java │ │ ├── Square.java │ │ ├── Triangle.java │ │ └── Volume.java ├── day46_Polymorphism │ ├── PolymorphismIntro.java │ └── day46 class notes.txt ├── day47_Polymorphism │ ├── EncapsulationReview.java │ ├── InheritanceReview.java │ ├── PolymorphismPractice.java │ ├── PolymorphismPractice2.java │ ├── ReferenceTypeCastings.java │ └── day47 class notes.txt ├── day48_Collections │ ├── ListIntro.java │ └── day48 class notes.txt ├── day49_Collections │ ├── QueuePractice.java │ ├── SetInterfacePractice.java │ ├── SetPractice2.java │ └── day49 class notes.txt ├── day50_Collections │ ├── IterablePractice.java │ ├── IterablePractice2.java │ ├── ListSetPractice.java │ ├── RemoveEven.java │ ├── RemovePalindromes.java │ └── day50 class notes.txt ├── day51_Map │ ├── Browser.java │ ├── FrequencyOfCharacters.java │ ├── IteratingTheMap.java │ ├── Level.java │ ├── MapClasses.java │ ├── MapMethods.java │ ├── MapPractice1.java │ ├── MapPractice2.java │ ├── MapPractice3.java │ ├── MapPractice4.java │ ├── Season.java │ ├── TestEnum.java │ └── day51 class notes.txt ├── day52_Map_FunctionalInterface │ ├── ArrayOfMap.java │ ├── ListOfMapPractice1.java │ ├── MyFirstFunctionalInterface.java │ ├── MySecondFunctionalInterface.java │ ├── NestedMap.java │ ├── Test.java │ ├── Test2.java │ ├── UniqueCharacters.java │ └── day52 class notes.txt ├── day53_FunctionalInterface │ ├── BuildInFunctionalInterfaces1.java │ ├── BuildInFunctionalInterfaces2.java │ ├── LambdaExpressions.java │ ├── MapPractice.java │ ├── MyThirdFunctionalInterface.java │ ├── StreamPractice.java │ └── day53 class notes.txt └── utilities │ ├── ArraysUtility.java │ ├── AssignmentOperators.java │ ├── MathUtility.java │ ├── StringUtility.java │ └── Timer.java └── taskSolutions ├── day02_PrintStatements ├── Rectangle.java ├── SelfIntro.java ├── Square.java └── Triangle.java ├── day05_Concatenations ├── FlightTicket.java └── PhoneNumber.java ├── day08_SingleIf ├── EligibleToBuyCigarettes.java ├── GradeLevel.java └── MaxNumber.java ├── day09_IfElse_MultiBranchIf ├── AgeGroups.java ├── Calculator.java ├── CampusHours.java ├── CharacterIdentity.java ├── ChooseLanguage.java ├── EqualNumbers.java ├── FINRA.java ├── FieldTrip.java ├── NumberToWord.java ├── OxygenTank.java └── SalaryCalculator.java ├── day10_NestedIf_Ternaries ├── AgeGroups.java ├── BiggerNum.java ├── CrewAndPassengers.java ├── Grade.java ├── GradeLevel.java ├── HTTP_StatusCode.java └── Loans.java ├── day11_SwitchStatements ├── Browser.java ├── CappuccinoBuyer.java ├── CydeoBatches.java ├── Elevator.java └── HTTP_StatusCode.java ├── day12_Scanner ├── CentsToDollars.java ├── GradeReport.java ├── NumberOfPeople.java ├── PlaceAnOrder.java ├── SalaryCalculator.java ├── SpeedCheck.java └── StockMarket.java ├── day13_String ├── CheckWords.java ├── FirstLastCharSame.java ├── FirstLastCharactersOfSentence.java ├── Initial.java ├── LogIn.java ├── LongestString.java ├── MiddleCharacter.java ├── Reverse.java ├── StringWithThreeCharacters.java ├── TipCalculator.java └── Travel.java ├── day14_String ├── AccountNumber.java ├── AddTwoWords.java ├── DigitUpperLowerSpecialChar.java ├── EmailTask1.java ├── EmailTask2.java ├── EndsWithLY.java ├── WithoutFirstChar.java └── WithoutX.java ├── day15_ForLoop ├── FactorialNumber.java ├── LettersDigitsSpecialChars.java ├── Palindrome.java ├── StringReverse.java ├── SumOfAllNumbers.java ├── SumOfDigits.java ├── SumOfEvenNumbers.java └── SumOfOddNumbers.java ├── day16_ForLoop_String ├── FrequencyOfAChar.java ├── FrequencyOfDogAndCat.java ├── FrequencyOfJava.java ├── MultiplyTwoNumbers.java └── PositiveNegativeNumbers.java ├── day17_While_DoWhileLoops ├── Calculator.java ├── DivideTwoNumbers.java ├── DivisibleBy3_5_15.java ├── InsuranceQuote.java ├── RoomReservation.java └── SumOfNumbers.java ├── day18_NestedLoop ├── Calculator2.java ├── FrequencyOfCharacters.java ├── MultiplicationTable.java ├── RoomReservationTask2.java └── UniqueCharacters.java ├── day19_LoopsAndString ├── CircleCalculator.java ├── GradeCalculator.java ├── HighestFrequency.java ├── RectangleCalculator.java ├── SalaryCalculator.java └── SquareCalculator.java ├── day20_Arrays ├── Classmates_Initials.java ├── Classmates_Reverse.java ├── CommonElements.java ├── Items.java ├── MoveAllZerosToTheEnd.java ├── Reverse.java └── StudentGrade.java ├── day21_ForEachLoop ├── CommonElements.java ├── CountPalindrome.java ├── EvenAndOddNumbers.java ├── JavaAndPython.java ├── MergeThreeArrays.java └── SortingArrayInDescendingOrder.java ├── day22_MultiDimensionalArray ├── CydeoStudents.java ├── Items.java └── ReverseTwoDimensionalArray.java ├── day23_CustomMethods_Void ├── Anagram.java ├── BuyAlcohol.java ├── CalculateCircle.java ├── CalculateGrade.java ├── CalculateSquare.java ├── Calculator.java ├── ConvertDollarToEuro.java ├── ConvertDollarToLira.java ├── ConvertKgToLb.java ├── EachCharacter.java ├── EachElement.java ├── EligibleToVote.java ├── NameFormat.java ├── PositiveNegativeZero.java ├── PrintEvenNumbers1To100.java └── PrintOddNumbers1To100.java ├── day24_CustomMethods_Return ├── AddElement.java ├── Contains.java ├── FrequencyOfElement.java ├── FrequencyOfWord.java ├── Merge.java ├── Palindrome.java ├── RemoveElement.java ├── Reverse.java ├── Reverse_Array.java └── isAnagram.java ├── day25_CustomMethods_Overloading ├── MaxNumber.java ├── MergeTwoArrays.java ├── MinNumber.java └── Reverse.java ├── day26_CustomMethodsPractice └── MathUtility.java ├── day27_WrapperClasses ├── InsertElement.java ├── LetterDigitSpecialChar.java ├── SwapElement.java └── UpperLowerEqual.java ├── day28_ArrayList ├── FirstDuplicatedElement.java ├── Grades.java ├── MaximumNumber.java ├── MergeTowArrays.java ├── MinimumNumber.java ├── MultiplyOddNumbers.java ├── SetTheLastElement.java └── SwapFirstAndLast.java ├── day31_CustomClass_Constructor ├── addressTask │ ├── Address.java │ └── Test.java ├── carpetTask │ ├── Carpet.java │ └── Test.java ├── itemTask │ ├── Item.java │ └── Test.java ├── movieTask │ ├── Movie.java │ └── MovieObjects.java ├── resturantTask │ ├── Chef.java │ ├── LocalRestaurant.java │ ├── Restaurant.java │ └── Server.java └── salaryCalculatorTask │ ├── SalaryCalculator.java │ └── Test.java ├── day33_CustomClass_Statics ├── addressTask │ ├── Address.java │ └── Test.java ├── carTask │ ├── Car.java │ └── Test.java ├── circleTask │ ├── Circle.java │ └── Test.java ├── cydeoStudentTask │ ├── CydeoStudent.java │ └── Test.java ├── dogTask │ ├── Dog.java │ └── Test.java ├── iphoneTask │ ├── IPhone.java │ └── Test.java └── personTask │ ├── Person.java │ └── Test.java ├── day35_Encapsulation ├── bankAccount │ └── BankAccount.java ├── candiesTask │ ├── Candy.java │ └── Test.java ├── carpetTask │ ├── Carpet.java │ └── Test.java ├── credentialsTask │ └── Credentials.java ├── itemTask │ ├── Item.java │ └── Test.java ├── pizzaTask │ ├── Pizza.java │ └── Test.java ├── rectangleTask │ ├── Rectangle.java │ └── Test.java ├── scrumTeamTask │ ├── Developer.java │ ├── ScrumTeam.java │ └── Tester.java └── squareTask │ ├── Square.java │ └── Test.java ├── day36_Inheritance ├── bookTask │ ├── AudioBook.java │ ├── Book.java │ └── EBook.java ├── cryptoTask │ ├── Bitcoin.java │ ├── Cardano.java │ ├── CryptoToken.java │ ├── Doge.java │ ├── Ethereum.java │ └── XRP.java ├── employeeTask │ ├── Developer.java │ ├── Driver.java │ ├── Employee.java │ ├── Teacher.java │ ├── Test.java │ └── Tester.java ├── phoneTask │ ├── Iphone.java │ ├── Nokia.java │ ├── Phone.java │ ├── Samsung.java │ └── Test.java ├── planetTask │ ├── Earth.java │ ├── Mercury.java │ ├── Moon.java │ ├── Planet.java │ └── Venus.java └── scrumTask │ ├── Developer.java │ ├── Employee.java │ ├── Person.java │ ├── ScrumTeam.java │ └── Tester.java ├── day38_MethodOverriding ├── animalTask │ ├── Animal.java │ ├── Cat.java │ ├── Dog.java │ ├── Eagle.java │ └── Tiger.java └── browserTask │ ├── Browser.java │ ├── Chrome.java │ ├── FireFox.java │ ├── Opera.java │ └── Safari.java └── day39_Inheritance_Ecnapsulation ├── animalTask ├── Animal.java ├── Bear.java ├── Cat.java ├── Crocodile.java ├── Dog.java ├── Dolphin.java ├── Eagle.java ├── FriendlyAnimal.java ├── Lion.java ├── Parrot.java ├── Python.java ├── Tiger.java └── WildAnimal.java └── deviceTask ├── BlackBerry.java ├── Computer.java ├── Desktop.java ├── Device.java ├── GooglePhone.java ├── Iphone.java ├── Laptop.java ├── Nokia.java ├── PersonalComputer.java ├── Phone.java ├── Samsung.java └── TV.java /.gitignore: -------------------------------------------------------------------------------- 1 | /JavaProgrammingEU8.iml 2 | /out/ 3 | /.idea/ 4 | -------------------------------------------------------------------------------- /AvengersHoursPractice/week01/CastingPractices.java: -------------------------------------------------------------------------------- 1 | package week01; 2 | 3 | public class CastingPractices { 4 | public static void main(String[] args) { 5 | 6 | // byte to short 7 | byte b = 10; 8 | short s = b; // implicit casting 9 | 10 | // double to int: explicit casting 11 | double d = 5.3; 12 | int i = (int) d; // there might be data loss, so the compiler asks you to specfy the commend 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /AvengersHoursPractice/week04/Notes.txt: -------------------------------------------------------------------------------- 1 | Inheritance : 2 | Builds IS-A relationship: Between OnSaleItem and Item class 3 | onsaleitem is an Item 4 | 5 | We also have HAS A relationship 6 | TJMaxx class holds variables/objects from Item and OnSaleItem classes -------------------------------------------------------------------------------- /AvengersHoursPractice/week05/Locators.java: -------------------------------------------------------------------------------- 1 | package week05; 2 | 3 | public class Locators { 4 | String locator; 5 | public Locators(String locator){ 6 | this.locator=locator; 7 | } 8 | } 9 | class ID extends Locators{ 10 | public ID(String locator) { 11 | super(locator); 12 | } 13 | } 14 | class Name extends Locators{ 15 | public Name(String locator) { 16 | super(locator); 17 | } 18 | } 19 | class TagName extends Locators{ 20 | public TagName(String locator) { 21 | super(locator); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /AvengersHoursPractice/week05/UsingThrowKeyword.java: -------------------------------------------------------------------------------- 1 | package week05; 2 | 3 | public class UsingThrowKeyword { 4 | public static void main(String[] args) { 5 | 6 | /* 7 | We can use throw keyword to create an exception object 8 | */ 9 | 10 | String userName = ""; 11 | 12 | if(userName.isEmpty()){ 13 | throw new RuntimeException("Username can NOT be empty"); 14 | } 15 | 16 | 17 | 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /AvengersHoursPractice/week05/WebTestExample.java: -------------------------------------------------------------------------------- 1 | package week05; 2 | 3 | public class WebTestExample { 4 | public static void main(String[] args) { 5 | 6 | WebDriver driver = new WebDriver("Opera"); 7 | 8 | // re-usability, and benefit of Method Overloading 9 | driver.findElement(new ID("ID_locator_provided")); 10 | driver.findElement(new Name("Name_locator_provided")); 11 | driver.findElement(new TagName("TagName_Locator_provided")); 12 | 13 | Locators object = driver.navigateTo("www.google.com"); // using parent class overridden method 14 | 15 | 16 | Chrome chromeDriver = new Chrome("Chrome"); 17 | 18 | ID ID_object= chromeDriver.navigateTo("www.tesla.com"); // using child class overriding method 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /AvengersHoursPractice/week06/Calculator.java: -------------------------------------------------------------------------------- 1 | package week06; 2 | 3 | public class Calculator { 4 | public Floor floor; // floor is an instance variable for Calculator class and also serves as the object of Floor class 5 | public Carpet carpet; 6 | 7 | public Calculator(Floor floor, Carpet carpet){ 8 | this.floor=floor; 9 | this.carpet=carpet; 10 | } 11 | 12 | // totalCost = cost(meter square) * area (total meter square) 13 | 14 | public double getTotalCost(){ 15 | double cost = carpet.getCost(); 16 | double area = floor.getArea(); 17 | return cost*area; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /AvengersHoursPractice/week06/CalculatorTest.java: -------------------------------------------------------------------------------- 1 | package week06; 2 | 3 | public class CalculatorTest { 4 | public static void main(String[] args) { 5 | 6 | Floor floorOfLivingRoom = new Floor(4,7); 7 | Carpet carpetFirstClass = new Carpet(200); 8 | Calculator calculator = new Calculator(floorOfLivingRoom,carpetFirstClass); 9 | 10 | System.out.println("TotalCost() of Living Room = " + calculator.getTotalCost()); 11 | 12 | 13 | calculator = new Calculator(new Floor(3,3),new Carpet(75)); 14 | System.out.println("TotalCost() of Kids Room = " + calculator.getTotalCost()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /AvengersHoursPractice/week06/Carpet.java: -------------------------------------------------------------------------------- 1 | package week06; 2 | 3 | public class Carpet { 4 | 5 | private double cost; 6 | 7 | public Carpet(double cost){ 8 | setCost(cost); 9 | } 10 | // If method's parameter and global parameter is same name we should use this 11 | public void setCost(double cost){ 12 | if(cost<0) 13 | this.cost=0; 14 | else 15 | this.cost=cost; 16 | } 17 | 18 | public double getCost() { 19 | return cost; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /AvengersHoursPractice/weekUnknown/Tests.java: -------------------------------------------------------------------------------- 1 | package weekUnknown; 2 | 3 | public class Tests { 4 | public static void main(String[] args) { 5 | 6 | for(int i = 100; i <100000 ; i++){ 7 | if(PracticeTasks.isArmstrong(i)){ 8 | System.out.println("i = " + i); 9 | } 10 | } 11 | 12 | String[] steps = {"x/","y/","../","z/","./"}; 13 | 14 | System.out.println(PracticeTasks.minSteps(steps)); 15 | 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /liveReview/extraPackageToShowImport/CalculatorTest2.java: -------------------------------------------------------------------------------- 1 | package extraPackageToShowImport; 2 | 3 | import week09.Calculator; 4 | 5 | 6 | 7 | 8 | public class CalculatorTest2 { 9 | 10 | public static void main(String[] args) { 11 | 12 | 13 | System.out.println("Calculator.add(3.0,4.5) = " + Calculator.add(3.0, 4.5)); 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /liveReview/week01/DateExample.java: -------------------------------------------------------------------------------- 1 | package week01; 2 | 3 | import java.time.LocalDateTime; 4 | import java.time.format.DateTimeFormatter; 5 | 6 | public class DateExample { 7 | public static void main(String[] args) { 8 | 9 | DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd HH"); 10 | LocalDateTime now = LocalDateTime.now(); 11 | // System.out.println(dtf.format(now)); 12 | String str = dtf.format(now); 13 | System.out.println(str); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /liveReview/week01/EscapeSquences.java: -------------------------------------------------------------------------------- 1 | package week01; 2 | 3 | public class EscapeSquences { 4 | 5 | public static void main(String[] args) { 6 | 7 | /* 8 | \t : tab 9 | \n: takes it to next line 10 | \\ : prints \ 11 | \" : prints " 12 | */ 13 | 14 | System.out.println("Learn\tJava\n\tthe\nHard\tWay\n\n"); // \H : illegal escape squence 15 | 16 | System.out.println("\tLearn JAVA the \" EASY WAY \" Way! \n\t\t With Oscar \\\\"); 17 | 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /liveReview/week01/PrintVsPrintln.java: -------------------------------------------------------------------------------- 1 | package week01; 2 | 3 | public class PrintVsPrintln { 4 | 5 | public static void main(String[] args) { 6 | 7 | System.out.print("One"); // CTRL + D , CMND+D 8 | System.out.println("Two"); // print first then go to the next line 9 | System.out.print("Three"); 10 | 11 | System.err.println("Error Statement"); 12 | 13 | // Single Line Commenting: it means, JAVA does not run these lines 14 | /* 15 | Whatever in between multiple comment lines or, block comment 16 | */ 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /liveReview/week01/SomeImportantRules.java: -------------------------------------------------------------------------------- 1 | package week01; 2 | 3 | public class SomeImportantRules { 4 | 5 | /* 6 | 1. Your class name and file name has to be same 7 | 2. At JAVA for every opening brackets "{","(","[" you need to have closing brackets "}",")","]" (balanced brackets) 8 | 3. you need to have semi column at each line of code ";" 9 | 4. You need to have main method to run your codes 10 | */ 11 | } 12 | -------------------------------------------------------------------------------- /liveReview/week02/Naming_Convention.java: -------------------------------------------------------------------------------- 1 | package week02; 2 | 3 | public class Naming_Convention { 4 | public static void main(String[] args) { 5 | /* Valid : V Invalid: I 6 | _average : V 7 | B4 : V 8 | ABC : V 9 | println : Valid 10 | "hello" : I - starts with " 11 | for : I -- reserved words 12 | sum_of_data : V 13 | first-name : I - dash sign not accepted 14 | AnnualSalary: V 15 | 42isThesolution : I - starts with number 16 | */ 17 | 18 | int _average; 19 | String println = "Hello"; 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /liveReview/week03/EvenOrOdd.java: -------------------------------------------------------------------------------- 1 | package week03; 2 | 3 | public class EvenOrOdd { 4 | public static void main(String[] args) { 5 | 6 | // Task: find if a given integer is even number or odd number 7 | // Hint: use % operator , and control flow statements 8 | 9 | int number = 100; 10 | 11 | boolean condition = number%2==0; 12 | 13 | if(condition){ 14 | System.out.println("The number is EVEN"); 15 | }else{ 16 | System.out.println("The number is ODD"); 17 | } 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /liveReview/week03/Questions.java: -------------------------------------------------------------------------------- 1 | package week03; 2 | 3 | public class Questions { 4 | public static void main(String[] args) { 5 | 6 | System.out.println(4+5+" "+4+5); // 9 45 int + space(string) = string | String + integer = String 7 | 8 | // Java runs from top to bottom and left to right 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /liveReview/week03/RelationalOperatorExample.java: -------------------------------------------------------------------------------- 1 | package week03; 2 | 3 | public class RelationalOperatorExample { 4 | public static void main(String[] args) { 5 | 6 | 7 | int i1,i2; 8 | i1=100; 9 | i2 =20; 10 | 11 | // i1>i2 this will return boolean data type 12 | 13 | boolean b = i1>i2; 14 | 15 | System.out.println(" Is the first number bigger than second one " + b); 16 | 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /liveReview/week03/SomeExtraTasks.java: -------------------------------------------------------------------------------- 1 | package week03; 2 | 3 | public class SomeExtraTasks { 4 | 5 | public static void main(String[] args) { 6 | 7 | int b = 2; 8 | 9 | boolean res = ++b == 2 || --b == 2 && --b == 2; // false (b:3), 2 == 2 (true) ---> true 10 | 11 | System.out.println(res); 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /liveReview/week04/AmazonFreeShipping.java: -------------------------------------------------------------------------------- 1 | package week04; 2 | 3 | public class AmazonFreeShipping { 4 | public static void main(String[] args) { 5 | 6 | double totalPrice = 55.50; 7 | 8 | if (totalPrice >= 25.0) { 9 | System.out.println("FREE Shipping eligible. Your order total : $ " + totalPrice); 10 | } else { 11 | System.out.println("NOT Eligible for free shipping : $ " + totalPrice); 12 | } 13 | 14 | System.out.println("Thanks for shopping with us !"); 15 | 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /liveReview/week04/NestedIfExample.java: -------------------------------------------------------------------------------- 1 | package week04; 2 | 3 | public class NestedIfExample { 4 | public static void main(String[] args) { 5 | 6 | boolean isRushHour = false; 7 | int carType = 2; // 1, 2, 3 ... 6: motorcyles 8 | double price = 0.0; 9 | 10 | if(carType == 1){ 11 | if(isRushHour){ 12 | price = 30.0; 13 | }else{ 14 | price = 5.0; 15 | } 16 | }else if(carType == 2){ 17 | if (isRushHour){ 18 | price = 55.30; 19 | }else{ 20 | price = 15.99; 21 | } 22 | } 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /liveReview/week04/TernaryExample.java: -------------------------------------------------------------------------------- 1 | package week04; 2 | 3 | public class TernaryExample { 4 | 5 | public static void main(String[] args) { 6 | 7 | int score1 = 25; 8 | String result1 = ""; 9 | 10 | if(score1>60){ 11 | result1 = "Pass"; 12 | }else { 13 | result1 = "Fail"; 14 | } 15 | 16 | // Same logic with ternary 17 | 18 | int score2 = 65; 19 | String result2 = (score2>60)? "Pass":"Fail"; 20 | System.out.println("result2 = " + result2); 21 | 22 | System.out.println((score2>60)? "Pass":"Fail"); 23 | 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /liveReview/week04/TrafficLightSelector.java: -------------------------------------------------------------------------------- 1 | package week04; 2 | 3 | public class TrafficLightSelector { 4 | public static void main(String[] args) { 5 | char color = 'r'; 6 | 7 | switch (color){ 8 | case 'R': case 'r': // or logic 9 | System.out.println("Red Light"); 10 | break; 11 | case 'O': case 'o': // or logic 12 | System.out.println("Orange Light"); 13 | break; 14 | case 'G': case 'g': // or logic 15 | System.out.println("Green Light"); 16 | break; 17 | default: 18 | System.out.println("Invalid Light"); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /liveReview/week06/InfiniteLoop.java: -------------------------------------------------------------------------------- 1 | package week06; 2 | 3 | public class InfiniteLoop { 4 | 5 | public static void main(String[] args) { 6 | int z = 0; 7 | for(int i = 0; i<100 ; z++ ){ // condition is NOT related to iteration 8 | System.out.println("z = " + z); // infinite loop 9 | } 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /liveReview/week06/PrintAllLetters.java: -------------------------------------------------------------------------------- 1 | package week06; 2 | 3 | public class PrintAllLetters { 4 | 5 | 6 | 7 | public static void main(String[] args) { 8 | 9 | // Print all the letters from A to Z 10 | // char A -- in ASCII table is value 65 , Z is 90 11 | // how can I turn integer into char : explicitly casting 12 | int i = 65; // global 13 | for(; i<= 90 ; i++){ 14 | System.out.print((char)i+" "); 15 | } 16 | 17 | System.out.println("(char)i = " + (char) i); 18 | 19 | // chars are also iterable 20 | System.out.println(); 21 | for(char c = 'A'; c<='Z' ; c++){ 22 | System.out.print(c+" "); 23 | } 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /liveReview/week08/CharArray.java: -------------------------------------------------------------------------------- 1 | package week08; 2 | 3 | public class CharArray { 4 | public static void main(String[] args) { 5 | 6 | char[] letters = {'j','a','v','a',' ','i','s',' ','f','u','n'}; 7 | 8 | for (char letter : letters) { 9 | System.out.print(letter+" "); 10 | } 11 | System.out.println(); 12 | String sentence = new String(letters); 13 | System.out.println("sentence = " + sentence); 14 | 15 | // there is apposite of the action 16 | 17 | char [] newArray = sentence.toCharArray(); 18 | for (char c : newArray) { 19 | System.out.print(c+" "); 20 | } 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /liveReview/week08/ReverseArray.java: -------------------------------------------------------------------------------- 1 | package week08; 2 | 3 | import java.util.Arrays; 4 | 5 | public class ReverseArray { 6 | public static void main(String[] args) { 7 | // 0 1 2 3 8 | int [] nums = {5 , 10 , 4, 1000, 35}; 9 | 10 | System.out.println("Before reverse : " + Arrays.toString(nums)); 11 | 12 | for (int i = 0; i < nums.length/2; i++) { 13 | int temp = nums[i]; // 5 14 | nums[i] = nums [nums.length-1 - i]; // assign 1000 to first index 15 | nums[nums.length-1 - i] = temp; 16 | } 17 | 18 | System.out.println("After reverse : " + Arrays.toString(nums)); 19 | 20 | 21 | 22 | 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /liveReview/week09/CalculatorTest.java: -------------------------------------------------------------------------------- 1 | package week09; 2 | 3 | public class CalculatorTest { 4 | public static void main(String[] args) { 5 | 6 | // I need to use my calculator again 7 | 8 | // CALL Methods of Other Classes 9 | 10 | System.out.println(Calculator.add(4.5,5.2)); 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /liveReview/week10/ArrayListExample01.java: -------------------------------------------------------------------------------- 1 | package week10; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class ArrayListExample01 { 6 | public static void main(String[] args) { 7 | 8 | // to show auto-boxing 9 | ArrayList arr = new ArrayList<>(); 10 | 11 | for (int i = 0; i < 10; i++) { // 0,1,2,3.. ---> primitives 12 | // How can I out primitives into Arraylist: with the help of autoboxing 13 | arr.add(i); 14 | 15 | } 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /liveReview/week10/R01_CountOfEven.java: -------------------------------------------------------------------------------- 1 | package week10; 2 | 3 | public class R01_CountOfEven { 4 | public static void main(String[] args) { 5 | 6 | 7 | int[] arr = {2,5,6,9,10,20,7,19}; 8 | 9 | System.out.println(counter(arr)); 10 | } 11 | 12 | // will take parameter: int [] arr 13 | // will return a number: integer (count of even numbers) 14 | 15 | public static int counter(int[] arr){ 16 | int count = 0; 17 | for (int eachNumber : arr) { 18 | if(eachNumber%2==0){ 19 | count++; 20 | } 21 | } 22 | return count; 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /liveReview/week10/R03_CalculateRetirement.java: -------------------------------------------------------------------------------- 1 | package week10; 2 | 3 | public class R03_CalculateRetirement { 4 | 5 | // This example was implemented to show that we can call a method from other methods 6 | 7 | public static void main(String[] args) { 8 | yearsUntilRetirement("Oscar",1977); 9 | } 10 | 11 | // calculate age of a person 12 | public static int calculateAge(int yearOfBirth){ 13 | return 2022-yearOfBirth; 14 | } 15 | 16 | // let's assume 65 is our retirement age 17 | 18 | public static void yearsUntilRetirement(String name, int yearOfBirth){ 19 | int yearsUntilRetirement = 65 - calculateAge(yearOfBirth); 20 | System.out.println(name+" retires in "+ yearsUntilRetirement+" years"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /liveReview/week11/Atts.java: -------------------------------------------------------------------------------- 1 | package week11; 2 | 3 | public class Atts { 4 | /* 5 | The class Atts holds a few attributes and has a method called asString. The attributes are name and color -both are strings and amount which is an int.Their visibility is public. asString returns a string showing all the Atts in a format. 6 | */ 7 | public String name,color; // instance variables: 8 | public int amount; 9 | 10 | public String asString(){ // instance methods 11 | return "name : "+name+" color : "+color+" amount : "+amount; 12 | } 13 | 14 | 15 | 16 | } 17 | -------------------------------------------------------------------------------- /liveReview/week11/AttsTest.java: -------------------------------------------------------------------------------- 1 | package week11; 2 | 3 | public class AttsTest { 4 | public static void main(String[] args) { 5 | 6 | Atts atts = new Atts(); 7 | 8 | atts.name = "cookie"; 9 | atts.color = "brown"; 10 | atts.amount = 10; 11 | 12 | System.out.println("atts.asString() = " + atts.asString()); 13 | 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /liveReview/week11/LocalVSInstance.java: -------------------------------------------------------------------------------- 1 | package week11; 2 | 3 | public class LocalVSInstance { 4 | 5 | public int a = 4; // initialized value 6 | 7 | public void showDifference(int number){ // Ques= I want to be able to change this a as well 8 | int a = number; // this a is local to the method 9 | System.out.println(a); 10 | } 11 | 12 | 13 | 14 | } 15 | -------------------------------------------------------------------------------- /liveReview/week11/LocalVSInstanceTest.java: -------------------------------------------------------------------------------- 1 | package week11; 2 | 3 | public class LocalVSInstanceTest { 4 | public static void main(String[] args) { 5 | 6 | LocalVSInstance obj = new LocalVSInstance(); 7 | System.out.println("--coming from the method---"); 8 | obj.showDifference(8); 9 | 10 | System.out.println("--coming from instance variable----"); 11 | System.out.println(obj.a); 12 | obj.a = 1; 13 | System.out.println(obj.a); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /liveReview/week12/TelephoneTest.java: -------------------------------------------------------------------------------- 1 | package week12; 2 | 3 | public class TelephoneTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | // System.out.println(Telephone.total); // static block initialize 8 | 9 | Telephone telephone = new Telephone(); // do I get my static block initialized? 10 | System.out.println(telephone.total); 11 | telephone.setNumber("555-5055050"); 12 | System.out.println(telephone.getNumber()); 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /liveReview/week12/ValueTest.java: -------------------------------------------------------------------------------- 1 | package week12; 2 | 3 | public class ValueTest { 4 | public static void main(String[] args) { 5 | Value value = new Value(); 6 | // print if I called set Value method 7 | System.out.println(value.calledMethod); // false 8 | // print the parameter without assigning anything 9 | System.out.println(value.getValue()); // 0 10 | 11 | value.setValue(5); 12 | System.out.println(value.calledMethod);// true 13 | System.out.println(value.getValue());// 5 14 | 15 | 16 | 17 | Value value1 = new Value(3); 18 | System.out.println(value1.calledConstructor); // true 19 | System.out.println(value1.calledMethod); // false 20 | System.out.println(value1.getValue()); // 3 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /liveReview/week13/CameraPhone.java: -------------------------------------------------------------------------------- 1 | package week13; 2 | 3 | public class CameraPhone extends Phone { 4 | int imageSize; // this one is in MegaBytes 5 | int memorySize;// this is in gigabytes 6 | 7 | public CameraPhone(int x, int y){ 8 | // super(); 9 | // super(); this(); 10 | imageSize=x; 11 | memorySize=y; 12 | // super(); compiler error, it has to be at the first line 13 | } 14 | 15 | public CameraPhone(){} 16 | 17 | public int numPictures(){ 18 | return memorySize*1000/imageSize; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /liveReview/week13/Login.java: -------------------------------------------------------------------------------- 1 | package week13; 2 | 3 | public class Login { 4 | public static void main(String[] args) { 5 | 6 | Credentials userOne = new Credentials(); 7 | /* System.out.println("Username at the system for userOne is: "+userOne.userName); 8 | System.out.println("Password at the system for userOne is: "+userOne.passWord); 9 | userOne.userName= "differentName"; 10 | userOne.passWord= "differentPassword"; 11 | System.out.println("Username at the system for userOne is: "+userOne.userName); 12 | System.out.println("Password at the system for userOne is: "+userOne.passWord);*/ 13 | 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /liveReview/week13/Notes.txt: -------------------------------------------------------------------------------- 1 | This is a message from Class -------------------------------------------------------------------------------- /liveReview/week13/Password.java: -------------------------------------------------------------------------------- 1 | package week13; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Password { 6 | private String password; 7 | 8 | public Password(){ 9 | 10 | } 11 | 12 | Scanner scanner = new Scanner(System.in); 13 | 14 | public String getPassword(){ 15 | if(password==null){ 16 | System.out.println("password is null. Assign a value for it"); 17 | password=scanner.next(); 18 | }else { 19 | System.out.println("It has a value, just returning it"); 20 | } 21 | return password; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /liveReview/week13/PasswordTest.java: -------------------------------------------------------------------------------- 1 | package week13; 2 | 3 | public class PasswordTest { 4 | public static void main(String[] args) { 5 | Password password = new Password(); 6 | 7 | password.getPassword(); 8 | 9 | String myPassword = password.getPassword(); 10 | 11 | System.out.println(myPassword); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /liveReview/week13/PersonTest.java: -------------------------------------------------------------------------------- 1 | package week13; 2 | 3 | public class PersonTest { 4 | public static void main(String[] args) { 5 | 6 | Person personOne = new Person("Mike","Smith",30); 7 | 8 | System.out.println(personOne); 9 | 10 | // can I change this person's name? 11 | // personOne.firstName= "Oscar"; no access to the data to change it 12 | 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /liveReview/week13/inheritance/AudioBook.java: -------------------------------------------------------------------------------- 1 | package week13.inheritance; 2 | 3 | public class AudioBook extends Book{ 4 | int length; 5 | String narrator; 6 | 7 | public AudioBook(String title, String type, String author, double price,int length,String narrator) { 8 | super(title, type, author, price); 9 | this.length=length; 10 | this.narrator=narrator; 11 | } 12 | 13 | 14 | public void listen(){ 15 | System.out.println("Listening to AudioBook"); 16 | System.out.println("title = " + title); 17 | System.out.println("type = " + type); 18 | System.out.println("author = " + author); 19 | System.out.println("length = " + length); 20 | System.out.println("narrator = " + narrator); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /liveReview/week13/inheritance/BookShop.java: -------------------------------------------------------------------------------- 1 | package week13.inheritance; 2 | 3 | public class BookShop { 4 | public static void main(String[] args) { 5 | 6 | Book bookOne = new Book(); 7 | bookOne.title= "intro to Java"; 8 | bookOne.author = "Savitch"; 9 | bookOne.type = "programming"; 10 | bookOne.price=85.90; 11 | 12 | System.out.println("bookOne = " + bookOne); 13 | 14 | AudioBook audioBook = new AudioBook("Selenium Cookbook","Automation","Unmesh",44.99,60,"Irina"); 15 | 16 | audioBook.listen(); 17 | 18 | // can I call parent class method with Child class object? 19 | audioBook.buy(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /liveReview/week13/inheritance/Ebook.java: -------------------------------------------------------------------------------- 1 | package week13.inheritance; 2 | 3 | public class Ebook extends Book{ 4 | int size; 5 | int pages; 6 | 7 | public Ebook(){ 8 | super(); 9 | } 10 | 11 | public void readBook(){ 12 | System.out.println("Reading the book from my Tablet"); 13 | System.out.println("title = " + title); 14 | System.out.println("author = " + author); 15 | System.out.println("price = " + price); 16 | System.out.println("size = " + size); 17 | System.out.println("pages = " + pages); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /liveReview/week14/browserPagesInheritance/CartPage.java: -------------------------------------------------------------------------------- 1 | package week14.browserPagesInheritance; 2 | 3 | public class CartPage extends AmazonHomePage{ 4 | 5 | public String buyerInfo; 6 | public CartPage(String name, String buyerInfo) { 7 | super(name); 8 | this.buyerInfo=buyerInfo; 9 | } 10 | 11 | public void fillInfo(){ 12 | System.out.println("Filling the necessary fields with :"+buyerInfo); 13 | } 14 | 15 | public void payFor(long cardNumber){ 16 | System.out.println("Paying with credit card : "+cardNumber); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /liveReview/week14/browserPagesInheritance/ProductPage.java: -------------------------------------------------------------------------------- 1 | package week14.browserPagesInheritance; 2 | 3 | public class ProductPage extends AmazonHomePage { 4 | public int quantity; 5 | 6 | public ProductPage(String name, int quantity){ 7 | super(name); 8 | this.quantity=quantity; 9 | } 10 | 11 | // need: our shopFor method is not specialized enough for this class 12 | @Override // annotation should be applicable to the method 13 | public void shopFor(String product){ 14 | super.product=product; 15 | System.out.println("Automating "+super.getName()); // which browser we are automating 16 | System.out.println("Adding "+quantity+" amount of "+super.product+" to cart"); 17 | } 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /liveReview/week15/ErrorExamples.java: -------------------------------------------------------------------------------- 1 | package week15; 2 | 3 | public class ErrorExamples { 4 | /* 5 | Normally we don't try to catch ERROR like the one below 6 | */ 7 | public static void main(String[] args) { 8 | try { 9 | deathlyMethod(); 10 | }catch (StackOverflowError error){ 11 | System.out.println(error.getMessage()); 12 | System.out.println(error.getCause()); 13 | System.out.println(error.getClass()); 14 | } 15 | 16 | 17 | 18 | } 19 | 20 | static int counter = 0; 21 | 22 | public static void deathlyMethod(){ 23 | System.out.println(counter++); 24 | deathlyMethod(); // infinite loop 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /liveReview/week15/FinallyBlock.java: -------------------------------------------------------------------------------- 1 | package week15; 2 | 3 | import java.util.InputMismatchException; 4 | import java.util.Scanner; 5 | 6 | public class FinallyBlock { 7 | public static void main(String[] args) { 8 | Scanner scanner = new Scanner(System.in); 9 | 10 | try { 11 | System.out.println("Enter a number : "); 12 | int num = scanner.nextInt(); 13 | System.out.println("You entered : "+num); 14 | }catch (InputMismatchException e){ 15 | System.out.println("You entered invalid value ! "); 16 | } finally { 17 | scanner.close();// close and clean up the scanner 18 | System.out.println("Finally block - runs always"); 19 | } 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /liveReview/week15/RuntimeErrorExample.java: -------------------------------------------------------------------------------- 1 | package week15; 2 | 3 | import java.util.Scanner; 4 | 5 | public class RuntimeErrorExample { 6 | public static void main(String[] args) { 7 | 8 | System.out.println("Hello"); 9 | int x = 5; 10 | Scanner scanner = new Scanner(System.in); 11 | int y = scanner.nextInt(); 12 | // if there is a line of code that I might get exception expectation 13 | try { 14 | System.out.println( x / y ); // when user puts zero this line will be skipped 15 | }catch(Exception e){ 16 | 17 | } 18 | System.out.println("How are you today ? "); 19 | System.out.println("Some more lines of code"); 20 | System.out.println("we swallowed the exception object"); 21 | 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /liveReview/week15/TryCatchExamples.java: -------------------------------------------------------------------------------- 1 | package week15; 2 | 3 | public class TryCatchExamples { 4 | public static void main(String[] args) { 5 | 6 | try { 7 | System.out.println(10 / 2); 8 | System.out.println(10 / 0); 9 | System.out.println(10 / 3); // this line is skipped 10 | }catch (ArithmeticException arithmeticException){ 11 | System.out.println("Arithmetic exception handled"); 12 | // System.out.println(arithmeticException.getMessage()); 13 | } 14 | 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /liveReview/week15/checkedExceptions/CheckedExceptionDemo.java: -------------------------------------------------------------------------------- 1 | package week15.checkedExceptions; 2 | 3 | public class CheckedExceptionDemo { 4 | public static void main(String[] args) throws InterruptedException{ 5 | 6 | //Thread.sleep(5000); // throws or causes an InterruptedException, which is a checked exception 7 | // 1. Try Catch 8 | try{ 9 | Thread.sleep(5000); 10 | }catch (Exception e){ 11 | 12 | } 13 | System.out.println("I will move on with my web automation"); 14 | 15 | // 2. Declare using the Throws Keyword 16 | Thread.sleep(5000); 17 | System.out.println("More automation after 5 more seconds"); 18 | 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /liveReview/week15/checkedExceptions/ReadFromFile.java: -------------------------------------------------------------------------------- 1 | package week15.checkedExceptions; 2 | 3 | public class ReadFromFile { 4 | public static void main(String[] args) { 5 | // tell java the path of the file 6 | String filePath = "liveReview/week15/checkedExceptions/data.txt"; 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /liveReview/week15/checkedExceptions/data.txt: -------------------------------------------------------------------------------- 1 | in 2 | this 3 | example 4 | we 5 | will 6 | see 7 | IOException 8 | another 9 | checked 10 | exception 11 | type 12 | we 13 | use 14 | File 15 | Class 16 | from 17 | Java 18 | -------------------------------------------------------------------------------- /liveReview/week15/customExceptions/BreakTimeException.java: -------------------------------------------------------------------------------- 1 | package week15.customExceptions; 2 | 3 | public class BreakTimeException extends RuntimeException{ 4 | public BreakTimeException(String message){ 5 | super(message); // call the constructor of RunTimeException class 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /liveReview/week15/customExceptions/InsufficientBalanceException.java: -------------------------------------------------------------------------------- 1 | package week15.customExceptions; 2 | 3 | public class InsufficientBalanceException extends RuntimeException{ 4 | 5 | public InsufficientBalanceException(){super();} 6 | 7 | public InsufficientBalanceException(String message){super(message);} 8 | 9 | } 10 | -------------------------------------------------------------------------------- /liveReview/week16/FreeWeight.java: -------------------------------------------------------------------------------- 1 | package week16; 2 | 3 | public class FreeWeight extends Lifting{ 4 | public FreeWeight(double weight) { 5 | super(weight); 6 | } 7 | 8 | @Override 9 | void perform() { 10 | System.out.println("Lifting Free Weight with dumbbells"); 11 | } 12 | 13 | @Override 14 | int getCaloriesCount(int minutes) { 15 | return (int) (minutes*6*(weight/100)); 16 | } 17 | 18 | @Override 19 | public void endLift() { 20 | System.out.println("Carefully re-rack dumbbells"); 21 | } 22 | /* 23 | How many methods does this class have to implement 24 | */ 25 | } 26 | -------------------------------------------------------------------------------- /liveReview/week16/Lifting.java: -------------------------------------------------------------------------------- 1 | package week16; 2 | 3 | public abstract class Lifting extends Exercise { 4 | public Lifting(double weight) { 5 | super(weight); 6 | } 7 | /* 8 | If an abstarct class inherits from another abstract class, it does not have to implement the abstract methods 9 | */ 10 | 11 | public abstract void endLift(); 12 | } 13 | -------------------------------------------------------------------------------- /liveReview/week16/Running.java: -------------------------------------------------------------------------------- 1 | package week16; 2 | 3 | public class Running extends Exercise{ 4 | 5 | public Running(double weight) { 6 | super(weight); 7 | } 8 | 9 | @Override 10 | public void perform() { 11 | System.out.println("Performing Running Exercise on the Track"); 12 | } 13 | 14 | @Override 15 | public int getCaloriesCount(int minutes) { 16 | return (int) (minutes*13*(weight/100)); 17 | } 18 | 19 | // public abstract void run(); you can declare your methods as abstract in regular classes 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /liveReview/week16/Swimming.java: -------------------------------------------------------------------------------- 1 | package week16; 2 | 3 | public class Swimming extends Exercise{ 4 | public Swimming(double weight) { 5 | super(weight); 6 | } 7 | 8 | @Override 9 | protected void perform() { 10 | System.out.println("Swimming in the pool doing laps"); 11 | } 12 | 13 | @Override 14 | protected int getCaloriesCount(int minutes) { 15 | return (int) (minutes*11*(weight/100)); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /liveReview/week17/interface_demo/WebDriver.java: -------------------------------------------------------------------------------- 1 | package week17.interface_demo; 2 | 3 | public interface WebDriver { 4 | void get(String url); // it is automatically public abstract 5 | void findElement(String locator); 6 | void quit(); 7 | String getTitle(); 8 | } 9 | -------------------------------------------------------------------------------- /liveReview/week18/poly_demo/Father.java: -------------------------------------------------------------------------------- 1 | package week18.poly_demo; 2 | 3 | public class Father extends Parent implements Worker{ 4 | 5 | @Override 6 | public void raiseKid() { 7 | System.out.println("Raising Kids, helping moms"); 8 | } 9 | 10 | @Override 11 | public void playWithKid() { 12 | System.out.println("Playing with Kids occasionally"); 13 | } 14 | 15 | @Override 16 | public void feedKid() { 17 | System.out.println("Providing food and supplies to home"); 18 | } 19 | 20 | @Override 21 | public void work(String job) { 22 | System.out.println("Working as "+job); 23 | } 24 | 25 | @Override 26 | public double getPaid() { 27 | return 100000.0; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /liveReview/week18/poly_demo/Parent.java: -------------------------------------------------------------------------------- 1 | package week18.poly_demo; 2 | 3 | public abstract class Parent { 4 | public abstract void raiseKid(); // no implementation 5 | public abstract void playWithKid(); 6 | public abstract void feedKid(); 7 | } 8 | -------------------------------------------------------------------------------- /liveReview/week18/poly_demo/Worker.java: -------------------------------------------------------------------------------- 1 | package week18.poly_demo; 2 | 3 | public interface Worker { 4 | public abstract void work(String job); // public abstract 5 | double getPaid(); 6 | } 7 | -------------------------------------------------------------------------------- /liveReview/week18/poly_demo2/InputField.java: -------------------------------------------------------------------------------- 1 | package week18.poly_demo2; 2 | 3 | public class InputField implements WebElement{ 4 | 5 | public String getValue(){ 6 | System.out.println("Getting value of the inputField"); 7 | return "Selenium"; 8 | } 9 | @Override 10 | public void sendKeys(String txt) { 11 | System.out.println("Typing into input field "+txt); 12 | } 13 | 14 | @Override 15 | public void click() { 16 | System.out.println("Clicking on the input field"); 17 | } 18 | 19 | @Override 20 | public String getText() { 21 | System.out.println("getting text of input field"); 22 | return "JAVA"; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /liveReview/week18/poly_demo2/Links.java: -------------------------------------------------------------------------------- 1 | package week18.poly_demo2; 2 | 3 | public class Links implements WebElement{ 4 | 5 | public void getLinkHref(){ 6 | System.out.println("https://www.java.com"); 7 | } 8 | 9 | @Override 10 | public void sendKeys(String txt) { 11 | System.out.println("Not Supported Action"); 12 | } 13 | 14 | @Override 15 | public void click() { 16 | System.out.println("Clicking the link"); 17 | } 18 | 19 | @Override 20 | public String getText() { 21 | System.out.println("Getting Link Text"); 22 | return "Oracle Java"; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /liveReview/week18/poly_demo2/WebElement.java: -------------------------------------------------------------------------------- 1 | package week18.poly_demo2; 2 | 3 | public interface WebElement { 4 | void sendKeys(String txt); 5 | void click(); 6 | String getText(); 7 | } 8 | -------------------------------------------------------------------------------- /liveReview/week18/poly_demo2/WebElementUtility.java: -------------------------------------------------------------------------------- 1 | package week18.poly_demo2; 2 | 3 | public class WebElementUtility { 4 | 5 | // we will have a method with polymorphic parameter 6 | // an object reference of WebElement Interface 7 | 8 | public static void clickElement(WebElement element){ 9 | System.out.println("Clicking on the Element"); 10 | element.click(); // our element object is a polyMorphic object and can reach either InputField or Links class click implementation 11 | } 12 | 13 | public static WebElement getLinkWithText(String txt){ 14 | System.out.println("Searching for a link with txt "+txt); 15 | return new Links(); // new InputField 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /liveReview/week19/Notes.txt: -------------------------------------------------------------------------------- 1 | What is collection framework? 2 | Data Structure 3 | Classes, Interfaces which are extended or implemented in such way to build this connection 4 | Why do we need collection framework? 5 | to organize our data 6 | 7 | inteview perspective: 8 | * What is the difference between ....(List) and ...(Set) ? 9 | * How did you use .....(LinkedList) in your framework? 10 | * we need to know collection framework verbally? 11 | 12 | Usage Perspective: 13 | * ArrayList, 14 | * List 15 | * Set 16 | * Map, List of Maps 17 | * Arrays 18 | 19 | Benefits: growable, different types of Data, OOP Concepts-Polymorphism, methods 20 | 21 | sync: running slow (vector) -- Thread-safe 22 | not sync: fast (arraylist) 23 | 24 | All collections are iterable. -------------------------------------------------------------------------------- /liveReview/week20/Day.java: -------------------------------------------------------------------------------- 1 | package week20; 2 | 3 | public enum Day { 4 | 5 | SUNDAY, 6 | MONDAY, 7 | TUESDAY, 8 | WEDNESDAY, 9 | THURSDAY, 10 | FRIDAY, 11 | SATURDAY 12 | 13 | } 14 | -------------------------------------------------------------------------------- /liveReview/week20/Notes.txt: -------------------------------------------------------------------------------- 1 | Last Week of JAVA 2 | Map Interface ---> does NOT extend Collection Interface, but we can consider as part Collection Framework 3 | - pairs of Data: key - value 4 | - keys must be unique(not duplicated), values can be dublicate 5 | - does not support primitives 6 | 7 | HashMap(C) implements Map Interface (similar to HashSet functions) 8 | order is random, faster, accepts null key, using hash code 9 | 10 | LinkedHashMap(C) --(LinkedList) 11 | keeps the insertion order, accepts null key 12 | 13 | TreeMap(C) - TreeSet 14 | Sorted, does not accept null key 15 | 16 | HashTable(C) --- kind of like Vector 17 | does not accept null key, order is random, synchronized (slower) 18 | 19 | ENUM: constant values that have been predefined : compass directions (North, East ...) 20 | -------------------------------------------------------------------------------- /replitTaksSolutions/_0_001_Basics_HelloWorld1.java: -------------------------------------------------------------------------------- 1 | //Write a statement that prints Hello world to the screen. 2 | //Output must exactly match the requirement 3 | public class _0_001_Basics_HelloWorld1 { 4 | public static void main(String[] args) { 5 | 6 | System.out.println("Hello world"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /replitTaksSolutions/_0_002_Basics_HelloWorld2.java: -------------------------------------------------------------------------------- 1 | //Write a complete main method that prints Hello world to the screen. 2 | public class _0_002_Basics_HelloWorld2 { 3 | public static void main(String[] args) { 4 | System.out.print("**`Hello world`**"); 5 | 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /replitTaksSolutions/_0_003_Basics_PrintName.java: -------------------------------------------------------------------------------- 1 | //Suppose your name was Alan Turing. 2 | // Write a main method and a statement that would print your last name, 3 | // followed by a comma, followed by a space and your first name. 4 | public class _0_003_Basics_PrintName { 5 | public static void main(String[] args) { 6 | 7 | System.out.println("Turing, Alan"); 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /replitTaksSolutions/_0_004_Basics_PrintNumbers.java: -------------------------------------------------------------------------------- 1 | //Write multiple print statements that will print from 1 to 10 in separate lines. 2 | // 3 | // 1 2 3 4 5 6 7 8 9 10 4 | public class _0_004_Basics_PrintNumbers { 5 | public static void main(String[] args) { 6 | 7 | System.out.println("\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10"); 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /replitTaksSolutions/_0_005_Basics_FixPrint.java: -------------------------------------------------------------------------------- 1 | //Rearrange the following code so that 2 | // it forms a correct program that prints out the letter Q 3 | public class _0_005_Basics_FixPrint { 4 | public static void main(String[] args) { 5 | 6 | System.out.print("Q"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /replitTaksSolutions/_0_006_Basics_Cool.java: -------------------------------------------------------------------------------- 1 | //Write a program that displays: I think being a programmer is cool 2 | 3 | public class _0_006_Basics_Cool { 4 | public static void main(String[] args) { 5 | 6 | System.out.println("I think being a programmer is cool"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /replitTaksSolutions/_0_010_Basics_PrintVariable1.java: -------------------------------------------------------------------------------- 1 | //Given an integer variable count write a statement that displays the value 2 | 3 | public class _0_010_Basics_PrintVariable1 { 4 | public static void main(String[] args) { 5 | //do not change 6 | int count = 100; 7 | 8 | System.out.println(count); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /replitTaksSolutions/_0_011_Basics_PrintVariable2.java: -------------------------------------------------------------------------------- 1 | //Given a String variable message write a statement to disply its value 2 | 3 | public class _0_011_Basics_PrintVariable2 { 4 | public static void main(String[] args) { 5 | //do not change 6 | String message = "I am a Cybertek school student."; 7 | 8 | System.out.println(message); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /replitTaksSolutions/_1_001_Variables_Primitives1.java: -------------------------------------------------------------------------------- 1 | //Declare an integer variable named degreesCelsius but do not assign any value 2 | // 3 | // Nothing else. Yes, its that simple! 4 | 5 | public class _1_001_Variables_Primitives1 { 6 | public static void main(String[] args) { 7 | //WRITE YOUR CODE HERE: 8 | 9 | int degreesCelsius; 10 | 11 | 12 | //DO NOT TOUCH BELOW LINES. 13 | degreesCelsius = 35; 14 | System.out.println(degreesCelsius); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /replitTaksSolutions/_3_001_String_VerifyContains.java: -------------------------------------------------------------------------------- 1 | //Write a program that will verify if the **sentence** contains **word**. 2 | // Print out the result as a boolean value. 3 | 4 | import java.util.Scanner; 5 | 6 | public class _3_001_String_VerifyContains { 7 | public static void main(String[] args) { 8 | Scanner scan = new Scanner(System.in); 9 | String word = scan.nextLine(); 10 | String sentence = scan.nextLine(); 11 | //WRITE YOUR CODE HERE 12 | System.out.println(sentence.contains(word)); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /replitTaksSolutions/_3_004_String_PrintFirstCharacter.java: -------------------------------------------------------------------------------- 1 | //Write a program that will print out the first character of the word. 2 | // 3 | // Ex: 4 | // 5 | // ``` 6 | // Input: jump 7 | // ``` 8 | // ``` 9 | // Output: j 10 | // ``` 11 | 12 | 13 | import java.util.Scanner; 14 | 15 | public class _3_004_String_PrintFirstCharacter { 16 | public static void main(String[] args) { 17 | //DO NOT CHANGE 18 | Scanner scan = new Scanner(System.in); 19 | String word = scan.next(); 20 | //WRITE YOUR CODE HERE: 21 | 22 | System.out.println(word.charAt(0)); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /replitTaksSolutions/_3_005_String_PrintLastCharacter.java: -------------------------------------------------------------------------------- 1 | //Write a program that will print out last letter of the word (string). 2 | // 3 | // Ex: 4 | // ``` 5 | // Input: java 6 | // ``` 7 | // ``` 8 | // Output: a 9 | // ``` 10 | 11 | import java.util.Scanner; 12 | 13 | public class _3_005_String_PrintLastCharacter { 14 | public static void main(String[] args) { 15 | //DO NOT CHANGE 16 | Scanner scan = new Scanner(System.in); 17 | String word = scan.next(); 18 | //WRITE YOUR CODE HERE 19 | System.out.println(word.charAt(word.length()-1)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /replitTaksSolutions/_3_006_String_PrintFirstAndLastLetters.java: -------------------------------------------------------------------------------- 1 | //Write a program that will print out first and last letters together. 2 | // 3 | // ``` 4 | // Input: adobe 5 | // ``` 6 | // 7 | // ``` 8 | // Output: ae 9 | // ``` 10 | 11 | import java.util.Scanner; 12 | 13 | public class _3_006_String_PrintFirstAndLastLetters { 14 | public static void main(String[] args) { 15 | //DO NOT CHANGE 16 | Scanner scan = new Scanner(System.in); 17 | String word = scan.next(); 18 | //WRITE YOUR CODE HERE 19 | 20 | 21 | System.out.println(Character.toString(word.charAt(0))+Character.toString(word.charAt(word.length()-1))); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /replitTaksSolutions/_3_008_String_DuplicateIt.java: -------------------------------------------------------------------------------- 1 | //You have 2 words 2 | // 3 | // Print the first word, second word, second word, first word 4 | // 5 | // ``` 6 | // Input: 7 | // 8 | // one 9 | // 10 | // two 11 | // ``` 12 | // 13 | // ``` 14 | // Output: 15 | // 16 | // onetwotwoone 17 | // ``` 18 | 19 | import java.util.Scanner; 20 | 21 | public class _3_008_String_DuplicateIt { 22 | public static void main(String[] args) { 23 | Scanner scan = new Scanner(System.in); 24 | String word1 = scan.next(); 25 | String word2 = scan.next(); 26 | //YOUR CODE HERE 27 | System.out.println(word1.concat(word2).concat(word2).concat(word1)); 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /replitTaksSolutions/_4_012_Loops_PrintNTimes.java: -------------------------------------------------------------------------------- 1 | //Given an int variable **n** print out **n** asterisks. So if n=5, five asterisks will be printed. 2 | // 3 | // Example: 4 | // 5 | // ``` 6 | // input: 1 7 | // 8 | // output: * 9 | // ``` 10 | // 11 | // Example: 12 | // 13 | // ``` 14 | // input: 3 15 | // 16 | // output: *** 17 | // ``` 18 | 19 | import java.util.Scanner; 20 | 21 | public class _4_012_Loops_PrintNTimes { 22 | public static void main(String[] args) { 23 | Scanner scan = new Scanner(System.in); 24 | int n = scan.nextInt(); 25 | //WRITE YOUR CODE HERE 26 | for(int i=0;i=end ; i=i-2) 11 | { 12 | System.out.print(i); 13 | if(i!=end) 14 | { 15 | System.out.print(" "); 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /replitTaksSolutions/_5_024_Arrays_SplitSentence.java: -------------------------------------------------------------------------------- 1 | //Given a String variable **sentence,** write code to type each word in separate lines. 2 | // 3 | // Example: 4 | // 5 | // ``` 6 | // sentence -> "Java is fun" 7 | // 8 | // Print 9 | // 10 | // Java 11 | // is 12 | // fun 13 | // ``` 14 | 15 | import java.util.Scanner; 16 | 17 | public class _5_024_Arrays_SplitSentence { 18 | public static void main(String[] args) { 19 | Scanner input = new Scanner(System.in); 20 | String sentence = input.nextLine(); 21 | 22 | //type your code below 23 | 24 | String[] tmp = sentence.split(" "); 25 | 26 | for(String word: tmp) 27 | { 28 | System.out.println(word); 29 | } 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /replitTaksSolutions/_6_001_Methods_HelloWorld.java: -------------------------------------------------------------------------------- 1 | //Given 2 static methods **hello()** and **world()**. Provide an implementation for both of them in order to print appropriate message. So hello() method should print "Hello" and world() method should print "World!".` 2 | // 3 | // ``` 4 | // output: 5 | // Hello 6 | // World! 7 | // ``` 8 | 9 | public class _6_001_Methods_HelloWorld { 10 | public static void main(String[] args) { 11 | hello(); 12 | world(); 13 | } 14 | 15 | public static void hello(){ 16 | //WRITE YOUR CODE HERE 17 | System.out.println("Hello"); 18 | } 19 | 20 | public static void world(){ 21 | //WRITE YOUR CODE HERE 22 | System.out.println("World!"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /replitTaksSolutions/_6_024_Methods_MethodsWithReturn3Locks.java: -------------------------------------------------------------------------------- 1 | //**threeLocks** accepts 3 booleans and returns a boolean. 2 | // 3 | // It returns true only if both **_a and b are true_** or **_c is true_**. 4 | // 5 | // Hint: See truth table 6 | 7 | import java.util.Scanner; 8 | 9 | public class _6_024_Methods_MethodsWithReturn3Locks { 10 | public static boolean threeLocks(boolean a, boolean b, boolean c) 11 | { 12 | boolean result=(a && b) || c; 13 | return result; 14 | 15 | }//end threeLocks 16 | 17 | public static void main(String[] args) { 18 | Scanner in = new Scanner(System.in); 19 | System.out.println(threeLocks(in.nextBoolean(), in.nextBoolean(),in.nextBoolean())); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /replitTaksSolutions/_6_035_Methods_MethodsWithStringBiggerString.java: -------------------------------------------------------------------------------- 1 | //The method accepts two strings and return the longest one 2 | // 3 | // Example": 4 | // ``` 5 | // bigger("apple","orange") ==> "orange" 6 | // ``` 7 | 8 | import java.util.Scanner; 9 | 10 | public class _6_035_Methods_MethodsWithStringBiggerString { 11 | public static String bigger(String a ,String b){ 12 | if(a.length()>b.length()) 13 | { 14 | return a; 15 | } 16 | else 17 | { 18 | return b; 19 | } 20 | 21 | } 22 | 23 | public static void main(String[] args) { 24 | Scanner in = new Scanner(System.in); 25 | System.out.println(bigger(in.next(), in.next())); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /replitTaksSolutions/_6_036_Methods_MethodsWithStringRemoveFirstChar.java: -------------------------------------------------------------------------------- 1 | //The method accepts a string and returns a string without the first character 2 | // 3 | // Example: 4 | // ``` 5 | // removeFirst("aaa") 6 | // 7 | // returns "aa" 8 | // 9 | // ``` 10 | 11 | import java.util.Scanner; 12 | 13 | public class _6_036_Methods_MethodsWithStringRemoveFirstChar { 14 | public static String removeFirst(String target) { 15 | 16 | return target.substring(1); 17 | } 18 | 19 | 20 | public static void main(String[] args) { 21 | Scanner in = new Scanner(System.in); 22 | System.out.println(removeFirst(in.next())); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/day01_JavaIntro/Test.java: -------------------------------------------------------------------------------- 1 | package day01_JavaIntro; 2 | 3 | import utilities.StringUtility; 4 | 5 | public class Test { 6 | 7 | public static void main(String[] args) { 8 | 9 | String str = "Wooden Spoon"; 10 | 11 | StringUtility.printEachChar(str); 12 | 13 | 14 | 15 | } 16 | 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/day02_HelloWorld/HelloCydeo.java: -------------------------------------------------------------------------------- 1 | package day02_HelloWorld; 2 | 3 | public class HelloCydeo { 4 | 5 | public static void main(String[] args) { 6 | 7 | System.out.println("Hello Cydeo"); 8 | System.out.println("Wooden Spoon"); 9 | 10 | } 11 | 12 | } 13 | 14 | -------------------------------------------------------------------------------- /src/day02_HelloWorld/HelloWorld.java: -------------------------------------------------------------------------------- 1 | package day02_HelloWorld; 2 | 3 | public class HelloWorld { 4 | 5 | public static void main(String[] args){ 6 | 7 | System.out.println("Hello World"); 8 | 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/day02_HelloWorld/PrintExecution.java: -------------------------------------------------------------------------------- 1 | package day02_HelloWorld; 2 | 3 | public class PrintExecution { 4 | 5 | public static void main(String[] args) { 6 | 7 | System.out.println("Duygu"); 8 | System.out.println("Oleksandr"); 9 | System.out.println("Zoia"); 10 | System.out.println(); 11 | System.out.println("Ahmet"); 12 | System.out.println("Yuliya"); 13 | System.out.println("Cassandra"); 14 | System.out.println(); 15 | System.out.println("Cydeo"); 16 | 17 | 18 | } 19 | 20 | 21 | } 22 | 23 | -------------------------------------------------------------------------------- /src/day03_EscapeSequences/AboutMe.java: -------------------------------------------------------------------------------- 1 | package day03_EscapeSequences; 2 | 3 | public class AboutMe { 4 | 5 | public static void main(String[] args) { 6 | 7 | System.out.println("\tMy favorite music is \"Rock\" musics. \n\t\t\t\tMy favorite book is \"Data Structure in Java\""); 8 | 9 | 10 | } 11 | 12 | } 13 | 14 | /* 15 | 1. Create a class called AboutMe.java 16 | write a program to tell us about yourself: 17 | favorite music 18 | favorite book 19 | favorite quote 20 | favorite TV show 21 | 22 | */ -------------------------------------------------------------------------------- /src/day03_EscapeSequences/Err_VS_Out.java: -------------------------------------------------------------------------------- 1 | package day03_EscapeSequences; 2 | 3 | public class Err_VS_Out { 4 | 5 | 6 | public static void main(String[] args) { 7 | 8 | System.out.println("Hello World"); 9 | 10 | System.out.println("----------------------------------"); 11 | 12 | System.err.println("Hello World"); 13 | 14 | 15 | 16 | } 17 | 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/day03_EscapeSequences/GasReceipt.java: -------------------------------------------------------------------------------- 1 | package day03_EscapeSequences; 2 | 3 | public class GasReceipt { 4 | 5 | public static void main(String[] args) { 6 | 7 | System.out.println(); 8 | System.out.println(" MCLEAN STORE"); 9 | System.out.println(); 10 | System.out.println("09/20/2021 09:25pm"); 11 | System.out.println(); 12 | System.out.println("Gallons: 11.840"); 13 | System.out.println("Price/gallon: $ 2.089"); 14 | System.out.println(); 15 | System.out.println("Fuel total: $ 24.734"); 16 | 17 | 18 | 19 | } 20 | 21 | } 22 | /* 23 | 1. Write a code to print the following output in the console: 24 | Pic is in day03 presentation slide 25 | 26 | */ -------------------------------------------------------------------------------- /src/day03_EscapeSequences/Println_VS_Print.java: -------------------------------------------------------------------------------- 1 | package day03_EscapeSequences; 2 | 3 | public class Println_VS_Print { 4 | 5 | public static void main(String[] args) { 6 | 7 | System.out.println("Hello Cydeo"); 8 | System.out.println("How are you all today?"); 9 | 10 | System.out.println("-----------------------------"); 11 | 12 | System.out.print("Hello Cydeo"); 13 | System.out.print("How are you all today?"); 14 | 15 | System.out.println("Java Programming"); 16 | 17 | System.out.print("Wooden Spoon"); 18 | 19 | System.out.println("I love Java"); 20 | 21 | 22 | 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/day03_EscapeSequences/RightTriangle.java: -------------------------------------------------------------------------------- 1 | package day03_EscapeSequences; 2 | 3 | public class RightTriangle { 4 | 5 | public static void main(String[] args) { 6 | 7 | System.out.println("*"); 8 | System.out.println("* *"); 9 | System.out.println("* * *"); 10 | System.out.println("* * * *"); 11 | System.out.println("* * * * *"); 12 | System.out.println("* * * * * *"); 13 | System.out.println("* * * * * * *"); 14 | 15 | } 16 | 17 | 18 | } 19 | 20 | /* 21 | 2. Create a class called RightTriangle.java and print the following shape of a right triangle: 22 | 23 | * 24 | * * 25 | * * * 26 | * * * * 27 | * * * * * 28 | * * * * * * 29 | * * * * * * * 30 | 31 | */ -------------------------------------------------------------------------------- /src/day03_EscapeSequences/Triangle.java: -------------------------------------------------------------------------------- 1 | package day03_EscapeSequences; 2 | 3 | public class Triangle { 4 | 5 | public static void main(String[] args) { 6 | 7 | System.out.println("\t\t\t ^"); 8 | System.out.println("\t\t\t / \\"); 9 | System.out.println("\t\t\t / \\"); 10 | System.out.println("\t\t\t / \\"); 11 | System.out.println("\t\t\t/ \\"); 12 | System.out.println("\t\t\t---------"); 13 | 14 | 15 | } 16 | 17 | } 18 | 19 | /* 20 | 2. Create a class called Triangle.java and print: 21 | 22 | ^ 23 | / \ 24 | / \ 25 | / \ 26 | / \ 27 | --------- 28 | 29 | 30 | %temp% 31 | */ -------------------------------------------------------------------------------- /src/day04_Variables/Currencies.java: -------------------------------------------------------------------------------- 1 | package day04_Variables; 2 | 3 | public class Currencies { 4 | 5 | public static void main(String[] args) { 6 | // $1000 7 | int dollar = 1000; 8 | 9 | double lira = dollar * 9.8; 10 | double euro = dollar * 0.86 ; 11 | double JPY = dollar * 115; 12 | double pound = dollar * 0.73; 13 | double CAD = dollar * 1.24; 14 | 15 | System.out.println("dollar = " + dollar); 16 | System.out.println("lira = " + lira); 17 | System.out.println("euro = " + euro); 18 | System.out.println("JPY = " + JPY); 19 | System.out.println("pound = " + pound); 20 | System.out.println("CAD = " + CAD); 21 | 22 | 23 | 24 | 25 | 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/day04_Variables/GallonsToLitters.java: -------------------------------------------------------------------------------- 1 | package day04_Variables; 2 | 3 | public class GallonsToLitters { 4 | 5 | public static void main(String[] args) { 6 | int gallons = 1000; 7 | 8 | double litters = gallons * 3.79 ; 9 | 10 | System.out.println("litters = " + litters); 11 | 12 | 13 | 14 | } 15 | 16 | } 17 | 18 | /* 19 | 5. Create a class named GallonsToLitters, Write a program that can convert gallon (int) to litter (double) 20 | Hints: 1 gallon = 3.79 litters 21 | */ -------------------------------------------------------------------------------- /src/day04_Variables/KgToPounds.java: -------------------------------------------------------------------------------- 1 | package day04_Variables; 2 | 3 | public class KgToPounds { 4 | 5 | public static void main(String[] args) { 6 | int kg = 75; 7 | 8 | double lb = kg * 2.2; 9 | 10 | // System.out.println("kg = " + kg); 11 | System.out.println("lb = " + lb); 12 | 13 | } 14 | 15 | } 16 | 17 | /* 18 | 4. Create a class named KgToPounds, write a program that can convert kg (int) to pounds (double) 19 | Hints: 1 kg = 2.2 pounds 20 | */ -------------------------------------------------------------------------------- /src/day04_Variables/SalaryCalculator.java: -------------------------------------------------------------------------------- 1 | package day04_Variables; 2 | 3 | public class SalaryCalculator { 4 | 5 | public static void main(String[] args) { 6 | // hourly Rate, weeklyHours 7 | 8 | int hourlyRate = 65; 9 | int weeklyHours = 45; 10 | int numberOfWeeks = 52; 11 | 12 | int salary = hourlyRate * weeklyHours * numberOfWeeks; 13 | 14 | // System.out.println(salary); 15 | System.out.println("hourlyRate = $" + hourlyRate); 16 | System.out.println("weeklyHours = " + weeklyHours); 17 | System.out.println("numberOfWeeks = " + numberOfWeeks); 18 | System.out.println("salary = $" + salary); 19 | 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/day04_Variables/Square.java: -------------------------------------------------------------------------------- 1 | package day04_Variables; 2 | 3 | public class Square { 4 | 5 | public static void main(String[] args) { 6 | //DataType variableName = Data; 7 | 8 | double side = 8.5; 9 | 10 | double area = side * side; 11 | double perimeter = side * 4; 12 | 13 | System.out.println("side = " + side); 14 | System.out.println("area = " + area); 15 | System.out.println("perimeter = " + perimeter); 16 | 17 | 18 | } 19 | 20 | } 21 | 22 | /* 23 | 1. Create a class named Square, write a program that can calculate the area & perimeter of any given square 24 | side (3.5) 25 | 26 | area = side * side; 27 | perimeter = 4 * side 28 | */ 29 | 30 | -------------------------------------------------------------------------------- /src/day05_Concatenation/Calculator.java: -------------------------------------------------------------------------------- 1 | package day05_Concatenation; 2 | 3 | public class Calculator { 4 | 5 | public static void main(String[] args) { 6 | 7 | int firstNumber = 100; 8 | int secondNumber = 50; 9 | 10 | int addition = firstNumber + secondNumber; 11 | int subtraction = firstNumber - secondNumber; 12 | 13 | 14 | // 100 + 50 = 150 15 | System.out.println(firstNumber + " + " + secondNumber +" = " + addition ); 16 | 17 | //100 - 50 = 50 18 | System.out.println(firstNumber + " - "+secondNumber+ " = " + subtraction); 19 | 20 | //100 * 50 = 5000 21 | 22 | 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/day05_Concatenation/Introduction.java: -------------------------------------------------------------------------------- 1 | package day05_Concatenation; 2 | 3 | public class Introduction { 4 | 5 | public static void main(String[] args) { 6 | String name = "Jimmy"; 7 | int age = 39; 8 | 9 | //Hello Everyone, My name is _____, and I am ___ years Old. 10 | System.out.println("Hello Everyone, My name is " + name + ", and I am " + age + " years old." ); 11 | 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/day08_IfStatements/EligibleToVote.java: -------------------------------------------------------------------------------- 1 | package day08_IfStatements; 2 | 3 | public class EligibleToVote { 4 | 5 | public static void main(String[] args) { 6 | 7 | String name = "Josh"; 8 | int age = 38; 9 | String citizen = "USA"; 10 | 11 | boolean isEligible = age >= 21 && citizen == "USA"; //True 12 | 13 | // Eligible 14 | if(isEligible){ // True 15 | System.out.println("Eligible"); 16 | } 17 | 18 | //Not Eligible 19 | if(!isEligible){ // !True ==> not true==> false 20 | System.out.println("Not Eligible"); 21 | } 22 | 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/day08_IfStatements/SwapTwoVariables_WithTemporaryVariable.java: -------------------------------------------------------------------------------- 1 | package day08_IfStatements; 2 | 3 | public class SwapTwoVariables_WithTemporaryVariable { 4 | 5 | public static void main(String[] args) { 6 | int a = 10; 7 | int b = 15; 8 | //----------------------------------- 9 | int c = b; // c= 15; 10 | 11 | b = a; //b= 10 12 | a = c; 13 | //-------------------------------------- 14 | System.out.println("a = " + a); // 15 15 | System.out.println("b = " + b); // 10 16 | 17 | } 18 | 19 | 20 | } 21 | 22 | /* 23 | 1. write a program that can swipe two variables' value by using a temporary variable 24 | 25 | Ex: 26 | if a= 10, b=15 27 | 28 | output: 29 | a = 15 30 | b = 10 31 | */ -------------------------------------------------------------------------------- /src/day09_IfStatements/LeapYear.java: -------------------------------------------------------------------------------- 1 | package day09_IfStatements; 2 | 3 | public class LeapYear { 4 | 5 | public static void main(String[] args) { 6 | 7 | int year = 2000; 8 | 9 | boolean leapYear = year % 4 == 0; 10 | 11 | if(leapYear){ 12 | System.out.println("Year "+year+" is a leap year"); 13 | } 14 | 15 | if(!leapYear){ 16 | System.out.println("Year "+year+" is NOT a leap year"); 17 | } 18 | 19 | 20 | System.out.println("-----------------------------------"); 21 | 22 | if(leapYear){ 23 | System.out.println("Year "+year+" is a leap year"); 24 | }else{ 25 | System.out.println("Year "+year+" is NOT a leap year"); 26 | } 27 | 28 | 29 | 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/day09_IfStatements/PassOrFail.java: -------------------------------------------------------------------------------- 1 | package day09_IfStatements; 2 | 3 | public class PassOrFail { 4 | 5 | public static void main(String[] args) { 6 | 7 | int score = 75; 8 | 9 | if(score >= 60) { 10 | System.out.println("Congrats, you passed"); 11 | }else{ 12 | System.out.println("Failed"); 13 | } 14 | 15 | 16 | 17 | 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/day10_NestedIf/NameOfMonth2.java: -------------------------------------------------------------------------------- 1 | package day10_NestedIf; 2 | 3 | public class NameOfMonth2 { 4 | 5 | public static void main(String[] args) { 6 | int n = 5; 7 | 8 | String name = (n==1)? "Jan" :(n==2)? "Feb" :(n==3)? "Mar" :(n==4)? "April" :(n==5)? "May" :(n==6)?"Jun" 9 | :(n==7)? "Jul" :(n==8)? "Aug" :(n==9)? "Sep" :(n==10)? "Oct" :(n==11)?"Nov" : "Dec"; 10 | 11 | System.out.println(name); 12 | 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/day10_NestedIf/TernariesWithNestedIf.java: -------------------------------------------------------------------------------- 1 | package day10_NestedIf; 2 | 3 | public class TernariesWithNestedIf { 4 | 5 | public static void main(String[] args) { 6 | 7 | int s = 5000; 8 | 9 | /* 10 | if(s >= 0 && s <= 100){ 11 | 12 | if(s >= 60){ 13 | System.out.println("Passed"); 14 | }else{ 15 | System.out.println("Failed"); 16 | } 17 | 18 | }else{ 19 | System.out.println("Invalid Score"); 20 | } 21 | */ 22 | 23 | String result = (s >= 0 && s <= 100)? (s >= 60)? "Passed" : "Failed" : "Invalid Score"; 24 | 25 | System.out.println(result); 26 | 27 | 28 | 29 | 30 | 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/day10_NestedIf/day10 class notes.txt: -------------------------------------------------------------------------------- 1 | Java Day10 2 | Topics: Nested If 3 | if without curly braces 4 | Ternaries 5 | 6 | package name: day10_NestedIf 7 | 8 | 9 | If Statements: used for conditional statements. if the condition true, the block gets executed 10 | 11 | single if: for one condition 12 | if(Condition) 13 | 14 | if & else: for 2 condition ONLY 15 | else{ 16 | 17 | } 18 | 19 | multi-branch if: for 3 or more conditions 20 | else if(Condition) 21 | 22 | nested if: Pre-condition 23 | 24 | 25 | 26 | 27 | Ternaries: shortcut of if statement 28 | 29 | 30 | if: (Condition)? 31 | else: : 32 | else if: :(Condition)? 33 | 34 | 35 | 36 | Monday: If Statements Short quiz 37 | 38 | 39 | come back at: 2pm US EST 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/day11_Switch_Scanner/Grade2.java: -------------------------------------------------------------------------------- 1 | package day11_Switch_Scanner; 2 | 3 | public class Grade2 { 4 | 5 | public static void main(String[] args) { 6 | 7 | char ch = 'E'; 8 | String result = ""; 9 | // || 10 | switch (ch){ 11 | 12 | case 'A': case 'B': case 'C': case 'D': 13 | result = "Passed"; 14 | break; 15 | 16 | case 'F': 17 | result = "Failed"; 18 | break; 19 | 20 | default: 21 | result = "Invalid"; 22 | 23 | } 24 | 25 | System.out.println(result); 26 | 27 | 28 | } 29 | 30 | } 31 | /* 32 | if the grade is A or B or C or D =====>"Passed" 33 | otherwise ==> "Failed" 34 | 35 | */ 36 | -------------------------------------------------------------------------------- /src/day11_Switch_Scanner/NumberToWords.java: -------------------------------------------------------------------------------- 1 | package day11_Switch_Scanner; 2 | 3 | public class NumberToWords { 4 | 5 | public static void main(String[] args) { 6 | 7 | int number = -1; 8 | 9 | String result = (number >= 0 && number <= 9) ? 10 | (number == 0) ? "Zero" : (number == 1) ? "One" : (number == 2) ? "Two" 11 | : (number == 3) ? "Three" : (number == 4) ? "Four" : (number == 5) ? "Five" 12 | : (number == 6) ? "Six" : (number == 7) ? "Seven" : (number == 8) ? "Eight" : "Nine" 13 | : "Invalid Number"; 14 | 15 | System.out.println(result); 16 | 17 | 18 | } 19 | 20 | } 21 | 22 | /* 23 | 2. Write a program that can convert numbers 0~9 to words. 24 | 25 | NOTE: MUST use ternary 26 | */ -------------------------------------------------------------------------------- /src/day12_Scanner/Circle.java: -------------------------------------------------------------------------------- 1 | package day12_Scanner; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Circle { 6 | 7 | public static void main(String[] args) { 8 | 9 | Scanner input = new Scanner(System.in); 10 | 11 | System.out.println("Enter the radius of the circle:"); 12 | 13 | double r = input.nextDouble(); 14 | 15 | double area = r * r * 3.14; 16 | double perimeter = 2 * r * 3.14; 17 | 18 | System.out.println("area = " + area); 19 | System.out.println("perimeter = " + perimeter); 20 | 21 | input.close(); 22 | 23 | } 24 | 25 | } 26 | 27 | /* 28 | 1. Circle: 29 | 1.1 Ask the user to enter the radius of the circle 30 | 1.1 Calculate the area and perimeter of the circle by using the radius 31 | 32 | */ -------------------------------------------------------------------------------- /src/day12_Scanner/ScannerPractice2.java: -------------------------------------------------------------------------------- 1 | package day12_Scanner; 2 | 3 | import java.util.Scanner; 4 | 5 | public class ScannerPractice2 { 6 | 7 | public static void main(String[] args) { 8 | 9 | Scanner input = new Scanner(System.in); 10 | 11 | // System.out.println("Enter true or false:"); 12 | // boolean result = input.nextBoolean(); 13 | 14 | System.out.println("Enter your name: "); 15 | String name = input.next(); // reads the input until a space 16 | 17 | System.out.println("name = " + name); // Java 18 | 19 | input.close(); 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/day13_String/Initials.java: -------------------------------------------------------------------------------- 1 | package day13_String; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Initials { 6 | 7 | public static void main(String[] args) { 8 | 9 | Scanner scan = new Scanner(System.in); 10 | 11 | System.out.println("Enter your first name"); 12 | String firstName = scan.next(); //"Java" 13 | 14 | System.out.println("Enter your last name"); 15 | String lastName = scan.next(); 16 | 17 | char f = firstName.charAt(0); 18 | char l = lastName.charAt(0); 19 | 20 | String initial = f + "." + l; 21 | 22 | System.out.println("initial = " + initial); 23 | 24 | 25 | scan.close(); 26 | 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/day15_ForLoop/ReplaceX.java: -------------------------------------------------------------------------------- 1 | package day15_ForLoop; 2 | 3 | public class ReplaceX { 4 | 5 | public static void main(String[] args) { 6 | String str = "xcodeX"; 7 | 8 | String result = str.replace("x", "a").replace("X", "a"); 9 | // "acodeX" "acodea" 10 | 11 | System.out.println(result); 12 | 13 | 14 | 15 | } 16 | 17 | } 18 | /* 19 | 2. Write a program that asks user to enter a word. and replace all the x or X with character a 20 | Input: 21 | xcodeX 22 | Output: 23 | acodea 24 | */ 25 | -------------------------------------------------------------------------------- /src/day15_ForLoop/startsWithX.java: -------------------------------------------------------------------------------- 1 | package day15_ForLoop; 2 | 3 | 4 | import java.util.Scanner; 5 | 6 | public class startsWithX { 7 | 8 | public static void main(String[] args) { 9 | 10 | System.out.println("Enter a word:"); 11 | String word = new Scanner(System.in).next(); //"xcodex" 12 | 13 | if(word.charAt(0) == 'x' ){ 14 | word = word.replaceFirst("x", "a"); //"acodex" 15 | } 16 | 17 | System.out.println(word); 18 | 19 | 20 | 21 | 22 | } 23 | 24 | } 25 | /* 26 | 1. Write a program that asks user to enter a word. If the word starts with x, replace it with a. 27 | Input: 28 | xcodex 29 | Output: 30 | acodex 31 | 32 | */ -------------------------------------------------------------------------------- /src/day16_ForLoopStringPractice/Palindrome.java: -------------------------------------------------------------------------------- 1 | package day16_ForLoopStringPractice; 2 | 3 | public class Palindrome { 4 | 5 | public static void main(String[] args) { 6 | 7 | String word = "Civic"; 8 | 9 | String reversed = ""; 10 | 11 | for (int i = word.length()-1; i >=0 ; i--) { 12 | reversed += word.charAt(i); 13 | } 14 | 15 | boolean isPalindrome = word.equalsIgnoreCase(reversed); 16 | 17 | System.out.println("isPalindrome = " + isPalindrome); 18 | 19 | 20 | } 21 | 22 | } 23 | 24 | /* 25 | "Java" ==> "avaJ" ===> false (not palindrome) 26 | "Anna" ==> "annA" ===>true 27 | 28 | "Level" 29 | "Racecar 30 | Dad 31 | Mom 32 | .... 33 | 34 | 35 | 36 | */ -------------------------------------------------------------------------------- /src/day17_While_DoWhile/DoWhileLoopIntro.java: -------------------------------------------------------------------------------- 1 | package day17_While_DoWhile; 2 | 3 | public class DoWhileLoopIntro { 4 | 5 | public static void main(String[] args) { 6 | boolean a = false; 7 | 8 | for(int i = 0; a;){ 9 | System.out.println("Wooden Spoon -- for loop"); 10 | } 11 | 12 | System.out.println("-------------------------------"); 13 | 14 | while(a){ 15 | System.out.println("Wooden Spoon -- while loop"); 16 | } 17 | 18 | System.out.println("-------------------------------"); 19 | 20 | 21 | do{ 22 | System.out.println("Wooden Spoon -- do-while loop"); 23 | }while(a); 24 | 25 | 26 | 27 | 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/day17_While_DoWhile/FrequencyOfWord2.java: -------------------------------------------------------------------------------- 1 | package day17_While_DoWhile; 2 | 3 | public class FrequencyOfWord2 { 4 | public static void main(String[] args) { 5 | String str = "Cat Cat Dog Dog cAt CAT caT"; 6 | 7 | int frequency = 0; 8 | 9 | for (int i = 0; i <= str.length()-3; i++) { 10 | String eachSub = str.substring(i, i+3 ); 11 | 12 | if(eachSub.equalsIgnoreCase("Cat")){ 13 | frequency++; 14 | } 15 | 16 | } 17 | 18 | System.out.println(frequency); 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/day17_While_DoWhile/LoopPractices.java: -------------------------------------------------------------------------------- 1 | package day17_While_DoWhile; 2 | 3 | public class LoopPractices { 4 | 5 | public static void main(String[] args) { 6 | 7 | for (int i = 1; i <= 10; i++) { 8 | System.out.println(i); 9 | } 10 | 11 | System.out.println("-----------------------------------"); 12 | 13 | int j=1; 14 | while(j <= 10){ 15 | 16 | System.out.println(j); 17 | j++; 18 | } 19 | 20 | System.out.println("-----------------------------------"); 21 | int k =1; 22 | do{ 23 | 24 | System.out.println(k); 25 | k++; 26 | }while(k <= 10); 27 | 28 | 29 | 30 | 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/day17_While_DoWhile/RemoveDuplicates.java: -------------------------------------------------------------------------------- 1 | package day17_While_DoWhile; 2 | 3 | public class RemoveDuplicates { 4 | 5 | public static void main(String[] args) { 6 | 7 | String str = "AABBCC"; 8 | 9 | String result = ""; //A 10 | 11 | for (int i = 0; i < str.length(); i++) { 12 | char ch = str.charAt(i); // "A", "A", "B", "B", "C", "C" 13 | if(result.contains(""+ch)){ // if the result already contains the character 14 | // break; // exit 15 | continue; // skip 16 | } 17 | result += ch; 18 | } 19 | 20 | System.out.println(result); 21 | 22 | 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/day17_While_DoWhile/WhileLoopIntro.java: -------------------------------------------------------------------------------- 1 | package day17_While_DoWhile; 2 | 3 | public class WhileLoopIntro { 4 | 5 | public static void main(String[] args) { 6 | 7 | if(true){ 8 | System.out.println("Wooden Spoon"); // 1 time 9 | } 10 | 11 | 12 | System.out.println("-----------------------------------------"); 13 | 14 | while(true){ // repeated if 15 | System.out.println("Wooden Spoon"); // 16 | } 17 | 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/day18_NestedLoop/NestedLoopPractice2.java: -------------------------------------------------------------------------------- 1 | package day18_NestedLoop; 2 | 3 | public class NestedLoopPractice2 { 4 | 5 | public static void main(String[] args) { 6 | 7 | for (int j = 0; j < 10; j++) { //j = 0, 1, 2 8 | 9 | for (int i = 0; i < 10; i++) { 10 | System.out.print("* "); 11 | } 12 | 13 | System.out.println(); 14 | 15 | } 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | } 25 | 26 | } 27 | 28 | /* 29 | 1. Print the following shape by using a nested Loop: 30 | * * * * * * * * * 31 | * * * * * * * * * 32 | * * * * * * * * * 33 | * * * * * * * * * 34 | * * * * * * * * * 35 | * * * * * * * * * 36 | * * * * * * * * * 37 | * * * * * * * * * 38 | */ -------------------------------------------------------------------------------- /src/day19_LoopPractices/ExitMethod.java: -------------------------------------------------------------------------------- 1 | package day19_LoopPractices; 2 | 3 | public class ExitMethod { 4 | 5 | public static void main(String[] args) { 6 | 7 | for (int i = 0; i < 5; i++) { //i: 0, 1, 2, 3, 4 8 | 9 | if(i == 3){ 10 | // break; // terminates the loop 11 | // continue; //terminates the current iteration of the loop 12 | System.exit(0); // terminates the program 13 | } 14 | 15 | System.out.println(i); 16 | } 17 | 18 | 19 | System.out.println("Wooden Spoon"); 20 | 21 | 22 | 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/day19_LoopPractices/LoopsWithoutCurlyBraces.java: -------------------------------------------------------------------------------- 1 | package day19_LoopPractices; 2 | 3 | public class LoopsWithoutCurlyBraces { 4 | 5 | public static void main(String[] args) { 6 | 7 | for (int i = 0; i < 5; i++) 8 | System.out.println("Cydeo"); 9 | 10 | for (int i = 0; i < 5; i++) { 11 | System.out.println("Batch 25"); 12 | } 13 | 14 | 15 | 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/day20_Arrays/AppearedTwice.java: -------------------------------------------------------------------------------- 1 | package day20_Arrays; 2 | 3 | public class AppearedTwice { 4 | 5 | public static void main(String[] args) { 6 | 7 | char[] chars = {'A', 'A', 'A', 'B', 'C', 'C', 'D', 'D', 'D'}; 8 | 9 | for (int j = 0; j < chars.length; j++) { 10 | char ch = chars[j]; //'A' 11 | int frequency = 0; 12 | for (int i = 0; i < chars.length; i++) { 13 | if(chars[i] ==ch){ 14 | frequency++; 15 | } 16 | } 17 | 18 | if(frequency == 2){ 19 | System.out.println(ch); 20 | } 21 | 22 | } 23 | 24 | 25 | 26 | 27 | 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/day20_Arrays/ArraysUtility.java: -------------------------------------------------------------------------------- 1 | package day20_Arrays; 2 | 3 | import java.util.Arrays; 4 | 5 | public class ArraysUtility { 6 | 7 | public static void main(String[] args) { 8 | 9 | int[] numbers ={10,9, 0,1,2,20, 4,6,7,8}; 10 | 11 | System.out.println(Arrays.toString(numbers)); 12 | 13 | Arrays.sort(numbers); // sorts the array in ascending order 14 | 15 | System.out.println(Arrays.toString(numbers)); 16 | 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/day20_Arrays/AverageNumbers.java: -------------------------------------------------------------------------------- 1 | package day20_Arrays; 2 | 3 | public class AverageNumbers { 4 | 5 | public static void main(String[] args) { 6 | 7 | int[] numbers = {10,20,30,40,50,60}; 8 | 9 | double sum = 0; //+10+20+30... 10 | 11 | for (int i = 0; i < numbers.length; i++) { 12 | sum += numbers[i]; 13 | } 14 | 15 | double averageNumber = sum/ numbers.length; 16 | 17 | System.out.println("averageNumber = " + averageNumber); 18 | 19 | 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/day20_Arrays/MaxNumberOfArray.java: -------------------------------------------------------------------------------- 1 | package day20_Arrays; 2 | 3 | public class MaxNumberOfArray { 4 | 5 | public static void main(String[] args) { 6 | 7 | int[] numbers = {10, 5, 4, 20, 1, 0}; 8 | int max = numbers[0];// 20 9 | 10 | for (int i = 0; i < numbers.length; i++) { 11 | 12 | if(numbers[i] > max ){ // if there is element in the array that's greater than the current max number 13 | max = numbers[i]; // assigning greater number to variable max 14 | } 15 | 16 | } 17 | 18 | System.out.println(max); 19 | 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/day20_Arrays/MinNumberOfArray.java: -------------------------------------------------------------------------------- 1 | package day20_Arrays; 2 | 3 | public class MinNumberOfArray { 4 | 5 | public static void main(String[] args) { 6 | 7 | int[] numbers = {100, 500, 30, 40, 600, 80, -90}; 8 | 9 | int min = numbers[0]; // 30 10 | 11 | for (int i = 0; i < numbers.length; i++) {//i: 0,1,2,3... 12 | 13 | if(numbers[i] < min){ // if there is an element in the array that's smaller 14 | min = numbers[i]; // smaller number will be assigned to the variable min 15 | } 16 | 17 | } 18 | 19 | System.out.println(min); 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/day21_ForEachLoop/AverageNumber.java: -------------------------------------------------------------------------------- 1 | package day21_ForEachLoop; 2 | 3 | public class AverageNumber { 4 | 5 | public static void main(String[] args) { 6 | 7 | int[] numbers = {10,20,30,40,50,60}; 8 | 9 | double sum = 0; 10 | 11 | for (int number : numbers) { 12 | sum += number; 13 | } 14 | 15 | double average = sum/ numbers.length; 16 | 17 | System.out.println("average = " + average); 18 | 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/day21_ForEachLoop/ForEachLoopIntro.java: -------------------------------------------------------------------------------- 1 | package day21_ForEachLoop; 2 | 3 | public class ForEachLoopIntro { 4 | 5 | public static void main(String[] args) { 6 | 7 | int[] numbers = {10,20,30,40,50,60,70}; 8 | // 0 1 2 3 4 5 6 9 | 10 | for (int i = 0; i < numbers.length; i++) { // i: indexes of the array 11 | int eachElement = numbers[i]; 12 | System.out.println(eachElement); 13 | } 14 | 15 | System.out.println("---------------------------------"); 16 | 17 | for(int each : numbers ){ // each: elements of the array 18 | System.out.println(each); 19 | } 20 | 21 | 22 | 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/day21_ForEachLoop/ForEachLoopPractice.java: -------------------------------------------------------------------------------- 1 | package day21_ForEachLoop; 2 | 3 | public class ForEachLoopPractice { 4 | 5 | public static void main(String[] args) { 6 | 7 | String[] words = {"Java Programming", "Cydeo School", "Wooden Spoon", "Early Birds", "Angry Birds"}; 8 | 9 | for(String each : words ){ 10 | System.out.println( each.charAt(0)+ ""+ each.charAt( each.length()-1 ) ); 11 | } 12 | 13 | 14 | 15 | } 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/day21_ForEachLoop/Initials.java: -------------------------------------------------------------------------------- 1 | package day21_ForEachLoop; 2 | 3 | public class Initials { 4 | 5 | public static void main(String[] args) { 6 | 7 | String[] names = {"Elminur Ablimit", "Ali Kilic", "Hulya Keles", "Simen Kaya", "Begench Begenjov", "Ruveyda Durna", 8 | "Jonathan Holly", "Alshaun Rodgers", "Manas Kalenov", "Gulsen Sohret"}; 9 | 10 | 11 | for(String each : names ){ 12 | String initial = each.charAt(0)+"."+ each.charAt( each.indexOf(" ") +1 ); 13 | System.out.println(initial); 14 | } 15 | 16 | 17 | 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/day21_ForEachLoop/MaxNumber.java: -------------------------------------------------------------------------------- 1 | package day21_ForEachLoop; 2 | 3 | public class MaxNumber { 4 | 5 | public static void main(String[] args) { 6 | 7 | int[] numbers = {10, 5, 4, 20, 1, 0}; 8 | int max = numbers[0];// 20 9 | 10 | /* 11 | for (int i = 0; i < numbers.length; i++) { 12 | 13 | if(numbers[i] > max ){ // if there is element in the array that's greater than the current max number 14 | max = numbers[i]; // assigning greater number to variable max 15 | } 16 | 17 | } 18 | 19 | */ 20 | 21 | for (int number : numbers) { 22 | if(number > max){ 23 | max =number; 24 | } 25 | } 26 | 27 | 28 | System.out.println(max); 29 | 30 | 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/day21_ForEachLoop/ReverseNames.java: -------------------------------------------------------------------------------- 1 | package day21_ForEachLoop; 2 | 3 | public class ReverseNames { 4 | 5 | public static void main(String[] args) { 6 | String[] names = {"Elminur Ablimit", "Ali Kilic", "Hulya Keles", "Simen Kaya", "Begench Begenjov", "Ruveyda Durna", 7 | "Jonathan Holly", "Alshaun Rodgers", "Manas Kalenov", "Gulsen Sohret"}; 8 | 9 | for (String each : names) { // each: "Elminur Ablimit", "Ali Kilic", "Hulya Keles" .... 10 | 11 | String reversed = ""; 12 | 13 | for (int i = each.length()-1; i>= 0; i--) { // reverses the string 14 | reversed += each.charAt(i); 15 | } 16 | 17 | System.out.println(reversed); 18 | 19 | } 20 | 21 | 22 | 23 | 24 | 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/day22_MultiDimensionalArray/day22 class notes.txt: -------------------------------------------------------------------------------- 1 | Java Day22 2 | Topic: Multi Dimensional Array 3 | 4 | package name: day22_MultiDimensionalArray 5 | 6 | warmup task: 7 | 1. Write a program that can reverse a sentence 8 | Ex: 9 | sentence = "Today is a good day to learn Java"; 10 | 11 | output: 12 | Java learn to day good a is Today 13 | 14 | 15 | 2. Write a program that can reverse the second word of the sentence 16 | Ex: 17 | sentence = "I Love Java"; 18 | 19 | output: 20 | I evoL Java 21 | 22 | 23 | Single Dimensional Array: container for the elemnts 24 | 10 25 | 20 26 | 40 27 | 28 | int[] array = {10, 20, 30}; 29 | 30 | 31 | Multi Dimensional Array: container for the arrays 32 | -------------------------------------------------------------------------------- /src/day23_CustomMethods_Void/CustomMethodsIntro.java: -------------------------------------------------------------------------------- 1 | package day23_CustomMethods_Void; 2 | 3 | public class CustomMethodsIntro { 4 | 5 | public static void main(String[] args) { 6 | 7 | System.out.println("Test Started"); 8 | 9 | greeting(); 10 | greeting(); 11 | 12 | System.out.println("Test Completed"); 13 | 14 | 15 | } 16 | 17 | 18 | public static void greeting(){ 19 | 20 | System.out.println("Hello Cydeo!"); 21 | System.out.println("How are you today?"); 22 | 23 | 24 | } 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/day25_CustomMethods_Overloading/MainMethodOverloading.java: -------------------------------------------------------------------------------- 1 | package day25_CustomMethods_Overloading; 2 | 3 | public class MainMethodOverloading { 4 | 5 | public static void main(String[] args) { 6 | System.out.println("String"); 7 | } 8 | 9 | public static void main(int[] args) { 10 | System.out.println("int"); 11 | } 12 | 13 | public static void main(double[] args) { 14 | System.out.println("double"); 15 | } 16 | 17 | public static void main(char[] args) { 18 | System.out.println("char"); 19 | } 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/day26_CustomMethodsPractice/ReverseArray2.java: -------------------------------------------------------------------------------- 1 | package day26_CustomMethodsPractice; 2 | 3 | import utilities.ArraysUtility; 4 | 5 | public class ReverseArray2 { 6 | 7 | public static int[] reverse(int[] array){ 8 | 9 | int[] result = {}; 10 | 11 | for (int i = array.length - 1; i >= 0; i--) { 12 | result = ArraysUtility.addElement(result, array[i]); 13 | } 14 | 15 | return result; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/day28_ArrayList/ArrayListIntro.java: -------------------------------------------------------------------------------- 1 | package day28_ArrayList; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class ArrayListIntro { 6 | 7 | public static void main(String[] args) { 8 | 9 | ArrayList numbers = new ArrayList<>() ; 10 | ArrayList names = new ArrayList<>(); 11 | 12 | System.out.println(numbers); 13 | System.out.println(names); 14 | 15 | 16 | } 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/day28_ArrayList/ArrayListPractice.java: -------------------------------------------------------------------------------- 1 | package day28_ArrayList; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class ArrayListPractice { 6 | 7 | public static void main(String[] args) { 8 | 9 | ArrayList list = new ArrayList<>(); 10 | list.add(10); 11 | list.add(20); 12 | list.add(30); 13 | list.add(40); 14 | list.add(50); 15 | 16 | System.out.println(list); 17 | 18 | for (int i = 0; i < list.size(); i++) { // i: index numbers of list 19 | list.set(i , list.get(i) *2 ); 20 | } 21 | 22 | System.out.println(list); 23 | 24 | 25 | } 26 | 27 | 28 | } 29 | /* 30 | {1,2,3,4,5,6} 31 | 32 | {2,4,6,8,10,12} 33 | */ -------------------------------------------------------------------------------- /src/day31_Constructors/Person.java: -------------------------------------------------------------------------------- 1 | package day31_Constructors; 2 | 3 | public class Person { 4 | 5 | public String name; 6 | public char gender; 7 | public int age; 8 | 9 | public Person(String name, char gender, int age){ 10 | this.name = name; 11 | this.gender = gender; 12 | this.age = age; 13 | } 14 | 15 | 16 | public String toString() { 17 | return "Person{" + 18 | "name='" + name + '\'' + 19 | ", gender=" + gender + 20 | ", age=" + age + 21 | '}'; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/day31_Constructors/PersonObjects.java: -------------------------------------------------------------------------------- 1 | package day31_Constructors; 2 | 3 | public class PersonObjects { 4 | 5 | public static void main(String[] args) { 6 | 7 | Person person1 = new Person("Daniel", 'M', 32); 8 | 9 | Person person2 = new Person("Kseniia", 'F', 28); 10 | 11 | person2.age = 30; 12 | 13 | System.out.println(person1); 14 | System.out.println(person2); 15 | 16 | 17 | 18 | 19 | } 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/day31_Constructors/RectangleObjects.java: -------------------------------------------------------------------------------- 1 | package day31_Constructors; 2 | 3 | public class RectangleObjects { 4 | 5 | public static void main(String[] args) { 6 | 7 | Rectangle rectangle1 = new Rectangle(5.5, 3.5); 8 | 9 | Rectangle rectangle2 = new Rectangle(10.5, 8.5); 10 | 11 | System.out.println(rectangle1); 12 | System.out.println(rectangle2); 13 | 14 | 15 | } 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/day31_Constructors/Student.java: -------------------------------------------------------------------------------- 1 | package day31_Constructors; 2 | 3 | public class Student { 4 | 5 | public String name; 6 | public int age; 7 | public char gender; 8 | public char grade; 9 | public int id; 10 | 11 | public Student(String name, int age, char gender, char grade, int id) { 12 | this.name = name; 13 | this.age = age; 14 | this.gender = gender; 15 | this.grade = grade; 16 | this.id = id; 17 | } 18 | 19 | public String toString() { 20 | return "Student{" + 21 | "name='" + name + '\'' + 22 | ", age=" + age + 23 | ", gender=" + gender + 24 | ", grade=" + grade + 25 | ", id=" + id + 26 | '}'; 27 | } 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/day31_Constructors/StudentObjects.java: -------------------------------------------------------------------------------- 1 | package day31_Constructors; 2 | 3 | public class StudentObjects { 4 | 5 | public static void main(String[] args) { 6 | 7 | Student student1 = new Student("Hulya", 26, 'F', 'B', 13); 8 | 9 | Student student2 = new Student("Ali",30,'M','A',42); 10 | 11 | System.out.println(student1); 12 | System.out.println(student2); 13 | 14 | 15 | } 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/day32_Constructors/CarObjects.java: -------------------------------------------------------------------------------- 1 | package day32_Constructors; 2 | 3 | public class CarObjects { 4 | 5 | public static void main(String[] args) { 6 | 7 | Car car1 = new Car("Toyota"); 8 | 9 | Car car2 = new Car("Honda", "Accord"); 10 | 11 | Car car3 = new Car("Lexus", "RX350", 2021); 12 | 13 | Car car4 = new Car("BMW", "X6", 2020, 50000); 14 | 15 | Car car5 = new Car("Tesla", "Model 3", 2019, 70000, "Black"); 16 | 17 | 18 | System.out.println(car1); 19 | System.out.println(car2); 20 | System.out.println(car3); 21 | System.out.println(car4); 22 | System.out.println(car5); 23 | 24 | 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/day32_Constructors/CarpetObjects.java: -------------------------------------------------------------------------------- 1 | package day32_Constructors; 2 | 3 | public class CarpetObjects { 4 | 5 | public static void main(String[] args) { 6 | 7 | Carpet carpet1 = new Carpet(3, 5, 8, true); 8 | 9 | Carpet carpet2 = new Carpet(10, 20, 10, false); 10 | 11 | 12 | System.out.println(carpet1); 13 | System.out.println(carpet2); 14 | 15 | 16 | } 17 | 18 | } 19 | 20 | /* 21 | object: 22 | new ExistingConstructor 23 | */ -------------------------------------------------------------------------------- /src/day32_Constructors/EmployeeObjects.java: -------------------------------------------------------------------------------- 1 | package day32_Constructors; 2 | 3 | public class EmployeeObjects { 4 | 5 | public static void main(String[] args) { 6 | 7 | Employee employee1 = new Employee("Aaron"); 8 | 9 | Employee employee2 = new Employee("Yuliya", 'F'); 10 | 11 | Employee employee3 = new Employee("Olga", 'F', "SDET"); 12 | 13 | 14 | System.out.println(employee1); 15 | 16 | System.out.println(employee2); 17 | 18 | System.out.println(employee3); 19 | 20 | } 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/day32_Constructors/Test.java: -------------------------------------------------------------------------------- 1 | package day32_Constructors; 2 | 3 | public class Test { 4 | 5 | public Test(){ //A 6 | System.out.println("A"); 7 | } 8 | 9 | public Test(int a){ //A B 10 | this(); 11 | System.out.println("B"); 12 | } 13 | 14 | public Test(double a){ //A B C 15 | this(10); 16 | System.out.println("C"); 17 | } 18 | 19 | public Test(String str){ // A B C D 20 | this(2.5); 21 | System.out.println("D"); 22 | } 23 | 24 | public static void main(String[] args) { 25 | 26 | new Test("Java"); 27 | 28 | } 29 | 30 | 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/day33_Statics/Employee.java: -------------------------------------------------------------------------------- 1 | package day33_Statics; 2 | 3 | public class Employee { 4 | 5 | public String name; 6 | 7 | public double salary; 8 | 9 | public static boolean isHuman = true; 10 | 11 | 12 | 13 | } 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/day33_Statics/StudentTask.java: -------------------------------------------------------------------------------- 1 | package day33_Statics; 2 | 3 | class StudentClass{ 4 | 5 | 6 | } 7 | 8 | class Test{ 9 | 10 | } 11 | 12 | public class StudentTask { 13 | 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/day33_Statics/TestIphone.java: -------------------------------------------------------------------------------- 1 | package day33_Statics; 2 | 3 | public class TestIphone { 4 | 5 | public static void main(String[] args) { 6 | 7 | System.out.println( Iphone.OS ); 8 | 9 | } 10 | 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/day34_GarbageCollection_AccessModifiers/AccessModifiers_Test.java: -------------------------------------------------------------------------------- 1 | package day34_GarbageCollection_AccessModifiers; 2 | 3 | public class AccessModifiers_Test { 4 | 5 | public static void main(String[] args) { 6 | 7 | System.out.println( AccessModifiers.publicData ); 8 | System.out.println( AccessModifiers.defaultData ); 9 | // System.out.println( AccessModifiers.privateData ); // private is not visible outside the class 10 | 11 | AccessModifiers.method1(); 12 | AccessModifiers.method2(); 13 | // AccessModifiers.method3(); // private is not visible outside the class 14 | 15 | 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/day34_GarbageCollection_AccessModifiers/Constructor_vs_StaticBlock.java: -------------------------------------------------------------------------------- 1 | package day34_GarbageCollection_AccessModifiers; 2 | 3 | public class Constructor_vs_StaticBlock { 4 | 5 | static{ 6 | System.out.println("Static Block"); 7 | } 8 | 9 | public Constructor_vs_StaticBlock(){ 10 | System.out.println("Constructor"); 11 | } 12 | 13 | public static void main(String[] args) { 14 | 15 | new Constructor_vs_StaticBlock(); //1 16 | new Constructor_vs_StaticBlock(); //2 17 | new Constructor_vs_StaticBlock(); //3 18 | new Constructor_vs_StaticBlock(); //4 19 | new Constructor_vs_StaticBlock(); //5 20 | 21 | } 22 | 23 | 24 | } -------------------------------------------------------------------------------- /src/day34_GarbageCollection_AccessModifiers/CydeoStudent.java: -------------------------------------------------------------------------------- 1 | package day34_GarbageCollection_AccessModifiers; 2 | 3 | public class CydeoStudent { 4 | 5 | public String studentName; 6 | public static String schoolName; 7 | 8 | public CydeoStudent(String studentName){ 9 | this.studentName = studentName; 10 | 11 | } 12 | 13 | static{ 14 | schoolName = "Cydeo School"; 15 | } 16 | 17 | } 18 | 19 | 20 | class CydeoStudentObject{ 21 | 22 | public static void main(String[] args) { 23 | 24 | CydeoStudent student1 = new CydeoStudent("Jimmy"); 25 | CydeoStudent student2 = new CydeoStudent("Kathy"); 26 | 27 | System.out.println(student1.schoolName); 28 | System.out.println(student2.schoolName); 29 | 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /src/day34_GarbageCollection_AccessModifiers/StaticBlock.java: -------------------------------------------------------------------------------- 1 | package day34_GarbageCollection_AccessModifiers; 2 | 3 | public class StaticBlock { 4 | 5 | public static void main(String[] args) { 6 | 7 | System.out.println("Main Method"); 8 | 9 | } 10 | 11 | static{ //runs first before anything, and only runs one time 12 | System.out.println("Static Block 1"); 13 | } 14 | 15 | static{ 16 | System.out.println("Static Block 2"); 17 | } 18 | 19 | static{ 20 | System.out.println("Static Block 3"); 21 | } 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/day34_GarbageCollection_AccessModifiers/StaticImport.java: -------------------------------------------------------------------------------- 1 | package day34_GarbageCollection_AccessModifiers; 2 | 3 | import static day34_GarbageCollection_AccessModifiers.Circle.pi; 4 | 5 | public class StaticImport { 6 | 7 | public static void main(String[] args) { 8 | 9 | 10 | System.out.println(pi); 11 | 12 | 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/day34_GarbageCollection_AccessModifiers/Test.java: -------------------------------------------------------------------------------- 1 | package day34_GarbageCollection_AccessModifiers; 2 | 3 | 4 | import static day34_GarbageCollection_AccessModifiers.Circle.*; 5 | import static utilities.MathUtility.*; 6 | 7 | public class Test { 8 | 9 | public static void main(String[] args) { 10 | 11 | System.out.println(pi); 12 | System.out.println(name); 13 | System.out.println(numbers); 14 | 15 | System.out.println("----------------------------"); 16 | 17 | // find the sum of 10, 20 18 | int r1 = sum(10, 20); 19 | 20 | // find the sum of 100, 200 21 | int r2 = sum(100, 200); 22 | 23 | 24 | int r3 = subtract(100,50); 25 | 26 | int r4 = max(1000, 2000); 27 | 28 | 29 | } 30 | 31 | } 32 | 33 | -------------------------------------------------------------------------------- /src/day35_Encapsulation/encapsulation/EmployeeObject.java: -------------------------------------------------------------------------------- 1 | package day35_Encapsulation.encapsulation; 2 | 3 | public class EmployeeObject { 4 | 5 | public static void main(String[] args) { 6 | 7 | Employee employee1 = new Employee("Tahir", 'M', 30, 120000); 8 | 9 | employee1.setAge(32); 10 | 11 | 12 | Employee employee2 = new Employee("Aygun", 'F', 31, 115000); 13 | employee2.setName("Elvira"); 14 | employee2.setSalary( employee2.getSalary() + 15000 ); 15 | 16 | System.out.println(employee1); 17 | System.out.println(employee2); 18 | 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/day35_Encapsulation/encapsulation/Person.java: -------------------------------------------------------------------------------- 1 | package day35_Encapsulation.encapsulation; 2 | 3 | public class Person { 4 | 5 | private String name; 6 | private int age; 7 | 8 | public String getName(){ 9 | return name; 10 | } 11 | 12 | public void setName(String name){ 13 | this.name = name; 14 | } 15 | 16 | 17 | public int getAge(){ 18 | return age; 19 | } 20 | 21 | public void setAge(int age){ 22 | if(age <= 0 || age > 150){ 23 | System.err.println("Invalid Age: "+age); 24 | System.exit(0); 25 | } 26 | 27 | this.age = age; 28 | } 29 | 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/day35_Encapsulation/encapsulation/PersonObjects.java: -------------------------------------------------------------------------------- 1 | package day35_Encapsulation.encapsulation; 2 | 3 | public class PersonObjects { 4 | 5 | public static void main(String[] args) { 6 | 7 | Person p1 = new Person(); 8 | // p1.name = "Daniel"; 9 | // p1.age = 28; 10 | 11 | // p1.name = ""; 12 | // p1.age = 2000; 13 | 14 | p1.setName("Daniel"); 15 | p1.setAge(45); 16 | 17 | // System.out.println(p1.name +" : "+p1.age); 18 | 19 | System.out.println(p1.getName()+" : "+p1.getAge()); 20 | 21 | 22 | 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/day36_Inheritance/animalTask/Cat.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.animalTask; 2 | 3 | public class Cat extends Animal { //Cat Is An Animal 4 | 5 | public void meow(){ 6 | System.out.println(name + "is meowing"); 7 | } 8 | 9 | public void scratch(){ 10 | System.out.println(name + " is scratching"); 11 | } 12 | 13 | } 14 | 15 | /* 16 | Cat: 17 | 6 variables 18 | 8 methods 19 | */ -------------------------------------------------------------------------------- /src/day36_Inheritance/animalTask/Dog.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.animalTask; 2 | 3 | public class Dog extends Animal { //Dog Is An animal 4 | // child parent 5 | 6 | public void bark(){ 7 | System.out.println(name + " is barking"); 8 | } 9 | 10 | 11 | } 12 | 13 | /* 14 | dog: 15 | 6 variables 16 | 7 methods 17 | 18 | */ -------------------------------------------------------------------------------- /src/day36_Inheritance/animalTask/Tiger.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.animalTask; 2 | 3 | public class Tiger extends Animal{ // Tiger Is An Animal 4 | 5 | public void hunt(){ 6 | System.out.println(name + "is hunting"); 7 | } 8 | 9 | 10 | public void roar(){ 11 | System.out.println(name + "is roaring"); 12 | } 13 | 14 | } 15 | 16 | /* 17 | Tiger: 18 | 6 variables 19 | 8 methods 20 | */ 21 | -------------------------------------------------------------------------------- /src/day36_Inheritance/encapsulation/StudentObject.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.encapsulation; 2 | 3 | public class StudentObject { 4 | 5 | public static void main(String[] args) { 6 | 7 | Student student1 = new Student("Daniel", 29, 'M', 'D', "MIT"); 8 | student1.setAge(39); 9 | System.out.println(student1); 10 | 11 | } 12 | 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/day37_Inheritance/ConstructorPractice.java: -------------------------------------------------------------------------------- 1 | package day37_Inheritance; 2 | 3 | class A{ 4 | 5 | public A(int a){ 6 | System.out.println("A"); 7 | } 8 | 9 | } 10 | 11 | class B extends A{ 12 | 13 | public B(){ 14 | super(9); 15 | System.out.println("B"); 16 | } 17 | 18 | } 19 | 20 | public class ConstructorPractice { 21 | 22 | public static void main(String[] args) { 23 | 24 | B obj = new B(); 25 | 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /src/day37_Inheritance/animalTask/Cat.java: -------------------------------------------------------------------------------- 1 | package day37_Inheritance.animalTask; 2 | 3 | public class Cat extends Animal { 4 | 5 | public Cat(String name, String breed, char gender, int age, String size, String color) { 6 | super(name, breed, gender, age, size, color); 7 | } 8 | 9 | public void scratch(){ 10 | System.out.println(name+" is scratching"); 11 | } 12 | 13 | 14 | } -------------------------------------------------------------------------------- /src/day37_Inheritance/animalTask/Dog.java: -------------------------------------------------------------------------------- 1 | package day37_Inheritance.animalTask; 2 | 3 | public class Dog extends Animal{ 4 | 5 | public Dog(String name, String breed, char gender, int age, String size, String color){ 6 | super(name, breed, gender, age, size, color); 7 | } 8 | 9 | public void bark(){ 10 | 11 | System.out.println(name+" is barking"); 12 | } 13 | 14 | } -------------------------------------------------------------------------------- /src/day37_Inheritance/animalTask/Parrot.java: -------------------------------------------------------------------------------- 1 | package day37_Inheritance.animalTask; 2 | 3 | public class Parrot extends Animal { 4 | 5 | // public String parrotWingColor; 6 | 7 | public Parrot(String name, String breed, char gender, int age, String size, String color) { 8 | super(name, breed, gender, age, size, color); 9 | // this.parrotWingColor = parrotWingColor; 10 | } 11 | 12 | public void sing(){ 13 | System.out.println(name+" is singing"); 14 | } 15 | 16 | 17 | } -------------------------------------------------------------------------------- /src/day37_Inheritance/phoneTask/Nokia.java: -------------------------------------------------------------------------------- 1 | package day37_Inheritance.phoneTask; 2 | 3 | public final class Nokia extends Phone { 4 | 5 | 6 | public Nokia( String model, String size, double price, String color) { 7 | super("Nokia", model, size, price, color); 8 | } 9 | 10 | public void selfDefense(){ 11 | System.out.println("You can use "+brand+" "+model+" as self defense tool"); 12 | } 13 | 14 | } 15 | 16 | 17 | /* 18 | 1.4 Create a sub class of Phone named Nokia: 19 | Variables: 20 | brand, model, size, price, color 21 | Methods: 22 | call(long phoneNumber) 23 | text(long phoneNumber) 24 | selfDefense() 25 | toString() 26 | */ -------------------------------------------------------------------------------- /src/day37_Inheritance/phoneTask/Samsung.java: -------------------------------------------------------------------------------- 1 | package day37_Inheritance.phoneTask; 2 | 3 | public final class Samsung extends Phone { 4 | 5 | 6 | public Samsung(String model, String size, double price, String color) { 7 | super("Samsung", model, size, price, color); 8 | } 9 | 10 | public void freeze() { 11 | System.out.println(brand + " " + model + " is freezing"); 12 | } 13 | 14 | } 15 | 16 | 17 | /* 18 | Create a subclass of Phone named Samsung: 19 | Variables: 20 | brand, model, size, price, color 21 | 22 | Methods: 23 | 24 | call(long phoneNumber) 25 | text(long phoneNumber) 26 | freeze() 27 | toString() 28 | */ -------------------------------------------------------------------------------- /src/day37_Inheritance/scrumTask/BusinessAnalyst.java: -------------------------------------------------------------------------------- 1 | package day37_Inheritance.scrumTask; 2 | 3 | public class BusinessAnalyst extends Employee { 4 | 5 | 6 | public BusinessAnalyst(String name, int age, char gender, int id, double salary, String companyName) { 7 | super(name, age, gender, "Business Analyst", id, salary, companyName); 8 | } 9 | 10 | public void analyze(){ 11 | System.out.println(name+ " is analyzing the documents"); 12 | } 13 | 14 | 15 | } -------------------------------------------------------------------------------- /src/day37_Inheritance/scrumTask/Developer.java: -------------------------------------------------------------------------------- 1 | package day37_Inheritance.scrumTask; 2 | 3 | public class Developer extends Employee { 4 | 5 | 6 | public Developer(String name, int age, char gender, String jobTitle, int id, double salary, String companyName) { 7 | super(name, age, gender, jobTitle, id, salary, companyName); 8 | } 9 | 10 | public void fixBugs(){ 11 | System.out.println(jobTitle+" "+name+" is crying"); 12 | } 13 | 14 | 15 | } -------------------------------------------------------------------------------- /src/day37_Inheritance/scrumTask/ProductOwner.java: -------------------------------------------------------------------------------- 1 | package day37_Inheritance.scrumTask; 2 | 3 | public class ProductOwner extends Employee{ 4 | 5 | 6 | public ProductOwner(String name, int age, char gender, int id, double salary, String companyName) { 7 | super(name, age, gender, "Product Owner", id, salary, companyName); 8 | } 9 | 10 | 11 | 12 | } -------------------------------------------------------------------------------- /src/day37_Inheritance/scrumTask/ScrumMaster.java: -------------------------------------------------------------------------------- 1 | package day37_Inheritance.scrumTask; 2 | 3 | public class ScrumMaster extends Employee { 4 | 5 | public ScrumMaster(String name, int age, char gender, int id, double salary, String companyName) { 6 | super(name, age, gender, "Scrum Master", id, salary, companyName); 7 | } 8 | 9 | } -------------------------------------------------------------------------------- /src/day37_Inheritance/scrumTask/Tester.java: -------------------------------------------------------------------------------- 1 | package day37_Inheritance.scrumTask; 2 | 3 | public class Tester extends Employee{ //Tester IS A Employee, Tester IS A Person 4 | 5 | public Tester(String name, int age, char gender, String jobTitle, int id, double salary, String companyName) { 6 | super(name, age, gender, jobTitle, id, salary, companyName); 7 | } 8 | 9 | public void createTicket(){ 10 | System.out.println(jobTitle + " " + name + "is creating ticket"); 11 | } 12 | 13 | 14 | } -------------------------------------------------------------------------------- /src/day38_Inheritance/carTask/BMW.java: -------------------------------------------------------------------------------- 1 | package day38_Inheritance.carTask; 2 | 3 | public class BMW extends Car{ 4 | 5 | public BMW(String model, int year, double price, String color, int miles) { 6 | super("BMW", model, year, price, color, miles); 7 | } 8 | 9 | public void breaksDown(){ 10 | System.out.println(brand + " "+ model +" is breaking down"); 11 | } 12 | 13 | public void racing(){ 14 | System.out.println(brand + " "+ model +" is a racing car"); 15 | } 16 | 17 | 18 | public void start(){ 19 | System.out.println("Call mechanic to jump start "+brand+" "+model); 20 | } 21 | 22 | 23 | } 24 | 25 | /* 26 | 2. BMW: 27 | extra methods: 28 | breaksDown() 29 | racing() 30 | */ -------------------------------------------------------------------------------- /src/day38_Inheritance/carTask/ParkingLot.java: -------------------------------------------------------------------------------- 1 | package day38_Inheritance.carTask; 2 | 3 | public class ParkingLot { 4 | 5 | public static void main(String[] args) { 6 | 7 | Toyota toyota = new Toyota("Camry", 2020, 20000, "Gray", 123456); 8 | 9 | 10 | Tesla tesla = new Tesla("Model S", 2022, 94990, "Red", 0); 11 | 12 | BMW bmw = new BMW("X5", 2020, 67350, "black", 12000); 13 | 14 | 15 | 16 | toyota.start(); 17 | tesla.start(); 18 | bmw.start(); 19 | 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/day38_Inheritance/carTask/Tesla.java: -------------------------------------------------------------------------------- 1 | package day38_Inheritance.carTask; 2 | 3 | public class Tesla extends Car{ 4 | 5 | public Tesla( String model, int year, double price, String color, int miles) { 6 | super("Tesla", model, year, price, color, miles); 7 | } 8 | 9 | public void autoPilot(){ 10 | System.out.println(brand+" "+model+" in autopilot mode"); 11 | } 12 | 13 | @Override 14 | public void start() { 15 | System.out.println("Say \"Start\" to start "+brand+" "+model); 16 | } 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/day38_Inheritance/carTask/Toyota.java: -------------------------------------------------------------------------------- 1 | package day38_Inheritance.carTask; 2 | 3 | public class Toyota extends Car { 4 | 5 | public Toyota( String model, int year, double price, String color, int miles) { 6 | super("Toyota", model, year, price, color, miles); 7 | } 8 | 9 | public void reliable(){ 10 | System.out.println(brand+" "+model+" is reliable"); 11 | } 12 | 13 | 14 | public void start(){ 15 | System.out.println("Twist the key to ignition to start "+brand+" "+model); 16 | } 17 | 18 | 19 | } 20 | 21 | /* 22 | 1. Toyota: 23 | extra methods: 24 | reliable() 25 | */ -------------------------------------------------------------------------------- /src/day39_Recap/MethodOverloading.java: -------------------------------------------------------------------------------- 1 | package day39_Recap; 2 | 3 | public class MethodOverloading { 4 | 5 | private void method1(){ 6 | 7 | } 8 | 9 | private int method1(int a){ 10 | return a; 11 | } 12 | 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/day39_Recap/cydeoTask/Teacher.java: -------------------------------------------------------------------------------- 1 | package day39_Recap.cydeoTask; 2 | 3 | public class Teacher extends Employee{ 4 | 5 | public Teacher(String name, int age, char gender, int employeeID, String jobTitle, double salary) { 6 | super(name, age, gender, employeeID, jobTitle, salary); 7 | } 8 | 9 | @Override 10 | public void work() { 11 | System.out.println(getJobTitle() + " " + getName() + " is teaching"); 12 | } 13 | 14 | } 15 | 16 | /* 17 | 5. Create a sub class of Employee named Teacher 18 | 19 | Override the work method 20 | */ -------------------------------------------------------------------------------- /src/day39_Recap/cydeoTask/Tester.java: -------------------------------------------------------------------------------- 1 | package day39_Recap.cydeoTask; 2 | 3 | public class Tester extends Employee{ 4 | 5 | public Tester(String name, int age, char gender, int employeeID, String jobTitle, double salary) { 6 | super(name, age, gender, employeeID, jobTitle, salary); 7 | } 8 | 9 | public void createTicket(){ 10 | System.out.println(getJobTitle() +" "+getName()+" is creating ticket"); 11 | } 12 | 13 | @Override 14 | public void work() { 15 | System.out.println(getJobTitle()+" "+getName()+" is testing the application"); 16 | } 17 | 18 | 19 | } 20 | /* 21 | 3. Create a sub class of Employee named Tester 22 | 23 | Override the work method 24 | 25 | Extra methods: 26 | createTicket() 27 | */ -------------------------------------------------------------------------------- /src/day40_FinalKeyword/Cat.java: -------------------------------------------------------------------------------- 1 | package day40_FinalKeyword; 2 | 3 | public final class Cat extends Animal { 4 | 5 | public Cat(String name, String breed, char gender, String color, String size, int age) { 6 | super(name, breed, gender, color, size, age); 7 | } 8 | 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/day40_FinalKeyword/Dog.java: -------------------------------------------------------------------------------- 1 | package day40_FinalKeyword; 2 | 3 | public final class Dog extends Animal { 4 | 5 | 6 | public Dog(String name, String breed, char gender, String color, String size, int age) { 7 | super(name, breed, gender, color, size, age); 8 | } 9 | 10 | public void eat(){ 11 | System.out.println(getName()+" is eating dog food"); 12 | } 13 | 14 | /* 15 | public void drink(){ // final methods can not be overridden 16 | System.out.println(getName()+" is drinking beer"); 17 | } 18 | */ 19 | 20 | public void bark(){ 21 | System.out.println(getName()+" is barking"); 22 | } 23 | 24 | } 25 | 26 | 27 | // eating dog food -------------------------------------------------------------------------------- /src/day40_FinalKeyword/EncapsulationReview.java: -------------------------------------------------------------------------------- 1 | package day40_FinalKeyword; 2 | 3 | import day39_Recap.shapeTask.Circle; 4 | import day39_Recap.shapeTask.Square; 5 | 6 | public class EncapsulationReview { 7 | 8 | private Circle circle; 9 | 10 | private Square square; 11 | 12 | public Circle getCircle(){ 13 | return circle; 14 | } 15 | 16 | public void setCircle(Circle circle){ 17 | 18 | if(circle.getRadius() < 5){ 19 | return; 20 | } 21 | 22 | this.circle = circle; 23 | } 24 | 25 | 26 | public Square getSquare() { 27 | return square; 28 | } 29 | 30 | public void setSquare(Square square) { 31 | this.square = square; 32 | } 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/day40_FinalKeyword/ProtectedAccessModifier.java: -------------------------------------------------------------------------------- 1 | package day40_FinalKeyword; 2 | 3 | public class ProtectedAccessModifier { 4 | 5 | static String name1 = "Cydeo"; //default access modifier 6 | protected static String name2 = "WoodenSpoon"; // protected 7 | 8 | 9 | static void method1(){ 10 | 11 | } 12 | 13 | protected static void method2(){ 14 | 15 | } 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/day40_FinalKeyword/Zoo.java: -------------------------------------------------------------------------------- 1 | package day40_FinalKeyword; 2 | 3 | public class Zoo { 4 | 5 | public static void main(String[] args) { 6 | 7 | Dog dog = new Dog("Max", "Husky", 'M', "White", "Large", 4); 8 | 9 | System.out.println(dog.getBreed()); 10 | System.out.println(dog.getGender()); 11 | 12 | dog.drink(); 13 | 14 | 15 | 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/day41_Exceptions/FinallyBlock.java: -------------------------------------------------------------------------------- 1 | package day41_Exceptions; 2 | 3 | public class FinallyBlock { 4 | 5 | public static void main(String[] args) { 6 | 7 | int[] arr = {1,2,3}; 8 | 9 | try { 10 | System.out.println(arr[10]); 11 | System.out.println("Try Block"); 12 | }catch (RuntimeException e){ 13 | System.out.println("Catch Block"); 14 | e.printStackTrace(); 15 | System.exit(0); 16 | }finally { 17 | System.out.println("Finally Block"); 18 | } 19 | 20 | 21 | 22 | 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/day42_Exceptions/DisadvantageOfThrowsKeyword.java: -------------------------------------------------------------------------------- 1 | package day42_Exceptions; 2 | 3 | public class DisadvantageOfThrowsKeyword { 4 | 5 | 6 | public static void main(String[] args) { 7 | 8 | System.out.println("Hello"); 9 | 10 | // sleep(2.5); // throws 11 | 12 | System.out.println("Hello world"); 13 | 14 | System.out.println("-------------------------"); 15 | 16 | System.out.println("Hello"); 17 | 18 | MorningWorkOut.sleep(2.5); // try & catch 19 | 20 | System.out.println("Cydeo"); 21 | 22 | 23 | } 24 | 25 | 26 | public static void sleep(double seconds) throws InterruptedException { 27 | 28 | Thread.sleep( (long) (seconds * 1000) ); 29 | 30 | } 31 | 32 | 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/day42_Exceptions/ThrowKeyword.java: -------------------------------------------------------------------------------- 1 | package day42_Exceptions; 2 | 3 | import java.util.InputMismatchException; 4 | import java.util.Scanner; 5 | 6 | public class ThrowKeyword { 7 | 8 | public static void main(String[] args) { 9 | 10 | System.out.println("Enter your age:"); // -20 11 | int age = new Scanner(System.in).nextInt(); 12 | 13 | if(age < 0){ 14 | throw new InputMismatchException("Age can not be negative: "+age); 15 | } 16 | 17 | if(age > 21){ 18 | System.out.println("You are eligible"); 19 | }else{ 20 | throw new RuntimeException("You must be at least 21 years old"); 21 | } 22 | 23 | 24 | 25 | 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/day42_Exceptions/ThrowKeyword2.java: -------------------------------------------------------------------------------- 1 | package day42_Exceptions; 2 | 3 | import java.util.NoSuchElementException; 4 | 5 | public class ThrowKeyword2 { 6 | 7 | public static void main(String[] args) { 8 | 9 | 10 | throw new NoSuchElementException("No such Element"); 11 | // throw new InterruptedException(); 12 | 13 | 14 | // System.out.println("hello world"); 15 | 16 | // throw new Rectangle(5,7); 17 | 18 | 19 | 20 | } 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/day42_Exceptions/ThrowsKeyword.java: -------------------------------------------------------------------------------- 1 | package day42_Exceptions; 2 | 3 | public class ThrowsKeyword { 4 | 5 | public static void main(String[] args) throws InterruptedException { 6 | 7 | System.out.println("-------- Test 1------------"); 8 | 9 | System.out.println("Hello"); 10 | Thread.sleep(3000); 11 | System.out.println("Cydeo"); 12 | 13 | System.out.println("-------- Test 1 Completed------------"); 14 | 15 | 16 | System.out.println("-------- Test 2------------"); 17 | 18 | System.out.println("Hello"); 19 | Thread.sleep(3000); 20 | System.out.println("Batch 25"); 21 | 22 | System.out.println("-------- Test 2 Completed------------"); 23 | 24 | 25 | 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/day42_Exceptions/ThrowsKeyword2.java: -------------------------------------------------------------------------------- 1 | package day42_Exceptions; 2 | 3 | public class ThrowsKeyword2 { 4 | 5 | public static void main(String[] args) throws ArithmeticException { 6 | 7 | System.out.println("Test started"); 8 | 9 | System.out.println(8/0); 10 | 11 | System.out.println("Test completed"); 12 | 13 | 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/day43_Abstraction/car/Audi.java: -------------------------------------------------------------------------------- 1 | package day43_Abstraction.car; 2 | 3 | public final class Audi extends Car { 4 | 5 | 6 | public Audi( String model, String color, int year, double price) { 7 | super("Audi", model, color, year, price); 8 | } 9 | 10 | 11 | public void start() { 12 | System.out.println("Push the start button"); 13 | } 14 | 15 | public void autoPark(){ 16 | System.out.println(getBrand()+" "+getModel()+" has auto park feature"); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/day43_Abstraction/car/Honda.java: -------------------------------------------------------------------------------- 1 | package day43_Abstraction.car; 2 | 3 | public final class Honda extends Car { 4 | 5 | public Honda( String model, String color, int year, double price) { 6 | super("Honda", model, color, year, price); 7 | } 8 | 9 | 10 | public void start(){ 11 | System.out.println("Twist the key to ignition"); 12 | } 13 | 14 | 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/day43_Abstraction/car/Tesla.java: -------------------------------------------------------------------------------- 1 | package day43_Abstraction.car; 2 | 3 | public final class Tesla extends Car { 4 | 5 | 6 | public Tesla( String model, String color, int year, double price) { 7 | super("Tesla", model, color, year, price); 8 | } 9 | 10 | public void start() { 11 | System.out.println("Say \"start\""); 12 | } 13 | 14 | public void autoPilot(){ 15 | System.out.println(getBrand()+" "+getModel()+" has auto pilot feature"); 16 | } 17 | 18 | 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/day43_Abstraction/employeeTask/Developer.java: -------------------------------------------------------------------------------- 1 | package day43_Abstraction.employeeTask; 2 | 3 | public final class Developer extends Employee{ 4 | 5 | 6 | public Developer(String name, int age, char gender, int id, String jobTitle, double salary) { 7 | super(name, age, gender, id, jobTitle, salary); 8 | } 9 | 10 | @Override 11 | public void work() { 12 | System.out.println(getName()+" is developing application"); 13 | } 14 | 15 | 16 | @Override 17 | public void sleep() { 18 | System.out.println(getName()+" sleeps 6 hours"); 19 | } 20 | 21 | public void unitTest(){ 22 | System.out.println(getName()+" is unit testing"); 23 | } 24 | 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/day43_Abstraction/employeeTask/Driver.java: -------------------------------------------------------------------------------- 1 | package day43_Abstraction.employeeTask; 2 | 3 | public final class Driver extends Employee{ 4 | 5 | public Driver(String name, int age, char gender, int id, String jobTitle, double salary) { 6 | super(name, age, gender, id, jobTitle, salary); 7 | } 8 | 9 | @Override 10 | public void work() { 11 | System.out.println(getName()+" is driving"); 12 | } 13 | 14 | @Override 15 | public void sleep() { 16 | System.out.println(getName()+" sleeps 10 hours"); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/day43_Abstraction/employeeTask/Teacher.java: -------------------------------------------------------------------------------- 1 | package day43_Abstraction.employeeTask; 2 | 3 | public final class Teacher extends Employee { 4 | 5 | 6 | public Teacher(String name, int age, char gender, int id, String jobTitle, double salary) { 7 | super(name, age, gender, id, jobTitle, salary); 8 | } 9 | 10 | @Override 11 | public void work() { 12 | System.out.println(getName()+" is teaching."); 13 | } 14 | 15 | @Override 16 | public void sleep() { 17 | System.out.println(getName()+" is slepping 8 hours."); 18 | } 19 | 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/day43_Abstraction/employeeTask/Tester.java: -------------------------------------------------------------------------------- 1 | package day43_Abstraction.employeeTask; 2 | 3 | public final class Tester extends Employee { 4 | 5 | 6 | public Tester(String name, int age, char gender, int id, String jobTitle, double salary) { 7 | super(name, age, gender, id, jobTitle, salary); 8 | } 9 | 10 | @Override 11 | public void work() { 12 | System.out.println(getName()+" is testing the application"); 13 | } 14 | 15 | @Override 16 | public void sleep() { 17 | System.out.println(getName()+" sleeps 8 hours"); 18 | } 19 | 20 | public void bugReport(){ 21 | System.out.println(getName()+" is creating bug reports"); 22 | } 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/day44_Abstraction/animalTask/Cat.java: -------------------------------------------------------------------------------- 1 | package day44_Abstraction.animalTask; 2 | 3 | public final class Cat extends Animal implements Playable{ 4 | 5 | 6 | public Cat(String name, String breed, char gender, int age, String size, String color) { 7 | super(name, breed, gender, age, size, color); 8 | } 9 | 10 | @Override 11 | public void eat() { 12 | System.out.println(getName()+" is eating biryani"); 13 | } 14 | 15 | public void meow(){ 16 | System.out.println(getName() + " is Meowing"); 17 | } 18 | 19 | 20 | @Override 21 | public void play() { 22 | 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/day44_Abstraction/animalTask/Dog.java: -------------------------------------------------------------------------------- 1 | package day44_Abstraction.animalTask; 2 | 3 | public final class Dog extends Animal implements Playable{ 4 | 5 | public Dog(String name, String breed, char gender, int age, String size, String color) { 6 | super(name, breed, gender, age, size, color); 7 | } 8 | 9 | public void bark(){ 10 | System.out.println(getName()+" is barking"); 11 | } 12 | 13 | 14 | public void eat() { 15 | System.out.println(getName()+" eats Pizza"); 16 | } 17 | 18 | public void play(){ 19 | System.out.println(getName() +" is playing with ball"); 20 | } 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/day44_Abstraction/animalTask/Eagle.java: -------------------------------------------------------------------------------- 1 | package day44_Abstraction.animalTask; 2 | 3 | public final class Eagle extends Animal implements WildAnimal, Flyable{ 4 | 5 | 6 | public Eagle(String name, String breed, char gender, int age, String size, String color) { 7 | super(name, breed, gender, age, size, color); 8 | } 9 | 10 | @Override 11 | public void eat() { 12 | System.out.println(getName()+" is eating snake"); 13 | } 14 | 15 | 16 | @Override 17 | public void hunt() { 18 | System.out.println(getName()+" hunts snake"); 19 | } 20 | 21 | @Override 22 | public void fly() { 23 | System.out.println(getName()+" can fly 50km/h"); 24 | } 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/day44_Abstraction/animalTask/Flyable.java: -------------------------------------------------------------------------------- 1 | package day44_Abstraction.animalTask; 2 | 3 | public interface Flyable { 4 | 5 | boolean canFly = true; 6 | 7 | void fly(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/day44_Abstraction/animalTask/Parrot.java: -------------------------------------------------------------------------------- 1 | package day44_Abstraction.animalTask; 2 | 3 | public final class Parrot extends Animal implements Playable, Flyable { 4 | 5 | public Parrot(String name, String breed, char gender, int age, String size, String color) { 6 | super(name, breed, gender, age, size, color); 7 | } 8 | 9 | @Override 10 | public void eat() { 11 | System.out.println(getName()+" is eating chocolate"); 12 | } 13 | 14 | @Override 15 | public void play() { 16 | 17 | } 18 | 19 | 20 | @Override 21 | public void fly() { 22 | System.out.println(getName()+" can fly 20km/h"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/day44_Abstraction/animalTask/Playable.java: -------------------------------------------------------------------------------- 1 | package day44_Abstraction.animalTask; 2 | 3 | public interface Playable { 4 | 5 | boolean isFriendly = true; // static & final by default 6 | 7 | /* 8 | public static void method1(){ 9 | System.out.println(isFriendly); 10 | } 11 | */ 12 | 13 | void play(); // abstract by default 14 | 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/day44_Abstraction/animalTask/Tiger.java: -------------------------------------------------------------------------------- 1 | package day44_Abstraction.animalTask; 2 | 3 | public final class Tiger extends Animal implements WildAnimal{ 4 | 5 | public Tiger(String name, String breed, char gender, int age, String size, String color) { 6 | super(name, breed, gender, age, size, color); 7 | } 8 | 9 | @Override 10 | public void eat() { 11 | System.out.println(getName()+" is eating deer"); 12 | } 13 | 14 | @Override 15 | public void hunt() { 16 | System.out.println(getName()+" hunts deer"); 17 | } 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/day44_Abstraction/animalTask/WildAnimal.java: -------------------------------------------------------------------------------- 1 | package day44_Abstraction.animalTask; 2 | 3 | public interface WildAnimal { 4 | 5 | boolean isWild = true; // static & final by default 6 | 7 | void hunt(); // abstract by default 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/day45_Abstraction/Extends_vs_Implements.java: -------------------------------------------------------------------------------- 1 | package day45_Abstraction; 2 | 3 | //extends: 4 | class C{ 5 | 6 | } 7 | 8 | class A{ 9 | 10 | } 11 | 12 | class B extends A{ 13 | 14 | } 15 | 16 | 17 | interface Z{ 18 | 19 | } 20 | 21 | interface X{ 22 | 23 | } 24 | 25 | interface Y extends X, Z{ 26 | 27 | } 28 | 29 | 30 | //implements 31 | 32 | class D implements X,Y,Z{ 33 | 34 | } 35 | 36 | 37 | public class Extends_vs_Implements extends A implements X, Y, Z{ 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/day45_Abstraction/shape/Cube.java: -------------------------------------------------------------------------------- 1 | package day45_Abstraction.shape; 2 | 3 | public class Cube extends Shape implements Volume{ 4 | 5 | 6 | public Cube(String name) { 7 | super(name); 8 | } 9 | 10 | @Override 11 | public double area() { 12 | return 0; 13 | } 14 | 15 | @Override 16 | public double perimeter() { 17 | return 0; 18 | } 19 | 20 | 21 | @Override 22 | public double volume() { 23 | return 0; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/day45_Abstraction/shape/Cylinder.java: -------------------------------------------------------------------------------- 1 | package day45_Abstraction.shape; 2 | 3 | public class Cylinder extends Shape implements Volume{ 4 | 5 | 6 | 7 | public Cylinder(String name) { 8 | super(name); 9 | } 10 | 11 | @Override 12 | public double area() { 13 | return 0; 14 | } 15 | 16 | @Override 17 | public double perimeter() { 18 | return 0; 19 | } 20 | 21 | 22 | @Override 23 | public double volume() { 24 | return 0; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/day45_Abstraction/shape/Pentagon.java: -------------------------------------------------------------------------------- 1 | package day45_Abstraction.shape; 2 | 3 | public class Pentagon extends Shape{ 4 | public Pentagon(String name) { 5 | super(name); 6 | } 7 | 8 | @Override 9 | public double area() { 10 | return 0; 11 | } 12 | 13 | @Override 14 | public double perimeter() { 15 | return 0; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/day45_Abstraction/shape/Rectangle.java: -------------------------------------------------------------------------------- 1 | package day45_Abstraction.shape; 2 | 3 | public class Rectangle extends Shape { 4 | public Rectangle(String name) { 5 | super(name); 6 | } 7 | 8 | @Override 9 | public double area() { 10 | return 0; 11 | } 12 | 13 | @Override 14 | public double perimeter() { 15 | return 0; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/day45_Abstraction/shape/Shape.java: -------------------------------------------------------------------------------- 1 | package day45_Abstraction.shape; 2 | 3 | public abstract class Shape { 4 | 5 | private final String name; 6 | 7 | public Shape(String name) { 8 | this.name = name; 9 | } 10 | 11 | public String getName() { 12 | return name; 13 | } 14 | 15 | public abstract double area(); 16 | 17 | public abstract double perimeter(); 18 | 19 | @Override 20 | public String toString() { 21 | return 22 | "name='" + name + '\'' + 23 | ", area='" + area() + '\'' + 24 | ", perimeter='" + perimeter() + '\''; 25 | 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/day45_Abstraction/shape/Sphere.java: -------------------------------------------------------------------------------- 1 | package day45_Abstraction.shape; 2 | 3 | public class Sphere extends Shape implements Volume{ 4 | 5 | 6 | public Sphere(String name) { 7 | super(name); 8 | } 9 | 10 | @Override 11 | public double area() { 12 | return 0; 13 | } 14 | 15 | @Override 16 | public double perimeter() { 17 | return 0; 18 | } 19 | 20 | @Override 21 | public double volume() { 22 | return 0; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/day45_Abstraction/shape/Triangle.java: -------------------------------------------------------------------------------- 1 | package day45_Abstraction.shape; 2 | 3 | public class Triangle extends Shape{ 4 | public Triangle(String name) { 5 | super(name); 6 | } 7 | 8 | @Override 9 | public double area() { 10 | return 0; 11 | } 12 | 13 | @Override 14 | public double perimeter() { 15 | return 0; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/day45_Abstraction/shape/Volume.java: -------------------------------------------------------------------------------- 1 | package day45_Abstraction.shape; 2 | 3 | public interface Volume { 4 | 5 | boolean hasVolume= true; 6 | 7 | double volume(); 8 | 9 | /* 10 | default void drink(){ 11 | System.out.println("Drinks water"); 12 | } 13 | */ 14 | 15 | } 16 | 17 | /* 18 | abstract class QQ{ 19 | 20 | } 21 | 22 | interface R{ 23 | 24 | } 25 | */ 26 | 27 | -------------------------------------------------------------------------------- /src/day46_Polymorphism/day46 class notes.txt: -------------------------------------------------------------------------------- 1 | Java Day46 2 | Topics: OOP Polymorphism Intro 3 | 4 | package name: day46_Polymorphism 5 | 6 | 7 | 8 | Abstraction short quiz due by 11:40 am 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/day49_Collections/day49 class notes.txt: -------------------------------------------------------------------------------- 1 | Java Day49 2 | Topic: Collections Continue 3 | Set 4 | Queue 5 | 6 | Package name: day49_Collections 7 | 8 | 9 | Collection (I): 10 | 11 | List (I): Has Index, Allows Duplicates 12 | 13 | 14 | Set (I): Does not have index, does not allow duplicates 15 | 16 | HashSet (C): order is random 17 | 18 | LinkedHashSet (C): keeps the insertion order 19 | 20 | TreeSet (C): keeps sorted order, does not accept null 21 | 22 | 23 | Queue(I) -------------------------------------------------------------------------------- /src/day50_Collections/RemoveEven.java: -------------------------------------------------------------------------------- 1 | package day50_Collections; 2 | 3 | import java.util.Arrays; 4 | import java.util.Iterator; 5 | import java.util.LinkedHashSet; 6 | import java.util.Set; 7 | 8 | public class RemoveEven { 9 | 10 | public static void main(String[] args) { 11 | 12 | Set set = new LinkedHashSet<>(Arrays.asList(1,2,3,4,5,6,100, 90, 80, 75, 45, 35, 25, 15)); 13 | 14 | // set.removeIf( p -> p %2 ==0); 15 | 16 | Iterator it= set.iterator(); 17 | while(it.hasNext()){ 18 | if(it.next() %2 ==0){ 19 | it.remove(); 20 | } 21 | } 22 | 23 | System.out.println(set); 24 | 25 | 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/day51_Map/Browser.java: -------------------------------------------------------------------------------- 1 | package day51_Map; 2 | 3 | public enum Browser { 4 | 5 | CHROME, 6 | FIREFOX, 7 | OPERA, 8 | EDGE, 9 | SAFARI 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/day51_Map/Level.java: -------------------------------------------------------------------------------- 1 | package day51_Map; 2 | 3 | public enum Level { 4 | 5 | EASY, 6 | MEDIUM, 7 | HARD, 8 | ADVANCED, 9 | EXPERT, 10 | CHUCK_NORRIS 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/day51_Map/Season.java: -------------------------------------------------------------------------------- 1 | package day51_Map; 2 | 3 | public enum Season { 4 | 5 | SUMMER, 6 | WINTER, 7 | SPRING, 8 | FALL 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/day52_Map_FunctionalInterface/MyFirstFunctionalInterface.java: -------------------------------------------------------------------------------- 1 | package day52_Map_FunctionalInterface; 2 | 3 | @FunctionalInterface 4 | public interface MyFirstFunctionalInterface { 5 | 6 | void apply(int n); 7 | 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/day52_Map_FunctionalInterface/MySecondFunctionalInterface.java: -------------------------------------------------------------------------------- 1 | package day52_Map_FunctionalInterface; 2 | 3 | @FunctionalInterface 4 | public interface MySecondFunctionalInterface { 5 | 6 | void test(T data); 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/day52_Map_FunctionalInterface/Test2.java: -------------------------------------------------------------------------------- 1 | package day52_Map_FunctionalInterface; 2 | 3 | public class Test2 { 4 | 5 | public static void main(String[] args) { 6 | 7 | MySecondFunctionalInterface printEach = s -> { 8 | for (String each : s.split("")) { 9 | System.out.println(each); 10 | } 11 | }; 12 | 13 | printEach.test("Wooden Spoon"); 14 | 15 | 16 | MySecondFunctionalInterface cube = n -> System.out.println(n*n*n); 17 | 18 | cube.test(5); 19 | 20 | 21 | 22 | 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/day53_FunctionalInterface/LambdaExpressions.java: -------------------------------------------------------------------------------- 1 | package day53_FunctionalInterface; 2 | 3 | public class LambdaExpressions { 4 | 5 | public static void main(String[] args) { 6 | 7 | MyThirdFunctionalInterface stringReverse = 8 | (s) -> { 9 | String reverse = new StringBuilder(s).reverse().toString(); 10 | return reverse; 11 | }; 12 | 13 | String result = stringReverse.method("Wooden Spoon"); 14 | 15 | System.out.println(result); 16 | 17 | //create a function that can return the cube of an integer 18 | 19 | 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/day53_FunctionalInterface/MyThirdFunctionalInterface.java: -------------------------------------------------------------------------------- 1 | package day53_FunctionalInterface; 2 | 3 | @FunctionalInterface 4 | public interface MyThirdFunctionalInterface { 5 | 6 | T method(T data); 7 | 8 | } 9 | 10 | /* 11 | 2. Create a Functional interface named MyThirdFunctionalInterface that has an abstract method takes 12 | one argument of any type and returns the same type 13 | */ -------------------------------------------------------------------------------- /taskSolutions/day02_PrintStatements/Rectangle.java: -------------------------------------------------------------------------------- 1 | package day02_PrintStatements; 2 | 3 | public class Rectangle { 4 | 5 | public static void main(String[] args) { 6 | 7 | System.out.println("* * * * * *"); 8 | System.out.println("* *"); 9 | System.out.println("* *"); 10 | System.out.println("* *"); 11 | System.out.println("* *"); 12 | System.out.println("* *"); 13 | System.out.println("* * * * * *"); 14 | 15 | } 16 | 17 | } 18 | /* 19 | 1. Create a class called Rectangle, and print the following shape of 20 | rectangle 21 | * * * * * * 22 | * * 23 | * * 24 | * * 25 | * * 26 | * * 27 | * * * * * * 28 | */ -------------------------------------------------------------------------------- /taskSolutions/day05_Concatenations/FlightTicket.java: -------------------------------------------------------------------------------- 1 | package day05_Concatenations; 2 | 3 | public class FlightTicket { 4 | 5 | public static void main(String[] args) { 6 | 7 | String from = "Las Vegas", 8 | to = "McLean"; 9 | 10 | double ticketPrice = 425.5; 11 | 12 | System.out.println("From " + from + " to " + to + " is $" + ticketPrice); 13 | 14 | 15 | } 16 | 17 | } 18 | 19 | /* 20 | create a class named FlightTicket, and declare the following 21 | variables: 22 | 1. from 23 | 2. to 24 | 3. ticketPrice 25 | use concatenation to display the full info of the ticket 26 | 27 | ex: 28 | From Las Vegas to McLean is $425.5 29 | */ -------------------------------------------------------------------------------- /taskSolutions/day08_SingleIf/EligibleToBuyCigarettes.java: -------------------------------------------------------------------------------- 1 | package day08_SingleIf; 2 | 3 | public class EligibleToBuyCigarettes { 4 | 5 | public static void main(String[] args) { 6 | 7 | byte age = 21; 8 | 9 | boolean eligible = age >= 21; 10 | 11 | if(eligible){ 12 | System.out.println("Eligible to buy "); 13 | } 14 | 15 | if(!eligible){ 16 | System.out.println("Not eligible to buy "); 17 | } 18 | 19 | } 20 | 21 | } 22 | /* 23 | 1. Given a number (byte) age, write a program that can check if the 24 | person is eligible to buy Cigarettes 25 | */ 26 | -------------------------------------------------------------------------------- /taskSolutions/day10_NestedIf_Ternaries/AgeGroups.java: -------------------------------------------------------------------------------- 1 | package day10_NestedIf_Ternaries; 2 | 3 | public class AgeGroups { 4 | 5 | public static void main(String[] args) { 6 | 7 | int age = 75; 8 | 9 | boolean valid = age >= 0 && age <= 150; 10 | 11 | String result = ""; 12 | 13 | if(valid){ 14 | 15 | if(age >= 55){ 16 | result = "Senior"; 17 | }else if(age >= 21){ 18 | result = "Adult"; 19 | }else{ 20 | result = "Teenager"; 21 | } 22 | 23 | }else{ 24 | result = "Invalid"; 25 | } 26 | 27 | System.out.println(result); 28 | 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /taskSolutions/day14_String/EndsWithLY.java: -------------------------------------------------------------------------------- 1 | package day14_String; 2 | 3 | import java.util.Scanner; 4 | 5 | public class EndsWithLY { 6 | 7 | public static void main(String[] args) { 8 | 9 | Scanner scan = new Scanner(System.in); 10 | 11 | System.out.println("Enter a word:"); 12 | String word = scan.next(); 13 | String lastTwoChars = word.substring( word.length()-2 ); 14 | 15 | if(lastTwoChars.equals("ly")){ 16 | System.out.println("really???"); 17 | }else{ 18 | System.out.println("Never mind"); 19 | } 20 | 21 | scan.close(); 22 | 23 | } 24 | 25 | } 26 | /* 27 | 2. ask the user to enter a word. if the word ends with "ly", print "really???" , 28 | otherwise, print "never mind" 29 | 30 | */ -------------------------------------------------------------------------------- /taskSolutions/day15_ForLoop/Palindrome.java: -------------------------------------------------------------------------------- 1 | package day15_ForLoop; 2 | 3 | public class Palindrome { 4 | 5 | public static void main(String[] args) { 6 | 7 | String str = "Java"; 8 | 9 | String result = ""; 10 | 11 | for (int i = str.length()-1; i >= 0 ; i--) { 12 | result += str.charAt(i); 13 | } 14 | 15 | boolean isPalindrome = str.equalsIgnoreCase(result); 16 | 17 | System.out.println(isPalindrome); 18 | 19 | } 20 | 21 | } 22 | /* 23 | 8. Write a program that can check if the given String is palindrome 24 | 25 | Ex: 26 | input: 27 | Level 28 | 29 | output: 30 | true 31 | 32 | 33 | input: 34 | Anna 35 | 36 | output: 37 | true 38 | 39 | */ 40 | -------------------------------------------------------------------------------- /taskSolutions/day15_ForLoop/StringReverse.java: -------------------------------------------------------------------------------- 1 | package day15_ForLoop; 2 | 3 | public class StringReverse { 4 | 5 | public static void main(String[] args) { 6 | 7 | String str = "Java"; 8 | 9 | String result = ""; 10 | 11 | for (int i = str.length()-1; i >= 0 ; i--) { 12 | result += str.charAt(i); 13 | } 14 | 15 | System.out.println(result); 16 | 17 | } 18 | 19 | } 20 | /* 21 | 7. Write a program that can reverse any given string 22 | 23 | Ex: 24 | input: 25 | Wooden Spoon 26 | 27 | output: 28 | noopS nedooW 29 | */ -------------------------------------------------------------------------------- /taskSolutions/day15_ForLoop/SumOfEvenNumbers.java: -------------------------------------------------------------------------------- 1 | package day15_ForLoop; 2 | 3 | public class SumOfEvenNumbers { 4 | 5 | public static void main(String[] args) { 6 | 7 | int sum = 0; 8 | 9 | for(int i=0; i <= 100; i++){ 10 | if(i%2==0){ 11 | sum += i; 12 | } 13 | } 14 | 15 | System.out.println("sum = " + sum); 16 | 17 | } 18 | 19 | } 20 | /* 21 | 1. Write a program that can return the sum of even numbers between 1 and 100 22 | */ 23 | -------------------------------------------------------------------------------- /taskSolutions/day15_ForLoop/SumOfOddNumbers.java: -------------------------------------------------------------------------------- 1 | package day15_ForLoop; 2 | 3 | public class SumOfOddNumbers { 4 | 5 | public static void main(String[] args) { 6 | 7 | int sum = 0; 8 | 9 | for(int i=0; i <= 100; i++){ 10 | if(i%2!=0){ 11 | sum += i; 12 | } 13 | } 14 | 15 | System.out.println("sum = " + sum); 16 | 17 | } 18 | 19 | } 20 | /* 21 | 2. Write a program that can return the sum of odd numbers between 1 and 100 22 | */ 23 | -------------------------------------------------------------------------------- /taskSolutions/day17_While_DoWhileLoops/DivideTwoNumbers.java: -------------------------------------------------------------------------------- 1 | package day17_While_DoWhileLoops; 2 | 3 | public class DivideTwoNumbers { 4 | 5 | public static void main(String[] args) { 6 | int a = 50; 7 | int b = 9; 8 | 9 | int count = 0; 10 | 11 | while (a >= b) { 12 | a -= b; 13 | count++; 14 | } 15 | 16 | System.out.println(count+" with a remainder of "+a); 17 | 18 | 19 | } 20 | 21 | } 22 | /* 23 | 1. Write a program that can divide two positive numbers without using / (division) and * (multiplication) operators. 24 | 25 | */ -------------------------------------------------------------------------------- /taskSolutions/day17_While_DoWhileLoops/SumOfNumbers.java: -------------------------------------------------------------------------------- 1 | package day17_While_DoWhileLoops; 2 | 3 | import java.util.Scanner; 4 | 5 | public class SumOfNumbers { 6 | 7 | public static void main(String[] args) { 8 | Scanner scan = new Scanner(System.in); 9 | 10 | int sum = 0; 11 | 12 | while(true){ 13 | System.out.println("Enter a number"); 14 | int num = scan.nextInt(); 15 | if( num < 0){ 16 | break; 17 | } 18 | sum += num; 19 | } 20 | 21 | 22 | System.out.println(sum); 23 | 24 | scan.close(); 25 | 26 | } 27 | 28 | } 29 | /* 30 | 2. Write a program that calculates the sum of numbers entered by the user until user enters a negative number. 31 | 32 | */ -------------------------------------------------------------------------------- /taskSolutions/day20_Arrays/CommonElements.java: -------------------------------------------------------------------------------- 1 | package day20_Arrays; 2 | 3 | public class CommonElements { 4 | 5 | public static void main(String[] args) { 6 | 7 | int[] arr1 = {1,2,3,4,5}; 8 | int[] arr2 = {4,5,6,7,8}; 9 | 10 | for (int i = 0; i < arr1.length; i++) { 11 | 12 | for (int j = 0; j < arr2.length; j++) { 13 | if(arr1[i] == arr2[j]){ 14 | System.out.println(arr1[i]); 15 | } 16 | } 17 | 18 | } 19 | 20 | 21 | } 22 | 23 | } 24 | /* 25 | 7. Write a program that can print out the common elements from two integer array 26 | Ex: 27 | arr1: {1,2,3,4,5} 28 | arr2: {4,5,6,7,8} 29 | 30 | output: 31 | 4 5 32 | 33 | */ -------------------------------------------------------------------------------- /taskSolutions/day20_Arrays/Reverse.java: -------------------------------------------------------------------------------- 1 | package day20_Arrays; 2 | 3 | import java.util.Arrays; 4 | 5 | public class Reverse { 6 | 7 | public static void main(String[] args) { 8 | 9 | int[] array = {1,2,3,4,5}; 10 | 11 | int[] reversedArray = new int[array.length]; 12 | 13 | for(int i = array.length-1, j=0; i >= 0 ; i--, j++){ 14 | reversedArray[j] = array[i]; 15 | } 16 | 17 | System.out.println( Arrays.toString(reversedArray) ); 18 | 19 | } 20 | 21 | } 22 | /* 23 | 5. Write a program that can reverse an array of integers and returns it as new array 24 | ex: 25 | array = {1,2,3,4,5}; 26 | 27 | output: 28 | reversedArray = {5,4,3,2,1}; 29 | 30 | */ -------------------------------------------------------------------------------- /taskSolutions/day21_ForEachLoop/SortingArrayInDescendingOrder.java: -------------------------------------------------------------------------------- 1 | package day21_ForEachLoop; 2 | 3 | import java.util.Arrays; 4 | 5 | public class SortingArrayInDescendingOrder { 6 | 7 | public static void main(String[] args){ 8 | 9 | int[] arr = {1,2,3,4,5,6,7,8,9}; 10 | int[] result = new int[arr.length]; 11 | 12 | for (int i = arr.length-1, j =0; i >=0 ; i--) { 13 | result[j] = arr[i]; 14 | } 15 | 16 | System.out.println(Arrays.toString(result)); 17 | 18 | } 19 | 20 | 21 | } 22 | /* 23 | 1. Write a program that sort the array of integer in descending order 24 | */ -------------------------------------------------------------------------------- /taskSolutions/day23_CustomMethods_Void/Anagram.java: -------------------------------------------------------------------------------- 1 | package day23_CustomMethods_Void; 2 | 3 | import java.util.Arrays; 4 | 5 | public class Anagram { 6 | 7 | public static void anagram(String str1, String str2){ 8 | char[] ch1 = str1.toCharArray(); 9 | char[] ch2 = str2.toCharArray(); 10 | Arrays.sort(ch1); 11 | Arrays.sort(ch2); 12 | 13 | if(Arrays.equals(ch1, ch2)){ 14 | System.out.println("Anagram"); 15 | }else{ 16 | System.out.println("Not anagram"); 17 | } 18 | 19 | } 20 | 21 | 22 | } 23 | /* 24 | 25 | 16. create a method that can check if two strings are anagram 26 | ex: 27 | anagram("silent", "listen") 28 | 29 | 30 | output: 31 | silent and listen are anagram 32 | 33 | 34 | */ -------------------------------------------------------------------------------- /taskSolutions/day23_CustomMethods_Void/BuyAlcohol.java: -------------------------------------------------------------------------------- 1 | package day23_CustomMethods_Void; 2 | 3 | public class BuyAlcohol { 4 | 5 | public static void eligible(int age){ 6 | 7 | if(age >= 21){ 8 | System.out.println("You are eligible"); 9 | }else{ 10 | System.out.println("You are not eligible"); 11 | } 12 | 13 | } 14 | 15 | 16 | } 17 | /* 18 | 3. create a method that can check if a person is eligible to buy alcohol 19 | */ -------------------------------------------------------------------------------- /taskSolutions/day23_CustomMethods_Void/CalculateCircle.java: -------------------------------------------------------------------------------- 1 | package day23_CustomMethods_Void; 2 | 3 | public class CalculateCircle { 4 | 5 | public static void areaOfCircle(double radius){ 6 | double area = radius * radius * 3.14; 7 | System.out.println("area = " + area); 8 | } 9 | 10 | 11 | } 12 | /* 13 | 6. create a method that can calculate the area of a circle 14 | */ -------------------------------------------------------------------------------- /taskSolutions/day23_CustomMethods_Void/CalculateGrade.java: -------------------------------------------------------------------------------- 1 | package day23_CustomMethods_Void; 2 | 3 | public class CalculateGrade { 4 | 5 | public static void grade(int score){ 6 | 7 | String grade = "Invalid"; 8 | 9 | if(score >=0 && score<= 100){ 10 | grade = (score >= 90)?"A" :(score >= 80)?"B" :(score >= 70)?"C" :(score >= 60)?"D" : "E"; 11 | } 12 | 13 | System.out.println("grade = " + grade); 14 | 15 | } 16 | 17 | } 18 | /* 19 | 5. create a method that can calculate the grade of the student based on the score 20 | 21 | */ -------------------------------------------------------------------------------- /taskSolutions/day23_CustomMethods_Void/CalculateSquare.java: -------------------------------------------------------------------------------- 1 | package day23_CustomMethods_Void; 2 | 3 | public class CalculateSquare { 4 | 5 | public static void areaOfSquare(double side){ 6 | double area = side * side; 7 | System.out.println("area = " + area); 8 | } 9 | 10 | 11 | } 12 | /* 13 | 7. create a method that can calculate the area of a square 14 | 15 | */ -------------------------------------------------------------------------------- /taskSolutions/day23_CustomMethods_Void/ConvertDollarToEuro.java: -------------------------------------------------------------------------------- 1 | package day23_CustomMethods_Void; 2 | 3 | public class ConvertDollarToEuro { 4 | 5 | public static void dollarToEuro(double dollarAmount){ 6 | double euro = dollarAmount * 1.13; 7 | System.out.println(dollarAmount+" dollar equal to "+euro+" euro"); 8 | } 9 | 10 | 11 | } 12 | /* 13 | 8. create a method that can convert dollar to euro 14 | 15 | */ -------------------------------------------------------------------------------- /taskSolutions/day23_CustomMethods_Void/ConvertDollarToLira.java: -------------------------------------------------------------------------------- 1 | package day23_CustomMethods_Void; 2 | 3 | public class ConvertDollarToLira { 4 | 5 | public static void dollarToLira(double dollarAmount){ 6 | double lira = dollarAmount * 13.85; 7 | System.out.println(dollarAmount+" dollar equal to "+lira+" lira"); 8 | } 9 | 10 | } 11 | 12 | /* 13 | 9. create a method that can can convert dollar to lira 14 | */ -------------------------------------------------------------------------------- /taskSolutions/day23_CustomMethods_Void/ConvertKgToLb.java: -------------------------------------------------------------------------------- 1 | package day23_CustomMethods_Void; 2 | 3 | public class ConvertKgToLb { 4 | 5 | public void kgToLb(double kg){ 6 | 7 | double lb = kg * 2.205; 8 | System.out.println(kg+" kg equal to "+lb+" pounds"); 9 | 10 | } 11 | 12 | } 13 | 14 | /* 15 | 10. create a method that can convert kg to lb 16 | */ -------------------------------------------------------------------------------- /taskSolutions/day23_CustomMethods_Void/EachCharacter.java: -------------------------------------------------------------------------------- 1 | package day23_CustomMethods_Void; 2 | 3 | public class EachCharacter { 4 | 5 | public static void eachCharacter(String str){ 6 | 7 | for (int i = 0; i < str.length(); i++) { 8 | System.out.println(str.charAt(i)); 9 | } 10 | 11 | } 12 | 13 | 14 | } 15 | /* 16 | 12. create a method named printEachChar that can print each characters of a string 17 | 18 | */ -------------------------------------------------------------------------------- /taskSolutions/day23_CustomMethods_Void/EachElement.java: -------------------------------------------------------------------------------- 1 | package day23_CustomMethods_Void; 2 | 3 | public class EachElement { 4 | 5 | public static void eachElement(int[] numbers) { 6 | 7 | for (int number : numbers) { 8 | System.out.println(number); 9 | } 10 | 11 | } 12 | 13 | 14 | } 15 | /* 16 | 13. create a method named printEachElement that can print each elements of an integer array 17 | 18 | */ -------------------------------------------------------------------------------- /taskSolutions/day23_CustomMethods_Void/EligibleToVote.java: -------------------------------------------------------------------------------- 1 | package day23_CustomMethods_Void; 2 | 3 | public class EligibleToVote { 4 | 5 | public static void eligibleToVote(int age, String citizen){ 6 | 7 | if (age >= 18 && citizen.equalsIgnoreCase("usa")){ 8 | System.out.println("You are eligible to vote"); 9 | }else{ 10 | System.out.println("You are not eligible to vote"); 11 | } 12 | 13 | } 14 | 15 | 16 | } 17 | /* 18 | 19 | 4. create a method that can check if a person is eligible to vote 20 | Ex: 21 | eligibleToVote(19, "USA"); 22 | 23 | output: 24 | You are not eligible to vote! 25 | 26 | 27 | */ -------------------------------------------------------------------------------- /taskSolutions/day23_CustomMethods_Void/NameFormat.java: -------------------------------------------------------------------------------- 1 | package day23_CustomMethods_Void; 2 | 3 | public class NameFormat { 4 | 5 | public static void fullName(String firstName, String lastName){ 6 | 7 | firstName = firstName.substring(0,1).toUpperCase() + firstName.substring(1).toLowerCase(); 8 | lastName = lastName.substring(0,1).toUpperCase() + lastName.substring(1).toLowerCase(); 9 | String fullName = firstName+" "+lastName; 10 | System.out.println("fullName = " + fullName); 11 | 12 | } 13 | 14 | 15 | } 16 | /* 17 | 15. write a method that can print out the full name of a person in regular format 18 | ex: 19 | fullName("cYdEo", "SCHOOL"); 20 | 21 | output: 22 | "Cydeo School" 23 | 24 | */ -------------------------------------------------------------------------------- /taskSolutions/day23_CustomMethods_Void/PositiveNegativeZero.java: -------------------------------------------------------------------------------- 1 | package day23_CustomMethods_Void; 2 | 3 | public class PositiveNegativeZero { 4 | 5 | public static void posNegZero(int number){ 6 | 7 | String result = (number>0)? "Positive" :(number<0)?"Negative" : "Zero"; 8 | System.out.println(result); 9 | 10 | } 11 | 12 | } 13 | /* 14 | 11. create a method that can if the given integer is positive, negative or zero 15 | 16 | */ -------------------------------------------------------------------------------- /taskSolutions/day23_CustomMethods_Void/PrintEvenNumbers1To100.java: -------------------------------------------------------------------------------- 1 | package day23_CustomMethods_Void; 2 | 3 | public class PrintEvenNumbers1To100 { 4 | 5 | public static void printEvenNumbers(){ 6 | for (int i = 1; i < 100 ; i++) { 7 | if(i%2 == 0){ 8 | System.out.print(i+" "); 9 | } 10 | } 11 | 12 | System.out.println(); 13 | } 14 | 15 | } 16 | /* 17 | 2. create a method that can print even numbers between 1~100 in a same line separated by space 18 | */ -------------------------------------------------------------------------------- /taskSolutions/day23_CustomMethods_Void/PrintOddNumbers1To100.java: -------------------------------------------------------------------------------- 1 | package day23_CustomMethods_Void; 2 | 3 | public class PrintOddNumbers1To100 { 4 | 5 | public static void printOddNumbers(){ 6 | for (int i = 1; i < 100 ; i++) { 7 | if(i%2!= 0){ 8 | System.out.print(i+" "); 9 | } 10 | } 11 | 12 | System.out.println(); 13 | } 14 | 15 | } 16 | /* 17 | 1. create a method that can print odd numbers between 1~100 in a same line separated by space 18 | */ -------------------------------------------------------------------------------- /taskSolutions/day24_CustomMethods_Return/AddElement.java: -------------------------------------------------------------------------------- 1 | package day24_CustomMethods_Return; 2 | 3 | public class AddElement { 4 | 5 | public static int[] addElement(int[] array, int element){ 6 | int[] result = new int[array.length + 1]; 7 | 8 | int i =0; 9 | for (int each : array) { 10 | result[i++] = each; 11 | } 12 | 13 | result[i] = element; 14 | 15 | return result; 16 | } 17 | 18 | 19 | } 20 | /* 21 | 6. create a method named addElement that takes one integer array and one integer, the method can add the Integer number after the last index of the integer array and returns the new array 22 | 23 | Ex: 24 | arr ={1,2,3}; 25 | num = 4; 26 | 27 | addElement(arr, num) ==> {1,2,3,4} 28 | */ -------------------------------------------------------------------------------- /taskSolutions/day24_CustomMethods_Return/Contains.java: -------------------------------------------------------------------------------- 1 | package day24_CustomMethods_Return; 2 | 3 | public class Contains { 4 | 5 | public static boolean contains(int[] array, int element){ 6 | 7 | boolean result = false; 8 | 9 | for (int each : array) { 10 | if(each == element){ 11 | result = true; 12 | } 13 | } 14 | 15 | return result; 16 | } 17 | 18 | } 19 | /* 20 | 9. Create a method named contains that passes one integer array and one integer parameters, the method returns true if the given integer is contained in the given array, otherwise returns false 21 | 22 | Ex: 23 | arr = {1,2,3,4,5,6,7}; 24 | num = 10; 25 | 26 | contains(arr, num) ===> false 27 | 28 | */ -------------------------------------------------------------------------------- /taskSolutions/day24_CustomMethods_Return/FrequencyOfElement.java: -------------------------------------------------------------------------------- 1 | package day24_CustomMethods_Return; 2 | 3 | public class FrequencyOfElement { 4 | 5 | public static int frequencyOfElement(int[] array, int element){ 6 | 7 | int count = 0; 8 | for (int each : array) { 9 | if(each == element){ 10 | count++; 11 | } 12 | } 13 | 14 | return count; 15 | } 16 | 17 | 18 | } 19 | /* 20 | 5. create method that accepts one integer array and one integer number and returns the frequency of the number 21 | 22 | Ex: 23 | int[] array ={1,1,1,1,1,2,2}; 24 | 25 | frequency(array, 1) ==> 5 26 | 27 | 28 | */ -------------------------------------------------------------------------------- /taskSolutions/day24_CustomMethods_Return/Merge.java: -------------------------------------------------------------------------------- 1 | package day24_CustomMethods_Return; 2 | 3 | public class Merge { 4 | 5 | public static int[] merge(int[] arr1, int[] arr2){ 6 | int[] result = new int[arr1.length + arr2.length]; 7 | int i = 0; 8 | 9 | for (int each : arr1) { 10 | result[i++] = each; 11 | } 12 | 13 | for (int each : arr2) { 14 | result[i++] = each; 15 | } 16 | 17 | return result; 18 | } 19 | 20 | } 21 | /* 22 | 23 | 7. Create a method named merge that passes two integer array parameters, the method can merge two integer arrays and return the new array 24 | 25 | Ex: 26 | arr1 = {1,2,3} 27 | arr2 = {4,5,6} 28 | 29 | merge(arr1, arr2) ====> {1,2,3,4,5,6} 30 | */ -------------------------------------------------------------------------------- /taskSolutions/day24_CustomMethods_Return/Palindrome.java: -------------------------------------------------------------------------------- 1 | package day24_CustomMethods_Return; 2 | 3 | public class Palindrome { 4 | 5 | 6 | public static boolean isPalindrome(String str){ 7 | return Reverse.reverse(str).equalsIgnoreCase(str); 8 | } 9 | 10 | 11 | } 12 | /* 13 | 4. By using the reverse method above to create another method named isPalindrome that passes a String parameter, the method returns true if the string is palindrome, otherwise returns false 14 | 15 | Ex: 16 | str = "Level" 17 | 18 | isPalindrome(str) ===> true 19 | 20 | */ -------------------------------------------------------------------------------- /taskSolutions/day24_CustomMethods_Return/Reverse.java: -------------------------------------------------------------------------------- 1 | package day24_CustomMethods_Return; 2 | 3 | public class Reverse { 4 | 5 | public static String reverse(String str){ 6 | String result = ""; 7 | 8 | for (int i = str.length()-1; i >= 0 ; i--) { 9 | result += str.charAt(i); 10 | } 11 | 12 | return result; 13 | } 14 | 15 | 16 | } 17 | /* 18 | 3. create a method named reverse that passes one string parameter, the method can return the reversed string 19 | 20 | Ex: 21 | str = "Java"; 22 | 23 | reverse(str) ==> avaJ 24 | */ -------------------------------------------------------------------------------- /taskSolutions/day24_CustomMethods_Return/Reverse_Array.java: -------------------------------------------------------------------------------- 1 | package day24_CustomMethods_Return; 2 | 3 | public class Reverse_Array { 4 | 5 | public static int[] reverse(int[] array){ 6 | 7 | int[] result = new int[array.length]; 8 | 9 | int j = 0; 10 | for (int i = array.length - 1; i >= 0; i--) { 11 | result[j++] = array[i]; 12 | } 13 | 14 | return result; 15 | } 16 | 17 | } 18 | /* 19 | 8. Create method named reverse that passes an integer array parameter, the method can return the reversed array 20 | 21 | Ex: 22 | arr = {10, 20, 30, 40}; 23 | 24 | reverse(arr) ==> {40, 30, 20, 10} 25 | 26 | 27 | */ -------------------------------------------------------------------------------- /taskSolutions/day24_CustomMethods_Return/isAnagram.java: -------------------------------------------------------------------------------- 1 | package day24_CustomMethods_Return; 2 | 3 | import java.util.Arrays; 4 | 5 | public class isAnagram { 6 | 7 | public static boolean isAnagram(String str1, String str2){ 8 | char[] ch1 =str1.toCharArray(); 9 | char[] ch2 =str2.toCharArray(); 10 | 11 | Arrays.sort(ch1); 12 | Arrays.sort(ch2); 13 | 14 | return Arrays.equals(ch1, ch2); 15 | } 16 | 17 | 18 | } 19 | /* 20 | 2. create a method named isAnagram that passes two String parameters, the method returns true if the given two strings are anagram, otherwise returns false 21 | Ex: 22 | str1 = "cba" 23 | str2 = "bac"; 24 | 25 | isAnagram(str1, str2) ====> true 26 | 27 | */ -------------------------------------------------------------------------------- /taskSolutions/day28_ArrayList/SetTheLastElement.java: -------------------------------------------------------------------------------- 1 | package day28_ArrayList; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | 6 | public class SetTheLastElement { 7 | 8 | public static void main(String[] args) { 9 | 10 | ArrayList list = new ArrayList<>(); 11 | list.addAll(Arrays.asList(1,2,3,4,5)); // adding multiple elements at once by using bulk operation 12 | 13 | list.set(list.size()-1, 0); 14 | 15 | System.out.println("list = " + list); 16 | 17 | 18 | } 19 | 20 | } 21 | /* 22 | 1. write a program that can set the last element of the Integer arraylist to zero 23 | ex: 24 | list = [1,2,3,4,5]; 25 | output: [1,2,3,4,0]; 26 | 27 | 28 | */ -------------------------------------------------------------------------------- /taskSolutions/day31_CustomClass_Constructor/addressTask/Test.java: -------------------------------------------------------------------------------- 1 | package day31_CustomClass_Constructor.addressTask; 2 | 3 | public class Test { 4 | 5 | public static void main(String[] args) { 6 | 7 | Address address1 = new Address("7925A", "Jones Branch Dr", "McLean", "VA", "22012"); 8 | 9 | System.out.println(address1); 10 | 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /taskSolutions/day31_CustomClass_Constructor/carpetTask/Test.java: -------------------------------------------------------------------------------- 1 | package day31_CustomClass_Constructor.carpetTask; 2 | 3 | public class Test { 4 | 5 | public static void main(String[] args) { 6 | Carpet carpet1 = new Carpet(3, 5, 8, true); 7 | 8 | Carpet carpet2 = new Carpet(10, 20, 10, false); 9 | 10 | 11 | System.out.println(carpet1); 12 | System.out.println(carpet2); 13 | 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /taskSolutions/day31_CustomClass_Constructor/itemTask/Test.java: -------------------------------------------------------------------------------- 1 | package day31_CustomClass_Constructor.itemTask; 2 | 3 | public class Test { 4 | 5 | public static void main(String[] args) { 6 | 7 | Item item1 = new Item("Wooden Spoon", 3.5, 100); 8 | 9 | System.out.println(item1); 10 | 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /taskSolutions/day31_CustomClass_Constructor/salaryCalculatorTask/Test.java: -------------------------------------------------------------------------------- 1 | package day31_CustomClass_Constructor.salaryCalculatorTask; 2 | 3 | public class Test { 4 | 5 | public static void main(String[] args) { 6 | 7 | SalaryCalculator obj = new SalaryCalculator(65,40,5.4, 25.5); 8 | 9 | System.out.println(obj); 10 | 11 | 12 | } 13 | 14 | 15 | } 16 | -------------------------------------------------------------------------------- /taskSolutions/day33_CustomClass_Statics/addressTask/Test.java: -------------------------------------------------------------------------------- 1 | package day33_CustomClass_Statics.addressTask; 2 | 3 | public class Test { 4 | 5 | public static void main(String[] args) { 6 | 7 | Address address = new Address(7925, "Jones Branch Dr", "McLean", "VA","22012"); 8 | 9 | System.out.println(address); 10 | 11 | 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /taskSolutions/day33_CustomClass_Statics/carTask/Test.java: -------------------------------------------------------------------------------- 1 | package day33_CustomClass_Statics.carTask; 2 | 3 | public class Test { 4 | 5 | public static void main(String[] args) { 6 | 7 | Car car = new Car("Toyota", "Corolla", "Gray", 2021, 35000); 8 | 9 | System.out.println(car); 10 | car.drive(); 11 | 12 | 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /taskSolutions/day33_CustomClass_Statics/circleTask/Test.java: -------------------------------------------------------------------------------- 1 | package day33_CustomClass_Statics.circleTask; 2 | 3 | public class Test { 4 | 5 | public static void main(String[] args) { 6 | 7 | Circle circle1 = new Circle(3.5); 8 | Circle circle2 = new Circle(3.5); 9 | 10 | System.out.println(circle1); 11 | System.out.println(circle2); 12 | 13 | System.out.println(circle1.pi); 14 | System.out.println(circle2.pi); 15 | 16 | 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /taskSolutions/day33_CustomClass_Statics/cydeoStudentTask/Test.java: -------------------------------------------------------------------------------- 1 | package day33_CustomClass_Statics.cydeoStudentTask; 2 | 3 | public class Test { 4 | 5 | public static void main(String[] args) { 6 | 7 | CydeoStudent student1 = new CydeoStudent("Jimmy", 39, 'M', 14, 25, 16, 'C'); 8 | 9 | CydeoStudent student2 = new CydeoStudent("Kathy", 29, 'F', 15, 25, 13, 'A'); 10 | 11 | System.out.println(student1); 12 | System.out.println(student2); 13 | 14 | student1.printSchoolName(); 15 | student2.printSchoolName(); 16 | 17 | student1.printProgLanguage(); 18 | student2.printProgLanguage(); 19 | 20 | 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /taskSolutions/day33_CustomClass_Statics/dogTask/Test.java: -------------------------------------------------------------------------------- 1 | package day33_CustomClass_Statics.dogTask; 2 | 3 | public class Test { 4 | 5 | public static void main(String[] args) { 6 | 7 | Dog dog = new Dog("Lucy", "Husky", "Small", 'F',4, "White" ); 8 | 9 | System.out.println(dog); 10 | dog.eat(); 11 | dog.play(); 12 | dog.sleep(); 13 | 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /taskSolutions/day33_CustomClass_Statics/iphoneTask/Test.java: -------------------------------------------------------------------------------- 1 | package day33_CustomClass_Statics.iphoneTask; 2 | 3 | public class Test { 4 | 5 | public static void main(String[] args) { 6 | 7 | IPhone iPhone = new IPhone("iphone 12", "Black", 1000, "5.6 inches"); 8 | 9 | System.out.println(iPhone); 10 | 11 | iPhone.faceTime(123456789); 12 | iPhone.faceTime("gmail@yahoo.com"); 13 | iPhone.call(123456789); 14 | iPhone.text(123456789); 15 | 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /taskSolutions/day33_CustomClass_Statics/personTask/Test.java: -------------------------------------------------------------------------------- 1 | package day33_CustomClass_Statics.personTask; 2 | 3 | public class Test { 4 | 5 | public static void main(String[] args) { 6 | 7 | Person person1 = new Person("Josh", 28, 'M'); 8 | Person person2 = new Person("Breanna", 32, 'F'); 9 | 10 | System.out.println(person1); 11 | System.out.println(person2); 12 | 13 | System.out.println(person1.numberOfHead); 14 | System.out.println(person2.numberOfHead); 15 | 16 | 17 | System.out.println(person1.numberOfEyes); 18 | System.out.println(person2.numberOfEyes); 19 | 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /taskSolutions/day35_Encapsulation/carpetTask/Test.java: -------------------------------------------------------------------------------- 1 | package day35_Encapsulation.carpetTask; 2 | 3 | public class Test { 4 | 5 | public static void main(String[] args) { 6 | 7 | Carpet carpet = new Carpet(4,5,3.5, false); 8 | 9 | System.out.println(carpet); 10 | 11 | carpet.setPersian(true); 12 | carpet.setUnitPrice(8); 13 | carpet.setWidth(7); 14 | carpet.setLength(6); 15 | 16 | System.out.println(carpet); 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /taskSolutions/day35_Encapsulation/itemTask/Test.java: -------------------------------------------------------------------------------- 1 | package day35_Encapsulation.itemTask; 2 | 3 | public class Test { 4 | 5 | public static void main(String[] args) { 6 | 7 | Item item = new Item("Apple", 0.5, 20); 8 | 9 | System.out.println(item); 10 | 11 | 12 | } 13 | 14 | 15 | } 16 | -------------------------------------------------------------------------------- /taskSolutions/day35_Encapsulation/pizzaTask/Test.java: -------------------------------------------------------------------------------- 1 | package day35_Encapsulation.pizzaTask; 2 | 3 | public class Test { 4 | 5 | public static void main(String[] args) { 6 | 7 | Pizza pizza = new Pizza(null, 2, 3); 8 | 9 | System.out.println(pizza); 10 | 11 | 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /taskSolutions/day35_Encapsulation/rectangleTask/Test.java: -------------------------------------------------------------------------------- 1 | package day35_Encapsulation.rectangleTask; 2 | 3 | public class Test { 4 | 5 | public static void main(String[] args) { 6 | 7 | Rectangle rectangle = new Rectangle(4, 5); 8 | 9 | System.out.println(rectangle); 10 | 11 | rectangle.setLength(10); 12 | rectangle.setWidth(20); 13 | 14 | System.out.println(rectangle.getLength()); 15 | System.out.println(rectangle.getWidth()); 16 | 17 | System.out.println(rectangle); 18 | 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /taskSolutions/day35_Encapsulation/squareTask/Test.java: -------------------------------------------------------------------------------- 1 | package day35_Encapsulation.squareTask; 2 | 3 | public class Test { 4 | 5 | public static void main(String[] args) { 6 | 7 | Square square = new Square(5); 8 | 9 | System.out.println(square); 10 | 11 | square.setSide(10); 12 | System.out.println(square.getSide()); 13 | 14 | System.out.println(square); 15 | 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /taskSolutions/day36_Inheritance/cryptoTask/Bitcoin.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.cryptoTask; 2 | 3 | public class Bitcoin extends CryptoToken{ 4 | 5 | } 6 | -------------------------------------------------------------------------------- /taskSolutions/day36_Inheritance/cryptoTask/Cardano.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.cryptoTask; 2 | 3 | public class Cardano extends CryptoToken{ 4 | } 5 | -------------------------------------------------------------------------------- /taskSolutions/day36_Inheritance/cryptoTask/Doge.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.cryptoTask; 2 | 3 | public class Doge extends CryptoToken{ 4 | } 5 | -------------------------------------------------------------------------------- /taskSolutions/day36_Inheritance/cryptoTask/Ethereum.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.cryptoTask; 2 | 3 | public class Ethereum extends CryptoToken{ 4 | } 5 | -------------------------------------------------------------------------------- /taskSolutions/day36_Inheritance/cryptoTask/XRP.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.cryptoTask; 2 | 3 | public class XRP extends CryptoToken{ 4 | } 5 | -------------------------------------------------------------------------------- /taskSolutions/day36_Inheritance/employeeTask/Developer.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.employeeTask; 2 | 3 | public class Developer extends Employee{ 4 | 5 | public void coding(){ 6 | System.out.println(jobTitle+" "+name+" is coding"); 7 | } 8 | 9 | public void fixingBugs(){ 10 | System.out.println(jobTitle+" "+name+" is fixing bugs"); 11 | } 12 | 13 | 14 | } 15 | 16 | /* 17 | 2.3 Create the sub class of Employee named Developer: 18 | variables: 19 | name, gender, age, id, jobTitle, salary 20 | 21 | Methods: 22 | setInfo() 23 | work() 24 | coding() 25 | fixingBugs() 26 | toString() 27 | 28 | */ -------------------------------------------------------------------------------- /taskSolutions/day36_Inheritance/employeeTask/Driver.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.employeeTask; 2 | 3 | public class Driver extends Employee{ 4 | 5 | public void driving(){ 6 | System.out.println(jobTitle+" "+name+" is driving"); 7 | } 8 | 9 | } 10 | 11 | /* 12 | 2.5 Create the sub class of Employee named Driver: 13 | variables: 14 | name, gender, age, id, jobTitle, salary 15 | 16 | Methods: 17 | setInfo() 18 | work() 19 | driving() 20 | toString() 21 | 22 | */ -------------------------------------------------------------------------------- /taskSolutions/day36_Inheritance/employeeTask/Teacher.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.employeeTask; 2 | 3 | public class Teacher extends Employee{ 4 | 5 | public void teaching(){ 6 | System.out.println(jobTitle+" "+name+" is teaching"); 7 | } 8 | 9 | 10 | } 11 | /* 12 | 2.4 Create the sub class of Employee named Teacher: 13 | variables: 14 | name, gender, age, id, jobTitle, salary 15 | 16 | Methods: 17 | setInfo() 18 | work() 19 | teaching() 20 | toString() 21 | 22 | */ -------------------------------------------------------------------------------- /taskSolutions/day36_Inheritance/employeeTask/Tester.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.employeeTask; 2 | 3 | public class Tester extends Employee{ 4 | 5 | public void testing(){ 6 | System.out.println(jobTitle+" "+name+" is testing"); 7 | } 8 | 9 | public void createTicket(){ 10 | System.out.println(jobTitle+" "+name+" is creating ticket"); 11 | } 12 | 13 | 14 | } 15 | 16 | /* 17 | 2.2 Create the sub class of Employee named Tester: 18 | variables: 19 | name, gender, age, id, jobTitle, salary 20 | 21 | Methods: 22 | setInfo() 23 | work() 24 | testing() 25 | creatingTicket() 26 | toString() 27 | */ -------------------------------------------------------------------------------- /taskSolutions/day36_Inheritance/phoneTask/Iphone.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.phoneTask; 2 | 3 | public class Iphone extends Phone { 4 | 5 | 6 | public void faceTime(long phoneNumber){ 7 | System.out.println(model+" is face timing with number "+phoneNumber); 8 | } 9 | 10 | public void faceTime(String email){ 11 | System.out.println(model+" is face timing with email "+email); 12 | } 13 | 14 | } 15 | 16 | /* 17 | 1.2 Create a sub class of Phone named IPhone: 18 | Variables: 19 | brand, model, size, price, color 20 | 21 | Methods: 22 | setInfo() 23 | call(long phoneNumber) 24 | text(long phoneNumber) 25 | faceTime(long phoneNumber) 26 | faceTime(String email) 27 | toString() 28 | 29 | */ -------------------------------------------------------------------------------- /taskSolutions/day36_Inheritance/phoneTask/Nokia.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.phoneTask; 2 | 3 | public class Nokia extends Phone{ 4 | 5 | public void selfDefense(){ 6 | System.out.println(brand+" "+model+" can be used for self defense"); 7 | } 8 | 9 | } 10 | 11 | /* 12 | 1.4 Create a sub class of Phone named Nokia: 13 | Variables: 14 | brand, model, size, price, color 15 | 16 | Methods: 17 | setInfo() 18 | call(long phoneNumber) 19 | text(long phoneNumber) 20 | selfDefense() 21 | toString() 22 | 23 | */ -------------------------------------------------------------------------------- /taskSolutions/day36_Inheritance/phoneTask/Samsung.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.phoneTask; 2 | 3 | public class Samsung extends Phone{ 4 | 5 | public void freeze(){ 6 | System.out.println(brand+" "+model+" is freezing"); 7 | } 8 | 9 | } 10 | /* 11 | 1.3 Create a sub class of Phone named Samsung: 12 | Variables: 13 | brand, model, size, price, color 14 | 15 | Methods: 16 | setInfo() 17 | call(long phoneNumber) 18 | text(long phoneNumber) 19 | freeze() 20 | toString() 21 | */ -------------------------------------------------------------------------------- /taskSolutions/day36_Inheritance/phoneTask/Test.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.phoneTask; 2 | 3 | public class Test { 4 | 5 | public static void main(String[] args) { 6 | 7 | Iphone iphone = new Iphone(); 8 | iphone.setInfo("iphone 12", "5.6 inches", "Black", 1000); 9 | 10 | Samsung samsung = new Samsung(); 11 | samsung.setInfo("galaxy S19", "6 inches", "White", 900); 12 | 13 | Nokia nokia = new Nokia(); 14 | nokia.setInfo("Brik", "4 inches", "Pink", 60); 15 | 16 | System.out.println(iphone); 17 | System.out.println(samsung); 18 | System.out.println(nokia); 19 | 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /taskSolutions/day36_Inheritance/planetTask/Earth.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.planetTask; 2 | 3 | public class Earth extends Planet{ 4 | 5 | } 6 | -------------------------------------------------------------------------------- /taskSolutions/day36_Inheritance/planetTask/Mercury.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.planetTask; 2 | 3 | public class Mercury extends Planet{ 4 | } 5 | -------------------------------------------------------------------------------- /taskSolutions/day36_Inheritance/planetTask/Moon.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.planetTask; 2 | 3 | public class Moon extends Planet{ 4 | } 5 | -------------------------------------------------------------------------------- /taskSolutions/day36_Inheritance/planetTask/Venus.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.planetTask; 2 | 3 | public class Venus extends Planet{ 4 | } 5 | -------------------------------------------------------------------------------- /taskSolutions/day36_Inheritance/scrumTask/Developer.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.scrumTask; 2 | 3 | public class Developer extends Employee{ 4 | 5 | public void fixBugs(){ 6 | System.out.println(getName()+" is fixing bugs"); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /taskSolutions/day36_Inheritance/scrumTask/Tester.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.scrumTask; 2 | 3 | public class Tester extends Employee{ 4 | 5 | public void createTicket(){ 6 | System.out.println(getName()+" is creating ticket"); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /taskSolutions/day38_MethodOverriding/animalTask/Cat.java: -------------------------------------------------------------------------------- 1 | package day38_MethodOverriding.animalTask; 2 | 3 | public class Cat extends Animal{ 4 | 5 | public Cat(String name, String breed, int age, char gender, String size, String color) { 6 | super(name, breed, age, gender, size, color); 7 | } 8 | 9 | @Override 10 | public void eat() { 11 | System.out.println(getName()+" eats cat food"); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /taskSolutions/day38_MethodOverriding/animalTask/Dog.java: -------------------------------------------------------------------------------- 1 | package day38_MethodOverriding.animalTask; 2 | 3 | public class Dog extends Animal{ 4 | 5 | public Dog(String name, String breed, int age, char gender, String size, String color) { 6 | super(name, breed, age, gender, size, color); 7 | } 8 | 9 | 10 | @Override 11 | public void eat() { 12 | System.out.println(getName()+" eats dog food"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /taskSolutions/day38_MethodOverriding/animalTask/Eagle.java: -------------------------------------------------------------------------------- 1 | package day38_MethodOverriding.animalTask; 2 | 3 | public class Eagle extends Animal{ 4 | 5 | 6 | public Eagle(String name, String breed, int age, char gender, String size, String color) { 7 | super(name, breed, age, gender, size, color); 8 | } 9 | 10 | @Override 11 | public void eat() { 12 | System.out.println(getName()+" eats snake"); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /taskSolutions/day38_MethodOverriding/animalTask/Tiger.java: -------------------------------------------------------------------------------- 1 | package day38_MethodOverriding.animalTask; 2 | 3 | public class Tiger extends Animal{ 4 | 5 | public Tiger(String name, String breed, int age, char gender, String size, String color) { 6 | super(name, breed, age, gender, size, color); 7 | } 8 | 9 | @Override 10 | public void eat() { 11 | System.out.println(getName()+" eats deer"); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /taskSolutions/day38_MethodOverriding/browserTask/Browser.java: -------------------------------------------------------------------------------- 1 | package day38_MethodOverriding.browserTask; 2 | 3 | public class Browser { 4 | 5 | public void openBrowser(){ 6 | System.out.println("Opening chrome browser"); 7 | } 8 | 9 | public void closeBrowser(){ 10 | System.out.println("Closing chrome browser"); 11 | } 12 | 13 | } 14 | 15 | /* 16 | Create a class named Browser: 17 | 18 | Methods: 19 | openBrowser(): prints "opening chrome browser" 20 | closeBrowser(): prints "closing chrome browser" 21 | */ -------------------------------------------------------------------------------- /taskSolutions/day38_MethodOverriding/browserTask/Chrome.java: -------------------------------------------------------------------------------- 1 | package day38_MethodOverriding.browserTask; 2 | 3 | public class Chrome extends Browser{ 4 | } 5 | -------------------------------------------------------------------------------- /taskSolutions/day38_MethodOverriding/browserTask/FireFox.java: -------------------------------------------------------------------------------- 1 | package day38_MethodOverriding.browserTask; 2 | 3 | public class FireFox extends Browser { 4 | @Override 5 | public void openBrowser() { 6 | System.out.println("Opening firefox browser"); 7 | } 8 | 9 | @Override 10 | public void closeBrowser() { 11 | System.out.println("closing firefox browser"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /taskSolutions/day38_MethodOverriding/browserTask/Opera.java: -------------------------------------------------------------------------------- 1 | package day38_MethodOverriding.browserTask; 2 | 3 | public class Opera extends Browser{ 4 | 5 | @Override 6 | public void openBrowser() { 7 | System.out.println("Opening opera browser"); 8 | } 9 | 10 | @Override 11 | public void closeBrowser() { 12 | System.out.println("closing opera browser"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /taskSolutions/day38_MethodOverriding/browserTask/Safari.java: -------------------------------------------------------------------------------- 1 | package day38_MethodOverriding.browserTask; 2 | 3 | public class Safari extends Browser{ 4 | 5 | @Override 6 | public void openBrowser() { 7 | System.out.println("Opening safari browser"); 8 | } 9 | 10 | @Override 11 | public void closeBrowser() { 12 | System.out.println("closing safari browser"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /taskSolutions/day39_Inheritance_Ecnapsulation/animalTask/Bear.java: -------------------------------------------------------------------------------- 1 | package day39_Inheritance_Ecnapsulation.animalTask; 2 | 3 | public class Bear extends WildAnimal{ 4 | 5 | public Bear(String name, String breed, int age, char gender, String size, String color) { 6 | super(name, breed, age, gender, size, color); 7 | } 8 | 9 | @Override 10 | public void hunt() { 11 | System.out.println("Bear "+getName()+" hunts fish"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /taskSolutions/day39_Inheritance_Ecnapsulation/animalTask/Cat.java: -------------------------------------------------------------------------------- 1 | package day39_Inheritance_Ecnapsulation.animalTask; 2 | 3 | public class Cat extends FriendlyAnimal{ 4 | 5 | public Cat(String name, String breed, int age, char gender, String size, String color) { 6 | super(name, breed, age, gender, size, color); 7 | } 8 | 9 | public void scratch(){ 10 | System.out.println(getName()+" is scratching"); 11 | } 12 | 13 | 14 | } 15 | -------------------------------------------------------------------------------- /taskSolutions/day39_Inheritance_Ecnapsulation/animalTask/Crocodile.java: -------------------------------------------------------------------------------- 1 | package day39_Inheritance_Ecnapsulation.animalTask; 2 | 3 | public class Crocodile extends WildAnimal{ 4 | 5 | public Crocodile(String name, String breed, int age, char gender, String size, String color) { 6 | super(name, breed, age, gender, size, color); 7 | } 8 | 9 | 10 | @Override 11 | public void hunt() { 12 | System.out.println("Crocodile "+getName()+" hunts reptiles"); 13 | } 14 | 15 | 16 | } 17 | -------------------------------------------------------------------------------- /taskSolutions/day39_Inheritance_Ecnapsulation/animalTask/Dog.java: -------------------------------------------------------------------------------- 1 | package day39_Inheritance_Ecnapsulation.animalTask; 2 | 3 | public class Dog extends FriendlyAnimal{ 4 | 5 | public Dog(String name, String breed, int age, char gender, String size, String color) { 6 | super(name, breed, age, gender, size, color); 7 | } 8 | 9 | public void bark(){ 10 | System.out.println(getName()+" is barking"); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /taskSolutions/day39_Inheritance_Ecnapsulation/animalTask/Dolphin.java: -------------------------------------------------------------------------------- 1 | package day39_Inheritance_Ecnapsulation.animalTask; 2 | 3 | public class Dolphin extends FriendlyAnimal{ 4 | 5 | public Dolphin(String name, String breed, int age, char gender, String size, String color) { 6 | super(name, breed, age, gender, size, color); 7 | } 8 | 9 | public void swim(){ 10 | System.out.println(getName()+" is swimming under the water"); 11 | } 12 | 13 | 14 | } 15 | -------------------------------------------------------------------------------- /taskSolutions/day39_Inheritance_Ecnapsulation/animalTask/Eagle.java: -------------------------------------------------------------------------------- 1 | package day39_Inheritance_Ecnapsulation.animalTask; 2 | 3 | public class Eagle extends WildAnimal{ 4 | 5 | public Eagle(String name, String breed, int age, char gender, String size, String color) { 6 | super(name, breed, age, gender, size, color); 7 | } 8 | 9 | @Override 10 | public void hunt() { 11 | System.out.println("Eagle "+getName()+" hunts snakes"); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /taskSolutions/day39_Inheritance_Ecnapsulation/animalTask/Lion.java: -------------------------------------------------------------------------------- 1 | package day39_Inheritance_Ecnapsulation.animalTask; 2 | 3 | public class Lion extends WildAnimal{ 4 | 5 | public Lion(String name, String breed, int age, char gender, String size, String color) { 6 | super(name, breed, age, gender, size, color); 7 | } 8 | 9 | @Override 10 | public void hunt() { 11 | System.out.println("Lion "+getName()+" hunts buffaloes"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /taskSolutions/day39_Inheritance_Ecnapsulation/animalTask/Parrot.java: -------------------------------------------------------------------------------- 1 | package day39_Inheritance_Ecnapsulation.animalTask; 2 | 3 | public class Parrot extends FriendlyAnimal{ 4 | 5 | public Parrot(String name, String breed, int age, char gender, String size, String color) { 6 | super(name, breed, age, gender, size, color); 7 | } 8 | 9 | public void fly(){ 10 | System.out.println(getName()+" is flying"); 11 | } 12 | 13 | public void sing(){ 14 | System.out.println(getName()+" is singing"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /taskSolutions/day39_Inheritance_Ecnapsulation/animalTask/Python.java: -------------------------------------------------------------------------------- 1 | package day39_Inheritance_Ecnapsulation.animalTask; 2 | 3 | public class Python extends WildAnimal{ 4 | 5 | public Python(String name, String breed, int age, char gender, String size, String color) { 6 | super(name, breed, age, gender, size, color); 7 | } 8 | 9 | @Override 10 | public void hunt() { 11 | System.out.println("Python "+getName()+" hunts lizards"); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /taskSolutions/day39_Inheritance_Ecnapsulation/animalTask/Tiger.java: -------------------------------------------------------------------------------- 1 | package day39_Inheritance_Ecnapsulation.animalTask; 2 | 3 | public class Tiger extends WildAnimal{ 4 | 5 | public Tiger(String name, String breed, int age, char gender, String size, String color) { 6 | super(name, breed, age, gender, size, color); 7 | } 8 | 9 | @Override 10 | public void hunt() { 11 | System.out.println("Tiger "+getName()+" hunts deers"); 12 | } 13 | 14 | 15 | } 16 | -------------------------------------------------------------------------------- /taskSolutions/day39_Inheritance_Ecnapsulation/animalTask/WildAnimal.java: -------------------------------------------------------------------------------- 1 | package day39_Inheritance_Ecnapsulation.animalTask; 2 | 3 | public class WildAnimal extends Animal{ 4 | 5 | public static boolean isWild = false, 6 | isFriendly = true, 7 | isPlayable = true; 8 | 9 | public WildAnimal(String name, String breed, int age, char gender, String size, String color) { 10 | super(name, breed, age, gender, size, color); 11 | } 12 | 13 | public void hunt(){ 14 | System.out.println(getName()+" is hunting"); 15 | } 16 | 17 | 18 | } 19 | 20 | /* 21 | Create a sub class of Animal named WildAnimal: 22 | Variable: 23 | isWild, isFriendly, isPlayable 24 | 25 | Extra Methods: 26 | hunt() 27 | */ -------------------------------------------------------------------------------- /taskSolutions/day39_Inheritance_Ecnapsulation/deviceTask/BlackBerry.java: -------------------------------------------------------------------------------- 1 | package day39_Inheritance_Ecnapsulation.deviceTask; 2 | 3 | public class BlackBerry extends Phone{ 4 | 5 | public BlackBerry(String brand, String model, String color, String size, double price) { 6 | super(brand, model, color, size, price); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /taskSolutions/day39_Inheritance_Ecnapsulation/deviceTask/Computer.java: -------------------------------------------------------------------------------- 1 | package day39_Inheritance_Ecnapsulation.deviceTask; 2 | 3 | public class Computer extends Device{ 4 | 5 | public Computer(String brand, String model, String color, String size, double price) { 6 | super(brand, model, color, size, price); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /taskSolutions/day39_Inheritance_Ecnapsulation/deviceTask/Desktop.java: -------------------------------------------------------------------------------- 1 | package day39_Inheritance_Ecnapsulation.deviceTask; 2 | 3 | public class Desktop extends Computer{ 4 | 5 | public Desktop(String brand, String model, String color, String size, double price) { 6 | super(brand, model, color, size, price); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /taskSolutions/day39_Inheritance_Ecnapsulation/deviceTask/GooglePhone.java: -------------------------------------------------------------------------------- 1 | package day39_Inheritance_Ecnapsulation.deviceTask; 2 | 3 | public class GooglePhone extends Phone{ 4 | 5 | public GooglePhone(String brand, String model, String color, String size, double price) { 6 | super(brand, model, color, size, price); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /taskSolutions/day39_Inheritance_Ecnapsulation/deviceTask/Iphone.java: -------------------------------------------------------------------------------- 1 | package day39_Inheritance_Ecnapsulation.deviceTask; 2 | 3 | public class Iphone extends Phone{ 4 | 5 | public Iphone(String brand, String model, String color, String size, double price) { 6 | super(brand, model, color, size, price); 7 | } 8 | 9 | public void faceTime(long phoneNum){ 10 | System.out.println(getBrand()+" "+getModel()+" is face timing with "+phoneNum); 11 | } 12 | 13 | public void faceTime(String email){ 14 | System.out.println(getBrand()+" "+getModel()+" is face timing with "+email); 15 | } 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /taskSolutions/day39_Inheritance_Ecnapsulation/deviceTask/Laptop.java: -------------------------------------------------------------------------------- 1 | package day39_Inheritance_Ecnapsulation.deviceTask; 2 | 3 | public class Laptop extends Computer{ 4 | 5 | public Laptop(String brand, String model, String color, String size, double price) { 6 | super(brand, model, color, size, price); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /taskSolutions/day39_Inheritance_Ecnapsulation/deviceTask/Nokia.java: -------------------------------------------------------------------------------- 1 | package day39_Inheritance_Ecnapsulation.deviceTask; 2 | 3 | public class Nokia extends Phone{ 4 | 5 | public Nokia(String brand, String model, String color, String size, double price) { 6 | super(brand, model, color, size, price); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /taskSolutions/day39_Inheritance_Ecnapsulation/deviceTask/PersonalComputer.java: -------------------------------------------------------------------------------- 1 | package day39_Inheritance_Ecnapsulation.deviceTask; 2 | 3 | public class PersonalComputer extends Computer{ 4 | 5 | public PersonalComputer(String brand, String model, String color, String size, double price) { 6 | super(brand, model, color, size, price); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /taskSolutions/day39_Inheritance_Ecnapsulation/deviceTask/Phone.java: -------------------------------------------------------------------------------- 1 | package day39_Inheritance_Ecnapsulation.deviceTask; 2 | 3 | public class Phone extends Device { 4 | 5 | 6 | public Phone(String brand, String model, String color, String size, double price) { 7 | super(brand, model, color, size, price); 8 | } 9 | 10 | public void call(long phoneNum) { 11 | System.out.println(getBrand() + " " + getModel() + " is calling " + phoneNum); 12 | } 13 | 14 | public void text(long phoneNum) { 15 | System.out.println(getBrand() + " " + getModel() + " is texting " + phoneNum); 16 | } 17 | 18 | } 19 | 20 | /* 21 | 2. Create a subclass of Device named Phone: 22 | 23 | Extra Methods: 24 | call(long phoneNum), text(long phoneNum) 25 | */ -------------------------------------------------------------------------------- /taskSolutions/day39_Inheritance_Ecnapsulation/deviceTask/Samsung.java: -------------------------------------------------------------------------------- 1 | package day39_Inheritance_Ecnapsulation.deviceTask; 2 | 3 | public class Samsung extends Phone{ 4 | 5 | public Samsung(String brand, String model, String color, String size, double price) { 6 | super(brand, model, color, size, price); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /taskSolutions/day39_Inheritance_Ecnapsulation/deviceTask/TV.java: -------------------------------------------------------------------------------- 1 | package day39_Inheritance_Ecnapsulation.deviceTask; 2 | 3 | public class TV extends Device{ 4 | 5 | public TV(String brand, String model, String color, String size, double price) { 6 | super(brand, model, color, size, price); 7 | } 8 | 9 | public void channelUp(){ 10 | System.out.println("Channeling up "+getBrand()+" "+getModel()); 11 | } 12 | 13 | public void channelDown(){ 14 | System.out.println("Channeling down "+getBrand()+" "+getModel()); 15 | } 16 | 17 | } 18 | --------------------------------------------------------------------------------