Skip to content

Commit

Permalink
feat: Create main. Build Jar
Browse files Browse the repository at this point in the history
  • Loading branch information
ZenoxTek committed Nov 30, 2019
1 parent c78e8c4 commit 2d4ac03
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
8 changes: 7 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ jacocoTestReport {
}
}

jar {
manifest {
attributes 'Main-Class': 'Main'
}
}

group 'org.example'
version '1.0-SNAPSHOT'
version '1.0'

mainClassName = 'Main'

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/Bot.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ private boolean parseMessage(String message) {
if (message.equals("@hello")) {
this.botName = "hello";
this.formatResponse();
return true;
System.out.println(getResponse());
return false;
}
return false;
return message.equals("++");
}
}
4 changes: 1 addition & 3 deletions src/main/java/ChatRoom.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@ public void initialize() throws IOException {
BufferedReader reader =
new BufferedReader(new InputStreamReader(System.in));
while (logic(reader));
reader.close();
}

private boolean logic(BufferedReader reader) throws IOException {
user.displayUserName();
String command = reader.readLine();
user.getUserMessage(command);
if (bot.receiveMessage(command)) {
System.out.println(bot.getResponse());
user.sayByeToBot();
return false;
}
return true;
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ public class Main {

public static void main(String[] args) throws IOException {
// TODO: Parse string
Parser parser = new Parser(args);
if (!parser.parse())
return ;
ChatRoom chatRoom = new ChatRoom();
chatRoom.setUserName("Toto");
chatRoom.setUserName(parser.getArgumentsAtIndex(0));
chatRoom.initialize();
}
}
11 changes: 0 additions & 11 deletions src/main/java/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,7 @@ public String getUserName() {
return this.username;
}

public void getUserMessage(String msg) {
System.out.println(msg);
}

public void displayUserName() {
System.out.print("[" + this.username + "] ");
}

public void sayByeToBot() {
displayUserName();
System.out.println(SAY_FOO);
displayUserName();
System.out.println(EXIT);
}
}

0 comments on commit 2d4ac03

Please sign in to comment.