Skip to content

Commit

Permalink
feat: Clean repo. Rename jar file. Refactor following checkstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
ZenoxTek committed Nov 30, 2019
1 parent 2d4ac03 commit f0e0cf9
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 13 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ group 'org.example'
version '1.0'

mainClassName = 'Main'
archivesBaseName = 'chatbot'

sourceCompatibility = 1.8

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/ChatRoom.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public void setUserName(String name) {
public void initialize() throws IOException {
BufferedReader reader =
new BufferedReader(new InputStreamReader(System.in));
while (logic(reader));
while (logic(reader)) {

}
reader.close();
}

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ public class Main {
public static void main(String[] args) throws IOException {
// TODO: Parse string
Parser parser = new Parser(args);
if (!parser.parse())
return ;
if (!parser.parse()) {
return;
}
ChatRoom chatRoom = new ChatRoom();
chatRoom.setUserName(parser.getArgumentsAtIndex(0));
chatRoom.initialize();
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@ public class Parser {
this.argumentsReceived = args;
}

public String getArgumentsAtIndex(int index){
if (this.argumentsToReturn != null){
if (index < this.argumentsToReturn.size() && index >= 0){
public String getArgumentsAtIndex(int index) {
if (this.argumentsToReturn != null) {
if (index < this.argumentsToReturn.size() && index >= 0) {
return this.argumentsToReturn.get(index);
}
}
return null;
}

public boolean parse(){
if (this.argumentsReceived != null){
for (int i = 0 ; i < this.argumentsReceived.length ; i++){
if (this.argumentsReceived[i].equals("-p") && i + 1 < this.argumentsReceived.length){
public boolean parse() {
if (this.argumentsReceived != null) {
for (int i = 0; i < this.argumentsReceived.length; i++) {
if (this.argumentsReceived[i].equals("-p")
&& i + 1 < this.argumentsReceived.length) {
this.argumentsToReturn.add(this.argumentsReceived[i + 1]);
return true;
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ public class User {
private static final String SAY_FOO = "foo";
private static final String EXIT = "++";

public User() { }
public User() {

}

public void setUserName(String username) {
this.username = username;
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/BotTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ public void receiveMessage() {
Bot bot = new Bot();
bot.setUserName("Toto");

assertTrue(bot.receiveMessage("@hello"));
assertTrue(bot.receiveMessage("++"));
}

@Test
public void receiveWrongMessage() {
Bot bot = new Bot();
bot.setUserName("Toto");

assertFalse(bot.receiveMessage("@bonjour"));
assertFalse(bot.receiveMessage("@hello"));
}

@Test
Expand Down

0 comments on commit f0e0cf9

Please sign in to comment.