JavaBootcamp:工具和思想的发源地

  • n2_767973
    了解作者
  • 71.6KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-14 19:57
    上传日期
Java Bootcamp中的项目 该存储库包含一些较小的项目-在下面的训练营中编写的代码练习。 每个项目都有一个任务内容以及从此存储库到我的解决方案的链接。 科技类 Java 11 玛文 JUnit的 目录 具有任务内容的项目 1.类和对象 1.1 创建类引擎。 引擎具有以下特性: 姓名, 马力, 容量, isStarted状态。 发动机可以启动或停止。 发动机每100 km / h速度需要50马力。 发动机每行驶100公里所消耗的燃料是其容量的10倍以上。 例如,如果发动机容量为2000 cm3(2L)-100公里需要20L。 创建类Car。 汽车具有以下特性: 姓名, 引擎(在引擎类后面查看), 油箱容量, 剩余燃油量。 汽车可以是tank(),可以将其满载。 可以开车(速度为N公里)。 速度受发动机可能性的限制。 汽车可以启动引擎()。 汽车可以stopE
JavaBootcamp-master.zip
内容介绍
# Projects from Java Bootcamp This repository contains a collection of smaller projects - coding excercises made during the bootcamp listed below. Each project has a task content and a link to my solution from this repository. ## Tech - Java 11 - Maven - JUnit ## Table of contents - [1. Classes and Objects](#1-classes-and-objects) - [1.1 Car with engine](#11-car-with-engine) - [1.2 Mobile phone](#12-mobile-phone) - [1.3 Cat](#13-cat) - [2. OOP principles](#2-oop-principles) - [2.1 Person and student](#21-person-and-student) - [2.2 Inheritance](#22-inheritance) - [2.3 Polymorphism](#23-polymorphism) - [3. Interface](#3-interface) - [3.1 Car with interface](#31-car-with-interface) - [4. Algorithms](#4-algorithms) - [4.1 Letter counter](#41-letter-counter) - [4.2 Factorial](#42-letter-counter) - [4.3 Fibonacci sequence](#43-fibonacci-sequence) - [4.4 The longest and the shortest words](#44-the-longest-and-the-shortest-words) - [4.5 Bubble sort](#45-bubble-sort) - [5. Object methods](#5-object-methods) - [5.1 Beer](#51-beer) - [5.2 Laptop cloning](#52-laptop-cloning) - [6. Collection framework](#6-collection-framework) - [6.1 Parts catalogue](#61-parts-catalogue) - [6.2 ArrayList vs LinkedList](#62-arraylist-vs-linkedlist) - [6.3 Unique letters](#63-unique-letters) - [7. Comparing objects](#7-comparing-objects) - [7.1 Items in online store](#71-items-in-online-store) - [8. Simple bank application](#8-simple-bank-application) - [8.1 Bank accounts](#81-bank-accounts) - [8.2 Transaction log](#82-transaction-log) - [8.3 Handle exceptions](#83-handle_exceptions) - [9. Generics](#9-generics) - [9.1 Boxes and shelves](#91-boxes-and-shelves) - [10. Enums](#10-enums) - [10.1 Week days](#101-week-days) - [11. Java 8 features](#11-java-8-features) - [11.1 Streams and lambdas](#111-streams-and-lambdas) - [11.2 User name with optional](#112-user-name-with-optional) - [11.3 Lambdas](#113-lambdas) - [12. Annotations](#12-annotations) - [12.1 Execute annotated method](#121-execute-annotated-method) - [13. Immutable objects](#13-immutable-objects) - [13.1 Immutable car](#13-1immutable-car) - [14. JUnit](#14-junit) - [14.1 Test bank application](#141-test-bank-application) - [15. Additional stuff](#15-additional-stuff) - [15.1 Work with files](#151-work-with-files) ## Projects with task content ### 1. Classes and Objects #### 1.1 [Car with engine](https://github.com/karolkurbiel/JavaBootcamp/tree/master/src/master/java/itacademy/_8/carwithengine) Create class Engine. Engine has properties: - name, - horsepower, - capacity, - isStarted status. Engine can be started or stopped. Engine need 50 horsepower for each 100 km/h speed. Engine uses fuel 10 times more than his capacity for each 100 km. For example, if engine capacity is 2000 cm3 (2L) - it need 20L for 100km. Create class Car. Car has properties: - name, - Engine (look behind for Engine class), - fuel tank capacity, - remaining fuel amount. - Car can be tank(), which tanks up for full capacity. Car can be drive(with speed, for N kilometers). Speed limited by Engine possibilities. Car can startEngine(). Car can stopEngine(); For drive a car we should start engine first. We can't start engine if it already started. We can't stop engine if it already stop. #### 1.2 [Mobile phone](https://github.com/karolkurbiel/JavaBootcamp/tree/master/src/master/java/itacademy/_8/mobilephone) Create class MobilePhone. Mobile phone has properties: - brand, - model, - battery capacity, - battery amount, - memory, - free memory. Mobile phone can be charged, which will make battery charged for full. Mobile phone can install(application name, which take out some amount of memory). Mobile phone can use some application(for n hours), each hour decrease remain battery amount for 100 mah. Discharged phone can't do anything except charge. If there are no free memory - new applications can't be installed. #### 1.3 [Cat](https://github.com/karolkurbiel/JavaBootcamp/tree/master/src/master/java/itacademy/_8/cat) Create class Cat. Cat has properites: name and isHungry. Cat can eat(some food), play(with toy) and sleep(some time). Cat also should be able to notify us is it hungry, or not. Cat never hungry after eating. And always hungry after sleeping. Cat never eats if it is not hungry. ### 2. OOP principles #### 2.1 [Person and student](https://github.com/karolkurbiel/JavaBootcamp/tree/master/src/master/java/itacademy/_10/personandstudent) Create classes Person and Student. One should extend another. Person should have private properties FirstName, LastName, BirthDate (type java.time.LocalDate) Create constructor with all mentioned parameters. Student should have additional private properties Faculty and GraduateYear Create constructor for Student, which has all the same parameters as Person, but also Faculty and GraduateYear. Inside of Student constructor use super constructor for Person. For Person and for Student create getter methods. Getter method - is a method which just returns value of private property. For Person and for Student create setter methods. Setter method - is a method which sets value for private property. #### 2.2 [Inheritance](https://github.com/karolkurbiel/JavaBootcamp/tree/master/src/master/java/itacademy/_10/inheritanceandpolymorphism) Create class hierarchy: Airplane, Transport, Car, Bus, Train, Bicycle, Tram, Public Transport, Scooter, Motorbike Think carefully which class should be parent to another. #### 2.3 [Polymorphism](https://github.com/karolkurbiel/JavaBootcamp/tree/master/src/master/java/itacademy/_10/inheritanceandpolymorphism) 1. Finish Inheritance task first. 2. In parent class create a METHOD which related to each child class. 3. In children classes override the METHOD, change the behavior in depends of class type. Create class for testing polymorphism. 1. Create main method for testing. 2. Create a method, which expects as a parameter object of the parent type for created hierarchy. Inside of this method call the METHOD from the object. Play around passing different class types to method and see what happens. ### 3. Interface #### 3.1 [Car with interface](https://github.com/karolkurbiel/JavaBootcamp/tree/master/src/master/java/itacademy/_11/carwinterface) Create Car class. It has manufacturer and model properties. Create constructor, setters and getters. Create interface Tankable with method tank() Create interface Chargable with method charge() Create class FuelCar, which extends Car and implements Tankable Create class ElectricCar, which extends Car and implements Chargable Create class HybridCar, which extends Car and implements Tankable and Chargable. Create CarTester class. Create several instances of different cars. Create array of cars. Put all the before created cars into that array. Iterate over array. Inside of loop check with instanceof operator: - if car is Chargable - charge it; - if car is Tankable - tank it. ### 4. Algorithms #### 4.1 [Letter counter](https://github.com/karolkurbiel/JavaBootcamp/tree/master/src/master/java/itacademy/_14/lettercounter) For given text print out count for each letter inside. For example: "This is a test text" Should give a response: T - 1, h - 1, i - 2, s - 3... and so on. #### 4.2 [Factorial](https://github.com/karolkurbiel/JavaBootcamp/tree/master/src/master/java/itacademy/_12/Factorial) Print factorial for numbers from 0 to 10. Expected output: 1 1 2 6 24 120 720 5040 40320 362880 3628800 For solution you should use recursive method call. #### 4.3 [Fibonacci sequence](https://github.com/karolkurbiel/JavaBootcamp/tree/master/src/master/java/itacademy/_9/fibonacci) Print first 10 numbers from Fibonacci Sequence. Expected output: 0 1 1 2 3 5 8 13 21 34 As a solution you should use method with recursive call. #### 4.4 [The longest and the shortest words](https://github.com/karolkurbiel/JavaBootcamp/tree/master/src/master/java/itac
评论
    相关推荐