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
25 changes: 23 additions & 2 deletions _1_basics/src/main/java/code/_3_in_class/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@
public class Main {

public static void main(String[] args) {
//TODO put your code changes in here
int[] ar = new int[] {1,2,3};

int[] v1 = ar;
int[] v2 = ar;

ar[0] = 10;
v1[0] = 100;
v2[0] = 1000;

displayVector("ar", ar);
displayVector("v1", v1);
displayVector("v2", v2);


}
private static void displayVector(String name, int[] arr) {
System.out.print(name + " = ");

for(int i=0;i<= arr.length;i++){
System.out.print(arr[i] + " ");
}
System.out.println();
}
}
}
7 changes: 7 additions & 0 deletions _1_basics/src/main/java/code/_3_in_class/Salut.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package code._3_in_class;

public class Salut {
public static void main(String[] args) {
System.out.println("hello world");
}
}
23 changes: 23 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,23 @@
package code._3_in_class;

public class Boxer {
String nume;
int health = 100;
int damnagePerAttack = 10;

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

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


void attack(Boxer opponent){
opponent.health = opponent.health-this.damnagePerAttack;
}
void defend() {}
}
32 changes: 31 additions & 1 deletion _2_oo/src/main/java/code/_3_in_class/Main.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,38 @@
package code._3_in_class;

import java.util.Random;

public class Main {

public static void main(String[] args) {
//TODO put your code changes in here
Boxer ion = new Boxer("ion",100,10);
Boxer vasile = new Boxer("vasile",100,10);

Random random = new Random();

startBoxingMatch(ion, vasile, random);

//anuntam castigatorul
endingResult(ion);
}

private static void endingResult(Boxer ion) {
if(ion.health < 0) {
System.out.println("Vasile a castigat meciul");
}
else{
System.out.println("Ion a castigat meciul");
}
}

private static void startBoxingMatch(Boxer ion, Boxer vasile, Random random) {
while(ion.health > 0 && vasile.health > 0) {
int zeroOrOne = random.nextInt(2);
if (zeroOrOne == 0) {
ion.attack(vasile);
} else {
vasile.attack(ion);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,51 @@
package clean.code.design_patterns.requirements;

import java.util.ArrayList;
import java.util.List;

public class Main {

public static void main(String[] args) {
//TODO implement your design patterns in this package
TeacherFactory monthlySalaryTeacherFactory = new MonthlySalaryTeacherFactory(500);
TeacherFactory hourlySalaryTeacherFactory = new HourlySalaryTeacherFactory(20, 40);

Teacher Andra = monthlySalaryTeacherFactory.createTeacher(1, "Andra");
Teacher Maria = monthlySalaryTeacherFactory.createTeacher(2, "Maria");
Teacher Valentina = hourlySalaryTeacherFactory.createTeacher(3, "Valentina");

List<Teacher> teacherList = new ArrayList<>();
teacherList.add(Andra);
teacherList.add(Maria);
teacherList.add(Valentina);

Student Raluca = new Student(1, "Raluca", 4);
Student Cristina = new Student(2, "Cristina", 10);
Student Iasmina = new Student(3, "Iasmina", 5);
List<Student> studentList = new ArrayList<>();

studentList.add(Raluca);
studentList.add(Cristina);
studentList.add(Iasmina);

School school = School.getInstance();
school.addTeacher(Andra);
school.addTeacher(Maria);
school.addTeacher(Valentina);

school.addStudent(Raluca);
school.addStudent(Cristina);
school.addStudent(Iasmina);

Raluca.payFees(5000);
Cristina.payFees(6000);
System.out.println("School has earned $" + school.getTotalMoneyEarned());

System.out.println("----Making SCHOOL PAY SALARY----");
Valentina.receiveSalary();
Maria.receiveSalary();
System.out.println("School has spent $" + school.getTotalMoneySpent());

System.out.println(Valentina);
System.out.println(Maria);
}
}