diff --git a/0-0-intro/src/main/java/com/bobocode/intro/ExerciseIntroduction.java b/0-0-intro/src/main/java/com/bobocode/intro/ExerciseIntroduction.java index 35d925636..e93dcdf62 100644 --- a/0-0-intro/src/main/java/com/bobocode/intro/ExerciseIntroduction.java +++ b/0-0-intro/src/main/java/com/bobocode/intro/ExerciseIntroduction.java @@ -2,6 +2,8 @@ import com.bobocode.util.ExerciseNotCompletedException; +import java.util.Base64; + /** * Welcome! This is an introduction exercise that will show you a simple example of Bobocode exercises. *
@@ -23,8 +25,7 @@ public class ExerciseIntroduction { * @return "The key to efficient learning is practice!" */ public String getWelcomeMessage() { - // todo: implement a method and return a message according to javadoc - throw new ExerciseNotCompletedException(); + return "The key to efficient learning is practice!"; } /** @@ -39,7 +40,7 @@ public String getWelcomeMessage() { * @return encoded message */ public String encodeMessage(String message) { - // todo: switch to branch "completed" in order to see how it should be implemented - throw new ExerciseNotCompletedException(); + return Base64.getEncoder().encodeToString(message.getBytes()); } } + diff --git a/0-0-intro/src/main/java/com/bobocode/intro/main.py b/0-0-intro/src/main/java/com/bobocode/intro/main.py new file mode 100644 index 000000000..1fae902cb --- /dev/null +++ b/0-0-intro/src/main/java/com/bobocode/intro/main.py @@ -0,0 +1 @@ +x = input() \ No newline at end of file diff --git a/0-0-intro/src/test/java/com/bobocode/intro/ExerciseIntroductionTest.java b/0-0-intro/src/test/java/com/bobocode/intro/ExerciseIntroductionTest.java index 093909fe9..e5e823a0c 100644 --- a/0-0-intro/src/test/java/com/bobocode/intro/ExerciseIntroductionTest.java +++ b/0-0-intro/src/test/java/com/bobocode/intro/ExerciseIntroductionTest.java @@ -3,6 +3,7 @@ import lombok.SneakyThrows; import org.junit.jupiter.api.*; +import java.lang.reflect.InvocationTargetException; import java.util.Arrays; import static org.assertj.core.api.Assertions.assertThat; @@ -22,8 +23,8 @@ */ @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class ExerciseIntroductionTest { - private ExerciseIntroduction exerciseIntroduction = new ExerciseIntroduction(); - private String EXPECTED_MESSAGE = "The key to efficient learning is practice!"; + private final ExerciseIntroduction exerciseIntroduction = new ExerciseIntroduction(); + private final String EXPECTED_MESSAGE = "The key to efficient learning is practice!"; @Test @Order(1) @@ -38,7 +39,7 @@ void getWelcomeMessage() { @Order(2) @DisplayName("encodeMessage returns correct encoded message") @SneakyThrows - void encodeMessageReturnsCorrectPhrase() { + void encodeMessageReturnsCorrectPhrase() throws InvocationTargetException, IllegalAccessException { var encodeMessageMethod = Arrays.stream(ExerciseIntroduction.class.getDeclaredMethods()) .filter(method -> method.getName().equals("encodeMessage")) .findAny() diff --git a/1-0-java-basics/1-3-0-hello-generics/src/main/java/com/bobocode/basics/Box.java b/1-0-java-basics/1-3-0-hello-generics/src/main/java/com/bobocode/basics/Box.java index 5a2d860ee..8ce2f7593 100644 --- a/1-0-java-basics/1-3-0-hello-generics/src/main/java/com/bobocode/basics/Box.java +++ b/1-0-java-basics/1-3-0-hello-generics/src/main/java/com/bobocode/basics/Box.java @@ -1,24 +1,15 @@ package com.bobocode.basics; -/** - * {@link Box} is a container class that can store a value of any given type. Using Object as a field type - * is flexible, because we can store anything we want there. But it is not safe, because it requires runtime casting - * and there is no guarantee that we know the type of the stored value. - *
- * todo: refactor this class so it uses generic type "T" and run {@link com.bobocode.basics.BoxTest} to verify it
- */
-public class Box {
- private Object value;
+import lombok.Getter;
+import lombok.Setter;
- public Box(Object value) {
- this.value = value;
- }
+@Setter
+@Getter
+public class Box
- * todo: refactor class {@link Box} to make type parameterization safe and make this demo fail at compile time
- */
public class BoxDemoApp {
public static void main(String[] args) {
- Box intBox = new Box(123);
- Box intBox2 = new Box(321);
+ Box
- * TODO: go step by step from top to bottom. Read the java doc, write code and run CrazyGenericsTest to verify your impl
- *
- * Hint: in some cases you will need to refactor the code, like replace {@link Object} with a generic type. In order
- * cases you will need to add new fields, create new classes, or add new methods. Always try to read java doc and update
- * the code according to it.
- *
- * TODO: to get the most out of your learning, visit our website
- *
- *
- * @author Taras Boychuk
- */
public class CrazyGenerics {
- /**
- * {@link Sourced} is a container class that allows storing any object along with the source of that data.
- * The value type can be specified by a type parameter "T".
- *
- * @param