Created
May 11, 2016 14:14
-
-
Save dante-byte/31e8e71d48e08d697d733bb65c825acd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tiy.week6; | |
/** | |
* Created by Dominique on 5/2/2016. | |
*/ | |
public class Dominique implements Programmer { | |
@Override | |
public void sayHello() { | |
System.out.println("Hello, from Dominique"); | |
} | |
@Override | |
public String getId() { | |
return "dominique@theironyard.com"; | |
} | |
@Override | |
public boolean isJavaProgrammer() { | |
return true; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tiy.week6; | |
/** | |
* Created by Dominique on 5/2/2016. | |
*/ | |
public class DominiqueRunner extends RunnerBase { | |
public DominiqueRunner(Programmer programmer) { | |
super(programmer); | |
} | |
public static void main(String[] args) { | |
Dominique dominique = new Dominique(); | |
DominiqueRunner runner = new DominiqueRunner(dominique); | |
runner.runProgrammer(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tiy.week6; | |
/** | |
* Created by Donta White on 5/2/2016. | |
*/ | |
public class DontaRunner extends RunnerBase { | |
public DontaRunner(Programmer programmer) { | |
super(programmer); | |
} | |
public static void main(String[] args) { | |
DontaWhite donta = new DontaWhite(); | |
DominiqueRunner runner = new DominiqueRunner(donta); | |
runner.runProgrammer(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tiy.week6; | |
/** | |
* Created by Donta White on 5/2/2016. | |
*/ | |
public class DontaWhite implements Programmer { | |
@Override | |
public void sayHello() { | |
System.out.println("Hello, from Dominique"); | |
} | |
@Override | |
public String getId() { | |
return "dominique@theironyard.com"; | |
} | |
@Override | |
public boolean isJavaProgrammer() { | |
return true; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tiy.week6; | |
/** | |
* Created by Dominique on 5/2/2016. | |
*/ | |
public interface Programmer { | |
public void sayHello(); | |
public String getId(); | |
public boolean isJavaProgrammer(); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tiy.week6; | |
/** | |
* Created by Dominique on 5/2/2016. | |
*/ | |
public class RunnerBase { | |
Programmer programmer; | |
public RunnerBase() { | |
} | |
public RunnerBase(Programmer programmer) { | |
this.programmer = programmer; | |
} | |
public void runProgrammer() { | |
programmer.sayHello(); | |
if (programmer.isJavaProgrammer()) { | |
System.out.println(programmer.getId() + " is a Java Programmer"); | |
} else { | |
System.out.println(programmer.getId() + " is not a Java Programmer"); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tiy.week6; | |
/** | |
* Created by Dominique on 5/2/2016. | |
*/ | |
public class Steve implements Programmer { | |
@Override | |
public void sayHello() { | |
System.out.println("Hello, from Steve"); | |
} | |
@Override | |
public String getId() { | |
return "steve@google.com"; | |
} | |
@Override | |
public boolean isJavaProgrammer() { | |
return true; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tiy.week6; | |
/** | |
* Created by Dominique on 5/2/2016. | |
*/ | |
public class SteveRunner extends RunnerBase { | |
public SteveRunner(Programmer programmer) { | |
super(programmer); | |
} | |
public static void main(String[] args) { | |
Steve steve = new Steve(); | |
SteveRunner runner = new SteveRunner(steve); | |
runner.runProgrammer(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tiy.week6; | |
/** | |
* Created by Dominique on 5/2/2016. | |
*/ | |
public class StringExercise { | |
public String reserveString(String toReverse) { | |
if (toReverse == null) { | |
return toReverse; | |
} | |
char[] toReverseArray = toReverse.toCharArray(); | |
// char[] reversedArray = new char[toReverseArray.length]; | |
int charIndex = toReverseArray.length -1; | |
StringBuilder reverseBuilder = new StringBuilder(); | |
for (char currentChar : toReverseArray) { | |
reverseBuilder.append(toReverseArray[charIndex]); | |
charIndex--; | |
} | |
return reverseBuilder.toString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment