Skip to content
Open
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
Expand Up @@ -20,7 +20,6 @@ public String fizzBuzz(int i) {
s = String.valueOf(i);
}


return s;
}

Expand All @@ -44,7 +43,6 @@ public String fizzBuzz2(int i) {
s = String.valueOf(i);
}


return s;
}
}
8 changes: 8 additions & 0 deletions _1_basics/src/main/java/code/_3_in_class/ClasaBunaZiua.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package code._3_in_class;

public class ClasaBunaZiua {

public static void main(String[] args) {
System.out.println("Buna ziua!");
}
}
8 changes: 0 additions & 8 deletions _1_basics/src/main/java/code/_4_student_effort/Main.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package code._4_student_effort.fizz_buzz;

public class Correlation {
private Integer number;
private String word;

public Correlation (Integer number, String word) {
this.number = number;
this.word = word;
}
public Integer getNumber() {
return this.number;
}
public String getWord() {
return this.word;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package code._4_student_effort.fizz_buzz;

public class Fizz2 {

public String fizz (int i) {
String s = "";

Correlation[] correlations = {
new Correlation(3, "Fizz"),
new Correlation(5, "Buzz"),
};

boolean isDivisible = false;
for(Correlation correlation : correlations) {
if(i % correlation.getNumber() == 0) {
isDivisible = true;
s += correlation.getWord();
}
}

if(!isDivisible) {
s = String.valueOf(i);
}

return s;
}
public String fizz2(int i) {
String s = "";
Correlation[] correlations = {
new Correlation(3, "Fizz"),
new Correlation(5, "Buzz"),
new Correlation(7, "Rizz"),
new Correlation(11, "Jazz"),
};

boolean isDivisible = false;
for(Correlation correlation : correlations) {
if(i % correlation.getNumber() == 0) {
isDivisible = true;
s+= correlation.getWord();
}
}

if(!isDivisible) {
s = String.valueOf(i);
}

return s;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package code._4_student_effort.fizz_buzz;
// basic implementation
//
public class Fizz_Buzz {
public static void main(String[] args) {
for(int i = 1; i < 101; i++) {
if (i % 3 == 0 && i % 5 == 0) {
System.out.println("FizzBuzz");
} else if (i % 5 == 0) {
System.out.println("Buzz");
} else if (i % 3 == 0) {
System.out.println("Fizz");
} else if(i % 7 == 0) {
System.out.println("Rizz");
} else if(i % 11 == 0) {
System.out.println("Jazz");
}
else {
System.out.println(i);
}

}
}
}
18 changes: 18 additions & 0 deletions _1_basics/src/main/java/code/_4_student_effort/fizz_buzz/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package code._4_student_effort.fizz_buzz;

public class Main {

public static void main(String[] args) {
Fizz2 test_obj = new Fizz2();
String s;
for(int i = 1; i < 101; i++) {
s = test_obj.fizz(i);
System.out.print(s + " ");
}
System.out.println();
for(int i = 1; i < 101; i++) {
s = test_obj.fizz2(i);
System.out.print(s + " ");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package code._4_student_effort.foo_bar_qix;

public class Correlation {
private Integer number;
private String word;

public Correlation(Integer number, String word) {
this.number = number;
this.word = word;
}

public Integer getNumber() {
return this.number;
}

public String getWord() {
return this.word;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package code._4_student_effort.foo_bar_qix;

public class Foo_Bar_Qix {
public String compute(int i) {
String s = "";

Correlation[] correlations = {
new Correlation(3, "Foo"),
new Correlation(5, "Bar"),
new Correlation(7, "Qix"),
};
boolean isDivisible = false;
boolean contains = false;
for(Correlation correlation : correlations) {
if(i % correlation.getNumber() == 0) {
isDivisible = true;
s+=correlation.getWord();
}
int temp = i;
while(temp > 0) {
if(temp % 10 == correlation.getNumber()) {
contains = true;
s+=correlation.getWord();
}
temp /= 10;
}
}
if(!isDivisible && !contains) {
s = String.valueOf(i);
}
return s;
}

public String compute2(int i) {
String s = "";

Correlation[] correlations = {
new Correlation(3, "Foo"),
new Correlation(5, "Bar"),
new Correlation(7, "Qix"),
};

boolean isDivisible = false;
for(Correlation correlation : correlations) {
if(i % correlation.getNumber() == 0) {
isDivisible = true;
s+=correlation.getWord();
}

}

char[] digits = String.valueOf(i).toCharArray();
for(char digit : digits) {
if(digit == '3') {s+= "Foo";}
else if(digit == '5') {s+="Bar";}
else if(digit == '7') {s+= "Qix";}
else if(digit == '0') {s+="*"; }
else if(!isDivisible) {s+=digit;}
}

return s;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package code._4_student_effort.foo_bar_qix;

public class Main {
public static void main(String[] args) {
Foo_Bar_Qix test_obj = new Foo_Bar_Qix();
String s;
// for(int i = 1; i < 61; i++) {
// s = test_obj.compute(i);
// System.out.print(s + " ");
// }
// System.out.println();
System.out.println(test_obj.compute2(101));
s = test_obj.compute2(303);
System.out.println(s);
s = test_obj.compute2(105);
System.out.println(s);
s = test_obj.compute2(10101);
System.out.println(s);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package code._4_student_effort;
12 changes: 12 additions & 0 deletions _1_basics/src/main/java/code/_4_student_effort/pair_of_2/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package code._4_student_effort.pair_of_2;

public class Main {

public static void main(String[] args) {
Integer[] numbers = new Integer[]{3, 2, -3, -2, 3, 0};
Integer[] numbers1 = new Integer[]{1, 1, 0, -1, -1};
Integer[] numbers2 = new Integer[]{5, 9, -5, 7, -5};
PairOfTwo pairOfTwo = new PairOfTwo();
System.out.println(pairOfTwo.pairs(numbers2));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package code._4_student_effort.pair_of_2;

public class PairOfTwo {

public Integer pairs(Integer[] numbers) {
Integer[] indexesInPairs = new Integer[numbers.length];
int pairs = 0;
int noOfIndexesInPairs = 0;

for(int i = 0; i < numbers.length - 1; i++) {
for(int j = i + 1; j < numbers.length; j++) {
boolean isInOtherPairs = false;
for(int k = 0; k < noOfIndexesInPairs; k++) {
if(indexesInPairs[k] == i || indexesInPairs[k] == j) {
isInOtherPairs = true;
break;
}
}
if(!isInOtherPairs && (numbers[i] + numbers[j] == 0)) {
indexesInPairs[noOfIndexesInPairs++] = i;
indexesInPairs[noOfIndexesInPairs++] = j;
pairs++;
break;
}
}
}
return pairs;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package code._4_student_effort.pair_of_3;

public class PairOfThree {
}
35 changes: 35 additions & 0 deletions _2_oo/src/main/java/code/_3_in_class/Boxer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package code._3_in_class;
import java.util.Random;

public class Boxer implements IBoxer {

String nume;
int health = 100;
int damagePerAttack = 10;

public Boxer(String nume, int health, int damagePerAttack) {
this.nume = nume;
this.health = health;
this.damagePerAttack = damagePerAttack;
}

public Boxer(String nume) {
this.nume = nume;
}

public void attack(Boxer opponent) {
int defendValue = this.damagePerAttack * this.defend() / 100;
opponent.health = opponent.health - this.damagePerAttack - defendValue;
// System.out.println(this.nume + " il ataca pe " + opponent.nume + " ");
System.out.println("defendValue: " + defendValue);
System.out.println("newHealth: " + opponent.health);
}
public int defend() {
Random random = new Random();
int defendPercentage = random.nextInt(101);


return defendPercentage;

}
}
12 changes: 12 additions & 0 deletions _2_oo/src/main/java/code/_3_in_class/BruceLee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package code._3_in_class;

//public class BruceLee extends Boxer {
// public BruceLee(String nume, int health, int damagePerAttack) {
// super(nume, health, damagePerAttack);
// }
//
// void attack(Boxer opponent) {
// opponent.health = 0;
//// System.out.println(this.nume + " il ataca pe " + opponent.nume + " ");
// }
//}
11 changes: 11 additions & 0 deletions _2_oo/src/main/java/code/_3_in_class/Gloves.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package code._3_in_class;

public class Gloves {

int size;
String color;
public Gloves(int size, String color) {
this.size = size;
this.color = color;
}
}
7 changes: 7 additions & 0 deletions _2_oo/src/main/java/code/_3_in_class/IBoxer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package code._3_in_class;

public interface IBoxer {

public void attack(Boxer opponent);
public int defend();
}
Loading