Skip to content

Turning in Bob and Alice #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
/**
* Created by iyasuwatts on 10/17/17.
*/

import java.util.Scanner;
public class Main {

public static void main(String[] args ){

Scanner input = new Scanner(System.in);
System.out.println("What is your name?");
String name = input.nextLine();
if (isBob(name)){
System.out.println("Heya Bob, how're the kids?");
}
else if (isAlice(name)){
System.out.println("Alice! It's been a while! How's the Tennis Elbow?");
}
else{
System.out.println("You're not Bob or Alice! Get the hell out of here!");
}


}

public static boolean isBob (String name){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good use of the SRP programming principle. 👍

if (name.equals("Bob") || name.equals("bob")){
return true;
}
return false;
}

public static boolean isAlice (String name){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thumbs up for the SRP 👍
Thumbs down for the code redundancy...

Notice the similarities between isBob and isAlice.
When you see patterns of redundancy like this, it means it can be abstracted.

if (name.equals("Alice") || name.equals("alice")){
return true;
}
return false;
}
}