Skip to content

Commit 5dd1371

Browse files
author
ccarella
committedApr 27, 2020
first commit
1 parent dc3b47a commit 5dd1371

File tree

8 files changed

+115
-0
lines changed

8 files changed

+115
-0
lines changed
 

‎.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.gradle/
2+
.idea/
3+
gradle/
4+
gradlew
5+
gradlew.bat

‎README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Design Principles
2+
3+
Solid Java

‎build.gradle

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
plugins {
2+
id 'java'
3+
}
4+
5+
group 'org.example'
6+
version '1.0-SNAPSHOT'
7+
8+
sourceCompatibility = 1.8
9+
10+
repositories {
11+
mavenCentral()
12+
}
13+
14+
dependencies {
15+
testCompile group: 'junit', name: 'junit', version: '4.12'
16+
}

‎settings.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
rootProject.name = 'designprinciples'
2+

‎src/README.md

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package singleresponsability;
2+
3+
// A separate class that is concerned only with printing
4+
public class BookPrinter {
5+
6+
// methods for outputting text
7+
void printTextToConsole(String text){
8+
//our code for formatting and printing the text
9+
}
10+
11+
void printTextToAnotherMedium(String text){
12+
// code for writing to any other location..
13+
}
14+
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package singleresponsability;
2+
3+
public class BookV1 {
4+
5+
private String name;
6+
private String author;
7+
private String text;
8+
9+
public BookV1(String name, String author, String text) {
10+
this.name = name;
11+
this.author = author;
12+
this.text = text;
13+
}
14+
15+
public String replaceWordInText(String word){
16+
return text.replaceAll(word, text);
17+
}
18+
19+
public boolean isWordInText(String word){
20+
return text.contains(word);
21+
}
22+
23+
void printTextToConsole() {
24+
// our code for formatting and printing the text
25+
}
26+
27+
public String getName() {
28+
return name;
29+
}
30+
31+
public String getAuthor() {
32+
return author;
33+
}
34+
35+
public String getText() {
36+
return text;
37+
}
38+
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package singleresponsability;
2+
3+
public class BookV2 {
4+
5+
private String name;
6+
private String author;
7+
private String text;
8+
9+
public BookV2(String name, String author, String text) {
10+
this.name = name;
11+
this.author = author;
12+
this.text = text;
13+
}
14+
15+
public String replaceWordInText(String word){
16+
return text.replaceAll(word, text);
17+
}
18+
19+
public boolean isWordInText(String word){
20+
return text.contains(word);
21+
}
22+
23+
public String getName() {
24+
return name;
25+
}
26+
27+
public String getAuthor() {
28+
return author;
29+
}
30+
31+
public String getText() {
32+
return text;
33+
}
34+
35+
}

0 commit comments

Comments
 (0)