Skip to content

Lab2.06 completed. #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
38 changes: 38 additions & 0 deletions Lab2.06/.gitignore
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions Lab2.06/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Lab2.06/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions Lab2.06/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Lab2.06/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions Lab2.06/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>Ironhack.schl</groupId>
<artifactId>Lab2.06</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

</project>
26 changes: 26 additions & 0 deletions Lab2.06/src/main/java/Ironhack/schl/Banking System diagram
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions Lab2.06/src/main/java/Ironhack/schl/Main.java
Original file line number Diff line number Diff line change
@@ -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<String, Student> 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<String, Student> entry : studentMap.entrySet()) {
System.out.println("Name: " + entry.getKey() + ", Grade: " + entry.getValue().getGrade());
}
}

public static void increaseGrades(HashMap<String, Student> studentMap) {
for (HashMap.Entry<String, Student> entry : studentMap.entrySet()) {
entry.getValue().increaseGrade();
}
}
}
42 changes: 42 additions & 0 deletions Lab2.06/src/main/java/Ironhack/schl/Student.java
Original file line number Diff line number Diff line change
@@ -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");
}
}
}