update solid ex
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package com.baeldung.s;
|
||||
|
||||
public class BadBook {
|
||||
|
||||
private String name;
|
||||
private String author;
|
||||
private String text;
|
||||
|
||||
//constructor, getters and setters
|
||||
|
||||
|
||||
//methods that directly relate to the book properties
|
||||
public String replaceWordInText(String word){
|
||||
return text.replaceAll(word, text);
|
||||
}
|
||||
|
||||
public boolean isWordInText(String word){
|
||||
return text.contains(word);
|
||||
}
|
||||
|
||||
//methods for outputting text to console - should this really be here?
|
||||
void printTextToConsole(){
|
||||
//our code for formatting and printing the text
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.baeldung.s;
|
||||
|
||||
public class BookPrinter {
|
||||
|
||||
//methods for outputting text
|
||||
void printTextToConsole(String text){
|
||||
//our code for formatting and printing the text
|
||||
}
|
||||
|
||||
void printTextToAnotherMedium(String text){
|
||||
//code for writing to any other location..
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.baeldung.s;
|
||||
|
||||
public class GoodBook {
|
||||
|
||||
private String name;
|
||||
private String author;
|
||||
private String text;
|
||||
|
||||
//constructor, getters and setters
|
||||
|
||||
//methods that directly relate to the book properties
|
||||
public String replaceWordInText(String word){
|
||||
return text.replaceAll(word, text);
|
||||
}
|
||||
|
||||
public boolean isWordInText(String word){
|
||||
return text.contains(word);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user