diff --git a/Lab2.06/.gitignore b/Lab2.06/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/Lab2.06/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/Lab2.06/.idea/.gitignore b/Lab2.06/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/Lab2.06/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/Lab2.06/.idea/encodings.xml b/Lab2.06/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/Lab2.06/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Lab2.06/.idea/misc.xml b/Lab2.06/.idea/misc.xml new file mode 100644 index 0000000..df00c07 --- /dev/null +++ b/Lab2.06/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Lab2.06/.idea/vcs.xml b/Lab2.06/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/Lab2.06/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Lab2.06/pom.xml b/Lab2.06/pom.xml new file mode 100644 index 0000000..12fb649 --- /dev/null +++ b/Lab2.06/pom.xml @@ -0,0 +1,17 @@ + + + 4.0.0 + + Ironhack.schl + Lab2.06 + 1.0-SNAPSHOT + + + 17 + 17 + UTF-8 + + + \ No newline at end of file diff --git a/Lab2.06/src/main/java/Ironhack/schl/Banking System diagram b/Lab2.06/src/main/java/Ironhack/schl/Banking System diagram new file mode 100644 index 0000000..14ad9c1 --- /dev/null +++ b/Lab2.06/src/main/java/Ironhack/schl/Banking System diagram @@ -0,0 +1,26 @@ +Class: User +- username: String +- password: String + +Class: Account +- accountId: String +- balance: Money +- isFrozen: boolean + +Class: Transaction +- transactionId: String +- amount: Money +- date: Date + +Class: Money +- amount: double +- currency: String + +Class: Admin +- username: String +- password: String + +Associations: +- User "1" -- "0..*" Account +- Account "1" -- "0..*" Transaction +- Admin "1" -- "0..*" Account \ No newline at end of file diff --git a/Lab2.06/src/main/java/Ironhack/schl/Main.java b/Lab2.06/src/main/java/Ironhack/schl/Main.java new file mode 100644 index 0000000..bff9cd4 --- /dev/null +++ b/Lab2.06/src/main/java/Ironhack/schl/Main.java @@ -0,0 +1,31 @@ +package Ironhack.schl; + +import java.util.HashMap; +import java.util.Map; + +public class Main { + public static void main(String[] args) { + HashMap studentMap = new HashMap<>(); + Student student1 = new Student("Iseult", 30); + Student student2 = new Student("Yolanth", 90); + Student student3 = new Student("Chindasvinto", 85); + Student student4 = new Student("Jirohito", 70); + + studentMap.put(student1.getName(), student1); + studentMap.put(student2.getName(), student2); + studentMap.put(student3.getName(), student3); + studentMap.put(student4.getName(), student4); + + increaseGrades(studentMap); + + for (HashMap.Entry entry : studentMap.entrySet()) { + System.out.println("Name: " + entry.getKey() + ", Grade: " + entry.getValue().getGrade()); + } + } + + public static void increaseGrades(HashMap studentMap) { + for (HashMap.Entry entry : studentMap.entrySet()) { + entry.getValue().increaseGrade(); + } + } +} diff --git a/Lab2.06/src/main/java/Ironhack/schl/Student.java b/Lab2.06/src/main/java/Ironhack/schl/Student.java new file mode 100644 index 0000000..7fdb01d --- /dev/null +++ b/Lab2.06/src/main/java/Ironhack/schl/Student.java @@ -0,0 +1,42 @@ +package Ironhack.schl; + + +public class Student { + private String name; + private int grade = 0; + + public Student(String name, int grade) { + this.name = name; + this.grade = grade; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public int getGrade() { + return this.grade; + } + + public int setGrade(int grade) throws IllegalArgumentException { + if (grade >= 0 && grade <= 100) { + return grade; + } else { + throw new IllegalArgumentException("Grade must be between 0 and 100"); + } + } + + public void increaseGrade() throws IllegalArgumentException { + int newGrade; + if (grade >= 0 && grade <= 100) { + grade = grade*11/10; + newGrade = grade; + } else { + throw new IllegalArgumentException("Grade must be between 0 and 100"); + } + } +}