-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a961c27
Showing
11 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
HELP.md | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/**/target/ | ||
!**/src/test/**/target/ | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### VS Code ### | ||
.vscode/ |
This file contains 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 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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>se.nackademin.java20</groupId> | ||
<artifactId>solid</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.5.1</version> | ||
<configuration> | ||
<source>11</source> | ||
<target>11</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
17 changes: 17 additions & 0 deletions
17
src/main/java/se/nackademin/java20/solid/_1sre/violation/Account.java
This file contains 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,17 @@ | ||
package se.nackademin.java20.solid._1sre.violation; | ||
|
||
public class Account { | ||
private int balance; | ||
|
||
public Account(int balance) { | ||
this.balance = balance; | ||
} | ||
|
||
public void deposit(int money) { | ||
this.balance += money; | ||
} | ||
|
||
public void print() { | ||
System.out.println("Current balance: " + balance); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/se/nackademin/java20/solid/_2ocp/violation/Validator.java
This file contains 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,11 @@ | ||
package se.nackademin.java20.solid._2ocp.violation; | ||
|
||
public class Validator { | ||
|
||
public boolean validate(int quantity) { | ||
if (quantity < 0) return false; | ||
if (quantity > 100) return false; | ||
return true; | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/se/nackademin/java20/solid/_3lsp/violation/Rectangle.java
This file contains 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,23 @@ | ||
package se.nackademin.java20.solid._3lsp.violation; | ||
|
||
public class Rectangle { | ||
private int width; | ||
private int height; | ||
|
||
public Rectangle(int width, int height) { | ||
this.width = width; | ||
this.height = height; | ||
} | ||
|
||
public void setWidth(int width) { | ||
this.width = width; | ||
} | ||
|
||
public void setHeight(int height) { | ||
this.height = height; | ||
} | ||
|
||
public int area() { | ||
return width * height; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/se/nackademin/java20/solid/_3lsp/violation/Square.java
This file contains 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,20 @@ | ||
package se.nackademin.java20.solid._3lsp.violation; | ||
|
||
public class Square extends Rectangle { | ||
public Square(int width, int height) { | ||
super(width, height); | ||
} | ||
|
||
@Override | ||
public void setWidth(int width) { | ||
super.setWidth(width); | ||
super.setHeight(width); | ||
} | ||
|
||
@Override | ||
public void setHeight(int height) { | ||
super.setHeight(height); | ||
super.setWidth(height); | ||
} | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/se/nackademin/java20/solid/_4isp/violation/Animal.java
This file contains 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,6 @@ | ||
package se.nackademin.java20.solid._4isp.violation; | ||
|
||
public interface Animal { | ||
void run(); | ||
void jump(); | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/se/nackademin/java20/solid/_4isp/violation/Elephant.java
This file contains 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,14 @@ | ||
package se.nackademin.java20.solid._4isp.violation; | ||
|
||
public class Elephant implements Animal { | ||
@Override | ||
public void run() { | ||
System.out.println("I am running super fast!"); | ||
} | ||
|
||
@Override | ||
public void jump() { | ||
throw new UnsupportedOperationException("I cannot jump!"); | ||
|
||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/se/nackademin/java20/solid/_4isp/violation/Tiger.java
This file contains 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,14 @@ | ||
package se.nackademin.java20.solid._4isp.violation; | ||
|
||
public class Tiger implements Animal { | ||
@Override | ||
public void run() { | ||
System.out.println("Like the speed of light!"); | ||
} | ||
|
||
@Override | ||
public void jump() { | ||
System.out.println("Jumping highest of them all!"); | ||
|
||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/se/nackademin/java20/solid/_5dip/violation/ConsolePrinter.java
This file contains 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 se.nackademin.java20.solid._5dip.violation; | ||
|
||
public class ConsolePrinter { | ||
void print(String text) { | ||
System.out.println(text); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/se/nackademin/java20/solid/_5dip/violation/TextPrinter.java
This file contains 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,13 @@ | ||
package se.nackademin.java20.solid._5dip.violation; | ||
|
||
public class TextPrinter { | ||
private final ConsolePrinter consolePrinter; | ||
|
||
public TextPrinter(ConsolePrinter consolePrinter) { | ||
this.consolePrinter = consolePrinter; | ||
} | ||
|
||
public void print(String text) { | ||
consolePrinter.print(text); | ||
} | ||
} |