Skip to content
Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
class AnnalynsInfiltration {
public static boolean canFastAttack(boolean knightIsAwake) {
throw new UnsupportedOperationException("Please implement the (static) AnnalynsInfiltration.canFastAttack() method");
public static boolean canFastAttack(boolean knightIsAwake){
// throw new UnsupportedOperationException("Please implement the (static) AnnalynsInfiltration.canFastAttack() method");
return !knightIsAwake;
}

public static boolean canSpy(boolean knightIsAwake, boolean archerIsAwake, boolean prisonerIsAwake) {
throw new UnsupportedOperationException("Please implement the (static) AnnalynsInfiltration.canSpy() method");
// throw new UnsupportedOperationException("Please implement the (static) AnnalynsInfiltration.canSpy() method");
return ((knightIsAwake || archerIsAwake) || prisonerIsAwake);
}

public static boolean canSignalPrisoner(boolean archerIsAwake, boolean prisonerIsAwake) {
throw new UnsupportedOperationException("Please implement the (static) AnnalynsInfiltration.canSignalPrisoner() method");
// throw new UnsupportedOperationException("Please implement the (static) AnnalynsInfiltration.canSignalPrisoner() method");
return !archerIsAwake && prisonerIsAwake;
}

public static boolean canFreePrisoner(boolean knightIsAwake, boolean archerIsAwake, boolean prisonerIsAwake, boolean petDogIsPresent) {
throw new UnsupportedOperationException("Please implement the (static) AnnalynsInfiltration.canFreePrisoner() method");
// throw new UnsupportedOperationException("Please implement the (static) AnnalynsInfiltration.canFreePrisoner() method");
return (prisonerIsAwake && !archerIsAwake && !knightIsAwake) || (!archerIsAwake && petDogIsPresent);
}
}
}
43 changes: 36 additions & 7 deletions exercises/concept/bird-watcher/src/main/java/BirdWatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,55 @@ public BirdWatcher(int[] birdsPerDay) {
}

public int[] getLastWeek() {
throw new UnsupportedOperationException("Please implement the BirdWatcher.getLastWeek() method");
// throw new UnsupportedOperationException("Please implement the BirdWatcher.getLastWeek() method");
int[] birdCount = new int[] {0,2,5,3,7,8,4};
return birdCount;
}

public int getToday() {
throw new UnsupportedOperationException("Please implement the BirdWatcher.getToday() method");
// throw new UnsupportedOperationException("Please implement the BirdWatcher.getToday() method");
return birdsPerDay[birdsPerDay.length-1];
}

public void incrementTodaysCount() {
throw new UnsupportedOperationException("Please implement the BirdWatcher.incrementTodaysCount() method");
/// throw new UnsupportedOperationException("Please implement the BirdWatcher.incrementTodaysCount() method");
birdsPerDay[birdsPerDay.length-1] += 1;
}

public boolean hasDayWithoutBirds() {
throw new UnsupportedOperationException("Please implement the BirdWatcher.hasDayWithoutBirds() method");
// throw new UnsupportedOperationException("Please implement the BirdWatcher.hasDayWithoutBirds() method");
boolean noBird = false;
for(int count : birdsPerDay){
if (count == 0){
noBird = true;
}

}
return noBird;
}

public int getCountForFirstDays(int numberOfDays) {
throw new UnsupportedOperationException("Please implement the BirdWatcher.getCountForFirstDays() method");
// throw new UnsupportedOperationException("Please implement the BirdWatcher.getCountForFirstDays() method");
int getTotalCount=0;
if(numberOfDays>birdsPerDay.length){
numberOfDays = birdsPerDay.length;
}
for(int i=0;i<numberOfDays;i++){
getTotalCount += birdsPerDay[i];
}
return getTotalCount;

}

public int getBusyDays() {
throw new UnsupportedOperationException("Please implement the BirdWatcher.getBusyDays() method");
// throw new UnsupportedOperationException("Please implement the BirdWatcher.getBusyDays() method");

int busyDays=0;
for (int count : birdsPerDay){
if(count >= 5) {
busyDays++;
}
}
return busyDays;
}
}
}
31 changes: 30 additions & 1 deletion exercises/concept/squeaky-clean/src/main/java/SqueakyClean.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
class SqueakyClean {
static String clean(String identifier) {
throw new UnsupportedOperationException("Please implement the (static) SqueakyClean.clean() method");
// throw new UnsupportedOperationException("Please implement the (static) SqueakyClean.clean() method");
int index =0;
String cleanString = identifier.replace(' ','_');
if(cleanString.contains("-")) {
index = cleanString.indexOf('-');
cleanString = cleanString.replace("-", "");
cleanString = cleanString.substring(0,index) + cleanString.substring(index,index+1).toUpperCase() + cleanString.substring(index+1);
}
char[] chars = cleanString.toCharArray();
String newString = "";
for(char c : chars) {
if(c=='4') c = 'a';
else if(c=='3') c = 'e';
else if(c=='0') c = 'o';
else if(c=='1') c = 'l';
else if(c=='7') c = 't';

newString += c;
}
cleanString = newString;

chars = cleanString.toCharArray();
newString = "";
for(char c : chars) {
if(Character.isAlphabetic(c)) newString += c;
else if(c=='_') newString += c;
}
cleanString = newString;

return cleanString;
}
}