├── .gitignore ├── TasksSolutions ├── 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 ├── liveReviewSessions ├── avengers_04_08_2022 │ ├── AddElementToArray.java │ ├── AnimalSpecies.java │ ├── CustomMethods.java │ ├── Notes.txt │ └── PreviousTopics.java ├── avengers_18_08_2022 │ ├── Item.java │ ├── Notes.txt │ ├── OnSaleItem.java │ ├── Question.java │ └── TJMaxx.java ├── avengers_25_08_2022 │ ├── ChildSpeak.java │ ├── CustomMethods.java │ ├── Notes.txt │ └── Test.java ├── avengers_28_07_2022 │ └── Replit_Method_LameDB.java ├── week01 │ ├── EscapeSequences.java │ └── SomeImportantRules.java ├── week02 │ ├── PrimitiveExamples.java │ └── ShoppingList.java ├── week03 │ ├── ArithmeticOperatorsExamples.java │ ├── If_Cond_Example.java │ ├── LogicalOperators.java │ ├── LogicalOperators02.java │ ├── OperatorsExamples.java │ ├── SmallConditionalTasks.java │ └── UnaryOperatorExamples.java ├── week04 │ ├── AdaireApartments.java │ ├── Calculator.java │ ├── ReadMe.MD │ └── ScannerMethods.java ├── week05 │ ├── DynamicSubstring.java │ ├── Notes.txt │ ├── Palindrome.java │ ├── StringReview01.java │ ├── StringReview02.java │ ├── StringReview03.java │ └── WebAddress.java ├── week06 │ ├── BasicLoopExamples.java │ ├── BasicLoopExamples02.java │ ├── FibonacciTask.java │ ├── Notes.txt │ └── RemoveDuplicates.java ├── week07 │ ├── Notes.txt │ ├── RandomPassword.java │ ├── ShoppingList2Replit.java │ ├── TaskNestedLoop01.java │ ├── TaskNestedLoop02.java │ └── WhileHungry.java ├── week08 │ ├── ArraysBasic.java │ ├── ArraysLoopWithConditions.java │ ├── ArraysUtilityExamples.java │ ├── CharArray.java │ ├── Notes.txt │ ├── ShoppingAppReportMax.java │ └── ShoppingAppTests.java ├── week09 │ ├── AmazonSearchTest.java │ ├── ArmstrongNumber.java │ ├── BiggestNumberin2DArray.java │ ├── DeepAndDeeper.java │ ├── Notes.txt │ ├── PassArg.java │ ├── RemoveSpaces.java │ ├── Reverse2DArray.java │ └── SearchTest.java ├── week10and11 │ ├── LoginTest.java │ ├── Notes.txt │ ├── SmallTasksWithArrayList.java │ ├── TV.java │ ├── TVtest.java │ └── WrapperClassExamples.java ├── week12 │ ├── NotesForGit.txt │ ├── accessModifierReview │ │ ├── Notes.txt │ │ └── PracticeTask.java │ ├── constructors │ │ ├── Employee.java │ │ ├── Microsoft.java │ │ └── Notes.txt │ └── fieldTypes │ │ ├── LocalvsInstance.java │ │ ├── Notes.txt │ │ ├── StaticMethods.java │ │ ├── StaticTest.java │ │ └── Telephone.java ├── week13 │ ├── CameraPhone.java │ ├── Credentials.java │ ├── Db.java │ ├── DbTest.java │ ├── Login.java │ ├── Notes.txt │ ├── PaperBook.java │ ├── Person.java │ ├── Phone.java │ └── inheritance │ │ ├── AudioBook.java │ │ ├── Book.java │ │ ├── BookStore.java │ │ └── Ebook.java ├── week14 │ ├── GroceryList.java │ ├── Notes.txt │ ├── ShopListMakerApp.java │ └── browserTest │ │ ├── Browser.java │ │ ├── DemoBlazeTest.java │ │ ├── LaptopTest.java │ │ ├── OS.java │ │ ├── SamsungPCTest.java │ │ ├── TestCase.java │ │ └── Tests.java ├── week15 │ ├── CheckedExceptionExample.java │ ├── ErrorExample.java │ ├── ExceptionExample.java │ ├── FinallyBlock.java │ ├── MultiCatchExample.java │ ├── MultiCatchExample02.java │ └── customExceptions │ │ ├── BreakTimeException.java │ │ ├── CustomExceptionTest.java │ │ └── InsufficientBalanceException.java ├── week16 │ ├── FinalKeyword.java │ └── abstractionExercise │ │ ├── Browser.java │ │ ├── Chrome.java │ │ ├── Electric.java │ │ ├── Exercise.java │ │ ├── FreeWeight.java │ │ ├── Lifting.java │ │ ├── Running.java │ │ └── Swimming.java ├── week17 │ ├── TestEdible.java │ └── interfaceDemo │ │ ├── ChromeDriver.java │ │ ├── DriverObjects.java │ │ ├── FirefoxDriver.java │ │ └── WebDriver.java ├── week18 │ ├── Notes.txt │ ├── interfaceDemo │ │ ├── Father.java │ │ ├── Mother.java │ │ ├── Parent.java │ │ ├── SuperFather.java │ │ ├── SuperManTest.java │ │ └── Worker.java │ └── polymorphismDemo │ │ ├── Browser.java │ │ ├── ElementsTest.java │ │ ├── InputFields.java │ │ ├── Links.java │ │ ├── WebElement.java │ │ └── WebElementUtility.java └── week19 │ ├── LinkListExample.java │ ├── ListExamples.java │ ├── QueueExamples.java │ └── SetExample.java ├── replitSolutions ├── _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 /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea/ 2 | /out/ 3 | *.iml 4 | -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/day02_PrintStatements/Triangle.java: -------------------------------------------------------------------------------- 1 | package day02_PrintStatements; 2 | 3 | public class Triangle { 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 | . Create a class called Triangle, and print the following shape of 21 | triangle 22 | * 23 | * * 24 | * * 25 | * * 26 | * * 27 | * * 28 | * * * * * * * 29 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/day05_Concatenations/PhoneNumber.java: -------------------------------------------------------------------------------- 1 | package day05_Concatenations; 2 | 3 | public class PhoneNumber { 4 | 5 | public static void main(String[] args) { 6 | 7 | int countryCode = 1, 8 | areaCode = 703, 9 | localNumber = 4512625; 10 | 11 | System.out.println("+"+countryCode+"(" + areaCode + ")-" + localNumber ); 12 | 13 | } 14 | 15 | } 16 | 17 | /* 18 | 1. create a class named Phone Number and declare the following variables: 19 | countryCode, areaCode, localNumber 20 | use string concatenation to display the phone number 21 | ex: 22 | if countryCode = 1 23 | areaCode = 703 24 | localNumber = 4512625 25 | 26 | output: 27 | +1(703)-4512625 28 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/day13_String/FirstLastCharactersOfSentence.java: -------------------------------------------------------------------------------- 1 | package day13_String; 2 | 3 | import java.util.Scanner; 4 | 5 | public class FirstLastCharactersOfSentence { 6 | 7 | public static void main(String[] args) { 8 | Scanner scan = new Scanner(System.in); 9 | 10 | System.out.println("Enter a sentence:"); 11 | String sentence = scan.nextLine(); 12 | scan.close(); 13 | 14 | char firstChar = sentence.charAt(0); 15 | char lastChar = sentence.charAt(sentence.length() - 1); 16 | 17 | String result = firstChar + "" + lastChar; 18 | 19 | System.out.println(result); 20 | 21 | 22 | } 23 | 24 | } 25 | /* 26 | 1. write a program that asks user to enter a sentence. 27 | then print the first & last characters of the sentence 28 | 29 | */ 30 | -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/day16_ForLoop_String/FrequencyOfJava.java: -------------------------------------------------------------------------------- 1 | package day16_ForLoop_String; 2 | 3 | public class FrequencyOfJava { 4 | public static void main(String[] args) { 5 | String str = "javajava"; 6 | 7 | int count = 0; 8 | for(int i= 0 ; i <= str.length()-4; i++){ //i:0 , 1, 2,3, 4 9 | 10 | String s = str.substring(i, i+4); 11 | if(s.equalsIgnoreCase("java")){ 12 | count++; 13 | } 14 | 15 | } 16 | 17 | System.out.println(count); 18 | } 19 | } 20 | /* 21 | 4. write a program that can return the frequency of the a word Java from the sentence 22 | 23 | Ex: 24 | sentence = "Java Java"; 25 | 26 | output: 27 | 2 28 | 29 | Hint: you need to create 30 | 31 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/day21_ForEachLoop/EvenAndOddNumbers.java: -------------------------------------------------------------------------------- 1 | package day21_ForEachLoop; 2 | 3 | import java.util.Arrays; 4 | 5 | public class EvenAndOddNumbers { 6 | 7 | public static void main(String[] args) { 8 | int[] arr = {1,2,3,4,5,6,7,8,9}; 9 | 10 | int countOdd = 0, 11 | countEven = 0; 12 | 13 | for (int each : arr) { 14 | if(each%2 ==0){ 15 | countEven++; 16 | }else{ 17 | countOdd++; 18 | } 19 | } 20 | 21 | System.out.println(Arrays.toString(arr) +" has "+countEven+" even numbers and "+countOdd+" odd numbers"); 22 | 23 | } 24 | 25 | } 26 | /* 27 | 2. Write a program that can count the even and odd number from an array of integers 28 | 29 | Note: MUST use for each loop 30 | 31 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/day24_CustomMethods_Return/FrequencyOfWord.java: -------------------------------------------------------------------------------- 1 | package day24_CustomMethods_Return; 2 | 3 | public class FrequencyOfWord { 4 | 5 | 6 | public static int frequencyOfWord(String sentence, String word){ 7 | int count = 0; 8 | while(sentence.contains(word)){ 9 | sentence = sentence.replaceFirst(word, ""); 10 | count++; 11 | } 12 | return count; 13 | } 14 | 15 | 16 | } 17 | /* 18 | 1. create a method named frequencyOfWord that passes two parameters: string sentence and String word, then returns the frequency of word from the sentence 19 | Ex: 20 | sentence = "Java java java python python" 21 | word = "java"; 22 | frequencyOfWord(sentence, word) ==> 3 23 | 24 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/day36_Inheritance/cryptoTask/Bitcoin.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.cryptoTask; 2 | 3 | public class Bitcoin extends CryptoToken{ 4 | 5 | } 6 | -------------------------------------------------------------------------------- /TasksSolutions/day36_Inheritance/cryptoTask/Cardano.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.cryptoTask; 2 | 3 | public class Cardano extends CryptoToken{ 4 | } 5 | -------------------------------------------------------------------------------- /TasksSolutions/day36_Inheritance/cryptoTask/Doge.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.cryptoTask; 2 | 3 | public class Doge extends CryptoToken{ 4 | } 5 | -------------------------------------------------------------------------------- /TasksSolutions/day36_Inheritance/cryptoTask/Ethereum.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.cryptoTask; 2 | 3 | public class Ethereum extends CryptoToken{ 4 | } 5 | -------------------------------------------------------------------------------- /TasksSolutions/day36_Inheritance/cryptoTask/XRP.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.cryptoTask; 2 | 3 | public class XRP extends CryptoToken{ 4 | } 5 | -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/day36_Inheritance/planetTask/Earth.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.planetTask; 2 | 3 | public class Earth extends Planet{ 4 | 5 | } 6 | -------------------------------------------------------------------------------- /TasksSolutions/day36_Inheritance/planetTask/Mercury.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.planetTask; 2 | 3 | public class Mercury extends Planet{ 4 | } 5 | -------------------------------------------------------------------------------- /TasksSolutions/day36_Inheritance/planetTask/Moon.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.planetTask; 2 | 3 | public class Moon extends Planet{ 4 | } 5 | -------------------------------------------------------------------------------- /TasksSolutions/day36_Inheritance/planetTask/Venus.java: -------------------------------------------------------------------------------- 1 | package day36_Inheritance.planetTask; 2 | 3 | public class Venus extends Planet{ 4 | } 5 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/day38_MethodOverriding/browserTask/Chrome.java: -------------------------------------------------------------------------------- 1 | package day38_MethodOverriding.browserTask; 2 | 3 | public class Chrome extends Browser{ 4 | } 5 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | */ -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /TasksSolutions/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 | -------------------------------------------------------------------------------- /liveReviewSessions/avengers_04_08_2022/Notes.txt: -------------------------------------------------------------------------------- 1 | Constructors: 2 | 3 | Special Methods 4 | Difference Between Methods and Constructors? 5 | Constructor: 6 | Does NOT have return Type 7 | the name has to be same with Class name 8 | it can be with both No parameter or with parameters 9 | Can not be static 10 | the purpose of Constructor is to create object: with new keyword 11 | can only be called by another constructor 12 | * methods can be called over and over again 13 | * Constructor can be called for that particular object only once 14 | -------------------------------------------------------------------------------- /liveReviewSessions/avengers_18_08_2022/Question.java: -------------------------------------------------------------------------------- 1 | package avengers_18_08_2022; 2 | 3 | import java.util.Arrays; 4 | import java.util.Scanner; 5 | 6 | public class Question { 7 | public static void main(String[] args) { 8 | 9 | // Scanner input = new Scanner(System.in); 10 | 11 | System.out.println("Enter an integer"); 12 | 13 | int num = new Scanner(System.in).nextInt(); 14 | 15 | int[] arr = {2,3,4,5}; 16 | Arrays.toString(arr); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /liveReviewSessions/avengers_25_08_2022/Notes.txt: -------------------------------------------------------------------------------- 1 | 2 | Rules about Creating Methods: 3 | 4 | Can we create another method in a method? NO, we can call another method 5 | 6 | Either No Return or with some return type methods. 7 | 8 | When you have a return type method, you HAVE to return that DataType. 9 | 10 | A method can have same name with class name 11 | 12 | Method overloading: same name, different parameters 13 | changing return type is NOT method overloading 14 | 15 | At Method OverRiding: return type has to be same or Co-variant 16 | 17 | static keyWord is a specifier, when you put it to a method, it makes that method part of the class, you can call that method with class name 18 | 19 | No static methods: Instance Methods --- Belongs to objects, and can be called only with object 20 | 21 | 22 | -------------------------------------------------------------------------------- /liveReviewSessions/avengers_25_08_2022/Test.java: -------------------------------------------------------------------------------- 1 | package avengers_25_08_2022; 2 | 3 | public class Test { 4 | public static void main(String[] args) { 5 | 6 | CustomMethods.methodC(); // how we call static method 7 | 8 | CustomMethods object = new CustomMethods(); 9 | 10 | object.methodE(); // instance method 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /liveReviewSessions/week03/LogicalOperators02.java: -------------------------------------------------------------------------------- 1 | package week03; 2 | 3 | public class LogicalOperators02 { 4 | public static void main(String[] args) { 5 | 6 | int b = 2; 7 | 8 | // boolean res = ++b == 2 || --b == 2 && --b == 2 ; 9 | boolean res = ++b == 2 || b == 2 && --b == 2 ; 10 | // false && ------- does not matter 11 | System.out.println("res = " + res); // false 12 | System.out.println("b = " + b); // 3 13 | 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /liveReviewSessions/week04/ReadMe.MD: -------------------------------------------------------------------------------- 1 | #Week 4 Class Notes 2 | ##Today's Topics 3 | 1. Scanner Class Methods 4 | 2. Conditional Statements 5 | a. If Else 6 | b. Branched If Else 7 | c. Nested Conditionals 8 | d. Switch 9 | e. Ternary Operator 10 | 11 | ###Scanner Class Methods 12 | ###Branched Conditionals 13 | 1. If Else If Else... 14 | 2. Switch 15 | a. it can only perform == (equals) comparison. > , < 16 | b. byte, char, int, String, short variables type 17 | c. data type of case and condition should be same 18 | d. use BREAK, to get out of Swtich Block 19 | -------------------------------------------------------------------------------- /liveReviewSessions/week06/BasicLoopExamples02.java: -------------------------------------------------------------------------------- 1 | package week06; 2 | 3 | public class BasicLoopExamples02 { 4 | public static void main(String[] args) { 5 | /* 6 | Question-3: 7 | 8 | Write a program that displays 9 | the number of even numbers between 5 and 50 (included) 10 | I am asking How Many 11 | */ 12 | 13 | int countOfEvens = 0; 14 | for(int i = 5; i<=50 ; i++){ 15 | if((i%2)==0){ 16 | ++countOfEvens; 17 | } 18 | } 19 | System.out.println("countOfEvens = " + countOfEvens); 20 | 21 | // & means what?????? 22 | System.out.println(23&10); 23 | 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /liveReviewSessions/week06/Notes.txt: -------------------------------------------------------------------------------- 1 | for loops : repeatable IF statements 2 | 3 | for (initialization ; condition ; iteration){ 4 | statements 5 | } 6 | initialization: starting point 7 | 8 | condition : ending point, it needs to be related to initialization 9 | 10 | iteration : co-related to Condition, must be capable of changing the condition to false 11 | 12 | 13 | 14 | JAVA Control Statements 15 | 1. Selection Statements 16 | - if ...else 17 | - switch ---case 18 | 2. Iteration Statements 19 | - for loop 20 | - while 21 | - do while 22 | 3. Jump statements 23 | - break 24 | - continue 25 | -------------------------------------------------------------------------------- /liveReviewSessions/week06/RemoveDuplicates.java: -------------------------------------------------------------------------------- 1 | package week06; 2 | 3 | public class RemoveDuplicates { 4 | public static void main(String[] args) { 5 | 6 | String str = "javaverygoodandsoon"; 7 | 8 | String result = ""; // not duplicate strings 9 | 10 | // iterate through the String for each Char element 11 | /* 12 | charAT(index)--to get each char 13 | */ 14 | 15 | for (int i=0; i Instance variables belong to OBJECTS 6 | public int volumeLevel; // default value to 1 7 | public boolean on; // default value is OFF 8 | 9 | public TV(){ 10 | channel = 1; 11 | volumeLevel = 1; 12 | on= false; 13 | } 14 | // action 15 | public void turnOn(){ 16 | on = true; 17 | } 18 | 19 | public void anotherMethod(){ 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /liveReviewSessions/week12/accessModifierReview/Notes.txt: -------------------------------------------------------------------------------- 1 | Access Modifiers: 2 | public : let's you reach from everywhere 3 | protected : can be reach from everywhere if there is inheritance relationship 4 | default : you need to be in the same package to reach methods/atts 5 | private : just from the class itself -------------------------------------------------------------------------------- /liveReviewSessions/week12/accessModifierReview/PracticeTask.java: -------------------------------------------------------------------------------- 1 | package week12.accessModifierReview; 2 | 3 | public class PracticeTask { 4 | 5 | 6 | 7 | } 8 | -------------------------------------------------------------------------------- /liveReviewSessions/week12/fieldTypes/Notes.txt: -------------------------------------------------------------------------------- 1 | static methods ---> can be called without creating an OBJECT-advantage, belongs to the class 2 | 3 | especially at testing we will create UTILITY classes, in these classes our methods will be all static methods 4 | 5 | static vs instance: 6 | 1. instance method can be called only by the object name 7 | 2. static methods CAN NOT reach non-static fields(instance) fields 8 | 3. from static method we can not call instance variables HOWEVER, we can call static field from an instance method -------------------------------------------------------------------------------- /liveReviewSessions/week12/fieldTypes/StaticMethods.java: -------------------------------------------------------------------------------- 1 | package week12.fieldTypes; 2 | 3 | public class StaticMethods { 4 | public int num=10; 5 | 6 | public static int count = 5; 7 | 8 | public static void displayMessage(String message){ 9 | System.out.println("message = " + message); 10 | 11 | // System.out.println("num = " + num); non-static field 12 | 13 | System.out.println("count = " + count); 14 | 15 | // instanceMethod(); non-static field 16 | } 17 | 18 | public void instanceMethod(){ 19 | System.out.println("instance method called"); 20 | // System.out.println("num = " + num); 21 | // System.out.println("count = " + count); 22 | displayMessage("hello from instance method"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /liveReviewSessions/week12/fieldTypes/StaticTest.java: -------------------------------------------------------------------------------- 1 | package week12.fieldTypes; 2 | 3 | public class StaticTest { 4 | 5 | 6 | public static void main(String[] args) { 7 | 8 | StaticMethods.displayMessage("Hello from static method"); 9 | 10 | StaticMethods object = new StaticMethods(); 11 | object.displayMessage("We are using object to call this static method"); 12 | 13 | System.out.println("StaticMethods.count = " + StaticMethods.count); 14 | 15 | System.out.println("object.num = " + object.num); 16 | 17 | System.out.println(new StaticMethods().num); 18 | // StaticMethods.instanceMethod(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /liveReviewSessions/week13/CameraPhone.java: -------------------------------------------------------------------------------- 1 | package week13; 2 | 3 | public class CameraPhone extends Phone{ 4 | 5 | int iSize; // mageByte 6 | int memorySize; // gigaBytes 7 | 8 | public CameraPhone(String make, String model, double price, int iSize, int memorySize) { 9 | // super(); this statement redundant 10 | super(make,model,price); 11 | this.iSize = iSize; 12 | this.memorySize = memorySize; 13 | } 14 | 15 | public CameraPhone(){ 16 | // super(); 17 | } 18 | 19 | 20 | public int numPictures(){ 21 | return memorySize*1000/iSize; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /liveReviewSessions/week13/Db.java: -------------------------------------------------------------------------------- 1 | package week13; 2 | 3 | public class Db { 4 | private String data; 5 | private int yInt; 6 | 7 | public Db(String data,int yInt) { 8 | setData(data); 9 | setyInt(yInt); 10 | } 11 | 12 | public void setData(String data) { 13 | this.data = data; 14 | } 15 | 16 | public void setyInt(int yInt) { 17 | this.yInt = yInt; 18 | } 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /liveReviewSessions/week13/DbTest.java: -------------------------------------------------------------------------------- 1 | package week13; 2 | 3 | public class DbTest { 4 | public static void main(String[] args) { 5 | Db infoOne = new Db("EU9 Students",9); 6 | 7 | System.out.println("infoOne.toString() = " + infoOne.toString()); 8 | // there is no way to read the Object info 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /liveReviewSessions/week13/PaperBook.java: -------------------------------------------------------------------------------- 1 | package week13; 2 | 3 | // WE HAD TO IMPORT THIS CLASS 4 | 5 | import week13.inheritance.Book; 6 | 7 | public class PaperBook extends Book { 8 | 9 | 10 | public void read() { 11 | System.out.println("Reading paper book"); 12 | System.out.println("title = " + title); // since these fields are protected I can reach even if they are NOT in the same package 13 | // System.out.println("price = " + price); // Cannot be accessed from outside package 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /liveReviewSessions/week13/inheritance/BookStore.java: -------------------------------------------------------------------------------- 1 | package week13.inheritance; 2 | 3 | public class BookStore { 4 | public static void main(String[] args) { 5 | 6 | Book book = new Book("1984", "George Orwell", "Distopia", 29.5); 7 | 8 | System.out.println("book = " + book); 9 | book.buy("D&R"); 10 | book.lend("Oscar"); 11 | // book.readBook(); can NOT reach like this to child method 12 | AudioBook audioBook = new AudioBook("Animal Farm", "Fiction", "George Orwell", 35.50, 180, "Benjamin May"); 13 | System.out.println("audioBook = " + audioBook); 14 | audioBook.buy("Amazon"); // child CAN USE parent method 15 | audioBook.listen(); 16 | 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /liveReviewSessions/week13/inheritance/Ebook.java: -------------------------------------------------------------------------------- 1 | package week13.inheritance; 2 | 3 | public class Ebook extends Book{ 4 | int sizeAtMemory; 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); // since there is inheritance relationship I cab reach this field 14 | System.out.println("author = " + author); 15 | System.out.println("type = " + type); 16 | System.out.println("price = " + price); 17 | System.out.println("sizeAtMemory = " + sizeAtMemory); 18 | System.out.println("pages = " + pages); 19 | } 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /liveReviewSessions/week14/browserTest/Browser.java: -------------------------------------------------------------------------------- 1 | package week14.browserTest; 2 | 3 | public class Browser { 4 | private String browserType; 5 | 6 | public Browser() { 7 | } 8 | 9 | public Browser(String browserType) { 10 | setBrowserType(browserType); 11 | } 12 | 13 | public String getBrowserType() { 14 | return browserType; 15 | } 16 | 17 | public void setBrowserType(String browserType) { 18 | this.browserType = browserType; 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return "Browser{" + 24 | "browserType='" + browserType + '\'' + 25 | '}'; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /liveReviewSessions/week14/browserTest/DemoBlazeTest.java: -------------------------------------------------------------------------------- 1 | package week14.browserTest; 2 | 3 | public class DemoBlazeTest extends TestCase{ 4 | public String product; 5 | 6 | public DemoBlazeTest(Browser browser, OS operatingSystem){ 7 | super(browser,operatingSystem); 8 | } 9 | 10 | public DemoBlazeTest() { 11 | } 12 | 13 | public void navigateTo(String productPage){ 14 | System.out.println("Navigating to "+productPage+" using "+super.browser.getBrowserType()); 15 | } 16 | 17 | void shopFor(String product){ 18 | this.product=product; 19 | System.out.println("Navigating to "+this.product+" \'s Page"); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /liveReviewSessions/week14/browserTest/LaptopTest.java: -------------------------------------------------------------------------------- 1 | package week14.browserTest; 2 | 3 | public class LaptopTest extends DemoBlazeTest{ 4 | 5 | public int quantity; 6 | 7 | public LaptopTest(Browser browser, OS operatingSystem, int quantity){ 8 | super(browser,operatingSystem); 9 | this.quantity=quantity; 10 | } 11 | 12 | 13 | void shopFor(String product){ 14 | super.product=product; 15 | System.out.println("Adding "+this.quantity+" amount of "+super.product+" to cart"); 16 | } 17 | 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /liveReviewSessions/week14/browserTest/OS.java: -------------------------------------------------------------------------------- 1 | package week14.browserTest; 2 | 3 | public class OS { 4 | private String OS; 5 | 6 | public OS() { 7 | } 8 | 9 | public OS(String OS) { 10 | setOS(OS); 11 | } 12 | 13 | public String getOS() { 14 | return OS; 15 | } 16 | 17 | public void setOS(String OS) { 18 | this.OS = OS; 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return "OS{" + 24 | "OS='" + OS + '\'' + 25 | '}'; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /liveReviewSessions/week15/CheckedExceptionExample.java: -------------------------------------------------------------------------------- 1 | package week15; 2 | 3 | public class CheckedExceptionExample { 4 | public static void main(String[] args) { 5 | 6 | try { 7 | Thread.sleep(5000); // checked exception: inside the method it throws an exception so we need to handle it 8 | } catch (InterruptedException e) { 9 | e.printStackTrace(); 10 | } 11 | 12 | /* 13 | There are two ways of handling checked exceptions 14 | 1. in method signature you can use throws keyword : throws InterruptedException 15 | 2. we can handle with try catch 16 | */ 17 | 18 | System.out.println("Hello after 5 seconds of sleep"); 19 | 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /liveReviewSessions/week15/customExceptions/BreakTimeException.java: -------------------------------------------------------------------------------- 1 | package week15.customExceptions; 2 | 3 | public class BreakTimeException extends RuntimeException{ 4 | public BreakTimeException(String message){ 5 | super(message); // calling super class constructor 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /liveReviewSessions/week15/customExceptions/InsufficientBalanceException.java: -------------------------------------------------------------------------------- 1 | package week15.customExceptions; 2 | 3 | public class InsufficientBalanceException extends RuntimeException{ 4 | public InsufficientBalanceException(String message){ 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /liveReviewSessions/week16/abstractionExercise/Browser.java: -------------------------------------------------------------------------------- 1 | package week16.abstractionExercise; 2 | 3 | abstract class Browser { 4 | 5 | 6 | 7 | // for JAVA this is OK!!!! 8 | 9 | 10 | } 11 | -------------------------------------------------------------------------------- /liveReviewSessions/week16/abstractionExercise/Chrome.java: -------------------------------------------------------------------------------- 1 | package week16.abstractionExercise; 2 | 3 | public class Chrome extends Browser{ 4 | 5 | public String browserType; 6 | public Chrome(){ 7 | this.browserType = "Chrome"; 8 | } 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /liveReviewSessions/week16/abstractionExercise/Electric.java: -------------------------------------------------------------------------------- 1 | package week16.abstractionExercise; 2 | 3 | public interface Electric { 4 | 5 | void charge(); // public abstract is over there implicitly 6 | 7 | boolean HASBATTERIES = true; // public static final is over there implicitly 8 | } 9 | -------------------------------------------------------------------------------- /liveReviewSessions/week16/abstractionExercise/Exercise.java: -------------------------------------------------------------------------------- 1 | package week16.abstractionExercise; 2 | 3 | public abstract class Exercise { 4 | 5 | public double weight; 6 | 7 | public int minutes = 10; 8 | 9 | public Exercise(double weight){ 10 | this.weight=weight; 11 | } 12 | 13 | public static void giveUpAndEatJunkFood(){ 14 | System.out.println("If you don't feel like use the default static method"); 15 | } 16 | public void start(){ 17 | System.out.println("Warming up and starting the exercise"); 18 | } 19 | 20 | public abstract int getCaloriesCount(int minutes); 21 | // no body, no implememtation, sub classes will override, they are created in a way that, they meant to be overriden 22 | 23 | public abstract void perform(); 24 | } 25 | -------------------------------------------------------------------------------- /liveReviewSessions/week16/abstractionExercise/FreeWeight.java: -------------------------------------------------------------------------------- 1 | package week16.abstractionExercise; 2 | 3 | public class FreeWeight extends Lifting{ 4 | 5 | 6 | public FreeWeight(double weight) { 7 | super(weight); 8 | } 9 | 10 | @Override 11 | public int getCaloriesCount(int minutes) { 12 | return (int)(minutes*6*(weight/100)); 13 | } 14 | 15 | @Override 16 | public void perform() { 17 | System.out.println("Lifting Free Weight with dumbbells"); 18 | } 19 | 20 | @Override 21 | void endLift() { 22 | System.out.println("Carefully re-rack dumbbells"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /liveReviewSessions/week16/abstractionExercise/Lifting.java: -------------------------------------------------------------------------------- 1 | package week16.abstractionExercise; 2 | 3 | public abstract class Lifting extends Exercise { 4 | 5 | public Lifting(double weight) { 6 | super(weight); 7 | } 8 | 9 | abstract void endLift(); 10 | } 11 | -------------------------------------------------------------------------------- /liveReviewSessions/week16/abstractionExercise/Running.java: -------------------------------------------------------------------------------- 1 | package week16.abstractionExercise; 2 | 3 | public class Running extends Exercise { 4 | 5 | public Running(double weight){ 6 | super(weight); // call parent abstract class constructor 7 | } 8 | 9 | @Override 10 | public int getCaloriesCount(int minutes) { // All overriding rules apply 11 | return (int)(minutes*13*(weight/100)); 12 | } 13 | 14 | @Override 15 | public void perform() { 16 | System.out.println("Performing running exercise on the Track"); 17 | } 18 | 19 | // Below overriding is NOT mandatory 20 | @Override 21 | public void start(){ 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /liveReviewSessions/week16/abstractionExercise/Swimming.java: -------------------------------------------------------------------------------- 1 | package week16.abstractionExercise; 2 | 3 | public class Swimming extends Exercise{ 4 | 5 | public Swimming(double weight) { 6 | super(weight); 7 | } 8 | 9 | @Override 10 | public int getCaloriesCount(int minutes) { 11 | return (int)(minutes*8*(weight/100)); 12 | } 13 | 14 | @Override 15 | public void perform() { 16 | System.out.println("Performing swimming exercise in the pool"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /liveReviewSessions/week17/interfaceDemo/WebDriver.java: -------------------------------------------------------------------------------- 1 | package week17.interfaceDemo; 2 | 3 | public interface WebDriver { 4 | void get(String url); 5 | void findElement(String locator); 6 | void quit(); 7 | String getTitle(); 8 | } 9 | -------------------------------------------------------------------------------- /liveReviewSessions/week18/Notes.txt: -------------------------------------------------------------------------------- 1 | Java is Object Oriented Programming Language ! 2 | 3 | * Re-Usability is main concern 4 | It means for Java what an OBJECT can reach in Coding Structure 5 | 6 | Object Oriented: 7 | Object what to reach and how to reach !!!!!!! 8 | Create a relationship between code structures 9 | 10 | Reference type decides what can be accessible. Object type decides to use most specific one. 11 | -------------------------------- 12 | Parent abstract class --- Mother and Father 13 | Worker abstract methods -- interface --- your friend, your children 14 | 15 | -------------------- 16 | WebElement: inputFields, links, buttons, checkboxes, radioButtons ...etc 17 | interface WebElement 18 | 19 | Method Overriding --- Co-variant 20 | 21 | -------------------------------------------------------------------------------- /liveReviewSessions/week18/interfaceDemo/Father.java: -------------------------------------------------------------------------------- 1 | package week18.interfaceDemo; 2 | 3 | public class Father extends Parent implements Worker { 4 | 5 | 6 | @Override 7 | public void raiseKid() { 8 | System.out.println("Helping mom to raise the kids"); 9 | } 10 | 11 | @Override 12 | public void playWithKid() { 13 | System.out.println("Playing with the kid occasionally"); 14 | } 15 | 16 | @Override 17 | public void feedKid() { 18 | System.out.println("Providing supplies to Home"); 19 | } 20 | 21 | @Override 22 | public void work(String work) { 23 | System.out.println("Working very hard as "+ work); 24 | } 25 | 26 | @Override 27 | public double getPaid() { 28 | return 100_000.0; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /liveReviewSessions/week18/interfaceDemo/Mother.java: -------------------------------------------------------------------------------- 1 | package week18.interfaceDemo; 2 | 3 | public class Mother extends Parent{ 4 | 5 | @Override 6 | public void raiseKid() { 7 | System.out.println("Raising the kid"); 8 | } 9 | 10 | @Override 11 | public void playWithKid() { 12 | System.out.println("Playing most of the time with kids"); 13 | } 14 | 15 | @Override 16 | public void feedKid() { 17 | System.out.println("Preparing the food"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /liveReviewSessions/week18/interfaceDemo/Parent.java: -------------------------------------------------------------------------------- 1 | package week18.interfaceDemo; 2 | 3 | public abstract class Parent { 4 | 5 | public abstract void raiseKid(); 6 | public abstract void playWithKid(); 7 | public abstract void feedKid(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /liveReviewSessions/week18/interfaceDemo/SuperFather.java: -------------------------------------------------------------------------------- 1 | package week18.interfaceDemo; 2 | 3 | public class SuperFather extends Father{ 4 | 5 | // @Override 6 | // public void playWithKid() { 7 | // System.out.println("Playing with the kid ALL THE TIME"); 8 | // } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /liveReviewSessions/week18/interfaceDemo/Worker.java: -------------------------------------------------------------------------------- 1 | package week18.interfaceDemo; 2 | 3 | public interface Worker { 4 | void work(String work); 5 | double getPaid(); 6 | } 7 | -------------------------------------------------------------------------------- /liveReviewSessions/week18/polymorphismDemo/Browser.java: -------------------------------------------------------------------------------- 1 | package week18.polymorphismDemo; 2 | 3 | public abstract class Browser { 4 | public abstract WebElement locateElement(String locator); 5 | } 6 | -------------------------------------------------------------------------------- /liveReviewSessions/week18/polymorphismDemo/InputFields.java: -------------------------------------------------------------------------------- 1 | package week18.polymorphismDemo; 2 | 3 | public class InputFields extends Browser implements WebElement{ 4 | 5 | 6 | @Override 7 | public void click() { 8 | System.out.println("Clicking the input field"); 9 | } 10 | 11 | @Override 12 | public void sendKeys(String input) { 13 | System.out.println(); 14 | } 15 | 16 | @Override 17 | public String getText() { 18 | return null; 19 | } 20 | 21 | @Override 22 | public InputFields locateElement(String locator) { 23 | return new InputFields(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /liveReviewSessions/week18/polymorphismDemo/Links.java: -------------------------------------------------------------------------------- 1 | package week18.polymorphismDemo; 2 | 3 | public class Links extends Browser implements WebElement{ 4 | 5 | 6 | public void getLinkHref(){ 7 | System.out.println("https://www.java.com"); 8 | } 9 | 10 | @Override 11 | public void click() { 12 | System.out.println("Clicking the Link"); 13 | } 14 | 15 | @Override 16 | public void sendKeys(String input) { 17 | System.out.println("Un-supported Action"); 18 | } 19 | 20 | @Override 21 | public String getText() { 22 | System.out.println("Getting Link Text"); 23 | return "Oracle Java"; 24 | } 25 | 26 | @Override 27 | public Links locateElement(String locator) { 28 | return new Links(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /liveReviewSessions/week18/polymorphismDemo/WebElement.java: -------------------------------------------------------------------------------- 1 | package week18.polymorphismDemo; 2 | 3 | public interface WebElement { 4 | 5 | void click(); 6 | void sendKeys(String input); 7 | String getText(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /liveReviewSessions/week18/polymorphismDemo/WebElementUtility.java: -------------------------------------------------------------------------------- 1 | package week18.polymorphismDemo; 2 | 3 | public class WebElementUtility { 4 | 5 | 6 | // we also have polyMorphism used here 7 | public static void clickElement (WebElement element){ 8 | System.out.println("Clicking on the Element"); 9 | element.click(); // object reference decides which method is reachable 10 | } 11 | 12 | public static WebElement getLinkWithText(String txt){ 13 | System.out.println("Searching for a link with txt "+txt); 14 | return new Links(); 15 | } 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /liveReviewSessions/week19/QueueExamples.java: -------------------------------------------------------------------------------- 1 | package week19; 2 | 3 | import java.util.ArrayDeque; 4 | import java.util.Arrays; 5 | import java.util.Queue; 6 | 7 | public class QueueExamples { // F I F O 8 | public static void main(String[] args) { 9 | 10 | Queue cities = new ArrayDeque<>(); 11 | cities.addAll(Arrays.asList("Edirne","Ankara","Izmir","Kayseri","Tirana","Chisinau","Oslo")); 12 | 13 | while (cities.size()>0){ 14 | System.out.println(cities.poll()); 15 | } 16 | 17 | System.out.println("cities = " + cities); 18 | 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /replitSolutions/_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 | -------------------------------------------------------------------------------- /replitSolutions/_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 | -------------------------------------------------------------------------------- /replitSolutions/_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 | -------------------------------------------------------------------------------- /replitSolutions/_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 | -------------------------------------------------------------------------------- /replitSolutions/_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 | -------------------------------------------------------------------------------- /replitSolutions/_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 | -------------------------------------------------------------------------------- /replitSolutions/_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 | -------------------------------------------------------------------------------- /replitSolutions/_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 | -------------------------------------------------------------------------------- /replitSolutions/_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 | -------------------------------------------------------------------------------- /replitSolutions/_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 | -------------------------------------------------------------------------------- /replitSolutions/_3_003_String_FindTheLength.java: -------------------------------------------------------------------------------- 1 | //Write a program that will output length of the text (string). 2 | // 3 | // Example: 4 | // 5 | // 6 | // ``` 7 | // Display message: "Please enter the text:" 8 | // ``` 9 | // 10 | // ``` 11 | // input: java 12 | // ``` 13 | // 14 | // ``` 15 | // Display message: "Length is: 4" 16 | // ``` 17 | 18 | import java.util.Scanner; 19 | 20 | public class _3_003_String_FindTheLength { 21 | public static void main(String[] args) { 22 | //WRITER YOU CODE HERE 23 | Scanner in = new Scanner(System.in); 24 | 25 | System.out.println("Please enter the text:"); 26 | String input=in.nextLine(); 27 | System.out.println("Length is: "+input.length()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /replitSolutions/_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 | -------------------------------------------------------------------------------- /replitSolutions/_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 | -------------------------------------------------------------------------------- /replitSolutions/_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 | -------------------------------------------------------------------------------- /replitSolutions/_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 | -------------------------------------------------------------------------------- /replitSolutions/_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 | -------------------------------------------------------------------------------- /replitSolutions/_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 | -------------------------------------------------------------------------------- /replitSolutions/_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 | -------------------------------------------------------------------------------- /replitSolutions/_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 | -------------------------------------------------------------------------------- /replitSolutions/_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 | -------------------------------------------------------------------------------- /replitSolutions/_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/PersonalInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | 1. Create a class called PersonalInfo and print followings: 3 | name 4 | gender 5 | date of birth 6 | address 7 | phone number 8 | SSN 9 | 10 | */ 11 | 12 | package day03_EscapeSequences; 13 | 14 | public class PersonalInfo { 15 | 16 | public static void main(String[] args) { 17 | 18 | System.out.println("Name: John"); 19 | System.out.println("Gender: Male"); 20 | System.out.println("Date Of Birth: 6/19/1993"); 21 | System.out.println("Address: Los Angles, CA"); 22 | System.out.println("Phone: (123)-304-2698"); 23 | System.out.println("SSN: (***)-**-**87 "); 24 | 25 | } 26 | 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /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/ArrayPractice2.java: -------------------------------------------------------------------------------- 1 | package day20_Arrays; 2 | 3 | import java.util.Arrays; 4 | 5 | public class ArrayPractice2 { 6 | 7 | public static void main(String[] args) { 8 | 9 | char[] letters = new char[26]; 10 | /* 11 | letters[0] = 'A'; 12 | letters[1] = 'B'; 13 | letter[2] = 'C'; 14 | .... 15 | */ 16 | 17 | /* 18 | for (int i = 0, j = 'A'; i < letters.length ; i++, j++ ) { //i: index numbers 0 ~ last index 19 | letters[i] = (char)j ; 20 | } 21 | */ 22 | 23 | char ch = 'A'; 24 | for (int i = 0; i < letters.length; i++, ch++) { 25 | letters[i] = ch; 26 | } 27 | 28 | System.out.println(Arrays.toString(letters)); //[A~Z] 29 | 30 | 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /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/day24_CustomMethods_Return/ReturnMethodPractice.java: -------------------------------------------------------------------------------- 1 | package day24_CustomMethods_Return; 2 | 3 | public class ReturnMethodPractice { 4 | 5 | public static void main(String[] args) { 6 | 7 | // find the max number between 100 & 200 8 | int maxNumber = max(100, 200); 9 | 10 | System.out.println(maxNumber); 11 | 12 | 13 | // multiply the max number by 2 14 | 15 | int multiplication = maxNumber * 2; 16 | 17 | System.out.println("multiplication = " + multiplication); 18 | 19 | } 20 | 21 | 22 | public static int max(int a, int b){ 23 | 24 | int result = 0; 25 | 26 | if(a > b){ 27 | result = a; 28 | }else{ 29 | result = b; 30 | } 31 | 32 | return result; 33 | } 34 | 35 | 36 | 37 | 38 | } 39 | -------------------------------------------------------------------------------- /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/Developer.java: -------------------------------------------------------------------------------- 1 | package day39_Recap.cydeoTask; 2 | 3 | public class Developer extends Employee { 4 | 5 | public Developer(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 fixingBugs(){ 10 | System.out.println(getJobTitle()+" "+getName()+" is fixing the bug"); 11 | } 12 | 13 | @Override 14 | public void work() { 15 | System.out.println(getJobTitle()+" "+getName()+" is developing the application"); 16 | } 17 | 18 | 19 | } 20 | 21 | /* 22 | 4. Create a sub class of Employee named Developer 23 | 24 | Override the work method 25 | 26 | Extra methods: 27 | fixingBugs() 28 | */ -------------------------------------------------------------------------------- /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/CustomExceptions.java: -------------------------------------------------------------------------------- 1 | package day42_Exceptions; 2 | 3 | class FadyException extends RuntimeException{ // custom unchecked exception 4 | 5 | public FadyException(){ 6 | super("Time for a short break"); 7 | } 8 | 9 | public FadyException(String message){ 10 | super(message); 11 | } 12 | 13 | } 14 | 15 | 16 | class NoBreakException extends Exception{ // custom checked exception 17 | 18 | } 19 | 20 | public class CustomExceptions { 21 | 22 | public static void main(String[] args) { 23 | 24 | // throw new FadyException("It's time for lunch break"); 25 | 26 | 27 | try { 28 | throw new NoBreakException(); 29 | } catch (NoBreakException e) { 30 | e.printStackTrace(); 31 | } 32 | 33 | 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /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 | */ --------------------------------------------------------------------------------