Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

AbstractSet

Empfohlene Antworten

Veröffentlicht

Wer kann mir ein Lösungsansatz (am besten mir richtigem Quellcode) geben für folgende Aufgabenstellung:

Es soll eine eigene Klasse geschrieben werden (z.B. "TestSet"), die aus der Klasse AbstractSet abgeleitet ist und das Interface Set (und damit auch das Interface Collection) implementiert. Die Elemente für die neue Klasse sollen dabei in einer einfach verketteten Liste gehalten werden.

Brauch Eure Hilfe möglichst schnell, da ich unter Zeitdruck bin.

Danke im Vorraus.

Vielleicht sowas hier?:

import java.util.*;

interface List{

int len();

boolean isempty();

Object first();

List rest();

void append(Object o);

void print();

List remove(Object o);

}//Interface

class PList implements List{

LinkedList l = new LinkedList();

boolean dummy;

Object odummy;

public int len(){

return(l.size());

}//len

public boolean isempty(){

return(l.isEmpty());

}//isempty

public Object first(){

return(l.get(0));

}//first

public List rest(){

odummy = l.remove(0);

return(this);

}//rest

public void append(Object o){

dummy = l.add(o);

}//append

public void print(){

for (int i=0; i<(l.size());i++){

System.out.println((l.get(i).toString()));

}//for

}//print

public List remove(Object o){

for (int i=0; i<(l.size());i++){

if((l.get(i)).equals(o)){

odummy= (l.remove(i));

}//if

}//for

return(this);

}//remove

}//class PList

class Test{

public static void main(String[] argf){

Test.test(new PList());

}//main

static void test(List l){

for(int i=0;i<4;i++) l.append(new Integer(i));

l.append("HalloHallo");

l.print();

l = l.remove(new Integer(2));

for(int i=0;i<4;i++) l.append(new Float(i/0.007));

while(!l.isempty()){

System.out.println(l.first().toString());

l=l.rest();

}//while

}//test

}//class Test

oder, wenn du die einfach verkettete Liste ganz selbst bauen musst, dann brauchst du ein Attribut next in deiner Klasse, das vom Typ Set ist und auf jedenfall brauchst du auch ein Attribut value vom Typ Object, falls du eine einfach verkettete Liste von Objekten darstellen willst.

Falls du den Code dfür brauchst, dann poste mal, dann schreib ich dir den hier auch noch rein. Aber vielleicht hab ich dir ja genug Denkanstoss gegeben, damit du es selbst packst. Das Erfolgserlebniss dürfte dann jedenfalls groesser sein ;)

ciaoi Picard!

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.