diff --git a/exercises/concept/annalyns-infiltration/src/main/java/AnnalynsInfiltration.java b/exercises/concept/annalyns-infiltration/src/main/java/AnnalynsInfiltration.java index 97a724d39..6d5bb7d84 100644 --- a/exercises/concept/annalyns-infiltration/src/main/java/AnnalynsInfiltration.java +++ b/exercises/concept/annalyns-infiltration/src/main/java/AnnalynsInfiltration.java @@ -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); } -} +} \ No newline at end of file diff --git a/exercises/concept/bird-watcher/src/main/java/BirdWatcher.java b/exercises/concept/bird-watcher/src/main/java/BirdWatcher.java index c19dd38e6..23efc7b8f 100644 --- a/exercises/concept/bird-watcher/src/main/java/BirdWatcher.java +++ b/exercises/concept/bird-watcher/src/main/java/BirdWatcher.java @@ -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= 5) { + busyDays++; + } + } + return busyDays; } -} +} \ No newline at end of file diff --git a/exercises/concept/squeaky-clean/src/main/java/SqueakyClean.java b/exercises/concept/squeaky-clean/src/main/java/SqueakyClean.java index c56787fab..2a8d51751 100644 --- a/exercises/concept/squeaky-clean/src/main/java/SqueakyClean.java +++ b/exercises/concept/squeaky-clean/src/main/java/SqueakyClean.java @@ -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; } }