├── README.md ├── part08-Part08_01.Cubes ├── .tmcproject.yml ├── Part08_01.Cubes.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── Cubes.java │ └── test │ │ └── java │ │ └── CubestTest.java └── target │ ├── classes │ └── Cubes.class │ └── test-classes │ └── CubestTest.class ├── part08-Part08_02.AverageOfPositiveNumbers ├── .checkstyle.xml ├── .tmcproject.json ├── .tmcproject.yml ├── Part08_02.AverageOfPositiveNumbers.iml ├── pom.xml └── src │ ├── main │ └── java │ │ └── AverageOfPositiveNumbers.java │ └── test │ └── java │ └── AverageOfPositiveNumbersTest.java ├── part08-Part08_03.LiquidContainers ├── .tmcproject.yml ├── Part08_03.LiquidContainers.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── LiquidContainers.java │ └── test │ │ └── java │ │ └── LiquidContainersTest.java └── target │ ├── classes │ └── LiquidContainers.class │ └── test-classes │ └── LiquidContainersTest.class ├── part08-Part08_04.LiquidContainers2 ├── .tmcproject.yml ├── Part08_04.LiquidContainers2.iml ├── pom.xml └── src │ ├── main │ └── java │ │ ├── Container.java │ │ └── LiquidContainers2.java │ └── test │ └── java │ └── LiquidContainers2Test.java ├── part08-Part08_05.TodoList ├── .tmcproject.yml ├── Part08_05.TodoList.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ ├── Main.java │ │ │ ├── TodoList.java │ │ │ └── UserInterface.java │ └── test │ │ └── java │ │ └── TodoListTest.java └── target │ ├── classes │ ├── AverageOfSelectedNumbers.class │ ├── Main.class │ └── TodoList.class │ └── test-classes │ └── TodoListTest.class ├── part08-Part08_06.Nicknames ├── .tmcproject.yml ├── Part08_06.Nicknames.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── Nicknames.java │ └── test │ │ └── java │ │ └── NicknamesTest.java └── target │ ├── classes │ └── Nicknames.class │ └── test-classes │ └── NicknamesTest.class ├── part08-Part08_07.Abbreviations ├── .tmcproject.yml ├── Part8_07.Abbreviations.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ ├── Abbreviations.java │ │ │ └── Main.java │ └── test │ │ └── java │ │ └── AbbreviationsTest.java └── target │ ├── classes │ ├── Abbreviations.class │ └── Main.class │ └── test-classes │ └── AbbreviationsTest.class ├── part08-Part08_08.PrintMeMyHashmap ├── .tmcproject.yml ├── Part08_08.PrintMeMyHashmap.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── Program.java │ └── test │ │ └── java │ │ └── PrintMeMyHashmapTest.java └── target │ ├── classes │ └── Program.class │ └── test-classes │ └── PrintMeMyHashmapTest.class ├── part08-Part08_09.PrintMeAnotherHashmap ├── .tmcproject.yml ├── Part08_09.PrintMeAnotherHashmap.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ ├── Book.java │ │ │ └── Program.java │ └── test │ │ └── java │ │ └── PrintMeAnotherHashmapTest.java └── target │ ├── classes │ ├── Book.class │ └── Program.class │ └── test-classes │ └── PrintMeAnotherHashmapTest.class ├── part08-Part08_10.IOweYou ├── .tmcproject.yml ├── Part08_10.IOweYou.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ ├── IOU.java │ │ │ └── Main.java │ └── test │ │ └── java │ │ └── IOUTest.java └── target │ ├── classes │ ├── IOU.class │ └── Main.class │ └── test-classes │ └── IOUTest.class ├── part08-Part08_11.SameDate ├── .idea │ ├── .gitignore │ ├── .name │ ├── compiler.xml │ ├── encodings.xml │ ├── jarRepositories.xml │ ├── libraries │ │ ├── Maven__fi_helsinki_cs_tmc_edu_test_utils_0_4_2.xml │ │ ├── Maven__junit_junit_4_12.xml │ │ └── Maven__org_hamcrest_hamcrest_core_1_3.xml │ ├── misc.xml │ ├── modules.xml │ └── vcs.xml ├── .tmcproject.yml ├── Part08_11.SameDate.iml ├── pom.xml └── src │ ├── main │ └── java │ │ ├── Main.java │ │ └── SimpleDate.java │ └── test │ └── java │ └── SimpleDateTest.java ├── part08-Part08_12.HashedDate ├── .idea │ ├── .gitignore │ ├── .name │ ├── compiler.xml │ ├── encodings.xml │ ├── jarRepositories.xml │ ├── libraries │ │ ├── Maven__fi_helsinki_cs_tmc_edu_test_utils_0_4_2.xml │ │ ├── Maven__junit_junit_4_12.xml │ │ └── Maven__org_hamcrest_hamcrest_core_1_3.xml │ ├── misc.xml │ ├── modules.xml │ └── vcs.xml ├── .tmcproject.yml ├── Part08_12.HashedDate.iml ├── pom.xml └── src │ ├── main │ └── java │ │ ├── Main.java │ │ └── SimpleDate.java │ └── test │ └── java │ └── SimpleDateTest.java ├── part08-Part08_13.VehicleRegistry ├── .idea │ ├── .gitignore │ ├── .name │ ├── compiler.xml │ ├── encodings.xml │ ├── jarRepositories.xml │ ├── libraries │ │ ├── Maven__fi_helsinki_cs_tmc_edu_test_utils_0_4_2.xml │ │ ├── Maven__junit_junit_4_12.xml │ │ └── Maven__org_hamcrest_hamcrest_core_1_3.xml │ ├── misc.xml │ ├── modules.xml │ └── vcs.xml ├── .tmcproject.yml ├── Osa08_13.VehicleRegistry.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ ├── LicensePlate.java │ │ │ ├── Main.java │ │ │ └── VehicleRegistry.java │ └── test │ │ └── java │ │ └── VehicleRegistryTest.java └── target │ ├── classes │ ├── LicensePlate.class │ ├── Main.class │ └── VehicleRegistry.class │ └── test-classes │ └── VehicleRegistryTest.class ├── part08-Part08_14.DictionaryOfManyTranslations ├── .tmcproject.yml ├── Part08_14.DictionaryOfManyTranslations.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ ├── DictionaryOfManyTranslations.java │ │ │ └── Program.java │ └── test │ │ └── java │ │ └── DictionaryOfManyTranslationsTest.java └── target │ ├── classes │ ├── DictionaryOfManyTranslations.class │ └── Program.class │ └── test-classes │ └── DictionaryOfManyTranslationsTest.class ├── part08-Part08_15.StorageFacility ├── .tmcproject.yml ├── Part08_15.StorageFacility.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ ├── Program.java │ │ │ └── StorageFacility.java │ └── test │ │ └── java │ │ └── StorageFacilityTest.java └── target │ ├── classes │ ├── Program.class │ └── StorageFacility.class │ └── test-classes │ └── StorageFacilityTest.class ├── part09-Part09_01.ABC ├── .tmcproject.yml ├── Part09_01.ABC.iml ├── pom.xml └── src │ ├── main │ └── java │ │ ├── A.java │ │ ├── B.java │ │ ├── C.java │ │ └── Main.java │ └── test │ └── java │ └── ABCTest.java ├── part09-Part09_02.PersonAndSubclasses ├── .tmcproject.yml ├── Part09_02.PersonAndSubclasses.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ ├── Main.java │ │ │ ├── Person.java │ │ │ ├── Student.java │ │ │ └── Teacher.java │ └── test │ │ └── java │ │ └── PersonAndSubclassesTest.java └── target │ ├── classes │ ├── Main.class │ ├── Person.class │ ├── Student.class │ └── Teacher.class │ └── test-classes │ └── PersonAndSubclassesTest.class ├── part09-Part09_03.Warehousing ├── .tmcproject.yml ├── Part09_03.Warehousing.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ ├── ChangeHistory.java │ │ │ ├── Main.java │ │ │ ├── ProductWarehouse.java │ │ │ ├── ProductWarehouseWithHistory.java │ │ │ └── Warehouse.java │ └── test │ │ └── java │ │ ├── A_ProductWarehouseTest.java │ │ ├── B_ChangeHistoryTest.java │ │ └── C_ProductWarehouseWithHistoryTest.java └── target │ ├── classes │ ├── ChangeHistory.class │ ├── Main.class │ ├── ProductWarehouse.class │ ├── ProductWarehouseWithHistory.class │ └── Warehouse.class │ └── test-classes │ ├── A_ProductWarehouseTest.class │ ├── B_ChangeHistoryTest.class │ └── C_ProductWarehouseWithHistoryTest.class ├── part09-Part09_04.DifferentKindsOfBoxes ├── .tmcproject.yml ├── Part09_04.DifferentKindsOfBoxes.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ ├── Box.java │ │ │ ├── BoxWithMaxWeight.java │ │ │ ├── Item.java │ │ │ ├── Main.java │ │ │ ├── MisplacingBox.java │ │ │ └── OneItemBox.java │ └── test │ │ └── java │ │ └── DifferentKindsOfBoxesTest.java └── target │ ├── classes │ ├── Box.class │ ├── BoxWithMaxWeight.class │ ├── Item.class │ └── Main.class │ └── test-classes │ └── DifferentKindsOfBoxesTest.class ├── part09-Part09_05.TacoBoxes ├── .tmcproject.yml ├── Part09_05.TacoBoxes.iml ├── pom.xml └── src │ ├── main │ └── java │ │ ├── CustomTacoBox.java │ │ ├── Main.java │ │ ├── TacoBox.java │ │ └── TripleTacoBox.java │ └── test │ └── java │ └── TacoBoxesTest.java ├── part09-Part09_06.InterfaceInABox ├── .tmcproject.yml ├── Part09_06.InterfaceInABox.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ ├── Book.java │ │ │ ├── Box.java │ │ │ ├── CD.java │ │ │ ├── Main.java │ │ │ └── Packable.java │ └── test │ │ └── java │ │ ├── Part1test.java │ │ └── Part2and3test.java └── target │ ├── classes │ ├── Book.class │ ├── Box.class │ ├── CD.class │ ├── Main.class │ └── Packable.class │ └── test-classes │ ├── Part1test.class │ └── Part2and3test.class ├── part09-Part09_07.ListAsAMethodParameter ├── .tmcproject.yml ├── Part09_07.ListAsAMethodParameter.iml ├── pom.xml └── src │ ├── main │ └── java │ │ └── mainProgram.java │ └── test │ └── java │ └── ListAsAMethodParameterTest.java ├── part09-Part09_08.MapAsAMethodParameter ├── .tmcproject.yml ├── Part09_08.MapAsAMethodParameter.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── MainProgram.java │ └── test │ │ └── java │ │ └── MapAsAMethodParameterTest.java └── target │ ├── classes │ └── MainProgram.class │ └── test-classes │ └── MapAsAMethodParameterTest.class ├── part09-Part09_09.SetAsMethodParameter ├── .tmcproject.yml ├── Part09_09.SetAsAMethodParameter.iml ├── pom.xml └── src │ ├── main │ └── java │ │ └── Main.java │ └── test │ └── java │ └── SetAsAMethodParameterTest.java ├── part09-Part09_10.OnlineShop ├── .tmcproject.yml ├── Part09_10.OnlineStore.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ ├── Item.java │ │ │ ├── Main.java │ │ │ ├── ShoppingCart.java │ │ │ ├── Store.java │ │ │ └── Warehouse.java │ └── test │ │ └── java │ │ ├── A_WarehouseTest.java │ │ ├── B_ItemTest.java │ │ └── C_ShoppingCartTest.java └── target │ ├── classes │ ├── Item.class │ ├── Main.class │ ├── ShoppingCart.class │ ├── Store.class │ └── Warehouse.class │ └── test-classes │ ├── A_WarehouseTest.class │ ├── B_ItemTest.class │ └── C_ShoppingCartTest.class ├── part09-Part09_11.Herds ├── .tmcproject.yml ├── Part09_11.Herds.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ ├── Herd.java │ │ │ ├── MainProgram.java │ │ │ ├── Movable.java │ │ │ └── Organism.java │ └── test │ │ └── java │ │ ├── HerdTest.java │ │ └── OrganismTest.java └── target │ ├── classes │ ├── Herd.class │ ├── MainProgram.class │ ├── Movable.class │ └── Organism.class │ └── test-classes │ ├── HerdTest.class │ └── OrganismTest.class ├── part09-Part09_12.Animals ├── .tmcproject.yml ├── Part09_12.Animals.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ ├── Animal.java │ │ │ ├── Cat.java │ │ │ ├── Dog.java │ │ │ ├── Main.java │ │ │ └── NoiseCapable.java │ └── test │ │ └── java │ │ └── AnimalsTest.java └── target │ ├── classes │ ├── Animal.class │ ├── Cat.class │ ├── Dog.class │ ├── Main.class │ └── NoiseCapable.class │ └── test-classes │ └── AnimalsTest.class ├── part10-Part10_01.AverageOfNumbers ├── .tmcproject.yml ├── Part10_01.AverageOfNumbers.iml ├── pom.xml └── src │ ├── main │ └── java │ │ └── AverageOfNumbers.java │ └── test │ └── java │ └── AverageOfNumbersTest.java ├── part10-Part10_02.AverageOfSelectedNumbers ├── .tmcproject.yml ├── Part10_02.AverageOfSelectedNumbers.iml ├── pom.xml └── src │ ├── main │ └── java │ │ └── AverageOfSelectedNumbers.java │ └── test │ └── java │ └── AverageOfSelectedNumbersTest.java ├── part10-Part10_03.PositiveNumbers ├── .tmcproject.yml ├── Part10_03.PositiveNumbers.iml ├── pom.xml └── src │ ├── main │ └── java │ │ └── PositiveNumbers.java │ └── test │ └── java │ └── PositiveNumbersTest.java ├── part10-Part10_04.Divisible ├── .tmcproject.yml ├── Part10_04.Divisible.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── Divisible.java │ └── test │ │ └── java │ │ └── DivisibleTest.java └── target │ ├── classes │ └── Divisible.class │ └── test-classes │ └── DivisibleTest.class ├── part10-Part10_05.PrintingUserInput ├── .tmcproject.yml ├── Part10_05.PrintingUserInput.iml ├── pom.xml └── src │ ├── main │ └── java │ │ └── PrintingUserInput.java │ └── test │ └── java │ └── PrintingUserInputTest.java ├── part10-Part10_06.LimitedNumbers ├── .tmcproject.yml ├── Part10_06.LimitedNumbers.iml ├── pom.xml └── src │ ├── main │ └── java │ │ └── LimitedNumbers.java │ └── test │ └── java │ └── LimitedNumbersTest.java ├── part10-Part10_07.UniqueLastNames ├── .tmcproject.yml ├── Part10_07.UniqueLastNames.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ ├── Person.java │ │ │ └── UniqueLastNames.java │ └── test │ │ └── java │ │ └── UniqueLastNamesTest.java └── target │ ├── classes │ ├── Person.class │ └── UniqueLastNames.class │ └── test-classes │ └── UniqueLastNamesTest.class ├── part10-Part10_08.Weighting ├── .tmcproject.yml ├── Part10_08.Weighting.iml ├── pom.xml └── src │ ├── main │ └── java │ │ ├── Hold.java │ │ ├── Item.java │ │ ├── Main.java │ │ └── Suitcase.java │ └── test │ └── java │ ├── A_ItemTest.java │ ├── B_SuitcaseTest.java │ ├── C_HoldTest.java │ ├── D_GeneralTest.java │ └── TestUtils.java ├── part10-Part10_09.ReadingFilesPerLine ├── .tmcproject.yml ├── Part10_09.ReadingFilesPerLine.iml ├── pom.xml └── src │ ├── main │ └── java │ │ └── ReadingFilesPerLine.java │ └── test │ └── java │ └── ReadingFilesPerLineTest.java ├── part10-Part10_10.BooksFromFile ├── .tmcproject.yml ├── Part10_10.BooksFromFile.iml ├── pom.xml └── src │ ├── main │ └── java │ │ ├── Book.java │ │ └── BooksFromFile.java │ └── test │ └── java │ └── BooksFromFileTest.java ├── part10-Part10_11.WageOrder ├── .tmcproject.yml ├── Part10_11.WageOrder.iml ├── pom.xml └── src │ ├── main │ └── java │ │ ├── Human.java │ │ └── MainProgram.java │ └── test │ └── java │ └── HumanTest.java ├── part10-Part10_12.StudentsOnAlphabeticalOrder ├── .tmcproject.yml ├── Part10_12.StudentsOnAplhabeticalOrder.iml ├── pom.xml └── src │ ├── main │ └── java │ │ ├── MainProgram.java │ │ └── Student.java │ └── test │ └── java │ └── StudentTest.java ├── part10-Part10_13.LiteracyComparison ├── .tmcproject.yml ├── Part10_13.LiteracyComparison.iml ├── literacy.csv ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── LiteracyComparison.java │ └── test │ │ └── java │ │ └── LiteracyComparisonTest.java └── target │ ├── classes │ └── LiteracyComparison.class │ └── test-classes │ └── LiteracyComparisonTest.class ├── part10-Part10_14.Literature ├── .tmcproject.yml ├── Part10_14.Literature.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ ├── Book.java │ │ │ └── MainProgram.java │ └── test │ │ └── java │ │ └── LiteratureTest.java └── target │ ├── classes │ ├── Book.class │ └── MainProgram.class │ └── test-classes │ └── LiteratureTest.class ├── part10-Part10_15.RegularExpressions ├── .tmcproject.yml ├── Part10_15.RegularExpressions.iml ├── pom.xml └── src │ ├── main │ └── java │ │ ├── Checker.java │ │ └── MainProgram.java │ └── test │ └── java │ └── RegularExpressionsTest.java ├── part10-Part10_16.EnumAndIterator ├── .tmcproject.yml ├── Part10_16.EnumAndIterator.iml ├── pom.xml └── src │ ├── main │ └── java │ │ ├── Education.java │ │ ├── Employees.java │ │ ├── MainProgram.java │ │ └── Person.java │ └── test │ └── java │ └── EmployeesTest.java ├── part10-Part10_17.SortThemCards ├── .tmcproject.yml ├── Part10_17.SortThemCards.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ ├── BySuitInValueOrder.java │ │ │ ├── Card.java │ │ │ ├── Hand.java │ │ │ ├── Main.java │ │ │ └── Suit.java │ └── test │ │ └── java │ │ ├── A_CardTest.java │ │ ├── B_HandTest.java │ │ ├── C_ComparatorTest.java │ │ ├── D_HandTest.java │ │ └── Help.java └── target │ ├── classes │ ├── BySuitInValueOrder.class │ ├── Card.class │ ├── Hand.class │ ├── Main.class │ └── Suit.class │ └── test-classes │ ├── A_CardTest.class │ ├── B_HandTest.class │ ├── C_ComparatorTest.class │ ├── D_HandTest.class │ └── Help.class ├── part11-Part11_01.Customer ├── .tmcproject.yml ├── Part11_01.Customer.iml ├── pom.xml └── src │ ├── main │ └── java │ │ ├── Customer.java │ │ └── Program.java │ └── test │ └── java │ └── CustomerTest.java ├── part11-Part11_02.ABookAndAPlane ├── .tmcproject.yml ├── Part11_02.ABookAndAPlane.iml ├── pom.xml └── src │ ├── main │ └── java │ │ ├── Book.java │ │ ├── Plane.java │ │ └── Program.java │ └── test │ └── java │ └── ABookAndAPlaneTest.java ├── part11-Part11_03.ShowAndTicket ├── .tmcproject.yml ├── Part11_03.ShowAndTicket.iml ├── pom.xml └── src │ ├── main │ └── java │ │ ├── Program.java │ │ ├── Show.java │ │ └── Ticket.java │ └── test │ └── java │ └── ShowAndTicketTest.java ├── part11-Part11_04.StudentAndUniversity ├── .tmcproject.yml ├── Part11_04.StudentAndUniversity.iml ├── pom.xml └── src │ ├── main │ └── java │ │ ├── Program.java │ │ ├── Student.java │ │ └── University.java │ └── test │ └── java │ └── StudentAndUniversityTest.java ├── part11-Part11_05.ThePlayerAndTheBot ├── .tmcproject.yml ├── Part11_05.PlayerAndBot.iml ├── pom.xml └── src │ ├── main │ └── java │ │ ├── Bot.java │ │ ├── Player.java │ │ └── Program.java │ └── test │ └── java │ └── PlayerAndBotTest.java ├── part11-Part11_06.SaveablePerson ├── .tmcproject.yml ├── Part11_06.SaveablePerson.iml ├── pom.xml └── src │ ├── main │ └── java │ │ ├── Person.java │ │ ├── Program.java │ │ └── Saveable.java │ └── test │ └── java │ └── SaveablePersonTest.java ├── part11-Part11_07.BiggerClassDiagram ├── .tmcproject.yml ├── Part11_07.BiggerClassDiagram.iml ├── pom.xml └── src │ ├── main │ └── java │ │ ├── A.java │ │ ├── B.java │ │ ├── C.java │ │ ├── D.java │ │ ├── E.java │ │ ├── IA.java │ │ ├── IB.java │ │ ├── IC.java │ │ └── Program.java │ └── test │ └── java │ └── BiggerClassDiagramTest.java ├── part11-Part11_08.FirstPackages ├── .tmcproject.yml ├── Part11_08.FirstPackages.iml ├── nbactions.xml ├── pom.xml └── src │ ├── main │ └── java │ │ └── mooc │ │ ├── Main.java │ │ ├── logic │ │ └── ApplicationLogic.java │ │ └── ui │ │ ├── TextInterface.java │ │ └── UserInterface.java │ └── test │ └── java │ └── FirstPackagesTest.java ├── part11-Part11_09.TheThreePackages ├── .tmcproject.yml ├── Part11_09.ThreePackages.iml ├── pom.xml └── src │ ├── main │ └── java │ │ ├── Program.java │ │ ├── a │ │ └── A.java │ │ ├── b │ │ └── B.java │ │ └── c │ │ └── C.java │ └── test │ └── java │ └── ThreePackagesTest.java ├── part11-Part11_10.FlightControl ├── .tmcproject.yml ├── Part11_10.FlightControl.iml ├── pom.xml └── src │ ├── main │ └── java │ │ └── FlightControl │ │ ├── Main.java │ │ ├── domain │ │ ├── Airplane.java │ │ ├── Flight.java │ │ └── Place.java │ │ ├── logic │ │ └── FlightControl.java │ │ └── ui │ │ └── TextUI.java │ └── test │ └── java │ └── FlightControlTest.java ├── part11-Part11_11.ValidatingParameters ├── .idea │ └── workspace.xml ├── .tmcproject.yml ├── Part11_11.ValidatingParameters.iml ├── pom.xml └── src │ ├── main │ └── java │ │ └── validating │ │ ├── Calculator.java │ │ └── Person.java │ └── test │ └── java │ └── ValidatingTest.java ├── part11-Part11_12.SensorsAndTemperature ├── .idea │ ├── .gitignore │ ├── .name │ ├── compiler.xml │ ├── encodings.xml │ ├── jarRepositories.xml │ ├── libraries │ │ ├── Maven__fi_helsinki_cs_tmc_edu_test_utils_0_4_2.xml │ │ ├── Maven__junit_junit_4_12.xml │ │ └── Maven__org_hamcrest_hamcrest_core_1_3.xml │ ├── misc.xml │ ├── modules.xml │ ├── uiDesigner.xml │ └── vcs.xml ├── .tmcproject.yml ├── Part11_12.SensorsAndTemperature.iml ├── pom.xml └── src │ ├── main │ └── java │ │ └── application │ │ ├── AverageSensor.java │ │ ├── Program.java │ │ ├── Sensor.java │ │ ├── StandardSensor.java │ │ └── TemperatureSensor.java │ └── test │ └── java │ └── SensorsAndTemperatureTest.java ├── part11-Part11_13.SaveableDictionary ├── .tmcproject.yml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── dictionary │ │ │ ├── Main.java │ │ │ └── SaveableDictionary.java │ └── test │ │ └── java │ │ └── dictionary │ │ └── SaveableDictionaryTest.java └── words.txt ├── part12-Part12_01.Hideout ├── .tmcproject.yml ├── Part12_01.Hideout.iml ├── pom.xml └── src │ ├── main │ └── java │ │ ├── Hideout.java │ │ └── Program.java │ └── test │ └── java │ └── HideoutTest.java ├── part12-Part12_02.Pipe ├── .tmcproject.yml ├── Part12_02.Pipe.iml ├── pom.xml └── src │ ├── main │ └── java │ │ ├── Pipe.java │ │ └── Program.java │ └── test │ └── java │ └── PipeTest.java ├── part12-Part12_03.SumTheseForMe ├── .tmcproject.yml ├── Part12_03.SumTheseForMe.iml ├── pom.xml └── src │ ├── main │ └── java │ │ └── Program.java │ └── test │ └── java │ └── SumTheseForMeTest.java ├── part12-Part12_04.List ├── .tmcproject.yml ├── Part12_04.List.iml ├── pom.xml └── src │ ├── main │ └── java │ │ ├── List.java │ │ └── Program.java │ └── test │ └── java │ └── ListTest.java ├── part12-Part12_05.HashMap ├── .tmcproject.yml ├── Part12_05.HashMap.iml ├── pom.xml └── src │ ├── main │ └── java │ │ ├── HashMap.java │ │ ├── Pair.java │ │ └── Program.java │ └── test │ └── java │ └── HashMapTest.java ├── part12-Part12_06.Numbers ├── .tmcproject.yml ├── Part12_06.Numbers.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── Program.java │ └── test │ │ └── java │ │ └── NumbersTest.java └── target │ ├── classes │ └── Program.class │ └── test-classes │ └── NumbersTest.class ├── part12-Part12_07.Die ├── .tmcproject.yml ├── Part12_07.Die.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ ├── Die.java │ │ │ └── Program.java │ └── test │ │ └── java │ │ └── DieTest.java └── target │ ├── classes │ ├── Die.class │ └── Program.class │ └── test-classes │ └── DieTest.class ├── part12-Part12_08.Lottery ├── .tmcproject.yml ├── Part12_08.Lottery.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ ├── LotteryRow.java │ │ │ └── Program.java │ └── test │ │ └── java │ │ └── LotteryRowTest.java └── target │ ├── classes │ ├── LotteryRow.class │ └── Program.class │ └── test-classes │ └── LotteryRowTest.class ├── part12-Part12_09.ArrayAsAString ├── .tmcproject.yml ├── Part12_09.ArrayAsString.iml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── Program.java │ └── test │ │ └── java │ │ └── ArrayAsStringTest.java └── target │ ├── classes │ └── Program.class │ └── test-classes │ └── ArrayAsStringTest.class ├── part12-Part12_10.MagicSquare ├── .tmcproject.yml ├── Part12_10.MagicSquare.iml ├── pom.xml └── src │ ├── main │ └── java │ │ ├── MagicSquare.java │ │ ├── MagicSquareFactory.java │ │ └── Program.java │ └── test │ └── java │ └── MagicSquareTest.java ├── part13-Part13_01.MyFirstApplication ├── .tmcparams ├── .tmcproject.yml ├── Part13_01.MyFirstApplication.iml ├── nbactions.xml ├── pom.xml └── src │ ├── main │ └── java │ │ └── myFirstApplication │ │ └── MyFirstApplication.java │ └── test │ └── java │ └── myFirstApplication │ └── MyFirstApplicationTest.java ├── part13-Part13_02.ButtonAndLabel ├── .tmcparams ├── .tmcproject.yml ├── Part13_02.ButtonAndLabel.iml ├── nbactions.xml ├── pom.xml ├── src │ ├── main │ │ └── java │ │ │ └── buttonandlabel │ │ │ └── ButtonAndLabelApplication.java │ └── test │ │ └── java │ │ └── buttonandlabel │ │ └── ButtonAndLabelTest.java └── target │ ├── classes │ └── buttonandlabel │ │ └── ButtonAndLabelApplication.class │ └── test-classes │ └── buttonandlabel │ └── ButtonAndLabelTest.class ├── part13-Part13_03.ButtonAndTextField ├── .tmcparams ├── .tmcproject.yml ├── Part13_03.ButtonAndTextField.iml ├── nbactions.xml ├── pom.xml └── src │ ├── main │ └── java │ │ └── buttonandtextfield │ │ └── ButtonAndTextFieldApplication.java │ └── test │ └── java │ └── buttonandtextfield │ └── ButtonAndTextFieldTest.java ├── part13-Part13_04.BorderPane ├── .tmcparams ├── .tmcproject.yml ├── Part13_04.BorderPane.iml ├── nbactions.xml ├── pom.xml └── src │ ├── main │ └── java │ │ └── borderpane │ │ └── BorderPaneApplication.java │ └── test │ └── java │ └── borderpane │ └── BorderPaneApplicationTest.java ├── part13-Part13_05.TextStatistics ├── .tmcparams ├── .tmcproject.yml ├── Part13_05.TextStatistics.iml ├── nbactions.xml ├── pom.xml └── src │ ├── main │ └── java │ │ └── textstatistics │ │ └── TextStatisticsApplication.java │ └── test │ └── java │ └── textstatistics │ └── TextStatisticsApplicationTest.java ├── part13-Part13_06.Notifier ├── .tmcparams ├── .tmcproject.yml ├── Part13_06.Notifier.iml ├── nbactions.xml ├── pom.xml └── src │ ├── main │ └── java │ │ └── notifier │ │ └── NotifierApplication.java │ └── test │ └── java │ └── notifier │ └── NotifierApplicationTest.java ├── part13-Part13_07.TextStatisticsPart2 ├── .tmcparams ├── .tmcproject.yml ├── Part13_07.TextStatisticsPart2.iml ├── nbactions.xml ├── pom.xml └── src │ ├── main │ └── java │ │ └── textstatistics │ │ └── TextStatisticsApplication.java │ └── test │ └── java │ └── textstatistics │ └── TextStatisticsApplicationTest.java ├── part13-Part13_08.UserTitle ├── .tmcparams ├── .tmcproject.yml ├── Part13_08.UserTitle.iml ├── nbactions.xml ├── pom.xml └── src │ ├── main │ └── java │ │ └── title │ │ ├── Main.java │ │ └── UserTitle.java │ └── test │ └── java │ └── title │ └── UserTitleTest.java ├── part13-Part13_09.MultipleViews ├── .tmcparams ├── .tmcproject.yml ├── Part13_09.MultipleViews.iml ├── nbactions.xml ├── pom.xml └── src │ ├── main │ └── java │ │ └── application │ │ └── MultipleViews.java │ └── test │ └── java │ └── application │ └── MultipleViewsTest.java ├── part13-Part13_10.Greeter ├── .tmcparams ├── .tmcproject.yml ├── Part13_10.Greeter.iml ├── nbactions.xml ├── pom.xml └── src │ ├── main │ └── java │ │ └── application │ │ └── GreeterApplication.java │ └── test │ └── java │ └── application │ └── GreeterApplicationTest.java ├── part13-Part13_11.Joke ├── .tmcparams ├── .tmcproject.yml ├── Part13_11.Joke.iml ├── nbactions.xml ├── pom.xml └── src │ ├── main │ └── java │ │ └── application │ │ └── JokeApplication.java │ └── test │ └── java │ └── application │ └── JokeApplicationTest.java ├── part13-Part13_12.VocabularyPractice ├── .tmcparams ├── .tmcproject.yml ├── Part13_12.VocabularyPractice.iml ├── nbactions.xml ├── pom.xml └── src │ ├── main │ └── java │ │ └── application │ │ ├── Dictionary.java │ │ ├── InputView.java │ │ ├── PracticeView.java │ │ └── VocabularyPracticeApplication.java │ └── test │ └── java │ └── application │ └── VocabularyPracticeTest.java ├── part13-Part13_13.TicTacToe ├── .tmcparams ├── .tmcproject.yml ├── Part13_13.TicTacToe.iml ├── nbactions.xml ├── pom.xml └── src │ ├── main │ └── java │ │ └── ticTacToe │ │ └── TicTacToeApplication.java │ └── test │ └── java │ └── ticTacToe │ └── TicTacToeApplicationTest.java ├── part14-Part14_01.Shanghai ├── .tmcparams ├── .tmcproject.yml ├── nbactions.xml ├── pom.xml └── src │ ├── main │ └── java │ │ └── application │ │ └── ShanghaiApplication.java │ └── test │ └── java │ └── application │ └── ShanghaiApplicationTest.java ├── part14-Part14_02.FinnishParties ├── .tmcparams ├── .tmcproject.yml ├── nbactions.xml ├── partiesdata.tsv ├── pom.xml └── src │ ├── main │ └── java │ │ └── application │ │ └── PartiesApplication.java │ └── test │ └── java │ └── application │ └── PartiesApplicationTest.java ├── part14-Part14_03.SavingsCalculator ├── .tmcparams ├── .tmcproject.yml ├── nbactions.xml ├── pom.xml └── src │ ├── main │ └── java │ │ └── application │ │ └── SavingsCalculatorApplication.java │ └── test │ └── java │ └── application │ └── SavingsCalculatorTest.java ├── part14-Part14_04.UnfairAdvertisement ├── .tmcparams ├── .tmcproject.yml ├── nbactions.xml ├── pom.xml └── src │ ├── main │ └── java │ │ └── application │ │ └── UnfairAdvertisementApplication.java │ └── test │ └── java │ └── application │ └── UnfairAdvertisementApplicationTest.java ├── part14-Part14_05.CyclingStatistics ├── .tmcparams ├── .tmcproject.yml ├── helsinki-cycling-statistics.csv ├── nbactions.xml ├── pom.xml └── src │ ├── main │ └── java │ │ └── application │ │ ├── CyclingStatistics.java │ │ └── CyclingStatisticsApplication.java │ └── test │ └── java │ └── application │ └── CyclingStatisticsTest.java ├── part14-Part14_06.Smiley ├── .tmcparams ├── .tmcproject.yml ├── nbactions.xml ├── pom.xml └── src │ ├── main │ └── java │ │ └── smiley │ │ └── SmileyApplication.java │ └── test │ └── java │ └── smiley │ └── SmileyTest.java ├── part14-Part14_07.Collage ├── .tmcparams ├── .tmcproject.yml ├── monalisa.png ├── nbactions.xml ├── pom.xml └── src │ ├── main │ └── java │ │ └── collage │ │ └── CollageApplication.java │ └── test │ └── java │ └── collage │ └── CollageApplicationTest.java ├── part14-Part14_08.Hurray ├── .tmcparams ├── .tmcproject.yml ├── Applause-Yannick_Lemieux.wav ├── nbactions.xml ├── pom.xml └── src │ ├── main │ └── java │ │ └── hurraa │ │ └── HurraaSovellus.java │ └── test │ └── java │ └── hurraa │ └── HurraaSovellusTest.java ├── part14-Part14_09.Asteroids ├── .tmcparams ├── .tmcproject.yml ├── nbactions.xml ├── pom.xml └── src │ ├── main │ └── java │ │ └── asteroids │ │ └── AsteroidsApplication.java │ └── test │ └── java │ └── asteroids │ └── AsteroidsTest.java └── part14-Part14_10.Database ├── .tmcproject.yml ├── pom.xml └── src ├── main └── java │ └── application │ ├── Progam.java │ ├── Todo.java │ ├── TodoDao.java │ └── UserInterface.java └── test └── java └── application └── DatabaseTest.java /README.md: -------------------------------------------------------------------------------- 1 | # mooc-java-programming-ii 2 | -------------------------------------------------------------------------------- /part08-Part08_01.Cubes/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part08-Part08_01.Cubes/Part08_01.Cubes.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /part08-Part08_01.Cubes/src/main/java/Cubes.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.Scanner; 3 | 4 | public class Cubes { 5 | 6 | public static void main(String[] args) { 7 | Scanner scanner = new Scanner(System.in); 8 | 9 | while (true) { 10 | String input = scanner.nextLine(); 11 | if (input.equals("end")) { 12 | break; 13 | } 14 | 15 | int num = Integer.valueOf(input); 16 | 17 | System.out.println(num * num * num); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /part08-Part08_01.Cubes/target/classes/Cubes.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_01.Cubes/target/classes/Cubes.class -------------------------------------------------------------------------------- /part08-Part08_01.Cubes/target/test-classes/CubestTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_01.Cubes/target/test-classes/CubestTest.class -------------------------------------------------------------------------------- /part08-Part08_02.AverageOfPositiveNumbers/.tmcproject.json: -------------------------------------------------------------------------------- 1 | { 2 | "checkstyle": { 3 | "strategy": "fail" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /part08-Part08_02.AverageOfPositiveNumbers/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part08-Part08_02.AverageOfPositiveNumbers/src/main/java/AverageOfPositiveNumbers.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.Scanner; 3 | 4 | public class AverageOfPositiveNumbers { 5 | 6 | public static void main(String[] args) { 7 | Scanner scanner = new Scanner(System.in); 8 | int sum = 0; 9 | int count = 0; 10 | while (true) { 11 | int input = Integer.valueOf(scanner.nextLine()); 12 | if (input == 0) { 13 | break; 14 | } 15 | 16 | if (input > 0) { 17 | sum += input; 18 | count++; 19 | } 20 | } 21 | if (count == 0) { 22 | System.out.println("Cannot calculate the average"); 23 | } else { 24 | System.out.println((double) sum / count); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /part08-Part08_03.LiquidContainers/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part08-Part08_03.LiquidContainers/target/classes/LiquidContainers.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_03.LiquidContainers/target/classes/LiquidContainers.class -------------------------------------------------------------------------------- /part08-Part08_03.LiquidContainers/target/test-classes/LiquidContainersTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_03.LiquidContainers/target/test-classes/LiquidContainersTest.class -------------------------------------------------------------------------------- /part08-Part08_04.LiquidContainers2/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part08-Part08_04.LiquidContainers2/src/main/java/Container.java: -------------------------------------------------------------------------------- 1 | public class Container { 2 | private int volume; 3 | 4 | public Container() { 5 | this.volume = 0; 6 | } 7 | 8 | public int contains() { 9 | return this.volume; 10 | } 11 | 12 | public void add(int amount) { 13 | if (amount < 0) { 14 | return; 15 | } else if (this.volume + amount >= 100) { 16 | this.volume = 100; 17 | } else { 18 | this.volume += amount; 19 | } 20 | } 21 | 22 | public void remove(int amount) { 23 | if (amount < 0) { 24 | return; 25 | } else if (this.volume <= amount) { 26 | this.volume = 0; 27 | } else { 28 | this.volume -= amount; 29 | } 30 | } 31 | 32 | public String toString() { 33 | return this.volume + "/100"; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /part08-Part08_05.TodoList/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part08-Part08_05.TodoList/src/main/java/Main.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.Scanner; 3 | 4 | public class Main { 5 | 6 | public static void main(String[] args) { 7 | 8 | // Here you can try out the combined functionality of your classes 9 | TodoList list = new TodoList(); 10 | Scanner scanner = new Scanner(System.in); 11 | 12 | UserInterface ui = new UserInterface(list, scanner); 13 | ui.start(); 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /part08-Part08_05.TodoList/src/main/java/TodoList.java: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList; 2 | 3 | public class TodoList { 4 | private ArrayList todolist; 5 | 6 | public TodoList() { 7 | this.todolist = new ArrayList<>(); 8 | } 9 | 10 | public void add(String task) { 11 | this.todolist.add(task); 12 | } 13 | 14 | public void print() { 15 | for (int i=0; i map = new HashMap<>(); 9 | 10 | map.put("matthew", "matt"); 11 | map.put("michael", "mix"); 12 | map.put("arthur", "artie"); 13 | 14 | System.out.println(map.get("matthew")); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /part08-Part08_06.Nicknames/src/test/java/NicknamesTest.java: -------------------------------------------------------------------------------- 1 | 2 | import fi.helsinki.cs.tmc.edutestutils.Points; 3 | import org.junit.*; 4 | 5 | @Points("08-06") 6 | public class NicknamesTest { 7 | 8 | @Test 9 | public void noTests() throws Exception { 10 | // no tests 11 | 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /part08-Part08_06.Nicknames/target/classes/Nicknames.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_06.Nicknames/target/classes/Nicknames.class -------------------------------------------------------------------------------- /part08-Part08_06.Nicknames/target/test-classes/NicknamesTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_06.Nicknames/target/test-classes/NicknamesTest.class -------------------------------------------------------------------------------- /part08-Part08_07.Abbreviations/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part08-Part08_07.Abbreviations/src/main/java/Abbreviations.java: -------------------------------------------------------------------------------- 1 | import java.util.HashMap; 2 | 3 | public class Abbreviations { 4 | private HashMap abbreviations; 5 | 6 | public Abbreviations() { 7 | this.abbreviations = new HashMap<>(); 8 | } 9 | 10 | public void addAbbreviation(String abbreviation, String explanation) { 11 | this.abbreviations.put(abbreviation, explanation); 12 | } 13 | 14 | public boolean hasAbbreviation(String abbreviation) { 15 | if (this.abbreviations.containsKey(abbreviation)) { 16 | return true; 17 | } 18 | 19 | return false; 20 | } 21 | 22 | public String findExplanationFor(String abbreviation) { 23 | if (this.hasAbbreviation(abbreviation)) { 24 | return this.abbreviations.get(abbreviation); 25 | } else { 26 | return null; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /part08-Part08_07.Abbreviations/src/main/java/Main.java: -------------------------------------------------------------------------------- 1 | 2 | public class Main { 3 | 4 | public static void main(String[] args) { 5 | // Test your program here! 6 | Abbreviations abbreviations = new Abbreviations(); 7 | abbreviations.addAbbreviation("e.g.", "for example"); 8 | abbreviations.addAbbreviation("etc.", "and so on"); 9 | abbreviations.addAbbreviation("i.e.", "more precisely"); 10 | 11 | String text = "e.g. i.e. etc. lol"; 12 | 13 | for (String part: text.split(" ")) { 14 | if(abbreviations.hasAbbreviation(part)) { 15 | part = abbreviations.findExplanationFor(part); 16 | } 17 | 18 | System.out.print(part); 19 | System.out.print(" "); 20 | } 21 | 22 | System.out.println(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /part08-Part08_07.Abbreviations/target/classes/Abbreviations.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_07.Abbreviations/target/classes/Abbreviations.class -------------------------------------------------------------------------------- /part08-Part08_07.Abbreviations/target/classes/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_07.Abbreviations/target/classes/Main.class -------------------------------------------------------------------------------- /part08-Part08_07.Abbreviations/target/test-classes/AbbreviationsTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_07.Abbreviations/target/test-classes/AbbreviationsTest.class -------------------------------------------------------------------------------- /part08-Part08_08.PrintMeMyHashmap/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part08-Part08_08.PrintMeMyHashmap/target/classes/Program.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_08.PrintMeMyHashmap/target/classes/Program.class -------------------------------------------------------------------------------- /part08-Part08_08.PrintMeMyHashmap/target/test-classes/PrintMeMyHashmapTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_08.PrintMeMyHashmap/target/test-classes/PrintMeMyHashmapTest.class -------------------------------------------------------------------------------- /part08-Part08_09.PrintMeAnotherHashmap/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part08-Part08_09.PrintMeAnotherHashmap/src/main/java/Program.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.HashMap; 3 | 4 | public class Program { 5 | 6 | public static void main(String[] args) { 7 | // Test your program here! 8 | HashMap hashmap = new HashMap<>(); 9 | hashmap.put("sense", new Book("Sense and Sensibility", 1811, "...")); 10 | hashmap.put("prejudice", new Book("Pride and prejudice", 1813, "....")); 11 | 12 | printValues(hashmap); 13 | System.out.println("---"); 14 | printValueIfNameContains(hashmap, "prejud"); 15 | } 16 | 17 | public static void printValues(HashMap hashmap) { 18 | for (Book book : hashmap.values()) { 19 | System.out.println(book); 20 | } 21 | } 22 | 23 | public static void printValueIfNameContains(HashMap hashmap, String text) { 24 | for (Book book : hashmap.values()) { 25 | if (book.getName().contains(text)) { 26 | System.out.println(book); 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /part08-Part08_09.PrintMeAnotherHashmap/target/classes/Book.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_09.PrintMeAnotherHashmap/target/classes/Book.class -------------------------------------------------------------------------------- /part08-Part08_09.PrintMeAnotherHashmap/target/classes/Program.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_09.PrintMeAnotherHashmap/target/classes/Program.class -------------------------------------------------------------------------------- /part08-Part08_09.PrintMeAnotherHashmap/target/test-classes/PrintMeAnotherHashmapTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_09.PrintMeAnotherHashmap/target/test-classes/PrintMeAnotherHashmapTest.class -------------------------------------------------------------------------------- /part08-Part08_10.IOweYou/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part08-Part08_10.IOweYou/Part08_10.IOweYou.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /part08-Part08_10.IOweYou/src/main/java/IOU.java: -------------------------------------------------------------------------------- 1 | import java.util.HashMap; 2 | 3 | public class IOU { 4 | private HashMap IOU; 5 | 6 | public IOU() { 7 | this.IOU = new HashMap<>(); 8 | } 9 | 10 | public void setSum(String toWhom, double amount) { 11 | this.IOU.put(toWhom, amount); 12 | } 13 | 14 | public double howMuchDoIOweTo(String toWhom) { 15 | return this.IOU.getOrDefault(toWhom, 0.0); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /part08-Part08_10.IOweYou/src/main/java/Main.java: -------------------------------------------------------------------------------- 1 | 2 | public class Main { 3 | 4 | public static void main(String[] args) { 5 | // Test your program here 6 | IOU mattsIOU = new IOU(); 7 | mattsIOU.setSum("Arthur", 51.5); 8 | mattsIOU.setSum("Arthur", 10.5); 9 | 10 | System.out.println(mattsIOU.howMuchDoIOweTo("Arthur")); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /part08-Part08_10.IOweYou/target/classes/IOU.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_10.IOweYou/target/classes/IOU.class -------------------------------------------------------------------------------- /part08-Part08_10.IOweYou/target/classes/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_10.IOweYou/target/classes/Main.class -------------------------------------------------------------------------------- /part08-Part08_10.IOweYou/target/test-classes/IOUTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_10.IOweYou/target/test-classes/IOUTest.class -------------------------------------------------------------------------------- /part08-Part08_11.SameDate/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /part08-Part08_11.SameDate/.idea/.name: -------------------------------------------------------------------------------- 1 | Part08_11.SameDate -------------------------------------------------------------------------------- /part08-Part08_11.SameDate/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /part08-Part08_11.SameDate/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /part08-Part08_11.SameDate/.idea/libraries/Maven__fi_helsinki_cs_tmc_edu_test_utils_0_4_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /part08-Part08_11.SameDate/.idea/libraries/Maven__junit_junit_4_12.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /part08-Part08_11.SameDate/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /part08-Part08_11.SameDate/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /part08-Part08_11.SameDate/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /part08-Part08_11.SameDate/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /part08-Part08_11.SameDate/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part08-Part08_11.SameDate/src/main/java/Main.java: -------------------------------------------------------------------------------- 1 | 2 | public class Main { 3 | 4 | public static void main(String[] args) { 5 | // make test programs here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /part08-Part08_12.HashedDate/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /part08-Part08_12.HashedDate/.idea/.name: -------------------------------------------------------------------------------- 1 | Part08_12.HashedDate -------------------------------------------------------------------------------- /part08-Part08_12.HashedDate/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /part08-Part08_12.HashedDate/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /part08-Part08_12.HashedDate/.idea/libraries/Maven__fi_helsinki_cs_tmc_edu_test_utils_0_4_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /part08-Part08_12.HashedDate/.idea/libraries/Maven__junit_junit_4_12.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /part08-Part08_12.HashedDate/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /part08-Part08_12.HashedDate/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /part08-Part08_12.HashedDate/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /part08-Part08_12.HashedDate/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /part08-Part08_12.HashedDate/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part08-Part08_12.HashedDate/src/main/java/Main.java: -------------------------------------------------------------------------------- 1 | 2 | public class Main { 3 | 4 | public static void main(String[] args) { 5 | // make test programs here 6 | 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /part08-Part08_13.VehicleRegistry/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /part08-Part08_13.VehicleRegistry/.idea/.name: -------------------------------------------------------------------------------- 1 | Osa08_13.VehicleRegistry -------------------------------------------------------------------------------- /part08-Part08_13.VehicleRegistry/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /part08-Part08_13.VehicleRegistry/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /part08-Part08_13.VehicleRegistry/.idea/libraries/Maven__fi_helsinki_cs_tmc_edu_test_utils_0_4_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /part08-Part08_13.VehicleRegistry/.idea/libraries/Maven__junit_junit_4_12.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /part08-Part08_13.VehicleRegistry/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /part08-Part08_13.VehicleRegistry/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /part08-Part08_13.VehicleRegistry/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /part08-Part08_13.VehicleRegistry/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /part08-Part08_13.VehicleRegistry/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part08-Part08_13.VehicleRegistry/target/classes/LicensePlate.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_13.VehicleRegistry/target/classes/LicensePlate.class -------------------------------------------------------------------------------- /part08-Part08_13.VehicleRegistry/target/classes/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_13.VehicleRegistry/target/classes/Main.class -------------------------------------------------------------------------------- /part08-Part08_13.VehicleRegistry/target/classes/VehicleRegistry.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_13.VehicleRegistry/target/classes/VehicleRegistry.class -------------------------------------------------------------------------------- /part08-Part08_13.VehicleRegistry/target/test-classes/VehicleRegistryTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_13.VehicleRegistry/target/test-classes/VehicleRegistryTest.class -------------------------------------------------------------------------------- /part08-Part08_14.DictionaryOfManyTranslations/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part08-Part08_14.DictionaryOfManyTranslations/src/main/java/DictionaryOfManyTranslations.java: -------------------------------------------------------------------------------- 1 | import java.lang.reflect.Array; 2 | import java.util.ArrayList; 3 | import java.util.HashMap; 4 | 5 | public class DictionaryOfManyTranslations { 6 | private HashMap> dictionary; 7 | 8 | public DictionaryOfManyTranslations() { 9 | this.dictionary = new HashMap<>(); 10 | } 11 | 12 | public void add(String word, String translation) { 13 | this.dictionary.putIfAbsent(word, new ArrayList<>()); 14 | this.dictionary.get(word).add(translation); 15 | } 16 | 17 | public ArrayList translate(String word) { 18 | ArrayList item = this.dictionary.get(word); 19 | if (item == null) { 20 | ArrayList empty = new ArrayList<>(); 21 | return empty; 22 | } else { 23 | return this.dictionary.get(word); 24 | } 25 | } 26 | 27 | public void remove(String word) { 28 | this.dictionary.remove(word); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /part08-Part08_14.DictionaryOfManyTranslations/src/main/java/Program.java: -------------------------------------------------------------------------------- 1 | 2 | public class Program { 3 | 4 | public static void main(String[] args) { 5 | DictionaryOfManyTranslations dictionary = new DictionaryOfManyTranslations(); 6 | dictionary.add("lie", "maata"); 7 | dictionary.add("lie", "valehdella"); 8 | 9 | dictionary.add("bow", "jousi"); 10 | dictionary.add("bow", "kumartaa"); 11 | 12 | System.out.println(dictionary.translate("lie")); 13 | dictionary.remove("bow"); 14 | System.out.println(dictionary.translate("try")); 15 | System.out.println(dictionary.translate("test")); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /part08-Part08_14.DictionaryOfManyTranslations/target/classes/DictionaryOfManyTranslations.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_14.DictionaryOfManyTranslations/target/classes/DictionaryOfManyTranslations.class -------------------------------------------------------------------------------- /part08-Part08_14.DictionaryOfManyTranslations/target/classes/Program.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_14.DictionaryOfManyTranslations/target/classes/Program.class -------------------------------------------------------------------------------- /part08-Part08_14.DictionaryOfManyTranslations/target/test-classes/DictionaryOfManyTranslationsTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_14.DictionaryOfManyTranslations/target/test-classes/DictionaryOfManyTranslationsTest.class -------------------------------------------------------------------------------- /part08-Part08_15.StorageFacility/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part08-Part08_15.StorageFacility/src/main/java/Program.java: -------------------------------------------------------------------------------- 1 | 2 | public class Program { 3 | 4 | public static void main(String[] args) { 5 | // Test your program here 6 | StorageFacility facility = new StorageFacility(); 7 | facility.add("a14", "ice skates"); 8 | facility.add("a14", "ice hockey stick"); 9 | facility.add("a14", "ice skates"); 10 | 11 | facility.add("f156", "rollerblades"); 12 | facility.add("f156", "rollerblades"); 13 | 14 | facility.add("g63", "six"); 15 | facility.add("g63", "pi"); 16 | 17 | facility.remove("f156", "rollerblades"); 18 | 19 | System.out.println(facility.contents("f156")); 20 | 21 | facility.remove("f156", "rollerblades"); 22 | 23 | System.out.println(facility.storageUnits()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /part08-Part08_15.StorageFacility/target/classes/Program.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_15.StorageFacility/target/classes/Program.class -------------------------------------------------------------------------------- /part08-Part08_15.StorageFacility/target/classes/StorageFacility.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_15.StorageFacility/target/classes/StorageFacility.class -------------------------------------------------------------------------------- /part08-Part08_15.StorageFacility/target/test-classes/StorageFacilityTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part08-Part08_15.StorageFacility/target/test-classes/StorageFacilityTest.class -------------------------------------------------------------------------------- /part09-Part09_01.ABC/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part09-Part09_01.ABC/Part09_01.ABC.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /part09-Part09_01.ABC/src/main/java/A.java: -------------------------------------------------------------------------------- 1 | public class A { 2 | 3 | public void a() { 4 | System.out.println('A'); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /part09-Part09_01.ABC/src/main/java/B.java: -------------------------------------------------------------------------------- 1 | public class B extends A { 2 | 3 | public void b() { 4 | System.out.println('B'); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /part09-Part09_01.ABC/src/main/java/C.java: -------------------------------------------------------------------------------- 1 | public class C extends B { 2 | 3 | public void c() { 4 | System.out.println('C'); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /part09-Part09_01.ABC/src/main/java/Main.java: -------------------------------------------------------------------------------- 1 | 2 | public class Main { 3 | 4 | public static void main(String[] args) { 5 | // write your test code here 6 | 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /part09-Part09_02.PersonAndSubclasses/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part09-Part09_02.PersonAndSubclasses/src/main/java/Person.java: -------------------------------------------------------------------------------- 1 | public class Person { 2 | private String name; 3 | private String address; 4 | 5 | public Person (String name, String address) { 6 | this.name=name; 7 | this.address=address; 8 | } 9 | 10 | public String getName() { 11 | return name; 12 | } 13 | 14 | public String getAddress() { 15 | return address; 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | return name + '\n' + " " + address; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /part09-Part09_02.PersonAndSubclasses/src/main/java/Student.java: -------------------------------------------------------------------------------- 1 | public class Student extends Person { 2 | private int credits; 3 | 4 | public Student(String name, String address) { 5 | super(name, address); 6 | this.credits = 0; 7 | } 8 | 9 | public void study() { 10 | this.credits++; 11 | } 12 | 13 | public int credits() { 14 | return credits; 15 | } 16 | 17 | @Override 18 | public String toString() { 19 | return super.getName() + '\n' + " " + super.getAddress() + '\n' + " Study credits " + this.credits(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /part09-Part09_02.PersonAndSubclasses/src/main/java/Teacher.java: -------------------------------------------------------------------------------- 1 | public class Teacher extends Person { 2 | private int salary; 3 | 4 | public Teacher(String name, String address, int salary) { 5 | super(name, address); 6 | this.salary = salary; 7 | } 8 | 9 | public int getSalary() { 10 | return salary; 11 | } 12 | 13 | @Override 14 | public String toString() { 15 | return super.getName() + '\n' + " " + super.getAddress() + '\n' + " salary " + this.getSalary() + " euro/month"; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /part09-Part09_02.PersonAndSubclasses/target/classes/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_02.PersonAndSubclasses/target/classes/Main.class -------------------------------------------------------------------------------- /part09-Part09_02.PersonAndSubclasses/target/classes/Person.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_02.PersonAndSubclasses/target/classes/Person.class -------------------------------------------------------------------------------- /part09-Part09_02.PersonAndSubclasses/target/classes/Student.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_02.PersonAndSubclasses/target/classes/Student.class -------------------------------------------------------------------------------- /part09-Part09_02.PersonAndSubclasses/target/classes/Teacher.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_02.PersonAndSubclasses/target/classes/Teacher.class -------------------------------------------------------------------------------- /part09-Part09_02.PersonAndSubclasses/target/test-classes/PersonAndSubclassesTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_02.PersonAndSubclasses/target/test-classes/PersonAndSubclassesTest.class -------------------------------------------------------------------------------- /part09-Part09_03.Warehousing/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part09-Part09_03.Warehousing/src/main/java/Main.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | public class Main { 4 | 5 | public static void main(String[] args) { 6 | // here you can write code to test your classes 7 | // the usual: 8 | ProductWarehouseWithHistory juice = new ProductWarehouseWithHistory("coffee", 10.0, 5.0); 9 | juice.takeFromWarehouse(7); 10 | // juice.addToWarehouse(1.0); 11 | //System.out.println(juice.history()); // [1000.0, 988.7, 989.7] 12 | 13 | juice.printAnalysis(); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /part09-Part09_03.Warehousing/src/main/java/ProductWarehouse.java: -------------------------------------------------------------------------------- 1 | public class ProductWarehouse extends Warehouse { 2 | private String productName; 3 | 4 | public ProductWarehouse(String productName, double capacity) { 5 | super(capacity); 6 | this.productName = productName; 7 | } 8 | 9 | public String getName() { 10 | return this.productName; 11 | } 12 | 13 | public void setName(String newName) { 14 | this.productName = newName; 15 | } 16 | 17 | public String toString() { 18 | // Juice: balance = 64.5, space left 123.5 19 | return this.productName + ": balance = " + super.getBalance() + ", space left " + super.howMuchSpaceLeft(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /part09-Part09_03.Warehousing/target/classes/ChangeHistory.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_03.Warehousing/target/classes/ChangeHistory.class -------------------------------------------------------------------------------- /part09-Part09_03.Warehousing/target/classes/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_03.Warehousing/target/classes/Main.class -------------------------------------------------------------------------------- /part09-Part09_03.Warehousing/target/classes/ProductWarehouse.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_03.Warehousing/target/classes/ProductWarehouse.class -------------------------------------------------------------------------------- /part09-Part09_03.Warehousing/target/classes/ProductWarehouseWithHistory.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_03.Warehousing/target/classes/ProductWarehouseWithHistory.class -------------------------------------------------------------------------------- /part09-Part09_03.Warehousing/target/classes/Warehouse.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_03.Warehousing/target/classes/Warehouse.class -------------------------------------------------------------------------------- /part09-Part09_03.Warehousing/target/test-classes/A_ProductWarehouseTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_03.Warehousing/target/test-classes/A_ProductWarehouseTest.class -------------------------------------------------------------------------------- /part09-Part09_03.Warehousing/target/test-classes/B_ChangeHistoryTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_03.Warehousing/target/test-classes/B_ChangeHistoryTest.class -------------------------------------------------------------------------------- /part09-Part09_03.Warehousing/target/test-classes/C_ProductWarehouseWithHistoryTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_03.Warehousing/target/test-classes/C_ProductWarehouseWithHistoryTest.class -------------------------------------------------------------------------------- /part09-Part09_04.DifferentKindsOfBoxes/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part09-Part09_04.DifferentKindsOfBoxes/src/main/java/Box.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.ArrayList; 3 | 4 | public abstract class Box { 5 | 6 | public abstract void add(Item item); 7 | 8 | public void add(ArrayList items) { 9 | for (Item item : items) { 10 | Box.this.add(item); 11 | } 12 | } 13 | 14 | public abstract boolean isInBox(Item item); 15 | } 16 | -------------------------------------------------------------------------------- /part09-Part09_04.DifferentKindsOfBoxes/src/main/java/BoxWithMaxWeight.java: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList; 2 | 3 | public class BoxWithMaxWeight extends Box { 4 | private int capacity; 5 | private ArrayList items; 6 | 7 | public BoxWithMaxWeight(int capacity) { 8 | this.capacity = capacity; 9 | this.items = new ArrayList<>(); 10 | } 11 | 12 | public void add(Item item) { 13 | if (this.capacity >= item.getWeight()) { 14 | this.capacity -= item.getWeight(); 15 | items.add(item); 16 | } 17 | } 18 | 19 | public boolean isInBox(Item item) { 20 | for (Item it: items) { 21 | if (it.equals(item)) { 22 | return true; 23 | } 24 | } 25 | return false; 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /part09-Part09_04.DifferentKindsOfBoxes/src/main/java/Item.java: -------------------------------------------------------------------------------- 1 | import java.util.Objects; 2 | 3 | public class Item { 4 | 5 | private String name; 6 | private int weight; 7 | 8 | public Item(String name, int weight) { 9 | this.name = name; 10 | this.weight = weight; 11 | } 12 | 13 | public Item(String name) { 14 | this(name, 0); 15 | } 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public int getWeight() { 22 | return weight; 23 | } 24 | 25 | @Override 26 | public boolean equals(Object o) { 27 | if (this == o) return true; 28 | if (o == null || getClass() != o.getClass()) return false; 29 | Item item = (Item) o; 30 | return Objects.equals(this.getName(), item.getName()); 31 | } 32 | 33 | @Override 34 | public int hashCode() { 35 | return Objects.hash(name); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /part09-Part09_04.DifferentKindsOfBoxes/src/main/java/Main.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | public class Main { 4 | 5 | public static void main(String[] args) { 6 | // You can test your program here 7 | BoxWithMaxWeight coffeeBox = new BoxWithMaxWeight(10); 8 | coffeeBox.add(new Item("Saludo", 5)); 9 | coffeeBox.add(new Item("Pirkka", 5)); 10 | coffeeBox.add(new Item("Kopi Luwak", 5)); 11 | 12 | System.out.println(coffeeBox.isInBox(new Item("Saludo"))); 13 | System.out.println(coffeeBox.isInBox(new Item("Pirkka"))); 14 | System.out.println(coffeeBox.isInBox(new Item("Kopi Luwak"))); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /part09-Part09_04.DifferentKindsOfBoxes/src/main/java/MisplacingBox.java: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList; 2 | 3 | public class MisplacingBox extends Box { 4 | private ArrayList items; 5 | 6 | public MisplacingBox() { 7 | this.items = new ArrayList<>(); 8 | } 9 | 10 | public void add(Item item) { 11 | items.add(item); 12 | } 13 | 14 | public boolean isInBox(Item item) { 15 | return false; 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /part09-Part09_04.DifferentKindsOfBoxes/src/main/java/OneItemBox.java: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList; 2 | 3 | public class OneItemBox extends Box { 4 | private int capacity; 5 | private ArrayList items; 6 | 7 | public OneItemBox() { 8 | this.capacity = 1; 9 | this.items = new ArrayList<>(); 10 | } 11 | 12 | public void add(Item item) { 13 | if (this.capacity > 0) { 14 | this.capacity -= 1; 15 | items.add(item); 16 | } 17 | } 18 | 19 | public boolean isInBox(Item item) { 20 | for (Item it: items) { 21 | if (it.equals(item)) { 22 | return true; 23 | } 24 | } 25 | return false; 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /part09-Part09_04.DifferentKindsOfBoxes/target/classes/Box.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_04.DifferentKindsOfBoxes/target/classes/Box.class -------------------------------------------------------------------------------- /part09-Part09_04.DifferentKindsOfBoxes/target/classes/BoxWithMaxWeight.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_04.DifferentKindsOfBoxes/target/classes/BoxWithMaxWeight.class -------------------------------------------------------------------------------- /part09-Part09_04.DifferentKindsOfBoxes/target/classes/Item.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_04.DifferentKindsOfBoxes/target/classes/Item.class -------------------------------------------------------------------------------- /part09-Part09_04.DifferentKindsOfBoxes/target/classes/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_04.DifferentKindsOfBoxes/target/classes/Main.class -------------------------------------------------------------------------------- /part09-Part09_04.DifferentKindsOfBoxes/target/test-classes/DifferentKindsOfBoxesTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_04.DifferentKindsOfBoxes/target/test-classes/DifferentKindsOfBoxesTest.class -------------------------------------------------------------------------------- /part09-Part09_05.TacoBoxes/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part09-Part09_05.TacoBoxes/src/main/java/CustomTacoBox.java: -------------------------------------------------------------------------------- 1 | public class CustomTacoBox implements TacoBox { 2 | private int tacos; 3 | 4 | public CustomTacoBox(int tacos) { 5 | this.tacos = tacos; 6 | } 7 | 8 | public int tacosRemaining() { 9 | return this.tacos; 10 | } 11 | 12 | public void eat() { 13 | if (this.tacos == 0) { 14 | return; 15 | } 16 | this.tacos -= 1; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /part09-Part09_05.TacoBoxes/src/main/java/Main.java: -------------------------------------------------------------------------------- 1 | 2 | public class Main { 3 | 4 | public static void main(String[] args) { 5 | // Test your code here! 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /part09-Part09_05.TacoBoxes/src/main/java/TacoBox.java: -------------------------------------------------------------------------------- 1 | 2 | public interface TacoBox { 3 | 4 | int tacosRemaining(); 5 | 6 | void eat(); 7 | } 8 | -------------------------------------------------------------------------------- /part09-Part09_05.TacoBoxes/src/main/java/TripleTacoBox.java: -------------------------------------------------------------------------------- 1 | public class TripleTacoBox implements TacoBox { 2 | public int tacos; 3 | 4 | public TripleTacoBox() { 5 | this.tacos = 3; 6 | } 7 | 8 | public int tacosRemaining() { 9 | return this.tacos; 10 | } 11 | 12 | public void eat() { 13 | if (this.tacos == 0) { 14 | return; 15 | } 16 | this.tacos -= 1; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /part09-Part09_06.InterfaceInABox/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part09-Part09_06.InterfaceInABox/src/main/java/Book.java: -------------------------------------------------------------------------------- 1 | public class Book implements Packable { 2 | private String author; 3 | private String name; 4 | private Double weight; 5 | 6 | public Book(String author, String name, double weight) { 7 | this.author=author; 8 | this.name=name; 9 | this.weight= weight; 10 | } 11 | 12 | public double weight(){ 13 | return this.weight; 14 | }; 15 | 16 | @Override 17 | public String toString() { 18 | return this.author + ": " + this.name; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /part09-Part09_06.InterfaceInABox/src/main/java/Box.java: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList; 2 | 3 | public class Box implements Packable { 4 | private double capacity; 5 | private ArrayList items; 6 | 7 | public Box(double capacity) { 8 | this.capacity=capacity; 9 | items = new ArrayList<>(); 10 | } 11 | 12 | 13 | public void add(Packable item) { 14 | if (this.capacity >= item.weight()) { 15 | items.add(item); 16 | this.capacity -= item.weight(); 17 | } 18 | } 19 | 20 | public double weight() { 21 | double weight = 0; 22 | for (Packable item: items) { 23 | weight += item.weight(); 24 | } 25 | return weight; 26 | } 27 | 28 | @Override 29 | public String toString() { 30 | // Box: 6 items, total weight 4.0 kg 31 | return "Box: " + items.size() + " items, total weight " + weight() + " kg"; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /part09-Part09_06.InterfaceInABox/src/main/java/CD.java: -------------------------------------------------------------------------------- 1 | public class CD implements Packable { 2 | private String author; 3 | private String name; 4 | private Double weight; 5 | private int year; 6 | 7 | public CD(String author, String name, int year) { 8 | this.author=author; 9 | this.name=name; 10 | this.year=year; 11 | this.weight=0.1; 12 | } 13 | 14 | public double weight(){ 15 | return this.weight; 16 | }; 17 | 18 | @Override 19 | public String toString() { 20 | return this.author + ": " + this.name + " (" + this.year + ")"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /part09-Part09_06.InterfaceInABox/src/main/java/Main.java: -------------------------------------------------------------------------------- 1 | 2 | public class Main { 3 | 4 | public static void main(String[] args) { 5 | // test your classes here 6 | Box box = new Box(10); 7 | 8 | box.add(new Book("Fyodor Dostoevsky", "Crime and Punishment", 2)) ; 9 | box.add(new Book("Robert Martin", "Clean Code", 1)); 10 | box.add(new Book("Kent Beck", "Test Driven Development", 0.7)); 11 | 12 | box.add(new CD("Pink Floyd", "Dark Side of the Moon", 1973)); 13 | box.add(new CD("Wigwam", "Nuclear Nightclub", 1975)); 14 | box.add(new CD("Rendezvous Park", "Closer to Being Here", 2012)); 15 | 16 | System.out.println(box); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /part09-Part09_06.InterfaceInABox/src/main/java/Packable.java: -------------------------------------------------------------------------------- 1 | public interface Packable { 2 | double weight(); 3 | } 4 | -------------------------------------------------------------------------------- /part09-Part09_06.InterfaceInABox/target/classes/Book.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_06.InterfaceInABox/target/classes/Book.class -------------------------------------------------------------------------------- /part09-Part09_06.InterfaceInABox/target/classes/Box.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_06.InterfaceInABox/target/classes/Box.class -------------------------------------------------------------------------------- /part09-Part09_06.InterfaceInABox/target/classes/CD.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_06.InterfaceInABox/target/classes/CD.class -------------------------------------------------------------------------------- /part09-Part09_06.InterfaceInABox/target/classes/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_06.InterfaceInABox/target/classes/Main.class -------------------------------------------------------------------------------- /part09-Part09_06.InterfaceInABox/target/classes/Packable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_06.InterfaceInABox/target/classes/Packable.class -------------------------------------------------------------------------------- /part09-Part09_06.InterfaceInABox/target/test-classes/Part1test.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_06.InterfaceInABox/target/test-classes/Part1test.class -------------------------------------------------------------------------------- /part09-Part09_06.InterfaceInABox/target/test-classes/Part2and3test.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_06.InterfaceInABox/target/test-classes/Part2and3test.class -------------------------------------------------------------------------------- /part09-Part09_07.ListAsAMethodParameter/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part09-Part09_07.ListAsAMethodParameter/src/main/java/mainProgram.java: -------------------------------------------------------------------------------- 1 | import java.util.List; 2 | 3 | public class mainProgram { 4 | 5 | public static void main(String[] args) { 6 | // test your method here 7 | 8 | } 9 | 10 | // Implement here a method returnSize 11 | // which returns the size of the list given to it 12 | //as a parameter 13 | public static int returnSize(List list) { 14 | return list.size(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /part09-Part09_08.MapAsAMethodParameter/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part09-Part09_08.MapAsAMethodParameter/src/main/java/MainProgram.java: -------------------------------------------------------------------------------- 1 | import java.util.HashMap; 2 | import java.util.Map; 3 | 4 | public class MainProgram { 5 | 6 | public static void main(String[] args) { 7 | // test your method here 8 | Map names = new HashMap<>(); 9 | names.put("1", "first"); 10 | names.put("2", "second"); 11 | 12 | System.out.println(returnSize(names)); 13 | } 14 | 15 | // Implement here a method returnSize, which takes a Map-object as a parameter 16 | // and returns the size of the map object 17 | public static int returnSize(Map maps) { 18 | int size = 0; 19 | for (Object item : maps.keySet()) { 20 | size++; 21 | } 22 | return size; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /part09-Part09_08.MapAsAMethodParameter/target/classes/MainProgram.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_08.MapAsAMethodParameter/target/classes/MainProgram.class -------------------------------------------------------------------------------- /part09-Part09_08.MapAsAMethodParameter/target/test-classes/MapAsAMethodParameterTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_08.MapAsAMethodParameter/target/test-classes/MapAsAMethodParameterTest.class -------------------------------------------------------------------------------- /part09-Part09_09.SetAsMethodParameter/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part09-Part09_09.SetAsMethodParameter/src/main/java/Main.java: -------------------------------------------------------------------------------- 1 | import java.util.HashSet; 2 | import java.util.Set; 3 | 4 | public class Main { 5 | 6 | public static void main(String[] args) { 7 | // You can test your method here 8 | Set names = new HashSet<>(); 9 | names.add("first"); 10 | names.add("first"); 11 | names.add("second"); 12 | names.add("second"); 13 | names.add("second"); 14 | 15 | System.out.println(returnSize(names)); 16 | } 17 | 18 | // implement the method returnSize here, which returns 19 | // the number of elements in the set that it receives as a parameter. 20 | public static int returnSize(Set set) { 21 | int size = 0; 22 | for (Object element: set) { 23 | size++; 24 | } 25 | return size; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /part09-Part09_10.OnlineShop/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part09-Part09_10.OnlineShop/src/main/java/Item.java: -------------------------------------------------------------------------------- 1 | import java.util.Objects; 2 | 3 | public class Item { 4 | private String product; 5 | private int qty; 6 | private int unitPrice; 7 | 8 | public Item(String product, int qty, int unitPrice) { 9 | this.product=product; 10 | this.qty=qty; 11 | this.unitPrice=unitPrice; 12 | } 13 | 14 | public int price() { 15 | return this.unitPrice*getQty(); 16 | } 17 | 18 | public String getProduct() { 19 | return product; 20 | } 21 | 22 | public int getQty() { 23 | return qty; 24 | } 25 | 26 | public void increaseQuantity() { 27 | this.qty++; 28 | } 29 | 30 | public String toString() { 31 | return this.product + ": " + this.qty; 32 | } 33 | 34 | @Override 35 | public boolean equals(Object o) { 36 | if (this == o) return true; 37 | if (o == null || getClass() != o.getClass()) return false; 38 | Item item = (Item) o; 39 | return Objects.equals(product, item.product); 40 | } 41 | 42 | @Override 43 | public int hashCode() { 44 | return Objects.hash(product); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /part09-Part09_10.OnlineShop/src/main/java/Main.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class Main { 4 | 5 | public static void main(String[] args) { 6 | // Test your app here 7 | Warehouse warehouse = new Warehouse(); 8 | warehouse.addProduct("coffee", 5, 10); 9 | warehouse.addProduct("milk", 3, 20); 10 | warehouse.addProduct("cream", 2, 55); 11 | warehouse.addProduct("bread", 7, 8); 12 | 13 | Scanner scanner = new Scanner(System.in); 14 | 15 | Store store = new Store(warehouse, scanner); 16 | store.shop("John"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /part09-Part09_10.OnlineShop/src/main/java/ShoppingCart.java: -------------------------------------------------------------------------------- 1 | import java.util.HashMap; 2 | import java.util.Map; 3 | 4 | public class ShoppingCart { 5 | private Map cart; 6 | 7 | public ShoppingCart() { 8 | this.cart = new HashMap<>(); 9 | } 10 | 11 | public void add(String product, int price) { 12 | Item item = new Item(product, 1, price); 13 | 14 | for (Item it : cart.values()) { 15 | if (it.equals(item)) { 16 | it.increaseQuantity(); 17 | return; 18 | } 19 | } 20 | cart.put(product, item); 21 | }; 22 | 23 | public int price() { 24 | int total = 0; 25 | for (Item item : cart.values()) { 26 | total += item.price(); 27 | } 28 | return total; 29 | } 30 | 31 | public void print() { 32 | for (Item item : cart.values()) { 33 | System.out.println(item.getProduct() + ": " + item.getQty()); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /part09-Part09_10.OnlineShop/target/classes/Item.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_10.OnlineShop/target/classes/Item.class -------------------------------------------------------------------------------- /part09-Part09_10.OnlineShop/target/classes/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_10.OnlineShop/target/classes/Main.class -------------------------------------------------------------------------------- /part09-Part09_10.OnlineShop/target/classes/ShoppingCart.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_10.OnlineShop/target/classes/ShoppingCart.class -------------------------------------------------------------------------------- /part09-Part09_10.OnlineShop/target/classes/Store.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_10.OnlineShop/target/classes/Store.class -------------------------------------------------------------------------------- /part09-Part09_10.OnlineShop/target/classes/Warehouse.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_10.OnlineShop/target/classes/Warehouse.class -------------------------------------------------------------------------------- /part09-Part09_10.OnlineShop/target/test-classes/A_WarehouseTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_10.OnlineShop/target/test-classes/A_WarehouseTest.class -------------------------------------------------------------------------------- /part09-Part09_10.OnlineShop/target/test-classes/B_ItemTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_10.OnlineShop/target/test-classes/B_ItemTest.class -------------------------------------------------------------------------------- /part09-Part09_10.OnlineShop/target/test-classes/C_ShoppingCartTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_10.OnlineShop/target/test-classes/C_ShoppingCartTest.class -------------------------------------------------------------------------------- /part09-Part09_11.Herds/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part09-Part09_11.Herds/Part09_11.Herds.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /part09-Part09_11.Herds/src/main/java/Herd.java: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList; 2 | 3 | public class Herd implements Movable { 4 | private ArrayList herd; 5 | 6 | public Herd() { 7 | this.herd = new ArrayList<>(); 8 | } 9 | 10 | public String toString() { 11 | String value = ""; 12 | 13 | for (Movable organism: herd) { 14 | value += organism.toString(); 15 | value += "\n"; 16 | } 17 | return value; 18 | }; 19 | 20 | public void addToHerd(Movable movable) { 21 | this.herd.add(movable); 22 | } 23 | 24 | public void move(int dx, int dy) { 25 | for (Movable organism: herd) { 26 | organism.move(dx, dy); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /part09-Part09_11.Herds/src/main/java/MainProgram.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | public class MainProgram { 4 | 5 | public static void main(String[] args) { 6 | //you can test the program here 7 | Herd herd = new Herd(); 8 | herd.addToHerd(new Organism(57, 66)); 9 | herd.addToHerd(new Organism(73, 56)); 10 | herd.addToHerd(new Organism(46, 52)); 11 | herd.addToHerd(new Organism(19, 107)); 12 | System.out.println(herd); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /part09-Part09_11.Herds/src/main/java/Movable.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | public interface Movable { 4 | 5 | void move(int dx, int dy); 6 | } 7 | -------------------------------------------------------------------------------- /part09-Part09_11.Herds/src/main/java/Organism.java: -------------------------------------------------------------------------------- 1 | public class Organism implements Movable { 2 | private int x; 3 | private int y; 4 | 5 | public Organism(int x, int y) { 6 | this.x = x; 7 | this.y = y; 8 | } 9 | 10 | public String toString() { 11 | return "x: " + this.x + "; y: " + this.y; 12 | }; 13 | 14 | public void move(int dx, int dy) { 15 | this.x += dx; 16 | this.y += dy; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /part09-Part09_11.Herds/target/classes/Herd.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_11.Herds/target/classes/Herd.class -------------------------------------------------------------------------------- /part09-Part09_11.Herds/target/classes/MainProgram.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_11.Herds/target/classes/MainProgram.class -------------------------------------------------------------------------------- /part09-Part09_11.Herds/target/classes/Movable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_11.Herds/target/classes/Movable.class -------------------------------------------------------------------------------- /part09-Part09_11.Herds/target/classes/Organism.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_11.Herds/target/classes/Organism.class -------------------------------------------------------------------------------- /part09-Part09_11.Herds/target/test-classes/HerdTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_11.Herds/target/test-classes/HerdTest.class -------------------------------------------------------------------------------- /part09-Part09_11.Herds/target/test-classes/OrganismTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_11.Herds/target/test-classes/OrganismTest.class -------------------------------------------------------------------------------- /part09-Part09_12.Animals/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part09-Part09_12.Animals/Part09_12.Animals.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /part09-Part09_12.Animals/src/main/java/Animal.java: -------------------------------------------------------------------------------- 1 | public abstract class Animal { 2 | private String name; 3 | 4 | public Animal(String name) { 5 | this.name = name; 6 | } 7 | 8 | public void eat() { 9 | System.out.println(this.name + " eats"); 10 | }; 11 | 12 | public void sleep() { 13 | System.out.println(this.name + " sleeps"); 14 | } 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /part09-Part09_12.Animals/src/main/java/Cat.java: -------------------------------------------------------------------------------- 1 | public class Cat extends Animal implements NoiseCapable { 2 | // private String name; 3 | 4 | public Cat() { 5 | super("Cat"); 6 | } 7 | 8 | public Cat(String name) { 9 | super(name); 10 | } 11 | 12 | public void purr() { 13 | System.out.println(super.getName() + " purrs"); 14 | } 15 | 16 | public void makeNoise() { 17 | this.purr(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /part09-Part09_12.Animals/src/main/java/Dog.java: -------------------------------------------------------------------------------- 1 | public class Dog extends Animal implements NoiseCapable { 2 | public Dog() { 3 | super("Dog"); 4 | } 5 | 6 | public Dog(String name) { 7 | super(name); 8 | } 9 | 10 | public void bark() { 11 | System.out.println(super.getName() + " barks"); 12 | } 13 | 14 | public void makeNoise() { 15 | this.bark(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /part09-Part09_12.Animals/src/main/java/Main.java: -------------------------------------------------------------------------------- 1 | 2 | public class Main { 3 | 4 | public static void main(String[] args) { 5 | // you can test how your classes work here 6 | NoiseCapable dog = new Dog(); 7 | dog.makeNoise(); 8 | 9 | NoiseCapable cat = new Cat("Garfield"); 10 | cat.makeNoise(); 11 | Cat c = (Cat) cat; 12 | c.purr(); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /part09-Part09_12.Animals/src/main/java/NoiseCapable.java: -------------------------------------------------------------------------------- 1 | public interface NoiseCapable { 2 | 3 | public void makeNoise(); 4 | } 5 | -------------------------------------------------------------------------------- /part09-Part09_12.Animals/target/classes/Animal.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_12.Animals/target/classes/Animal.class -------------------------------------------------------------------------------- /part09-Part09_12.Animals/target/classes/Cat.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_12.Animals/target/classes/Cat.class -------------------------------------------------------------------------------- /part09-Part09_12.Animals/target/classes/Dog.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_12.Animals/target/classes/Dog.class -------------------------------------------------------------------------------- /part09-Part09_12.Animals/target/classes/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_12.Animals/target/classes/Main.class -------------------------------------------------------------------------------- /part09-Part09_12.Animals/target/classes/NoiseCapable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_12.Animals/target/classes/NoiseCapable.class -------------------------------------------------------------------------------- /part09-Part09_12.Animals/target/test-classes/AnimalsTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part09-Part09_12.Animals/target/test-classes/AnimalsTest.class -------------------------------------------------------------------------------- /part10-Part10_01.AverageOfNumbers/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part10-Part10_01.AverageOfNumbers/src/main/java/AverageOfNumbers.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.ArrayList; 3 | import java.util.Scanner; 4 | 5 | public class AverageOfNumbers { 6 | 7 | public static void main(String[] args) { 8 | Scanner scanner = new Scanner(System.in); 9 | // Write your program here 10 | ArrayList inputs = new ArrayList<>(); 11 | 12 | while (true) { 13 | String input = scanner.nextLine(); 14 | 15 | if (input.equals("end")) { 16 | break; 17 | } 18 | inputs.add(input); 19 | } 20 | 21 | Double avg = inputs.stream() 22 | .mapToInt(s -> Integer.valueOf(s)) 23 | .average(). 24 | getAsDouble(); 25 | 26 | System.out.println("average of the numbers: " + avg); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /part10-Part10_02.AverageOfSelectedNumbers/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part10-Part10_03.PositiveNumbers/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part10-Part10_03.PositiveNumbers/src/main/java/PositiveNumbers.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.List; 3 | import java.util.Scanner; 4 | import java.util.stream.Collectors; 5 | 6 | public class PositiveNumbers { 7 | 8 | public static void main(String[] args) { 9 | Scanner scanner = new Scanner(System.in); 10 | // test your method here 11 | 12 | 13 | } 14 | 15 | public static List positive(List numbers) { 16 | return numbers.stream().filter(s -> s > 0).collect(Collectors.toList()); 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /part10-Part10_04.Divisible/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part10-Part10_04.Divisible/src/main/java/Divisible.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.ArrayList; 3 | import java.util.stream.Collectors; 4 | 5 | public class Divisible { 6 | 7 | public static void main(String[] args) { 8 | ArrayList numbers = new ArrayList<>(); 9 | numbers.add(3); 10 | numbers.add(2); 11 | numbers.add(-17); 12 | numbers.add(-5); 13 | numbers.add(7); 14 | 15 | ArrayList divisible = divisible(numbers); 16 | 17 | divisible.stream() 18 | .forEach(luku -> System.out.println(luku)); 19 | } 20 | 21 | public static ArrayList divisible(ArrayList numbers) { 22 | return numbers.stream().filter(s -> s%2==0 || s%3==0 || s%5==0).collect(Collectors.toCollection(ArrayList::new)); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /part10-Part10_04.Divisible/target/classes/Divisible.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part10-Part10_04.Divisible/target/classes/Divisible.class -------------------------------------------------------------------------------- /part10-Part10_04.Divisible/target/test-classes/DivisibleTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part10-Part10_04.Divisible/target/test-classes/DivisibleTest.class -------------------------------------------------------------------------------- /part10-Part10_05.PrintingUserInput/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part10-Part10_05.PrintingUserInput/src/main/java/PrintingUserInput.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.ArrayList; 3 | import java.util.Scanner; 4 | 5 | public class PrintingUserInput { 6 | 7 | public static void main(String[] args) { 8 | Scanner scanner = new Scanner(System.in); 9 | ArrayList inputs = new ArrayList<>(); 10 | 11 | while (true) { 12 | String input = scanner.nextLine(); 13 | if ((input.isEmpty())) { 14 | break; 15 | } 16 | 17 | inputs.add(input); 18 | } 19 | 20 | inputs.stream().forEach(item -> System.out.println(item)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /part10-Part10_06.LimitedNumbers/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part10-Part10_06.LimitedNumbers/src/main/java/LimitedNumbers.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.ArrayList; 3 | import java.util.Scanner; 4 | 5 | public class LimitedNumbers { 6 | 7 | public static void main(String[] args) { 8 | Scanner scanner = new Scanner(System.in); 9 | ArrayList inputs = new ArrayList<>(); 10 | 11 | while (true) { 12 | String input = scanner.nextLine(); 13 | if (Integer.valueOf(input) < 0) { 14 | break; 15 | } 16 | 17 | inputs.add(input); 18 | } 19 | 20 | inputs.stream().mapToInt(s -> Integer.valueOf(s)).filter(s -> s > 0 && s < 6).forEach(s -> System.out.println(s)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /part10-Part10_07.UniqueLastNames/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part10-Part10_07.UniqueLastNames/src/main/java/Person.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | public class Person { 5 | 6 | private String firstName; 7 | private String lastName; 8 | private int birthYear; 9 | 10 | public Person(String firstName, String lastName, int birthYear) { 11 | this.firstName = firstName; 12 | this.lastName = lastName; 13 | this.birthYear = birthYear; 14 | } 15 | 16 | public String getFirstName() { 17 | return firstName; 18 | } 19 | 20 | public String getLastName() { 21 | return lastName; 22 | } 23 | 24 | public int getBirthYear() { 25 | return birthYear; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /part10-Part10_07.UniqueLastNames/target/classes/Person.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part10-Part10_07.UniqueLastNames/target/classes/Person.class -------------------------------------------------------------------------------- /part10-Part10_07.UniqueLastNames/target/classes/UniqueLastNames.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part10-Part10_07.UniqueLastNames/target/classes/UniqueLastNames.class -------------------------------------------------------------------------------- /part10-Part10_07.UniqueLastNames/target/test-classes/UniqueLastNamesTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part10-Part10_07.UniqueLastNames/target/test-classes/UniqueLastNamesTest.class -------------------------------------------------------------------------------- /part10-Part10_08.Weighting/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part10-Part10_08.Weighting/src/main/java/Item.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | public class Item { 4 | 5 | private String name; 6 | private int weight; 7 | 8 | public Item(String name, int weight) { 9 | this.name = name; 10 | this.weight = weight; 11 | } 12 | 13 | public String getName() { 14 | return this.name; 15 | } 16 | 17 | public int getWeight() { 18 | return this.weight; 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return this.name + ": (" + this.weight + " kg)"; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /part10-Part10_08.Weighting/src/main/java/Main.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | public class Main { 4 | 5 | public static void main(String[] args) { 6 | // Use this main program for testing your classes! 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /part10-Part10_09.ReadingFilesPerLine/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part10-Part10_09.ReadingFilesPerLine/src/main/java/ReadingFilesPerLine.java: -------------------------------------------------------------------------------- 1 | 2 | import java.nio.file.Files; 3 | import java.nio.file.Paths; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import java.util.Scanner; 7 | import java.util.stream.Collectors; 8 | 9 | public class ReadingFilesPerLine { 10 | 11 | public static void main(String[] args) { 12 | Scanner scanner = new Scanner(System.in); 13 | // test the method here 14 | 15 | } 16 | 17 | public static List read(String file) { 18 | List rows = new ArrayList<>(); 19 | 20 | try { 21 | Files.lines(Paths.get(file)).forEach(row -> rows.add(row)); 22 | } catch (Exception e) { 23 | System.out.println("Error: " + e.getMessage()); 24 | } 25 | 26 | return rows; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /part10-Part10_10.BooksFromFile/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part10-Part10_10.BooksFromFile/src/main/java/Book.java: -------------------------------------------------------------------------------- 1 | 2 | public class Book { 3 | 4 | private String name; 5 | private int publishingYear; 6 | private int pageCount; 7 | private String author; 8 | 9 | public Book(String name, int ReleaseYear, int pages, String author) { 10 | this.name = name; 11 | this.publishingYear = ReleaseYear; 12 | this.pageCount = pages; 13 | this.author = author; 14 | } 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | public int getPublishingYear() { 21 | return publishingYear; 22 | } 23 | 24 | public String getAuthor() { 25 | return author; 26 | } 27 | 28 | public int getPagecount() { 29 | return pageCount; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /part10-Part10_10.BooksFromFile/src/main/java/BooksFromFile.java: -------------------------------------------------------------------------------- 1 | 2 | import java.nio.file.Files; 3 | import java.nio.file.Paths; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import java.util.Scanner; 7 | import java.util.stream.Collectors; 8 | 9 | public class BooksFromFile { 10 | 11 | public static void main(String[] args) { 12 | Scanner scanner = new Scanner(System.in); 13 | // test your method here 14 | 15 | } 16 | 17 | public static List readBooks(String file) { 18 | ArrayList books = new ArrayList<>(); 19 | 20 | try { 21 | Files.lines(Paths.get(file)) 22 | .map(row -> row.split(",")) 23 | .filter(parts -> parts.length >= 4) 24 | .map(parts -> new Book(parts[0], Integer.valueOf(parts[1]), Integer.valueOf(parts[2]), parts[3])) 25 | .forEach(book -> books.add(book)); 26 | } catch(Exception e) { 27 | System.out.println("Error: " + e.getMessage()); 28 | } 29 | 30 | return books; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /part10-Part10_11.WageOrder/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part10-Part10_11.WageOrder/src/main/java/Human.java: -------------------------------------------------------------------------------- 1 | 2 | public class Human implements Comparable { 3 | 4 | private int wage; 5 | private String name; 6 | 7 | public Human(String name, int wage) { 8 | this.name = name; 9 | this.wage = wage; 10 | } 11 | 12 | public String getName() { 13 | return name; 14 | } 15 | 16 | public int getWage() { 17 | return wage; 18 | } 19 | 20 | 21 | @Override 22 | public String toString() { 23 | return name + " " + wage; 24 | } 25 | 26 | public int compareTo(Human human) { 27 | return human.getWage() - this.wage ; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /part10-Part10_11.WageOrder/src/main/java/MainProgram.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.ArrayList; 3 | import java.util.Collections; 4 | 5 | public class MainProgram { 6 | 7 | public static void main(String[] args) { 8 | ArrayList humans = new ArrayList<>(); 9 | humans.add(new Human("Matti", 150000)); 10 | humans.add(new Human("Merja", 500)); 11 | humans.add(new Human("Pertti", 80)); 12 | 13 | System.out.println(humans); 14 | 15 | /* 16 | * Uncomment the comment below when you have completed the compareTo-method. 17 | */ 18 | //Collections.sort(humans); 19 | System.out.println(humans); 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /part10-Part10_12.StudentsOnAlphabeticalOrder/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part10-Part10_12.StudentsOnAlphabeticalOrder/src/main/java/MainProgram.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | public class MainProgram { 4 | 5 | public static void main(String[] args) { 6 | // Student first = new Student("jamo"); 7 | // Student second = new Student("jamo1"); 8 | // System.out.println(first.compareTo(second)); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /part10-Part10_12.StudentsOnAlphabeticalOrder/src/main/java/Student.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | public class Student implements Comparable { 4 | 5 | private String name; 6 | 7 | public Student(String name) { 8 | this.name = name; 9 | } 10 | 11 | public String getName() { 12 | return name; 13 | } 14 | 15 | @Override 16 | public String toString() { 17 | return name; 18 | } 19 | 20 | @Override 21 | public int compareTo(Student o) { 22 | return this.getName().compareTo(o.getName()); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /part10-Part10_13.LiteracyComparison/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part10-Part10_13.LiteracyComparison/src/main/java/LiteracyComparison.java: -------------------------------------------------------------------------------- 1 | 2 | import java.io.IOException; 3 | import java.nio.file.Files; 4 | import java.nio.file.Paths; 5 | import java.util.ArrayList; 6 | 7 | public class LiteracyComparison { 8 | 9 | public static void main(String[] args) { 10 | ArrayList> lines = new ArrayList<>(); 11 | 12 | try { 13 | Files.lines(Paths.get("literacy.csv")) 14 | .map(row -> row.split(",")) 15 | .filter(parts -> parts.length >= 6) 16 | // .filter(parts -> { 17 | // parts[2] = parts[2].trim(); 18 | // String[] gender = parts[2].split("\\s+"); 19 | // return String.format(gender[0]).equals("female"); 20 | // }) 21 | .sorted((p1, p2) -> { 22 | return p1[5].compareTo(p2[5]); 23 | }) 24 | .forEach(p -> System.out.println(p[3] + " (" + p[4] + "), " + String.format(p[2].trim().split("\\s+")[0]) + ", " + p[5])); 25 | } catch (Exception e) { 26 | System.out.println(e); 27 | } 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /part10-Part10_13.LiteracyComparison/target/classes/LiteracyComparison.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part10-Part10_13.LiteracyComparison/target/classes/LiteracyComparison.class -------------------------------------------------------------------------------- /part10-Part10_13.LiteracyComparison/target/test-classes/LiteracyComparisonTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part10-Part10_13.LiteracyComparison/target/test-classes/LiteracyComparisonTest.class -------------------------------------------------------------------------------- /part10-Part10_14.Literature/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part10-Part10_14.Literature/src/main/java/Book.java: -------------------------------------------------------------------------------- 1 | public class Book { 2 | private String name; 3 | private int age; 4 | 5 | public Book(String name, int age) { 6 | this.name=name; 7 | this.age=age; 8 | } 9 | 10 | public String getName() { 11 | return name; 12 | } 13 | 14 | public int getAge() { 15 | return age; 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | return this.getName() + "(recommended for " + this.getAge() + " years-olds or older)"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /part10-Part10_14.Literature/src/main/java/MainProgram.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.ArrayList; 3 | import java.util.Collections; 4 | import java.util.Comparator; 5 | import java.util.Scanner; 6 | 7 | public class MainProgram { 8 | 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | ArrayList inputs = new ArrayList<>(); 12 | 13 | while (true) { 14 | System.out.println("Input the name of the book, empty stops: "); 15 | String name = scanner.nextLine(); 16 | if (name.isEmpty()) { 17 | break; 18 | } 19 | 20 | System.out.println("Input the age recommendation: "); 21 | Integer age = Integer.valueOf(scanner.nextLine()); 22 | 23 | inputs.add(new Book(name, age)); 24 | } 25 | 26 | System.out.println(inputs.size() + " books in total."); 27 | 28 | Comparator comparator = Comparator 29 | .comparing(Book::getAge) 30 | .thenComparing(Book::getName); 31 | Collections.sort(inputs, comparator); 32 | 33 | System.out.println("Books"); 34 | for (Book book: inputs) { 35 | System.out.println(book); 36 | } 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /part10-Part10_14.Literature/target/classes/Book.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part10-Part10_14.Literature/target/classes/Book.class -------------------------------------------------------------------------------- /part10-Part10_14.Literature/target/classes/MainProgram.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part10-Part10_14.Literature/target/classes/MainProgram.class -------------------------------------------------------------------------------- /part10-Part10_14.Literature/target/test-classes/LiteratureTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part10-Part10_14.Literature/target/test-classes/LiteratureTest.class -------------------------------------------------------------------------------- /part10-Part10_15.RegularExpressions/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part10-Part10_15.RegularExpressions/src/main/java/Checker.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | public class Checker { 4 | 5 | public boolean isDayOfWeek(String string) { 6 | if (string.matches("mon|tue|wed|thu|fri|sat|sun")) { 7 | return true; 8 | } 9 | return false; 10 | } 11 | 12 | public boolean allVowels(String string) { 13 | if (string.matches("[aeiou]+")) { 14 | return true; 15 | } 16 | return false; 17 | } 18 | 19 | public boolean timeOfDay(String string) { 20 | if (string.matches("(((0|1)[0-9])|(2[0-3])):[0-5][0-9]:[0-5][0-9]")) { 21 | return true; 22 | } 23 | return false; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /part10-Part10_15.RegularExpressions/src/main/java/MainProgram.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | public class MainProgram { 4 | 5 | public static void main(String[] args) { 6 | // you can create test code here. Call the methods that you'll implement 7 | // during the course of this exercise 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /part10-Part10_16.EnumAndIterator/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part10-Part10_16.EnumAndIterator/src/main/java/Education.java: -------------------------------------------------------------------------------- 1 | public enum Education { 2 | PHD, MA, BA, HS 3 | } 4 | -------------------------------------------------------------------------------- /part10-Part10_16.EnumAndIterator/src/main/java/MainProgram.java: -------------------------------------------------------------------------------- 1 | 2 | public class MainProgram { 3 | 4 | public static void main(String[] args) { 5 | // test your classes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /part10-Part10_16.EnumAndIterator/src/main/java/Person.java: -------------------------------------------------------------------------------- 1 | public class Person { 2 | private String name; 3 | private Education education; 4 | 5 | public Person (String name, Education education) { 6 | this.name = name; 7 | this.education = education; 8 | } 9 | 10 | public Education getEducation() { 11 | return this.education; 12 | } 13 | 14 | @Override 15 | public String toString() { 16 | return name + ", " + education; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /part10-Part10_17.SortThemCards/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part10-Part10_17.SortThemCards/src/main/java/BySuitInValueOrder.java: -------------------------------------------------------------------------------- 1 | import java.util.Comparator; 2 | 3 | public class BySuitInValueOrder implements Comparator { 4 | public int compare(Card c1, Card c2) { 5 | if (c1.getSuit().ordinal() == c2.getSuit().ordinal()) { 6 | // if (c1.getValue() == 2 && c2.getValue() != 2) { 7 | // return 15 - c2.getValue(); 8 | // } else if (c2.getValue() == 2 && c1.getValue() != 2) { 9 | // return c1.getValue() - 15; 10 | // } 11 | return c1.getValue() - c2.getValue(); 12 | } 13 | 14 | return c1.getSuit().ordinal() - c2.getSuit().ordinal(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /part10-Part10_17.SortThemCards/src/main/java/Main.java: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList; 2 | import java.util.Collections; 3 | 4 | public class Main { 5 | 6 | public static void main(String[] args) { 7 | // test your code here 8 | 9 | Hand hand = new Hand(); 10 | 11 | hand.add(new Card(2, Suit.DIAMOND)); 12 | hand.add(new Card(14, Suit.SPADE)); 13 | hand.add(new Card(12, Suit.HEART)); 14 | hand.add(new Card(2, Suit.SPADE)); 15 | 16 | hand.sort(); 17 | 18 | hand.print(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /part10-Part10_17.SortThemCards/src/main/java/Suit.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | public enum Suit { 4 | CLUB, DIAMOND, HEART, SPADE; 5 | 6 | } 7 | -------------------------------------------------------------------------------- /part10-Part10_17.SortThemCards/src/test/java/Help.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | public class Help { 4 | 5 | public static Suit m(int m) { 6 | if (m == 0) { 7 | return Suit.CLUB; 8 | } 9 | 10 | if (m == 1) { 11 | return Suit.DIAMOND; 12 | } 13 | 14 | if (m == 2) { 15 | return Suit.HEART; 16 | } 17 | 18 | return Suit.SPADE; 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /part10-Part10_17.SortThemCards/target/classes/BySuitInValueOrder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part10-Part10_17.SortThemCards/target/classes/BySuitInValueOrder.class -------------------------------------------------------------------------------- /part10-Part10_17.SortThemCards/target/classes/Card.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part10-Part10_17.SortThemCards/target/classes/Card.class -------------------------------------------------------------------------------- /part10-Part10_17.SortThemCards/target/classes/Hand.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part10-Part10_17.SortThemCards/target/classes/Hand.class -------------------------------------------------------------------------------- /part10-Part10_17.SortThemCards/target/classes/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part10-Part10_17.SortThemCards/target/classes/Main.class -------------------------------------------------------------------------------- /part10-Part10_17.SortThemCards/target/classes/Suit.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part10-Part10_17.SortThemCards/target/classes/Suit.class -------------------------------------------------------------------------------- /part10-Part10_17.SortThemCards/target/test-classes/A_CardTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part10-Part10_17.SortThemCards/target/test-classes/A_CardTest.class -------------------------------------------------------------------------------- /part10-Part10_17.SortThemCards/target/test-classes/B_HandTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part10-Part10_17.SortThemCards/target/test-classes/B_HandTest.class -------------------------------------------------------------------------------- /part10-Part10_17.SortThemCards/target/test-classes/C_ComparatorTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part10-Part10_17.SortThemCards/target/test-classes/C_ComparatorTest.class -------------------------------------------------------------------------------- /part10-Part10_17.SortThemCards/target/test-classes/D_HandTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part10-Part10_17.SortThemCards/target/test-classes/D_HandTest.class -------------------------------------------------------------------------------- /part10-Part10_17.SortThemCards/target/test-classes/Help.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part10-Part10_17.SortThemCards/target/test-classes/Help.class -------------------------------------------------------------------------------- /part11-Part11_01.Customer/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part11-Part11_01.Customer/src/main/java/Customer.java: -------------------------------------------------------------------------------- 1 | public class Customer { 2 | private String name; 3 | private String address; 4 | private String email; 5 | } 6 | -------------------------------------------------------------------------------- /part11-Part11_01.Customer/src/main/java/Program.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.Scanner; 3 | 4 | public class Program { 5 | 6 | public static void main(String[] args) { 7 | Scanner scanner = new Scanner(System.in); 8 | // you can test your class here 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /part11-Part11_02.ABookAndAPlane/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part11-Part11_02.ABookAndAPlane/src/main/java/Book.java: -------------------------------------------------------------------------------- 1 | public class Book { 2 | private String name; 3 | private String author; 4 | private int pageCount; 5 | 6 | } 7 | -------------------------------------------------------------------------------- /part11-Part11_02.ABookAndAPlane/src/main/java/Plane.java: -------------------------------------------------------------------------------- 1 | public class Plane { 2 | private String ID; 3 | private String model; 4 | private int yearOfIntroduction; 5 | } 6 | -------------------------------------------------------------------------------- /part11-Part11_02.ABookAndAPlane/src/main/java/Program.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.Scanner; 3 | 4 | public class Program { 5 | 6 | public static void main(String[] args) { 7 | Scanner scanner = new Scanner(System.in); 8 | // you can test your classes here 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /part11-Part11_03.ShowAndTicket/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part11-Part11_03.ShowAndTicket/src/main/java/Program.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.Scanner; 3 | 4 | public class Program { 5 | 6 | public static void main(String[] args) { 7 | Scanner scanner = new Scanner(System.in); 8 | // you can test your classes here 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /part11-Part11_03.ShowAndTicket/src/main/java/Show.java: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList; 2 | 3 | public class Show { 4 | private String movie; 5 | private String time; 6 | } 7 | -------------------------------------------------------------------------------- /part11-Part11_03.ShowAndTicket/src/main/java/Ticket.java: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList; 2 | 3 | public class Ticket { 4 | private int seat; 5 | private int code; 6 | private Show shows; 7 | } 8 | -------------------------------------------------------------------------------- /part11-Part11_04.StudentAndUniversity/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part11-Part11_04.StudentAndUniversity/src/main/java/Program.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.Scanner; 3 | 4 | public class Program { 5 | 6 | public static void main(String[] args) { 7 | Scanner scanner = new Scanner(System.in); 8 | // you can test your classes here 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /part11-Part11_04.StudentAndUniversity/src/main/java/Student.java: -------------------------------------------------------------------------------- 1 | public class Student { 2 | private int studentID; 3 | private String name; 4 | private University university; 5 | } 6 | -------------------------------------------------------------------------------- /part11-Part11_04.StudentAndUniversity/src/main/java/University.java: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList; 2 | 3 | public class University { 4 | private String name; 5 | private ArrayList students; 6 | } 7 | -------------------------------------------------------------------------------- /part11-Part11_05.ThePlayerAndTheBot/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part11-Part11_05.ThePlayerAndTheBot/src/main/java/Bot.java: -------------------------------------------------------------------------------- 1 | public class Bot extends Player { 2 | public void play() { 3 | 4 | } 5 | 6 | public void addMove(String move) { 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /part11-Part11_05.ThePlayerAndTheBot/src/main/java/Player.java: -------------------------------------------------------------------------------- 1 | public class Player { 2 | private String name; 3 | 4 | public void play() { 5 | 6 | } 7 | 8 | public void printName() { 9 | System.out.println(name); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /part11-Part11_05.ThePlayerAndTheBot/src/main/java/Program.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.Scanner; 3 | 4 | public class Program { 5 | 6 | public static void main(String[] args) { 7 | Scanner scanner = new Scanner(System.in); 8 | // you can test your classes here 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /part11-Part11_06.SaveablePerson/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part11-Part11_06.SaveablePerson/src/main/java/Person.java: -------------------------------------------------------------------------------- 1 | public class Person implements Saveable { 2 | private String name; 3 | private String address; 4 | 5 | public void save(){}; 6 | public void delete(){}; 7 | public void load(String address){}; 8 | } 9 | -------------------------------------------------------------------------------- /part11-Part11_06.SaveablePerson/src/main/java/Program.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.Scanner; 3 | 4 | public class Program { 5 | 6 | public static void main(String[] args) { 7 | Scanner scanner = new Scanner(System.in); 8 | // you can test your program here 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /part11-Part11_06.SaveablePerson/src/main/java/Saveable.java: -------------------------------------------------------------------------------- 1 | public interface Saveable { 2 | public void save(); 3 | public void delete(); 4 | public void load(String address); 5 | } 6 | -------------------------------------------------------------------------------- /part11-Part11_07.BiggerClassDiagram/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part11-Part11_07.BiggerClassDiagram/src/main/java/A.java: -------------------------------------------------------------------------------- 1 | public class A implements IA { 2 | } 3 | -------------------------------------------------------------------------------- /part11-Part11_07.BiggerClassDiagram/src/main/java/B.java: -------------------------------------------------------------------------------- 1 | public class B extends A implements IB { 2 | } 3 | -------------------------------------------------------------------------------- /part11-Part11_07.BiggerClassDiagram/src/main/java/C.java: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList; 2 | 3 | public class C extends B implements IC { 4 | private ArrayList e; 5 | } 6 | -------------------------------------------------------------------------------- /part11-Part11_07.BiggerClassDiagram/src/main/java/D.java: -------------------------------------------------------------------------------- 1 | public class D { 2 | private IA ia; 3 | } 4 | -------------------------------------------------------------------------------- /part11-Part11_07.BiggerClassDiagram/src/main/java/E.java: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList; 2 | 3 | public class E { 4 | private ArrayList c; 5 | } 6 | -------------------------------------------------------------------------------- /part11-Part11_07.BiggerClassDiagram/src/main/java/IA.java: -------------------------------------------------------------------------------- 1 | public interface IA { 2 | } 3 | -------------------------------------------------------------------------------- /part11-Part11_07.BiggerClassDiagram/src/main/java/IB.java: -------------------------------------------------------------------------------- 1 | public interface IB { 2 | } 3 | -------------------------------------------------------------------------------- /part11-Part11_07.BiggerClassDiagram/src/main/java/IC.java: -------------------------------------------------------------------------------- 1 | public interface IC { 2 | } 3 | -------------------------------------------------------------------------------- /part11-Part11_07.BiggerClassDiagram/src/main/java/Program.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.Scanner; 3 | 4 | public class Program { 5 | 6 | public static void main(String[] args) { 7 | Scanner scanner = new Scanner(System.in); 8 | // you can test your classes here 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /part11-Part11_08.FirstPackages/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part11-Part11_08.FirstPackages/nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | run 5 | 6 | jar 7 | 8 | 9 | process-classes 10 | org.codehaus.mojo:exec-maven-plugin:1.2.1:exec 11 | 12 | 13 | -classpath %classpath mooc.Main 14 | java 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /part11-Part11_08.FirstPackages/src/main/java/mooc/Main.java: -------------------------------------------------------------------------------- 1 | package mooc; 2 | 3 | public class Main { 4 | 5 | public static void main(String[] args) { 6 | System.out.println("Hello packages!"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /part11-Part11_08.FirstPackages/src/main/java/mooc/logic/ApplicationLogic.java: -------------------------------------------------------------------------------- 1 | package mooc.logic; 2 | import mooc.ui.UserInterface; 3 | 4 | public class ApplicationLogic { 5 | private UserInterface ui; 6 | 7 | public ApplicationLogic(UserInterface ui) { 8 | this.ui = ui; 9 | } 10 | 11 | public void execute(int times) { 12 | for (int i=0;i setSize) { 19 | throw new IllegalArgumentException("subset must be smaller than the set!"); 20 | } 21 | int numerator = factorial(setSize); 22 | int denominator = factorial(subsetSize) * factorial(setSize - subsetSize); 23 | 24 | return numerator / denominator; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /part11-Part11_11.ValidatingParameters/src/main/java/validating/Person.java: -------------------------------------------------------------------------------- 1 | package validating; 2 | 3 | public class Person { 4 | 5 | private String name; 6 | private int age; 7 | 8 | public Person(String name, int age) { 9 | if (name == null || name.isEmpty() || name.length() > 40) { 10 | throw new IllegalArgumentException("Name must not be empty, null or greater than 40 characters!"); 11 | } else if ( age < 0 || age > 120) { 12 | throw new IllegalArgumentException("age out of range"); 13 | } 14 | this.name = name; 15 | this.age = age; 16 | } 17 | 18 | public String getName() { 19 | return name; 20 | } 21 | 22 | public int getAge() { 23 | return age; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /part11-Part11_12.SensorsAndTemperature/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /part11-Part11_12.SensorsAndTemperature/.idea/.name: -------------------------------------------------------------------------------- 1 | Part11_12.SensorsAndTemperature -------------------------------------------------------------------------------- /part11-Part11_12.SensorsAndTemperature/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /part11-Part11_12.SensorsAndTemperature/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /part11-Part11_12.SensorsAndTemperature/.idea/libraries/Maven__fi_helsinki_cs_tmc_edu_test_utils_0_4_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /part11-Part11_12.SensorsAndTemperature/.idea/libraries/Maven__junit_junit_4_12.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /part11-Part11_12.SensorsAndTemperature/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /part11-Part11_12.SensorsAndTemperature/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /part11-Part11_12.SensorsAndTemperature/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /part11-Part11_12.SensorsAndTemperature/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /part11-Part11_12.SensorsAndTemperature/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part11-Part11_12.SensorsAndTemperature/src/main/java/application/Program.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | public class Program { 4 | 5 | public static void main(String[] args) { 6 | Sensor kumpula = new TemperatureSensor(); 7 | kumpula.setOn(); 8 | System.out.println("temperature in Kumpula " + kumpula.read() + " degrees Celsius"); 9 | 10 | Sensor kaisaniemi = new TemperatureSensor(); 11 | Sensor helsinkiVantaaAirport = new TemperatureSensor(); 12 | 13 | AverageSensor helsinkiRegion = new AverageSensor(); 14 | helsinkiRegion.addSensor(kumpula); 15 | helsinkiRegion.addSensor(kaisaniemi); 16 | helsinkiRegion.addSensor(helsinkiVantaaAirport); 17 | 18 | helsinkiRegion.setOn(); 19 | System.out.println("temperature in Helsinki region " + helsinkiRegion.read() + " degrees Celsius"); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /part11-Part11_12.SensorsAndTemperature/src/main/java/application/Sensor.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | public interface Sensor { 4 | 5 | boolean isOn(); // returns true if the sensor is on 6 | void setOn(); // sets the sensor on 7 | void setOff(); // sets the sensor off 8 | int read(); // returns the value of the sensor if it's on 9 | // if the sensor is not on throw a IllegalStateException 10 | } 11 | -------------------------------------------------------------------------------- /part11-Part11_12.SensorsAndTemperature/src/main/java/application/StandardSensor.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | public class StandardSensor implements Sensor { 4 | private int value; 5 | 6 | public StandardSensor(int value) { 7 | this.value = value; 8 | } 9 | 10 | public boolean isOn() { 11 | return true; 12 | } 13 | 14 | public void setOn() { 15 | } 16 | 17 | public void setOff() { 18 | } 19 | 20 | public int read() { 21 | if (true) { 22 | return value; 23 | } else { 24 | throw new IllegalStateException("Illegal state!"); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /part11-Part11_12.SensorsAndTemperature/src/main/java/application/TemperatureSensor.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | import java.util.Random; 4 | 5 | public class TemperatureSensor implements Sensor { 6 | private boolean isOn; 7 | private int value; 8 | 9 | public TemperatureSensor() { 10 | this.isOn = false; 11 | } 12 | 13 | public boolean isOn() { 14 | return isOn; 15 | } 16 | 17 | public void setOn() { 18 | this.isOn = true; 19 | } 20 | 21 | public void setOff() { 22 | this.isOn = false; 23 | } 24 | 25 | public int read() { 26 | if (isOn) { 27 | return new Random().nextInt(61) - 30; 28 | } else { 29 | throw new IllegalStateException("Illegal state!"); 30 | } 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /part11-Part11_13.SaveableDictionary/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part11-Part11_13.SaveableDictionary/src/main/java/dictionary/Main.java: -------------------------------------------------------------------------------- 1 | package dictionary; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | // You can test your dictionary here 6 | SaveableDictionary dictionary = new SaveableDictionary("words.txt"); 7 | boolean wasSuccessful = dictionary.load(); 8 | 9 | if (wasSuccessful) { 10 | System.out.println("Successfully loaded the dictionary from file"); 11 | } 12 | 13 | System.out.println(dictionary.translate("apina")); 14 | System.out.println(dictionary.translate("ohjelmointi")); 15 | System.out.println(dictionary.translate("alla oleva")); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /part11-Part11_13.SaveableDictionary/words.txt: -------------------------------------------------------------------------------- 1 | apina:monkey 2 | alla oleva:below 3 | olut:beer 4 | -------------------------------------------------------------------------------- /part12-Part12_01.Hideout/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part12-Part12_01.Hideout/Part12_01.Hideout.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /part12-Part12_01.Hideout/src/main/java/Hideout.java: -------------------------------------------------------------------------------- 1 | public class Hideout { 2 | private T hidden; 3 | 4 | public Hideout() { 5 | } 6 | 7 | public void putIntoHideout(T toHide) { 8 | hidden = toHide; 9 | } 10 | 11 | public T takeFromHideout() { 12 | if (this.hidden == null) { 13 | return null; 14 | } 15 | T taken = this.hidden; 16 | this.hidden = null; 17 | return taken; 18 | } 19 | 20 | public boolean isInHideout() { 21 | return this.hidden == null; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /part12-Part12_01.Hideout/src/main/java/Program.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.Scanner; 3 | 4 | public class Program { 5 | 6 | public static void main(String[] args) { 7 | Scanner scanner = new Scanner(System.in); 8 | // you may try out your class here 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /part12-Part12_01.Hideout/src/test/java/HideoutTest.java: -------------------------------------------------------------------------------- 1 | 2 | import fi.helsinki.cs.tmc.edutestutils.Points; 3 | import org.junit.Test; 4 | 5 | @Points("12-01") 6 | public class HideoutTest { 7 | 8 | @Test 9 | public void noTests() { 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /part12-Part12_02.Pipe/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part12-Part12_02.Pipe/Part12_02.Pipe.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /part12-Part12_02.Pipe/src/main/java/Pipe.java: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList; 2 | import java.util.List; 3 | 4 | public class Pipe{ 5 | private ArrayList values; 6 | 7 | public Pipe() { 8 | this.values = new ArrayList<>(); 9 | } 10 | 11 | public boolean isEmpty() { 12 | return this.values.size() == 0; 13 | } 14 | 15 | public int size() { 16 | return this.values.size(); 17 | } 18 | 19 | public void putIntoPipe(T value) { 20 | this.values.add(value); 21 | } 22 | 23 | public T takeFromPipe() { 24 | return this.values.remove(0); 25 | } 26 | 27 | public boolean isInPipe() { 28 | return this.values.size() > 0; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /part12-Part12_02.Pipe/src/main/java/Program.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.Scanner; 3 | 4 | public class Program { 5 | 6 | public static void main(String[] args) { 7 | Scanner scanner = new Scanner(System.in); 8 | // you may try out your class here 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /part12-Part12_02.Pipe/src/test/java/PipeTest.java: -------------------------------------------------------------------------------- 1 | 2 | import fi.helsinki.cs.tmc.edutestutils.Points; 3 | import org.junit.Test; 4 | 5 | @Points("12-02") 6 | public class PipeTest { 7 | 8 | @Test 9 | public void noTests() { 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /part12-Part12_03.SumTheseForMe/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part12-Part12_03.SumTheseForMe/src/main/java/Program.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.Scanner; 3 | 4 | public class Program { 5 | 6 | public static void main(String[] args) { 7 | Scanner scan = new Scanner(System.in); 8 | // test your method here 9 | 10 | } 11 | 12 | public static int sum(int[] array, int fromWhere, int toWhere, int smallest, int largest) { 13 | int total = 0; 14 | 15 | if (fromWhere < 0) { 16 | fromWhere = 0; 17 | } 18 | if (toWhere > array.length) { 19 | toWhere = array.length - 1; 20 | } 21 | 22 | for (int i = fromWhere; i < toWhere; i++) { 23 | if (array[i] >= smallest && array[i] <= largest) { 24 | total += array[i]; 25 | } 26 | } 27 | 28 | return total; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /part12-Part12_04.List/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part12-Part12_04.List/Part12_04.List.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /part12-Part12_04.List/src/main/java/Program.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.Scanner; 3 | 4 | public class Program { 5 | 6 | public static void main(String[] args) { 7 | Scanner scan = new Scanner(System.in); 8 | // test your class here 9 | 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /part12-Part12_04.List/src/test/java/ListTest.java: -------------------------------------------------------------------------------- 1 | 2 | import fi.helsinki.cs.tmc.edutestutils.Points; 3 | import org.junit.Test; 4 | 5 | @Points("12-04.1 12-04.2") 6 | public class ListTest { 7 | 8 | @Test 9 | public void noTests() { 10 | 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /part12-Part12_05.HashMap/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part12-Part12_05.HashMap/Part12_05.HashMap.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /part12-Part12_05.HashMap/src/main/java/Pair.java: -------------------------------------------------------------------------------- 1 | public class Pair { 2 | private K key; 3 | private V value; 4 | 5 | public Pair(K key, V value) { 6 | this.key=key; 7 | this.value=value; 8 | } 9 | 10 | public K getKey() { 11 | return key; 12 | } 13 | 14 | public V getValue() { 15 | return value; 16 | } 17 | 18 | public void setKey(K key) { 19 | this.key = key; 20 | } 21 | 22 | public void setValue(V value) { 23 | this.value = value; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /part12-Part12_05.HashMap/src/main/java/Program.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.Scanner; 3 | 4 | public class Program { 5 | 6 | public static void main(String[] args) { 7 | Scanner scanner = new Scanner(System.in); 8 | // You can test the class here 9 | 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /part12-Part12_05.HashMap/src/test/java/HashMapTest.java: -------------------------------------------------------------------------------- 1 | 2 | import fi.helsinki.cs.tmc.edutestutils.Points; 3 | import org.junit.Test; 4 | 5 | @Points("12-05.1 12-05.2 12-05.3") 6 | public class HashMapTest { 7 | 8 | @Test 9 | public void noTests() { 10 | 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /part12-Part12_06.Numbers/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part12-Part12_06.Numbers/src/main/java/Program.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.Random; 3 | import java.util.Scanner; 4 | 5 | public class Program { 6 | 7 | public static void main(String[] args) { 8 | Scanner scanner = new Scanner(System.in); 9 | System.out.println("How many random numbers should be printed?"); 10 | int num = Integer.valueOf(scanner.nextLine()); 11 | Random random = new Random(); 12 | for (int i = 0; i < num; i++) { 13 | System.out.println(random.nextInt(11)); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /part12-Part12_06.Numbers/target/classes/Program.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part12-Part12_06.Numbers/target/classes/Program.class -------------------------------------------------------------------------------- /part12-Part12_06.Numbers/target/test-classes/NumbersTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part12-Part12_06.Numbers/target/test-classes/NumbersTest.class -------------------------------------------------------------------------------- /part12-Part12_07.Die/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part12-Part12_07.Die/Part12_07.Die.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /part12-Part12_07.Die/src/main/java/Die.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.Random; 3 | 4 | public class Die { 5 | 6 | private Random random; 7 | private int numberOfFaces; 8 | 9 | public Die(int numberOfFaces) { 10 | this.random = new Random(); 11 | // Initialize the value of numberOfFaces here 12 | this.numberOfFaces = numberOfFaces; 13 | } 14 | 15 | public int throwDie() { 16 | // generate a random number which may be any number 17 | // between one and the number of faces, and then return it 18 | return random.nextInt(numberOfFaces) + 1; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /part12-Part12_07.Die/src/main/java/Program.java: -------------------------------------------------------------------------------- 1 | 2 | public class Program { 3 | 4 | public static void main(String[] args) { 5 | // main program 6 | Die die = new Die(6); 7 | 8 | int i = 0; 9 | while (i < 10) { 10 | System.out.println(die.throwDie()); 11 | i++; 12 | } 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /part12-Part12_07.Die/target/classes/Die.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part12-Part12_07.Die/target/classes/Die.class -------------------------------------------------------------------------------- /part12-Part12_07.Die/target/classes/Program.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part12-Part12_07.Die/target/classes/Program.class -------------------------------------------------------------------------------- /part12-Part12_07.Die/target/test-classes/DieTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part12-Part12_07.Die/target/test-classes/DieTest.class -------------------------------------------------------------------------------- /part12-Part12_08.Lottery/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part12-Part12_08.Lottery/src/main/java/LotteryRow.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.ArrayList; 3 | import java.util.Random; 4 | 5 | public class LotteryRow { 6 | 7 | private ArrayList numbers; 8 | 9 | public LotteryRow() { 10 | // Draw the numbers when the LotteryRow is created 11 | this.randomizeNumbers(); 12 | } 13 | 14 | public ArrayList numbers() { 15 | return this.numbers; 16 | } 17 | 18 | public void randomizeNumbers() { 19 | // Initialize the list for numbers 20 | this.numbers = new ArrayList<>(); 21 | // Implement the random number generation here 22 | // the method containsNumber is probably useful 23 | Random random = new Random(); 24 | for (int i = 0; i < 7; i++) { 25 | int num = random.nextInt(40) + 1; 26 | while (containsNumber(num)) { 27 | num = random.nextInt(40) + 1; 28 | } 29 | this.numbers.add(num); 30 | } 31 | } 32 | 33 | public boolean containsNumber(int number) { 34 | // Check here whether the number is among the drawn numbers 35 | return numbers.contains(number); 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /part12-Part12_08.Lottery/src/main/java/Program.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.ArrayList; 3 | 4 | public class Program { 5 | 6 | public static void main(String[] args) { 7 | LotteryRow row = new LotteryRow(); 8 | ArrayList lotteryNumbers = row.numbers(); 9 | 10 | System.out.println("Lottery numbers:"); 11 | for (Integer number : lotteryNumbers) { 12 | System.out.print(number + " "); 13 | } 14 | System.out.println(""); 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /part12-Part12_08.Lottery/target/classes/LotteryRow.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part12-Part12_08.Lottery/target/classes/LotteryRow.class -------------------------------------------------------------------------------- /part12-Part12_08.Lottery/target/classes/Program.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part12-Part12_08.Lottery/target/classes/Program.class -------------------------------------------------------------------------------- /part12-Part12_08.Lottery/target/test-classes/LotteryRowTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part12-Part12_08.Lottery/target/test-classes/LotteryRowTest.class -------------------------------------------------------------------------------- /part12-Part12_09.ArrayAsAString/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part12-Part12_09.ArrayAsAString/src/main/java/Program.java: -------------------------------------------------------------------------------- 1 | 2 | public class Program { 3 | 4 | public static void main(String[] args) { 5 | // Test your method here 6 | int rows = 2; 7 | int columns = 3; 8 | int[][] matrix = new int[rows][columns]; 9 | matrix[0][1] = 5; 10 | matrix[1][0] = 3; 11 | matrix[1][2] = 7; 12 | System.out.println(arrayAsString(matrix)); 13 | } 14 | 15 | public static String arrayAsString(int[][] array) { 16 | StringBuilder result = new StringBuilder(); 17 | for (int i =0; i < array.length; i++) { 18 | for (int j = 0; j < array[i].length; j++) { 19 | result.append(array[i][j]); 20 | } 21 | result.append("\n"); 22 | } 23 | 24 | return result.toString(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /part12-Part12_09.ArrayAsAString/target/classes/Program.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part12-Part12_09.ArrayAsAString/target/classes/Program.class -------------------------------------------------------------------------------- /part12-Part12_09.ArrayAsAString/target/test-classes/ArrayAsStringTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part12-Part12_09.ArrayAsAString/target/test-classes/ArrayAsStringTest.class -------------------------------------------------------------------------------- /part12-Part12_10.MagicSquare/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part12-Part12_10.MagicSquare/src/main/java/Program.java: -------------------------------------------------------------------------------- 1 | 2 | public class Program { 3 | 4 | public static void main(String[] args) { 5 | // Test the MagicSquare class here 6 | 7 | MagicSquareFactory msFactory = new MagicSquareFactory(); 8 | System.out.println(msFactory.createMagicSquare(5)); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /part13-Part13_01.MyFirstApplication/.tmcparams: -------------------------------------------------------------------------------- 1 | export SERVER="true" 2 | -------------------------------------------------------------------------------- /part13-Part13_01.MyFirstApplication/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part13-Part13_01.MyFirstApplication/nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CUSTOM-custom maven command 5 | custom maven command 6 | 7 | mvn 8 | -version 9 | 10 | 11 | 12 | run 13 | 14 | jar 15 | 16 | 17 | process-classes 18 | fi.helsinki.cs.tmc:runner-maven-plugin:1.0.1:run-javafx 19 | 20 | 21 | 22 | -classpath %classpath ${packageClassName} 23 | java 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /part13-Part13_01.MyFirstApplication/src/main/java/myFirstApplication/MyFirstApplication.java: -------------------------------------------------------------------------------- 1 | package myFirstApplication; 2 | 3 | import javafx.application.Application; 4 | import javafx.stage.Stage; 5 | 6 | public class MyFirstApplication extends Application { 7 | 8 | @Override 9 | public void start(Stage window) { 10 | window.setTitle("My first application"); 11 | window.show(); 12 | } 13 | 14 | public static void main(String[] args) { 15 | launch(MyFirstApplication.class); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /part13-Part13_02.ButtonAndLabel/.tmcparams: -------------------------------------------------------------------------------- 1 | export SERVER="true" 2 | -------------------------------------------------------------------------------- /part13-Part13_02.ButtonAndLabel/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part13-Part13_02.ButtonAndLabel/nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CUSTOM-custom maven command 5 | custom maven command 6 | 7 | mvn 8 | -version 9 | 10 | 11 | 12 | run 13 | 14 | jar 15 | 16 | 17 | process-classes 18 | fi.helsinki.cs.tmc:runner-maven-plugin:1.0.1:run-javafx 19 | 20 | 21 | 22 | -classpath %classpath ${packageClassName} 23 | java 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /part13-Part13_02.ButtonAndLabel/src/main/java/buttonandlabel/ButtonAndLabelApplication.java: -------------------------------------------------------------------------------- 1 | package buttonandlabel; 2 | 3 | import javafx.application.Application; 4 | import javafx.scene.Scene; 5 | import javafx.scene.control.Button; 6 | import javafx.scene.control.Label; 7 | import javafx.scene.layout.FlowPane; 8 | import javafx.stage.Stage; 9 | 10 | public class ButtonAndLabelApplication extends Application { 11 | 12 | public void start(Stage window) { 13 | Button buttonComponent = new Button("This is a button"); 14 | Label textComponent = new Label("Text element"); 15 | 16 | FlowPane componentGroup = new FlowPane(); 17 | componentGroup.getChildren().add(textComponent); 18 | componentGroup.getChildren().add(buttonComponent); 19 | 20 | Scene view = new Scene(componentGroup); 21 | 22 | window.setScene(view); 23 | window.show(); 24 | } 25 | 26 | public static void main(String[] args) { 27 | launch(ButtonAndLabelApplication.class); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /part13-Part13_02.ButtonAndLabel/target/classes/buttonandlabel/ButtonAndLabelApplication.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part13-Part13_02.ButtonAndLabel/target/classes/buttonandlabel/ButtonAndLabelApplication.class -------------------------------------------------------------------------------- /part13-Part13_02.ButtonAndLabel/target/test-classes/buttonandlabel/ButtonAndLabelTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part13-Part13_02.ButtonAndLabel/target/test-classes/buttonandlabel/ButtonAndLabelTest.class -------------------------------------------------------------------------------- /part13-Part13_03.ButtonAndTextField/.tmcparams: -------------------------------------------------------------------------------- 1 | export SERVER="true" 2 | -------------------------------------------------------------------------------- /part13-Part13_03.ButtonAndTextField/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part13-Part13_03.ButtonAndTextField/nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CUSTOM-custom maven command 5 | custom maven command 6 | 7 | mvn 8 | -version 9 | 10 | 11 | 12 | run 13 | 14 | jar 15 | 16 | 17 | process-classes 18 | fi.helsinki.cs.tmc:runner-maven-plugin:1.0.1:run-javafx 19 | 20 | 21 | 22 | -classpath %classpath ${packageClassName} 23 | java 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /part13-Part13_03.ButtonAndTextField/src/main/java/buttonandtextfield/ButtonAndTextFieldApplication.java: -------------------------------------------------------------------------------- 1 | package buttonandtextfield; 2 | 3 | import javafx.application.Application; 4 | import javafx.scene.Scene; 5 | import javafx.scene.control.Button; 6 | import javafx.scene.control.TextField; 7 | import javafx.scene.layout.FlowPane; 8 | import javafx.stage.Stage; 9 | 10 | public class ButtonAndTextFieldApplication extends Application { 11 | @Override 12 | public void start(Stage window) { 13 | Button buttonComponent = new Button("This is a button"); 14 | TextField textComponent = new TextField("Text element"); 15 | 16 | FlowPane componentGroup = new FlowPane(); 17 | componentGroup.getChildren().add(buttonComponent); 18 | componentGroup.getChildren().add(textComponent); 19 | 20 | Scene view = new Scene(componentGroup); 21 | 22 | window.setScene(view); 23 | window.show(); 24 | } 25 | 26 | public static void main(String[] args) { 27 | launch(ButtonAndTextFieldApplication.class); 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /part13-Part13_04.BorderPane/.tmcparams: -------------------------------------------------------------------------------- 1 | export SERVER="true" 2 | -------------------------------------------------------------------------------- /part13-Part13_04.BorderPane/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part13-Part13_04.BorderPane/nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CUSTOM-custom maven command 5 | custom maven command 6 | 7 | mvn 8 | -version 9 | 10 | 11 | 12 | run 13 | 14 | jar 15 | 16 | 17 | process-classes 18 | fi.helsinki.cs.tmc:runner-maven-plugin:1.0.1:run-javafx 19 | 20 | 21 | 22 | -classpath %classpath ${packageClassName} 23 | java 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /part13-Part13_04.BorderPane/src/main/java/borderpane/BorderPaneApplication.java: -------------------------------------------------------------------------------- 1 | package borderpane; 2 | 3 | 4 | import javafx.application.Application; 5 | import javafx.scene.Scene; 6 | import javafx.scene.control.Label; 7 | import javafx.scene.layout.BorderPane; 8 | import javafx.stage.Stage; 9 | 10 | public class BorderPaneApplication extends Application { 11 | 12 | @Override 13 | public void start(Stage window) { 14 | BorderPane layout = new BorderPane(); 15 | layout.setTop(new Label("NORTH")); 16 | layout.setRight(new Label("EAST")); 17 | layout.setBottom(new Label("SOUTH")); 18 | // layout.setLeft(new Label("WEST")); 19 | // layout.setCenter(new Label("center")); 20 | 21 | Scene view = new Scene(layout); 22 | 23 | window.setScene(view); 24 | window.show(); 25 | } 26 | 27 | public static void main(String[] args) { 28 | launch(BorderPaneApplication.class); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /part13-Part13_05.TextStatistics/.tmcparams: -------------------------------------------------------------------------------- 1 | export SERVER="true" 2 | -------------------------------------------------------------------------------- /part13-Part13_05.TextStatistics/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part13-Part13_05.TextStatistics/nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CUSTOM-custom maven command 5 | custom maven command 6 | 7 | mvn 8 | -version 9 | 10 | 11 | 12 | run 13 | 14 | jar 15 | 16 | 17 | process-classes 18 | fi.helsinki.cs.tmc:runner-maven-plugin:1.0.1:run-javafx 19 | 20 | 21 | 22 | -classpath %classpath ${packageClassName} 23 | java 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /part13-Part13_06.Notifier/.tmcparams: -------------------------------------------------------------------------------- 1 | export SERVER="true" 2 | -------------------------------------------------------------------------------- /part13-Part13_06.Notifier/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part13-Part13_06.Notifier/nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CUSTOM-custom maven command 5 | custom maven command 6 | 7 | mvn 8 | -version 9 | 10 | 11 | 12 | run 13 | 14 | jar 15 | 16 | 17 | process-classes 18 | fi.helsinki.cs.tmc:runner-maven-plugin:1.0.1:run-javafx 19 | 20 | 21 | 22 | -classpath %classpath ${packageClassName} 23 | java 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /part13-Part13_06.Notifier/src/main/java/notifier/NotifierApplication.java: -------------------------------------------------------------------------------- 1 | package notifier; 2 | 3 | import javafx.application.Application; 4 | import javafx.scene.Scene; 5 | import javafx.scene.control.Button; 6 | import javafx.scene.control.Label; 7 | import javafx.scene.control.TextField; 8 | import javafx.scene.layout.VBox; 9 | import javafx.stage.Stage; 10 | 11 | 12 | public class NotifierApplication extends Application { 13 | 14 | 15 | public static void main(String[] args) { 16 | launch(NotifierApplication.class); 17 | } 18 | 19 | @Override 20 | public void start(Stage stage) throws Exception { 21 | TextField text = new TextField(""); 22 | Button button = new Button("Update"); 23 | Label label = new Label(""); 24 | 25 | button.setOnAction((event) -> { 26 | label.setText(text.getText()); 27 | }); 28 | 29 | 30 | VBox layout = new VBox(); 31 | layout.getChildren().addAll(text, button, label); 32 | 33 | Scene scene = new Scene(layout); 34 | stage.setScene(scene); 35 | stage.show(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /part13-Part13_07.TextStatisticsPart2/.tmcparams: -------------------------------------------------------------------------------- 1 | export SERVER="true" 2 | -------------------------------------------------------------------------------- /part13-Part13_07.TextStatisticsPart2/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part13-Part13_07.TextStatisticsPart2/nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CUSTOM-custom maven command 5 | custom maven command 6 | 7 | mvn 8 | -version 9 | 10 | 11 | 12 | run 13 | 14 | jar 15 | 16 | 17 | process-classes 18 | fi.helsinki.cs.tmc:runner-maven-plugin:1.0.1:run-javafx 19 | 20 | 21 | 22 | -classpath %classpath ${packageClassName} 23 | java 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /part13-Part13_08.UserTitle/.tmcparams: -------------------------------------------------------------------------------- 1 | export SERVER="true" 2 | -------------------------------------------------------------------------------- /part13-Part13_08.UserTitle/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part13-Part13_08.UserTitle/nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CUSTOM-custom maven command 5 | custom maven command 6 | 7 | mvn 8 | -version 9 | 10 | 11 | 12 | run 13 | 14 | jar 15 | 16 | 17 | process-classes 18 | fi.helsinki.cs.tmc:runner-maven-plugin:1.0.1:run-javafx 19 | 20 | 21 | 22 | -classpath %classpath ${packageClassName} 23 | java 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /part13-Part13_08.UserTitle/src/main/java/title/Main.java: -------------------------------------------------------------------------------- 1 | package title; 2 | 3 | import java.util.Scanner; 4 | import javafx.application.Application; 5 | 6 | public class Main { 7 | 8 | public static void main(String[] args) { 9 | Scanner scanner = new Scanner(System.in); 10 | System.out.println("Hi there, please give a title for the application: "); 11 | String title = scanner.nextLine(); 12 | Application.launch(UserTitle.class, "--title=" + title); //passes the title parameter from the user input 13 | 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /part13-Part13_08.UserTitle/src/main/java/title/UserTitle.java: -------------------------------------------------------------------------------- 1 | package title; 2 | 3 | import javafx.application.Application; 4 | import javafx.stage.Stage; 5 | 6 | 7 | public class UserTitle extends Application{ 8 | 9 | @Override 10 | public void start(Stage stage) throws Exception { 11 | Parameters params = getParameters(); 12 | String title = params.getNamed().get("title"); 13 | 14 | stage.setTitle(title); 15 | stage.show(); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /part13-Part13_08.UserTitle/src/test/java/title/UserTitleTest.java: -------------------------------------------------------------------------------- 1 | package title; 2 | 3 | import fi.helsinki.cs.tmc.edutestutils.Points; 4 | import org.junit.*; 5 | 6 | @Points("13-08") 7 | public class UserTitleTest { 8 | 9 | @Test 10 | public void noTests() { 11 | 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /part13-Part13_09.MultipleViews/.tmcparams: -------------------------------------------------------------------------------- 1 | export SERVER="true" 2 | -------------------------------------------------------------------------------- /part13-Part13_09.MultipleViews/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part13-Part13_09.MultipleViews/nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CUSTOM-custom maven command 5 | custom maven command 6 | 7 | mvn 8 | -version 9 | 10 | 11 | 12 | run 13 | 14 | jar 15 | 16 | 17 | process-classes 18 | fi.helsinki.cs.tmc:runner-maven-plugin:1.0.1:run-javafx 19 | 20 | 21 | 22 | -classpath %classpath ${packageClassName} 23 | java 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /part13-Part13_10.Greeter/.tmcparams: -------------------------------------------------------------------------------- 1 | export SERVER="true" 2 | -------------------------------------------------------------------------------- /part13-Part13_10.Greeter/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part13-Part13_10.Greeter/nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CUSTOM-custom maven command 5 | custom maven command 6 | 7 | mvn 8 | -version 9 | 10 | 11 | 12 | run 13 | 14 | jar 15 | 16 | 17 | process-classes 18 | fi.helsinki.cs.tmc:runner-maven-plugin:1.0.1:run-javafx 19 | 20 | 21 | 22 | -classpath %classpath ${packageClassName} 23 | java 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /part13-Part13_11.Joke/.tmcparams: -------------------------------------------------------------------------------- 1 | export SERVER="true" 2 | -------------------------------------------------------------------------------- /part13-Part13_11.Joke/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part13-Part13_11.Joke/nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CUSTOM-custom maven command 5 | custom maven command 6 | 7 | mvn 8 | -version 9 | 10 | 11 | 12 | run 13 | 14 | jar 15 | 16 | 17 | process-classes 18 | fi.helsinki.cs.tmc:runner-maven-plugin:1.0.1:run-javafx 19 | 20 | 21 | 22 | -classpath %classpath ${packageClassName} 23 | java 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /part13-Part13_12.VocabularyPractice/.tmcparams: -------------------------------------------------------------------------------- 1 | export SERVER="true" 2 | -------------------------------------------------------------------------------- /part13-Part13_12.VocabularyPractice/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part13-Part13_12.VocabularyPractice/nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CUSTOM-custom maven command 5 | custom maven command 6 | 7 | mvn 8 | -version 9 | 10 | 11 | 12 | run 13 | 14 | jar 15 | 16 | 17 | process-classes 18 | fi.helsinki.cs.tmc:runner-maven-plugin:1.0.1:run-javafx 19 | 20 | 21 | 22 | -classpath %classpath ${packageClassName} 23 | java 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /part13-Part13_12.VocabularyPractice/src/main/java/application/Dictionary.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.Random; 6 | 7 | public class Dictionary { 8 | private ArrayList words; 9 | private HashMap translations; 10 | 11 | public Dictionary(){ 12 | this.words = new ArrayList(); 13 | this.translations = new HashMap(); 14 | 15 | //adds sample word 16 | addWord("palabra", "word"); 17 | } 18 | 19 | public String getTranslation(String word){ 20 | if(this.translations.containsKey(word)){ 21 | return this.translations.get(word); 22 | } 23 | 24 | return "Translation not found"; 25 | } 26 | 27 | public void addWord(String word, String translation){ 28 | if(!this.translations.containsKey(word)){ 29 | this.words.add(word); 30 | } 31 | 32 | this.translations.put(word, translation); 33 | } 34 | 35 | public String getRandomWord(){ 36 | Random rand = new Random(); 37 | return this.words.get(rand.nextInt(this.words.size())); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /part13-Part13_12.VocabularyPractice/src/test/java/application/VocabularyPracticeTest.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | import fi.helsinki.cs.tmc.edutestutils.Points; 4 | import org.junit.Test; 5 | 6 | @Points("13-12") 7 | public class VocabularyPracticeTest { 8 | 9 | @Test 10 | public void noTests() { 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /part13-Part13_13.TicTacToe/.tmcparams: -------------------------------------------------------------------------------- 1 | export SERVER="true" 2 | -------------------------------------------------------------------------------- /part13-Part13_13.TicTacToe/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part13-Part13_13.TicTacToe/nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CUSTOM-custom maven command 5 | custom maven command 6 | 7 | mvn 8 | -version 9 | 10 | 11 | 12 | run 13 | 14 | jar 15 | 16 | 17 | process-classes 18 | fi.helsinki.cs.tmc:runner-maven-plugin:1.0.1:run-javafx 19 | 20 | 21 | 22 | -classpath %classpath ${packageClassName} 23 | java 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /part14-Part14_01.Shanghai/.tmcparams: -------------------------------------------------------------------------------- 1 | export SERVER="true" 2 | -------------------------------------------------------------------------------- /part14-Part14_01.Shanghai/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part14-Part14_01.Shanghai/nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CUSTOM-custom maven command 5 | custom maven command 6 | 7 | mvn 8 | -version 9 | 10 | 11 | 12 | run 13 | 14 | jar 15 | 16 | 17 | process-classes 18 | fi.helsinki.cs.tmc:runner-maven-plugin:1.0.1:run-javafx 19 | 20 | 21 | 22 | -classpath %classpath ${packageClassName} 23 | java 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /part14-Part14_01.Shanghai/src/main/java/application/ShanghaiApplication.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | public class ShanghaiApplication { 4 | 5 | public static void main(String[] args) { 6 | System.out.println("Hello world!"); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /part14-Part14_02.FinnishParties/.tmcparams: -------------------------------------------------------------------------------- 1 | export SERVER="true" 2 | -------------------------------------------------------------------------------- /part14-Part14_02.FinnishParties/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part14-Part14_02.FinnishParties/nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CUSTOM-custom maven command 5 | custom maven command 6 | 7 | mvn 8 | -version 9 | 10 | 11 | 12 | run 13 | 14 | jar 15 | 16 | 17 | process-classes 18 | fi.helsinki.cs.tmc:runner-maven-plugin:1.0.1:run-javafx 19 | 20 | 21 | 22 | -classpath %classpath ${packageClassName} 23 | java 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /part14-Part14_02.FinnishParties/partiesdata.tsv: -------------------------------------------------------------------------------- 1 | Party 1968 1972 1976 1980 1984 1988 1992 1996 2000 2004 2008 2 | KOK 16.1 18.1 20.9 22.9 23.0 22.9 19.1 21.6 20.8 21.8 23.4 3 | SDP 23.9 27.1 24.8 25.5 24.7 25.2 27.1 24.5 23.0 24.1 21.2 4 | KESK 18.9 18.0 18.4 18.7 20.2 21.1 19.2 21.8 23.8 22.8 20.1 5 | VIHR - - - - 2.8 2.3 6.9 6.3 7.7 7.4 8.9 6 | VAS 16.9 17.5 18.5 16.6 13.1 12.6 11.7 10.4 9.9 9.6 8.8 7 | PS 7.3 5.0 2.1 3.0 5.3 3.6 2.4 0.9 0.7 0.9 5.4 8 | RKP 5.6 5.2 4.7 4.7 5.1 5.3 5.0 5.4 5.1 5.2 4.7 9 | -------------------------------------------------------------------------------- /part14-Part14_02.FinnishParties/src/main/java/application/PartiesApplication.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | public class PartiesApplication { 4 | 5 | public static void main(String[] args) { 6 | System.out.println("Hello world!"); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /part14-Part14_03.SavingsCalculator/.tmcparams: -------------------------------------------------------------------------------- 1 | export SERVER="true" 2 | -------------------------------------------------------------------------------- /part14-Part14_03.SavingsCalculator/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part14-Part14_03.SavingsCalculator/nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CUSTOM-custom maven command 5 | custom maven command 6 | 7 | mvn 8 | -version 9 | 10 | 11 | 12 | run 13 | 14 | jar 15 | 16 | 17 | process-classes 18 | fi.helsinki.cs.tmc:runner-maven-plugin:1.0.1:run-javafx 19 | 20 | 21 | 22 | -classpath %classpath ${packageClassName} 23 | java 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /part14-Part14_03.SavingsCalculator/src/main/java/application/SavingsCalculatorApplication.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | public class SavingsCalculatorApplication { 4 | 5 | public static void main(String[] args) { 6 | System.out.println("Hello world!"); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /part14-Part14_04.UnfairAdvertisement/.tmcparams: -------------------------------------------------------------------------------- 1 | export SERVER="true" 2 | -------------------------------------------------------------------------------- /part14-Part14_04.UnfairAdvertisement/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part14-Part14_04.UnfairAdvertisement/nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CUSTOM-custom maven command 5 | custom maven command 6 | 7 | mvn 8 | -version 9 | 10 | 11 | 12 | run 13 | 14 | jar 15 | 16 | 17 | process-classes 18 | fi.helsinki.cs.tmc:runner-maven-plugin:1.0.1:run-javafx 19 | 20 | 21 | 22 | -classpath %classpath ${packageClassName} 23 | java 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /part14-Part14_04.UnfairAdvertisement/src/test/java/application/UnfairAdvertisementApplicationTest.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | import fi.helsinki.cs.tmc.edutestutils.Points; 4 | import org.junit.Test; 5 | 6 | @Points("14-04") 7 | public class UnfairAdvertisementApplicationTest { 8 | 9 | @Test 10 | public void noTests() { 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /part14-Part14_05.CyclingStatistics/.tmcparams: -------------------------------------------------------------------------------- 1 | export SERVER="true" 2 | -------------------------------------------------------------------------------- /part14-Part14_05.CyclingStatistics/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part14-Part14_05.CyclingStatistics/nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CUSTOM-custom maven command 5 | custom maven command 6 | 7 | mvn 8 | -version 9 | 10 | 11 | 12 | run 13 | 14 | jar 15 | 16 | 17 | process-classes 18 | fi.helsinki.cs.tmc:runner-maven-plugin:1.0.1:run-javafx 19 | 20 | 21 | 22 | -classpath %classpath ${packageClassName} 23 | java 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /part14-Part14_06.Smiley/.tmcparams: -------------------------------------------------------------------------------- 1 | export SERVER="true" 2 | -------------------------------------------------------------------------------- /part14-Part14_06.Smiley/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part14-Part14_06.Smiley/nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CUSTOM-custom maven command 5 | custom maven command 6 | 7 | mvn 8 | -version 9 | 10 | 11 | 12 | run 13 | 14 | jar 15 | 16 | 17 | process-classes 18 | fi.helsinki.cs.tmc:runner-maven-plugin:1.0.1:run-javafx 19 | 20 | 21 | 22 | -classpath %classpath ${packageClassName} 23 | java 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /part14-Part14_06.Smiley/src/main/java/smiley/SmileyApplication.java: -------------------------------------------------------------------------------- 1 | package smiley; 2 | 3 | 4 | public class SmileyApplication { 5 | 6 | 7 | public static void main(String[] args) { 8 | System.out.println("Hello world!"); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /part14-Part14_07.Collage/.tmcparams: -------------------------------------------------------------------------------- 1 | export SERVER="true" 2 | -------------------------------------------------------------------------------- /part14-Part14_07.Collage/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part14-Part14_07.Collage/monalisa.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rwu8/mooc-java-programming-ii/2a70785bc1ae4f5b397e6fbc2e5694affe6e4bc1/part14-Part14_07.Collage/monalisa.png -------------------------------------------------------------------------------- /part14-Part14_07.Collage/nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CUSTOM-custom maven command 5 | custom maven command 6 | 7 | mvn 8 | -version 9 | 10 | 11 | 12 | run 13 | 14 | jar 15 | 16 | 17 | process-classes 18 | fi.helsinki.cs.tmc:runner-maven-plugin:1.0.1:run-javafx 19 | 20 | 21 | 22 | -classpath %classpath ${packageClassName} 23 | java 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /part14-Part14_08.Hurray/.tmcparams: -------------------------------------------------------------------------------- 1 | export SERVER="true" 2 | -------------------------------------------------------------------------------- /part14-Part14_08.Hurray/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part14-Part14_08.Hurray/nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CUSTOM-custom maven command 5 | custom maven command 6 | 7 | mvn 8 | -version 9 | 10 | 11 | 12 | run 13 | 14 | jar 15 | 16 | 17 | process-classes 18 | fi.helsinki.cs.tmc:runner-maven-plugin:1.0.1:run-javafx 19 | 20 | 21 | 22 | -classpath %classpath ${packageClassName} 23 | java 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /part14-Part14_08.Hurray/src/main/java/hurraa/HurraaSovellus.java: -------------------------------------------------------------------------------- 1 | package hurraa; 2 | 3 | import javafx.application.Application; 4 | import javafx.scene.Scene; 5 | import javafx.scene.control.Button; 6 | import javafx.scene.layout.BorderPane; 7 | import javafx.stage.Stage; 8 | 9 | public class HurraaSovellus extends Application { 10 | 11 | @Override 12 | public void start(Stage stage) throws Exception { 13 | BorderPane pane = new BorderPane(); 14 | 15 | Button nappi = new Button("Hurraa!"); 16 | pane.setCenter(nappi); 17 | 18 | 19 | Scene scene = new Scene(pane, 600, 400); 20 | 21 | stage.setScene(scene); 22 | stage.show(); 23 | } 24 | 25 | public static void main(String[] args) { 26 | launch(args); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /part14-Part14_08.Hurray/src/test/java/hurraa/HurraaSovellusTest.java: -------------------------------------------------------------------------------- 1 | package hurraa; 2 | 3 | import fi.helsinki.cs.tmc.edutestutils.Points; 4 | import org.junit.Test; 5 | 6 | public class HurraaSovellusTest { 7 | 8 | @Test 9 | @Points("14-08") 10 | public void noTests() { 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /part14-Part14_09.Asteroids/.tmcparams: -------------------------------------------------------------------------------- 1 | export SERVER="true" 2 | -------------------------------------------------------------------------------- /part14-Part14_09.Asteroids/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part14-Part14_09.Asteroids/nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CUSTOM-custom maven command 5 | custom maven command 6 | 7 | mvn 8 | -version 9 | 10 | 11 | 12 | run 13 | 14 | jar 15 | 16 | 17 | process-classes 18 | fi.helsinki.cs.tmc:runner-maven-plugin:1.0.1:run-javafx 19 | 20 | 21 | 22 | -classpath %classpath ${packageClassName} 23 | java 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /part14-Part14_09.Asteroids/src/main/java/asteroids/AsteroidsApplication.java: -------------------------------------------------------------------------------- 1 | package asteroids; 2 | 3 | public class AsteroidsApplication { 4 | 5 | public static void main(String[] args) { 6 | System.out.println("Hello, world!"); 7 | } 8 | 9 | public static int partsCompleted() { 10 | // State how many parts you have completed using the return value of this method 11 | return 0; 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /part14-Part14_09.Asteroids/src/test/java/asteroids/AsteroidsTest.java: -------------------------------------------------------------------------------- 1 | package asteroids; 2 | 3 | import fi.helsinki.cs.tmc.edutestutils.Points; 4 | import static junit.framework.Assert.assertTrue; 5 | import org.junit.Test; 6 | 7 | public class AsteroidsTest { 8 | 9 | @Test 10 | @Points("14-09.1") 11 | public void part1Done() { 12 | assertTrue(AsteroidsApplication.partsCompleted() >= 1); 13 | } 14 | 15 | @Test 16 | @Points("14-09.2") 17 | public void part2Done() { 18 | assertTrue(AsteroidsApplication.partsCompleted() >= 2); 19 | } 20 | 21 | @Test 22 | @Points("14-09.3") 23 | public void part3Done() { 24 | assertTrue(AsteroidsApplication.partsCompleted() >= 3); 25 | } 26 | 27 | @Test 28 | @Points("14-09.4") 29 | public void part4Done() { 30 | assertTrue(AsteroidsApplication.partsCompleted() >= 4); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /part14-Part14_10.Database/.tmcproject.yml: -------------------------------------------------------------------------------- 1 | force_new_sandbox: true 2 | -------------------------------------------------------------------------------- /part14-Part14_10.Database/src/main/java/application/Progam.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | import java.sql.SQLException; 4 | import java.util.Scanner; 5 | 6 | public class Progam { 7 | 8 | public static void main(String[] args) throws SQLException { 9 | String databasePath = "jdbc:h2:./todo-database"; 10 | if (args.length > 0) { 11 | databasePath = args[0]; 12 | } 13 | 14 | TodoDao database = new TodoDao(databasePath); 15 | Scanner scanner = new Scanner(System.in); 16 | 17 | new UserInterface(scanner, database).start(); 18 | } 19 | } 20 | --------------------------------------------------------------------------------