-
Notifications
You must be signed in to change notification settings - Fork 0
Core work4 #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SL-TX
wants to merge
5
commits into
master
Choose a base branch
from
core-work4
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Core work4 #16
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,37 @@ | ||
| package ru.skypro; | ||
|
|
||
| import ru.skypro.transport.*; | ||
|
|
||
| public class Main { | ||
| public static void main(String[] args){ | ||
|
|
||
| Car car1 = new Car("brand1","car1",1.6); | ||
| Transport car2 = new Car("brand2","car2",2.0); | ||
| Bus bus1 = new Bus("brand1","bus1",3.0); | ||
| Truck truck1 = new Truck("brand2","truck1",4.0); | ||
| car1.startMoving(); | ||
| car2.startMoving(); | ||
| bus1.startMoving(); | ||
| truck1.startMoving(); | ||
| truck1.stopMoving(); | ||
| car1.stopMoving(); | ||
| bus1.stopMoving(); | ||
| car2.stopMoving(); | ||
| car1.pitStop(); | ||
| car1.bestTime(); | ||
| car1.maxSpeed(); | ||
| truck1.pitStop(); | ||
| truck1.bestTime(); | ||
| truck1.maxSpeed(); | ||
| bus1.pitStop(); | ||
| bus1.bestTime(); | ||
| bus1.maxSpeed(); | ||
| Driver<Car> driver1 = new Driver<>("F I O 1", true,5); | ||
| Driver<Transport> driver2 = new Driver<>("F I O 2", false,0); | ||
| Driver<Bus> driver3 = new Driver<>("F I O 3", true,9); | ||
| Driver<Truck> driver4 = new Driver<>("F I O 4", true,7); | ||
| driver1.refill(car1); | ||
| driver2.refill(car2); | ||
| driver3.refill(bus1); | ||
| driver4.refill(truck1); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package ru.skypro.transport; | ||
|
|
||
| public class Bus extends Transport implements Competitive { | ||
|
|
||
| public Bus(String brand, String model, Double engineVolume) { | ||
| super(brand, model, engineVolume); | ||
| } | ||
|
|
||
| @Override | ||
| public void startMoving() { | ||
| super.startMoving(); | ||
| } | ||
|
|
||
| @Override | ||
| public void stopMoving() { | ||
| super.stopMoving(); | ||
| } | ||
| @Override | ||
| public void pitStop() { | ||
| System.out.println("false"); | ||
| } | ||
|
|
||
| @Override | ||
| public void maxSpeed() { | ||
| System.out.println("200"); | ||
| } | ||
|
|
||
| @Override | ||
| public void bestTime() { | ||
| System.out.println("9.00"); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package ru.skypro.transport; | ||
|
|
||
| public class Car extends Transport implements Competitive{ | ||
| public Car(String brand, String model, Double engineVolume) { | ||
| super(brand, model, engineVolume); | ||
| } | ||
|
|
||
| @Override | ||
| public void startMoving() { | ||
| super.startMoving(); | ||
| } | ||
|
|
||
| @Override | ||
| public void stopMoving() { | ||
| super.stopMoving(); | ||
| } | ||
|
|
||
| @Override | ||
| public void pitStop() { | ||
| System.out.println("false"); | ||
| } | ||
|
|
||
| @Override | ||
| public void maxSpeed() { | ||
| System.out.println("160"); | ||
| } | ||
|
|
||
| @Override | ||
| public void bestTime() { | ||
| System.out.println("10.00"); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package ru.skypro.transport; | ||
|
|
||
| public interface Competitive { | ||
| void pitStop(); | ||
| void maxSpeed(); | ||
| void bestTime(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package ru.skypro.transport; | ||
|
|
||
| public class Driver<T extends Transport > { | ||
| private String fio; | ||
| private Boolean haveRights; | ||
| private Integer stazh; | ||
|
|
||
| public Driver(String fio, Boolean haveRights, Integer stazh) { | ||
| this.fio = fio; | ||
| this.haveRights = haveRights; | ||
| this.stazh = stazh; | ||
| } | ||
|
|
||
| public void startMoving(T transport){ | ||
| transport.startMoving(); | ||
| } | ||
| public void stopMoving(T transport){ | ||
| transport.stopMoving(); | ||
|
|
||
| } | ||
| public void refill(T transport){ | ||
| System.out.println("водитель "+fio+" управляет автомобилем "+transport.getBrand()+" "+transport.getModel()+" и будет участвовать в заезде"); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| package ru.skypro.transport; | ||
|
|
||
| public abstract class Transport { | ||
| private String brand; | ||
| private String model; | ||
| private Double engineVolume; | ||
|
|
||
| public Transport(String brand, String model, Double engineVolume) { | ||
| this.brand = brand == null || brand.equals("") ? "default" : brand; | ||
| this.model = model == null || model.equals("") ? "default" : model; | ||
| this.engineVolume = (engineVolume == null || engineVolume<0) ? 1.6 : engineVolume; | ||
| } | ||
|
|
||
| public void startMoving(){ | ||
| System.out.println(this.getClass() +" "+ this.brand +" "+ this.model + "Начал движение"); | ||
| } | ||
| public void stopMoving(){ | ||
| System.out.println(this.getClass() +" "+ this.brand +" "+ this.model + "Закончил движение"); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "Transport{" + | ||
| "brand='" + brand + '\'' + | ||
| ", model='" + model + '\'' + | ||
| ", engineVolume=" + engineVolume + | ||
| '}'; | ||
| } | ||
|
|
||
| public String getBrand() { | ||
| return brand; | ||
| } | ||
|
|
||
| public String getModel() { | ||
| return model; | ||
| } | ||
|
|
||
| public void setBrand(String brand) { | ||
| this.brand = brand; | ||
| } | ||
|
|
||
| public void setModel(String model) { | ||
| this.model = model; | ||
| } | ||
|
|
||
| public Double getEngineVolume() { | ||
| return engineVolume; | ||
| } | ||
|
|
||
| public void setEngineVolume(Double engineVolume) { | ||
| this.engineVolume = engineVolume; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package ru.skypro.transport; | ||
|
|
||
| public class Truck extends Transport implements Competitive{ | ||
|
|
||
| public Truck(String brand, String model, Double engineVolume) { | ||
| super(brand, model, engineVolume); | ||
| } | ||
|
|
||
| @Override | ||
| public void startMoving() { | ||
| System.out.println(super.getBrand() +" "+ super.getModel() + " Начал движение"); | ||
| } | ||
|
|
||
| @Override | ||
| public void stopMoving() { | ||
| System.out.println(super.getBrand() +" "+ super.getModel() + " Закончил движение"); | ||
| } | ||
|
|
||
| @Override | ||
| public void pitStop() { | ||
| System.out.println("true"); | ||
| } | ||
|
|
||
| @Override | ||
| public void maxSpeed() { | ||
| System.out.println("330"); | ||
| } | ||
|
|
||
| @Override | ||
| public void bestTime() { | ||
| System.out.println("6.00"); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Должно быть так, у нас водители которые ездят на гоночных автомобилях а не просто на транспорте: extends Transport implements Competitive