diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 000000000..c16c5cfbf
Binary files /dev/null and b/.DS_Store differ
diff --git a/0-0-intro/.DS_Store b/0-0-intro/.DS_Store
new file mode 100644
index 000000000..bbfd89351
Binary files /dev/null and b/0-0-intro/.DS_Store differ
diff --git a/0-0-intro/src/.DS_Store b/0-0-intro/src/.DS_Store
new file mode 100644
index 000000000..a03beddc9
Binary files /dev/null and b/0-0-intro/src/.DS_Store differ
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..67786990e 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,44 +2,13 @@
import com.bobocode.util.ExerciseNotCompletedException;
-/**
- * Welcome! This is an introduction exercise that will show you a simple example of Bobocode exercises.
- *
- * JavaDoc is a way of communication with other devs. We use Java Docs in every exercise to define the task.
- * So PLEASE MAKE SURE you read the Java Docs carefully.
- *
- * Every exercise is covered with tests, see {@link ExerciseIntroductionTest}.
- *
- * In this repo you'll find dozens of exercises covering various fundamental topics.
- * They all have the same structure helping you to focus on practice and build strong skills!
- *
- * @author Taras Boychuk
- */
+import java.util.Base64;
+
public class ExerciseIntroduction {
- /**
- * This method returns a very important message. If understood well, it can save you years of inefficient learning,
- * and unlock your potential!
- *
- * @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!";
}
-
- /**
- * Method encodeMessage accepts one {@link String} parameter and returns encoded {@link String}.
- *
- * PLEASE NOTE THAT YOU WILL GET STUCK ON THIS METHOD INTENTIONALLY! ;)
- *
- * Every exercise has a completed solution that is stored in the branch "completed". So in case you got stuck
- * and don't know what to do, go check out completed solution.
- *
- * @param message input message
- * @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/1-0-java-basics/.DS_Store b/1-0-java-basics/.DS_Store
new file mode 100644
index 000000000..66499debf
Binary files /dev/null and b/1-0-java-basics/.DS_Store differ
diff --git a/1-0-java-basics/1-3-0-hello-generics/.DS_Store b/1-0-java-basics/1-3-0-hello-generics/.DS_Store
new file mode 100644
index 000000000..66469a926
Binary files /dev/null and b/1-0-java-basics/1-3-0-hello-generics/.DS_Store differ
diff --git a/1-0-java-basics/1-3-0-hello-generics/src/.DS_Store b/1-0-java-basics/1-3-0-hello-generics/src/.DS_Store
new file mode 100644
index 000000000..1155297d3
Binary files /dev/null and b/1-0-java-basics/1-3-0-hello-generics/src/.DS_Store differ
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..180603a28 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
@@ -7,18 +7,18 @@
*
* 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;
+public class Box {
+ private T value;
- public Box(Object value) {
+ public Box(T value) {
this.value = value;
}
- public Object getValue() {
+ public T getValue() {
return value;
}
- public void setValue(Object value) {
+ public void setValue(T value) {
this.value = value;
}
}
diff --git a/1-0-java-basics/1-3-1-crazy-generics/.DS_Store b/1-0-java-basics/1-3-1-crazy-generics/.DS_Store
new file mode 100644
index 000000000..349608b84
Binary files /dev/null and b/1-0-java-basics/1-3-1-crazy-generics/.DS_Store differ
diff --git a/1-0-java-basics/1-3-1-crazy-generics/src/.DS_Store b/1-0-java-basics/1-3-1-crazy-generics/src/.DS_Store
new file mode 100644
index 000000000..bfbd4bd3a
Binary files /dev/null and b/1-0-java-basics/1-3-1-crazy-generics/src/.DS_Store differ
diff --git a/1-0-java-basics/1-3-1-crazy-generics/src/main/java/com/bobocode/basics/CrazyGenerics.java b/1-0-java-basics/1-3-1-crazy-generics/src/main/java/com/bobocode/basics/CrazyGenerics.java
index 751d5899f..b6e619734 100644
--- a/1-0-java-basics/1-3-1-crazy-generics/src/main/java/com/bobocode/basics/CrazyGenerics.java
+++ b/1-0-java-basics/1-3-1-crazy-generics/src/main/java/com/bobocode/basics/CrazyGenerics.java
@@ -5,231 +5,157 @@
import lombok.Data;
import java.io.Serializable;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Objects;
-
-/**
- * {@link CrazyGenerics} is an exercise class. It consists of classes, interfaces and methods that should be updated
- * using generics.
- *
- * 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
- */
+import java.util.*;
+import java.util.function.Predicate;
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 – value type
- */
+
@Data
- public static class Sourced { // todo: refactor class to introduce type parameter and make value generic
- private Object value;
+ public static class Sourced {
+ private T value;
private String source;
}
- /**
- * {@link Limited} is a container class that allows storing an actual value along with possible min and max values.
- * It is special form of triple. All three values have a generic type that should be a subclass of {@link Number}.
- *
- * @param – actual, min and max type
- */
@Data
- public static class Limited {
- // todo: refactor class to introduce type param bounded by number and make fields generic numbers
- private final Object actual;
- private final Object min;
- private final Object max;
+ public static class Limited {
+ private final T actual;
+ private final T min;
+ private final T max;
}
- /**
- * {@link Converter} interface declares a typical contract of a converter. It works with two independent generic types.
- * It defines a convert method which accepts one parameter of one type and returns a converted result of another type.
- *
- * @param – source object type
- * @param - converted result type
- */
- public interface Converter { // todo: introduce type parameters
- // todo: add convert method
+ public interface Converter {
+ R convert(T obj);
}
- /**
- * {@link MaxHolder} is a container class that keeps track of the maximum value only. It works with comparable objects
- * and allows you to put new values. Every time you put a value, it is stored only if the new value is greater
- * than the current max.
- *
- * @param – value type
- */
- public static class MaxHolder { // todo: refactor class to make it generic
- private Object max;
-
- public MaxHolder(Object max) {
+ public static class MaxHolder> {
+ private T max;
+
+ public MaxHolder(T max) {
this.max = max;
}
- /**
- * Puts a new value to the holder. A new value is stored to the max, only if it is greater than current max value.
- *
- * @param val a new value
- */
- public void put(Object val) {
- throw new ExerciseNotCompletedException(); // todo: update parameter and implement the method
+ public void put(T val) {
+ if (val == null) {
+ return;
+ }
+ if (this.max == null) {
+ this.max = val;
+ return;
+ }
+ if (val.compareTo(this.max) > 0) {
+ this.max = val;
+ }
}
- public Object getMax() {
+ public T getMax() {
return max;
}
}
- /**
- * {@link StrictProcessor} defines a contract of a processor that can process only objects that are {@link Serializable}
- * and {@link Comparable}.
- *
- * @param – the type of objects that can be processed
- */
- interface StrictProcessor { // todo: make it generic
- void process(Object obj);
+ interface StrictProcessor> {
+ void process(T obj);
}
- /**
- * {@link CollectionRepository} defines a contract of a runtime store for entities based on any {@link Collection}.
- * It has methods that allow to save new entity, and get whole collection.
- *
- * @param – a type of the entity that should be a subclass of {@link BaseEntity}
- * @param – a type of any collection
- */
- interface CollectionRepository { // todo: update interface according to the javadoc
- void save(Object entity);
-
- Collection