PR review changes
This commit is contained in:
parent
6a05a88066
commit
369c5bae80
|
@ -2,41 +2,41 @@ package com.baeldung.interface_vs_abstract_class;
|
|||
|
||||
public class Car extends Vehicle {
|
||||
|
||||
public Car(String vechicleName) {
|
||||
super(vechicleName);
|
||||
}
|
||||
public Car(String vechicleName) {
|
||||
super(vechicleName);
|
||||
}
|
||||
|
||||
public Car(String vechicleName, String vehicleModel) {
|
||||
super(vechicleName, vehicleModel);
|
||||
}
|
||||
public Car(String vechicleName, String vehicleModel) {
|
||||
super(vechicleName, vehicleModel);
|
||||
}
|
||||
|
||||
public Car(String vechicleName, String vehicleModel, Long makeYear) {
|
||||
super(vechicleName, vehicleModel, makeYear);
|
||||
}
|
||||
public Car(String vechicleName, String vehicleModel, Long makeYear) {
|
||||
super(vechicleName, vehicleModel, makeYear);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void start() {
|
||||
// code implementation details on starting a car.
|
||||
}
|
||||
@Override
|
||||
protected void start() {
|
||||
// code implementation details on starting a car.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void stop() {
|
||||
// code implementation details on stopping a car.
|
||||
}
|
||||
@Override
|
||||
protected void stop() {
|
||||
// code implementation details on stopping a car.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drive() {
|
||||
// code implementation details on start driving a car.
|
||||
}
|
||||
@Override
|
||||
protected void drive() {
|
||||
// code implementation details on start driving a car.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void changeGear() {
|
||||
// code implementation details on changing the car gear.
|
||||
}
|
||||
@Override
|
||||
protected void changeGear() {
|
||||
// code implementation details on changing the car gear.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void reverse() {
|
||||
// code implementation details on reverse driving a car.
|
||||
}
|
||||
@Override
|
||||
protected void reverse() {
|
||||
// code implementation details on reverse driving a car.
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ import java.io.File;
|
|||
|
||||
public class ImageSender implements Sender {
|
||||
|
||||
@Override
|
||||
public void send(File fileToBeSent) {
|
||||
// image sending implementation code.
|
||||
}
|
||||
@Override
|
||||
public void send(File fileToBeSent) {
|
||||
// image sending implementation code.
|
||||
}
|
||||
|
||||
}
|
|
@ -4,5 +4,5 @@ import java.io.File;
|
|||
|
||||
public interface Sender {
|
||||
|
||||
void send(File fileToBeSent);
|
||||
void send(File fileToBeSent);
|
||||
}
|
||||
|
|
|
@ -2,56 +2,56 @@ package com.baeldung.interface_vs_abstract_class;
|
|||
|
||||
public abstract class Vehicle {
|
||||
|
||||
private String vehicleName;
|
||||
private String vehicleModel;
|
||||
private Long makeYear;
|
||||
private String vehicleName;
|
||||
private String vehicleModel;
|
||||
private Long makeYear;
|
||||
|
||||
public Vehicle(String vehicleName) {
|
||||
this.vehicleName = vehicleName;
|
||||
}
|
||||
public Vehicle(String vehicleName) {
|
||||
this.vehicleName = vehicleName;
|
||||
}
|
||||
|
||||
public Vehicle(String vehicleName, String vehicleModel) {
|
||||
this(vehicleName);
|
||||
this.vehicleModel = vehicleModel;
|
||||
}
|
||||
public Vehicle(String vehicleName, String vehicleModel) {
|
||||
this(vehicleName);
|
||||
this.vehicleModel = vehicleModel;
|
||||
}
|
||||
|
||||
public Vehicle(String vechicleName, String vehicleModel, Long makeYear) {
|
||||
this(vechicleName, vehicleModel);
|
||||
this.makeYear = makeYear;
|
||||
}
|
||||
public Vehicle(String vechicleName, String vehicleModel, Long makeYear) {
|
||||
this(vechicleName, vehicleModel);
|
||||
this.makeYear = makeYear;
|
||||
}
|
||||
|
||||
public String getVehicleName() {
|
||||
return vehicleName;
|
||||
}
|
||||
public String getVehicleName() {
|
||||
return vehicleName;
|
||||
}
|
||||
|
||||
public void setVehicleName(String vehicleName) {
|
||||
this.vehicleName = vehicleName;
|
||||
}
|
||||
public void setVehicleName(String vehicleName) {
|
||||
this.vehicleName = vehicleName;
|
||||
}
|
||||
|
||||
public String getVehicleModel() {
|
||||
return vehicleModel;
|
||||
}
|
||||
public String getVehicleModel() {
|
||||
return vehicleModel;
|
||||
}
|
||||
|
||||
public void setVehicleModel(String vehicleModel) {
|
||||
this.vehicleModel = vehicleModel;
|
||||
}
|
||||
public void setVehicleModel(String vehicleModel) {
|
||||
this.vehicleModel = vehicleModel;
|
||||
}
|
||||
|
||||
public Long getMakeYear() {
|
||||
return makeYear;
|
||||
}
|
||||
public Long getMakeYear() {
|
||||
return makeYear;
|
||||
}
|
||||
|
||||
public void setMakeYear(Long makeYear) {
|
||||
this.makeYear = makeYear;
|
||||
}
|
||||
public void setMakeYear(Long makeYear) {
|
||||
this.makeYear = makeYear;
|
||||
}
|
||||
|
||||
protected abstract void start();
|
||||
protected abstract void start();
|
||||
|
||||
protected abstract void stop();
|
||||
protected abstract void stop();
|
||||
|
||||
protected abstract void drive();
|
||||
protected abstract void drive();
|
||||
|
||||
protected abstract void changeGear();
|
||||
protected abstract void changeGear();
|
||||
|
||||
protected abstract void reverse();
|
||||
protected abstract void reverse();
|
||||
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ import java.io.File;
|
|||
|
||||
public class VideoSender implements Sender {
|
||||
|
||||
@Override
|
||||
public void send(File fileToBeSent) {
|
||||
// video sending implementation code
|
||||
}
|
||||
@Override
|
||||
public void send(File fileToBeSent) {
|
||||
// video sending implementation code
|
||||
}
|
||||
|
||||
}
|
|
@ -7,14 +7,14 @@ import java.io.File;
|
|||
|
||||
class SenderUnitTest {
|
||||
|
||||
public final static String IMAGE_FILE_PATH = "/sample_image_file_path/photo.jpg";
|
||||
public final static String IMAGE_FILE_PATH = "/sample_image_file_path/photo.jpg";
|
||||
|
||||
@Test
|
||||
void givenImageUploaded_whenButtonClicked_thenSendImage() {
|
||||
File imageFile = new File(IMAGE_FILE_PATH);
|
||||
@Test
|
||||
void givenImageUploaded_whenButtonClicked_thenSendImage() {
|
||||
File imageFile = new File(IMAGE_FILE_PATH);
|
||||
|
||||
Sender sender = new ImageSender();
|
||||
sender.send(imageFile);
|
||||
}
|
||||
Sender sender = new ImageSender();
|
||||
sender.send(imageFile);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@ import org.junit.jupiter.api.Test;
|
|||
|
||||
class VehicleUnitTest {
|
||||
|
||||
@Test
|
||||
void givenVehicle_whenNeedToDrive_thenStart() {
|
||||
Vehicle car = new Car("BMW");
|
||||
@Test
|
||||
void givenVehicle_whenNeedToDrive_thenStart() {
|
||||
Vehicle car = new Car("BMW");
|
||||
|
||||
car.start();
|
||||
car.drive();
|
||||
car.changeGear();
|
||||
car.stop();
|
||||
}
|
||||
car.start();
|
||||
car.drive();
|
||||
car.changeGear();
|
||||
car.stop();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue