From e8d754c8b9184c445779458ba8f863d6cc99b718 Mon Sep 17 00:00:00 2001 From: obaya Date: Tue, 13 Aug 2024 00:18:06 +0200 Subject: [PATCH] WhatsappGruppe --- Programmierung2/src/Übungen/Whatsapp.java | 21 ++++++++++++++----- Programmierung2/src/Übungen/WhatsappTest.java | 14 +++++++++++-- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/Programmierung2/src/Übungen/Whatsapp.java b/Programmierung2/src/Übungen/Whatsapp.java index be0840c..5e63849 100644 --- a/Programmierung2/src/Übungen/Whatsapp.java +++ b/Programmierung2/src/Übungen/Whatsapp.java @@ -8,6 +8,8 @@ public class Whatsapp extends Nacnhrichten { private Whatsapp empf; private ArrayList speicherContact; private ArrayList speicherNummern; + private ArrayList addGrouppe; + private String grouppeName; @@ -20,6 +22,8 @@ public class Whatsapp extends Nacnhrichten { this.empf = null; this.speicherContact = new ArrayList<>(); this.speicherNummern = new ArrayList<>(); + this.addGrouppe = new ArrayList<>(); + this.grouppeName = null; } @@ -29,6 +33,18 @@ public class Whatsapp extends Nacnhrichten { nachrichtenlists.add(getSendeNachricht()); } + + public void addgrouppe(String grouppeName,ArrayList addGrouppe) { + this.addGrouppe.addAll(addGrouppe); + this.grouppeName = grouppeName; + } + + public void printgrouppe(){ + System.out.println(this.name + " hat die Grouppe " + this.grouppeName + " erstellt"); + for (int i = 0; i < addGrouppe.size(); i++){ + System.out.println(addGrouppe.get(i)); + } + } public void addContact(String name, String teleN){ if (name != null && teleN != null){ @@ -55,7 +71,6 @@ public class Whatsapp extends Nacnhrichten { for (int i = 0; i < speicherContact.size(); i++){ System.out.println("Name: " + speicherContact.get(i) + ", Telefonnummer: " + speicherNummern.get(i)); } - } public String getSendeNachricht() { @@ -71,10 +86,6 @@ public class Whatsapp extends Nacnhrichten { return nachrichtenlists; } - - - - public String getName() { return name; } diff --git a/Programmierung2/src/Übungen/WhatsappTest.java b/Programmierung2/src/Übungen/WhatsappTest.java index 0126a95..67bb2a6 100644 --- a/Programmierung2/src/Übungen/WhatsappTest.java +++ b/Programmierung2/src/Übungen/WhatsappTest.java @@ -6,11 +6,21 @@ public class WhatsappTest { public static void main(String[] args) { Whatsapp obai = new Whatsapp("obai", "049321384324"); Whatsapp omar = new Whatsapp("Omar", "049321384324"); + Whatsapp abd = new Whatsapp("abd", "049321384324"); + obai.sendeNachricht(omar, "Hallo"); omar.sendeNachricht(obai, "Hi"); - - Nacnhrichten.printNachrichtLists(); + + ArrayList gr1 = new ArrayList<>(); + gr1.add(omar); + gr1.add(abd); + obai.addgrouppe("Almidani",gr1); + obai.printgrouppe(); + obai.addContact("abd", "049321384324"); + obai.printContacte(); + + //Nacnhrichten.printNachrichtLists(); }