Skip to content
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

Adding a PR on - Tutorial 3/essential oodp/polymorphism solutions - OOPs concept with Inheritance+Polymorphism with abstraction #71

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Created by .ignore support plugin (hsz.mobi)
### Maven template
target/
test-output/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
Expand Down
118 changes: 67 additions & 51 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,56 +1,72 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.wakaleo.tutorials</groupId>
<artifactId>vet-clinic</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<groupId>com.wakaleo.tutorials</groupId>
<artifactId>vet-clinic</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>tutorials</name>
<url>http://maven.apache.org</url>
<name>tutorials</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<includes>
<include>**/When*.java</include>
<include>**/*Test.java</include>
<include>**/*TestSuite.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.8.0</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>23.0</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<includes>
<include>**/When*.java</include>
<include>**/*Test.java</include>
<include>**/*TestSuite.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package serenitylabs.tutorials.vetclinic.domain;
import java.time.LocalDateTime;

public class AppointmentBookerBuilderEntity {

private final String petName;
private String owner;
private String reason;

public AppointmentBookerBuilderEntity(String petName) {
this.petName = petName;
}

public AppointmentBookerBuilderEntity ownedBy(String owner) {
this.owner = owner;
return this;
}

public AppointmentBookerBuilderEntity because(String reason) {
this.reason = reason;
return this;
}

public AppointmentEntity at(LocalDateTime appointmentTime) {
return new AppointmentEntity(petName, owner, appointmentTime, reason);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package serenitylabs.tutorials.vetclinic.domain;
import java.time.LocalDateTime;
import java.util.Optional;

public class AppointmentEntity {

private final String petName;
private final String owner;
private final LocalDateTime appointmentTime;
private final Optional<String> reason;

public AppointmentEntity(String petName, String owner, LocalDateTime appointmentTime,String reason) {
this.petName = petName;
this.owner = owner;
this.appointmentTime = appointmentTime;
this.reason = Optional.ofNullable(reason);
}

public AppointmentEntity(String petName, String owner, LocalDateTime appointmentTime) {
this(petName, owner, appointmentTime, null);
}

public String getPetName() {
return petName;
}

public String getOwner() {
return owner;
}

public LocalDateTime getAppointmentTime() {
return appointmentTime;
}

public Optional<String> getReason() {
return reason;
}

public boolean isBefore(LocalDateTime isBeforeLocatDt)
{
return true;
}

public boolean isAfter(LocalDateTime isAfterLocatDt)
{
return true;
}


public static AppointmentBookerBuilderEntity forPetCalled(String petName) {
return new AppointmentBookerBuilderEntity(petName);

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package serenitylabs.tutorials.vetclinic.domain;
import java.time.LocalDate;

public class DogBreederEntityBuilder implements WithIBreedable,IwithColourable {

private String name;
private String breed;
private String favouriteColour;
private String optFldFavouriteFood;
private String optFldFavouriteToy;

public DogBreederEntityBuilder(String name) {
this.name=name;
System.out.println("DogBreederEntityBuilder - builders object initialized.");
}

public DogBreederEntityBuilder ofDogBreed(String breed) {
this.breed=breed;
return this;
}

public DogEntityImmutableType bornOn(LocalDate localDate) {
return new DogEntityImmutableType(name, breed, localDate,favouriteColour,optFldFavouriteFood,optFldFavouriteToy);
}


public DogEntity dgEntityBornOn(LocalDate localDate) {
return new DogEntity(name, breed, localDate,favouriteColour,optFldFavouriteFood,optFldFavouriteToy);
}

@Override
public IwithColourable ofBreed(String breed) {
return new DogBreederEntityBuilder(breed);
}

public DogBreederEntityBuilder ofDogColour(String strFavColour) {
this.favouriteColour=strFavColour;
return this;
}


public DogEntityImmutableType ofColour(String favColour) {
return new DogEntityImmutableType(favColour);
}

public DogBreederEntityBuilder setOptFldFavouriteFood(String strOptFavFood) {
this.optFldFavouriteFood=strOptFavFood;
return this;
}

public DogBreederEntityBuilder setOptFldFavouriteToy(String strOptFavToy) {
this.optFldFavouriteToy=strOptFavToy;
return this;
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package serenitylabs.tutorials.vetclinic.domain;
import java.time.LocalDate;

/**
* Mutable DogEntity class as its fields values state can be modifyed with the
* help of setter methods.
*
*/

public class DogEntity {

private String dogName;
private String dogBreed;
private LocalDate birthDateTime;
private String favouriteColour;
private String optFldFavouriteFood;
private String optFldFavouriteToy;

DogEntity(String dogName, String dogBreed, LocalDate birthDateTime,String favColour,String strFavFood,String strFavToy) {
this.dogName = dogName;
this.dogBreed = dogBreed;
this.birthDateTime = birthDateTime;
this.favouriteColour=favColour;
this.optFldFavouriteFood=strFavFood;
this.optFldFavouriteToy=strFavToy;
}

public DogEntity(){
System.out.println("Default constructor of Mutable DogEntity class called.");
}

public String getDogName() {
return dogName;
}
public String getDogBreed() {
return dogBreed;
}
public LocalDate getBirthDateTime() {
return birthDateTime;
}

public String getFavouriteColour() {
return favouriteColour;
}

public String getOptFldFavouriteFood() {
return optFldFavouriteFood;
}

public String getOptFldFavouriteToy() {
return optFldFavouriteToy;
}

public static WithIBreedable called(String name)
{
return new DogBreederEntityBuilder(name);
}

public DogEntity dgEntityBornOn(LocalDate localDate) {
return new DogEntity(dogName, dogBreed, localDate,favouriteColour,optFldFavouriteFood,optFldFavouriteToy);
}

public void setDogName(String strDgName) {
this.dogName=strDgName;
}

public void setDogBreed(String strDgBreed) {
this.dogBreed=strDgBreed;
}

public void setBirthDateTime(LocalDate locDateTimeObj) {
this.birthDateTime=locDateTimeObj;
}

}
Loading