From e1626aa9dbe2ed74dc7fe6bbaaf7bf633fede592 Mon Sep 17 00:00:00 2001 From: Giacomo Radaelli Date: Wed, 29 Mar 2023 20:20:09 +0200 Subject: [PATCH] Aggiunto Appointment (P9.3) da finire --- Appointment P9.3/.idea/.gitignore | 3 + Appointment P9.3/.idea/misc.xml | 6 ++ Appointment P9.3/.idea/modules.xml | 8 ++ Appointment P9.3/.idea/uiDesigner.xml | 124 ++++++++++++++++++++++++++ Appointment P9.3/.idea/vcs.xml | 6 ++ Appointment P9.3/Appointment P9.3.iml | 11 +++ Appointment P9.3/src/Appointment.java | 22 +++++ Appointment P9.3/src/Daily.java | 11 +++ Appointment P9.3/src/Monthly.java | 11 +++ Appointment P9.3/src/OneTime.java | 6 ++ Appointment P9.3/src/Tester.java | 13 +++ 11 files changed, 221 insertions(+) create mode 100644 Appointment P9.3/.idea/.gitignore create mode 100644 Appointment P9.3/.idea/misc.xml create mode 100644 Appointment P9.3/.idea/modules.xml create mode 100644 Appointment P9.3/.idea/uiDesigner.xml create mode 100644 Appointment P9.3/.idea/vcs.xml create mode 100644 Appointment P9.3/Appointment P9.3.iml create mode 100644 Appointment P9.3/src/Appointment.java create mode 100644 Appointment P9.3/src/Daily.java create mode 100644 Appointment P9.3/src/Monthly.java create mode 100644 Appointment P9.3/src/OneTime.java create mode 100644 Appointment P9.3/src/Tester.java diff --git a/Appointment P9.3/.idea/.gitignore b/Appointment P9.3/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/Appointment P9.3/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/Appointment P9.3/.idea/misc.xml b/Appointment P9.3/.idea/misc.xml new file mode 100644 index 0000000..03f397c --- /dev/null +++ b/Appointment P9.3/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Appointment P9.3/.idea/modules.xml b/Appointment P9.3/.idea/modules.xml new file mode 100644 index 0000000..e767f47 --- /dev/null +++ b/Appointment P9.3/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Appointment P9.3/.idea/uiDesigner.xml b/Appointment P9.3/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/Appointment P9.3/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Appointment P9.3/.idea/vcs.xml b/Appointment P9.3/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/Appointment P9.3/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Appointment P9.3/Appointment P9.3.iml b/Appointment P9.3/Appointment P9.3.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Appointment P9.3/Appointment P9.3.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Appointment P9.3/src/Appointment.java b/Appointment P9.3/src/Appointment.java new file mode 100644 index 0000000..e113154 --- /dev/null +++ b/Appointment P9.3/src/Appointment.java @@ -0,0 +1,22 @@ +public class Appointment { + private final String description; + private final int day; + private final int month; + private final int year; + + public Appointment(String description, int day, int month, int year) { + this.description = description; + this.day = day; + this.month = month; + this.year = year; + } + + public boolean occursOn(int day, int month, int year) { + return (this.day == day && this.month == month && this.year == year); + } + + @Override + public String toString() { + return "Appuntamento " + this.getClass().getName() + " {" + description + " il " + day + "/" + month + "/" + year + '}'; + } +} \ No newline at end of file diff --git a/Appointment P9.3/src/Daily.java b/Appointment P9.3/src/Daily.java new file mode 100644 index 0000000..a332b1d --- /dev/null +++ b/Appointment P9.3/src/Daily.java @@ -0,0 +1,11 @@ +public class Daily extends Appointment { + + public Daily(String description, int day, int month, int year) { + super(description, day, month, year); + } + + @Override + public boolean occursOn(int day, int month, int year) { + return super.occursOn(day + 1, month, year); + } +} \ No newline at end of file diff --git a/Appointment P9.3/src/Monthly.java b/Appointment P9.3/src/Monthly.java new file mode 100644 index 0000000..68154e2 --- /dev/null +++ b/Appointment P9.3/src/Monthly.java @@ -0,0 +1,11 @@ +public class Monthly extends Appointment { + + public Monthly(String description, int day, int month, int year) { + super(description, day, month, year); + } + + @Override + public boolean occursOn(int day, int month, int year) { + return super.occursOn(day, month + 1, year); + } +} \ No newline at end of file diff --git a/Appointment P9.3/src/OneTime.java b/Appointment P9.3/src/OneTime.java new file mode 100644 index 0000000..8041e5f --- /dev/null +++ b/Appointment P9.3/src/OneTime.java @@ -0,0 +1,6 @@ +public class OneTime extends Appointment { + + public OneTime(String description, int day, int month, int year) { + super(description, day, month, year); + } +} diff --git a/Appointment P9.3/src/Tester.java b/Appointment P9.3/src/Tester.java new file mode 100644 index 0000000..95bb618 --- /dev/null +++ b/Appointment P9.3/src/Tester.java @@ -0,0 +1,13 @@ +import java.util.ArrayList; + +public class Tester { + + public static void main(String[] args) { + ArrayList agenda= new ArrayList<>(); + + agenda.add(new OneTime("Dentista", 24, 3, 22)); + + System.out.println(agenda.toString()); + System.out.println(agenda.get(0).occursOn(24, 3, 22)); + } +}