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,6 +1,7 @@
package com.bobocode.intro;

import com.bobocode.util.ExerciseNotCompletedException;
import java.nio.charset.StandardCharsets;
import java.util.Base64;

/**
* Welcome! This is an introduction exercise that will show you a simple example of Bobocode exercises.
Expand All @@ -16,15 +17,16 @@
* @author Taras Boychuk
*/
public class ExerciseIntroduction {

private static final String VARY_IMPORTANT_MESSAGE = "The key to efficient learning is practice!";
/**
* 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 VARY_IMPORTANT_MESSAGE;
}

/**
Expand All @@ -39,7 +41,6 @@ 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(StandardCharsets.UTF_8));
}
}
21 changes: 21 additions & 0 deletions 0-0-intro/src/main/java/com/bobocode/intro/FindMax.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.bobocode.intro;

public class FindMax {
public static void main(String[] args) {
System.out.println(findMax(new int[]{1, 2, 23, 24, 98, 4}));
System.out.println(findMax(new int[]{}));
}

public static int findMax(int[] input) {
if (0 == input.length) {
throw new IllegalArgumentException("Array is empty");
}
int max = input[0];
for (int i = 1; i < input.length; i++) {
if (input[i] > max) {
max = input[i];
}
}
return max;
}
}
14 changes: 14 additions & 0 deletions 0-0-intro/src/main/java/com/bobocode/intro/findMax.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function findMax(array) {
let max;
if (array) {
max = array[0];
for (let i = 0; i < array.length; i++) {
if (array[i] > max) {
max = array[i];
}
}
}
return max;
}

console.log(findMax([1, 2, 34, 23, 22]));
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.bobocode.basics;

public class StackOverflowOutOfMemory {

public static void main(String[] args) {
try {
throwStackOverFlow();
} catch (StackOverflowError er) {
System.out.println("StackOverflowError caught");
}
try {
throwOutOfMemory();
} catch (OutOfMemoryError er) {
System.out.println("OutOfMemoryError caught");
}
}

private static void throwStackOverFlow() {
throwStackOverFlow();
}

private static void throwOutOfMemory() {
byte[] bytes = new byte[Integer.MAX_VALUE];
}
}