From a399f9321b71d1055a28acc5feb194b69a35dbea Mon Sep 17 00:00:00 2001 From: schrom01 Date: Fri, 22 Apr 2022 11:42:39 +0200 Subject: [PATCH 1/4] created simple classes Issue #5 --- .gitignore | 6 +++ .../zhaw/projekt2/turnierverwaltung/Game.java | 47 +++++++++++++++++++ .../projekt2/turnierverwaltung/Location.java | 17 +++++++ .../turnierverwaltung/Participant.java | 6 +++ .../projekt2/turnierverwaltung/Person.java | 37 +++++++++++++++ .../projekt2/turnierverwaltung/Player.java | 10 ++++ .../zhaw/projekt2/turnierverwaltung/Team.java | 37 +++++++++++++++ .../turnierverwaltung/Tournament.java | 17 +++++++ 8 files changed, 177 insertions(+) create mode 100644 app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Game.java create mode 100644 app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Location.java create mode 100644 app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Participant.java create mode 100644 app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Person.java create mode 100644 app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Player.java create mode 100644 app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Team.java create mode 100644 app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Tournament.java diff --git a/.gitignore b/.gitignore index a1c2a23..47af25b 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,9 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* + +# Ignore Gradle project-specific cache directory +.gradle + +# Ignore Gradle build output directory +build diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Game.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Game.java new file mode 100644 index 0000000..e04b84d --- /dev/null +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Game.java @@ -0,0 +1,47 @@ +package ch.zhaw.projekt2.turnierverwaltung; + +public class Game { + private int participant1, Participant2; + private int points1, points2; + private Location location; + + public Location getLocation() { + return location; + } + + public void setLocation(Location location) { + this.location = location; + } + + public int getPoints1() { + return points1; + } + + public void setPoints1(int points1) { + this.points1 = points1; + } + + public int getPoints2() { + return points2; + } + + public void setPoints2(int points2) { + this.points2 = points2; + } + + public int getParticipant1() { + return participant1; + } + + public void setParticipant1(int participant1) { + this.participant1 = participant1; + } + + public int getParticipant2() { + return Participant2; + } + + public void setParticipant2(int participant2) { + Participant2 = participant2; + } +} diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Location.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Location.java new file mode 100644 index 0000000..448ae67 --- /dev/null +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Location.java @@ -0,0 +1,17 @@ +package ch.zhaw.projekt2.turnierverwaltung; + +public class Location { + private String name; + + public Location(String name){ + setName(name); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Participant.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Participant.java new file mode 100644 index 0000000..e48f3a1 --- /dev/null +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Participant.java @@ -0,0 +1,6 @@ +package ch.zhaw.projekt2.turnierverwaltung; + +public interface Participant { + String getName(); + void setName(String name); +} diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Person.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Person.java new file mode 100644 index 0000000..1165e7d --- /dev/null +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Person.java @@ -0,0 +1,37 @@ +package ch.zhaw.projekt2.turnierverwaltung; + +public class Person { + private String name; + private String firstName; + private String phoneNumber; + + public Person(String firstName, String name, String phoneNumber){ + setFirstName(firstName); + setName(name); + setPhoneNumber(phoneNumber); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getPhoneNumber() { + return phoneNumber; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } +} diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Player.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Player.java new file mode 100644 index 0000000..567f49b --- /dev/null +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Player.java @@ -0,0 +1,10 @@ +package ch.zhaw.projekt2.turnierverwaltung; + +public class Player extends Person{ + + + public Player(String firstName, String name, String phoneNumber){ + super(firstName, name, phoneNumber); + } + +} diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Team.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Team.java new file mode 100644 index 0000000..880cc13 --- /dev/null +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Team.java @@ -0,0 +1,37 @@ +package ch.zhaw.projekt2.turnierverwaltung; + +import java.util.ArrayList; +import java.util.List; + +public class Team implements Participant { + private String name; + private List players; + private Person contactPerson; + + public Team(String name){ + setName(name); + players = new ArrayList<>(); + } + + public void addPlayer(Player player){ + players.add(player); + } + + @Override + public String getName() { + return name; + } + + @Override + public void setName(String name) { + this.name = name; + } + + public Person getContactPerson() { + return contactPerson; + } + + public void setContactPerson(Person contactPerson) { + this.contactPerson = contactPerson; + } +} diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Tournament.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Tournament.java new file mode 100644 index 0000000..c6d6211 --- /dev/null +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Tournament.java @@ -0,0 +1,17 @@ +package ch.zhaw.projekt2.turnierverwaltung; + +public abstract class Tournament { + private String name; + + public Tournament(String name){ + setName(name); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} From 3dfa71dab18224455cc5563a08d420b6bed955b7 Mon Sep 17 00:00:00 2001 From: schrom01 Date: Fri, 22 Apr 2022 11:53:11 +0200 Subject: [PATCH 2/4] Created Interface Participant changed Class Game to save Participant Objects instad of int. --- .../java/ch/zhaw/projekt2/turnierverwaltung/Game.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Game.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Game.java index e04b84d..bab3390 100644 --- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Game.java +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Game.java @@ -1,7 +1,7 @@ package ch.zhaw.projekt2.turnierverwaltung; public class Game { - private int participant1, Participant2; + private Participant participant1, Participant2; private int points1, points2; private Location location; @@ -29,19 +29,19 @@ public class Game { this.points2 = points2; } - public int getParticipant1() { + public Participant getParticipant1() { return participant1; } - public void setParticipant1(int participant1) { + public void setParticipant1(Participant participant1) { this.participant1 = participant1; } - public int getParticipant2() { + public Participant getParticipant2() { return Participant2; } - public void setParticipant2(int participant2) { + public void setParticipant2(Participant participant2) { Participant2 = participant2; } } From 61a778ad545e048f7cc0d11c8608562f5ab0a761 Mon Sep 17 00:00:00 2001 From: schrom01 Date: Thu, 28 Apr 2022 14:10:41 +0200 Subject: [PATCH 3/4] added Date of Birth to Player.java --- .../zhaw/projekt2/turnierverwaltung/Player.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Player.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Player.java index 567f49b..4273fd1 100644 --- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Player.java +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Player.java @@ -1,10 +1,21 @@ package ch.zhaw.projekt2.turnierverwaltung; -public class Player extends Person{ +import java.util.Date; +public class Player extends Person implements Participant{ - public Player(String firstName, String name, String phoneNumber){ + private Date dateOfBirth; + + public Player(String firstName, String name, String phoneNumber, Date dateOfBirth){ super(firstName, name, phoneNumber); + setDateOfBirth(dateOfBirth); } + public Date getDateOfBirth() { + return dateOfBirth; + } + + public void setDateOfBirth(Date dateOfBirth) { + this.dateOfBirth = dateOfBirth; + } } From 5d26137c8de3ab36a2f8a1af1da5425b77ab9239 Mon Sep 17 00:00:00 2001 From: schrom01 Date: Thu, 28 Apr 2022 14:50:45 +0200 Subject: [PATCH 4/4] made Tournament not abstract. --- .../java/ch/zhaw/projekt2/turnierverwaltung/Tournament.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Tournament.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Tournament.java index c6d6211..5845a12 100644 --- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Tournament.java +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Tournament.java @@ -1,6 +1,6 @@ package ch.zhaw.projekt2.turnierverwaltung; -public abstract class Tournament { +public class Tournament { private String name; public Tournament(String name){