Einfach verkettete Liste PDF

Title Einfach verkettete Liste
Author Naima Kira
Course Informatik I
Institution Universität zu Köln
Pages 6
File Size 54.2 KB
File Type PDF
Total Downloads 779
Total Views 892

Summary

Einfach verkettete Liste import java.util; public class Listeeinfach<E> { class Knoten<T> { private T dat; private Knoten<T> next; public Knoten() { this (null); } public Knoten(T dat) { this = dat; } public T ...


Description

Einfach verkettete Liste import java.util.Scanner;

public class Listeeinfach {

class Knoten {

private T dat; private Knoten next;

public Knoten() { this (null); }

public Knoten(T dat) { this.dat = dat; }

public T zugriff() { return this.next.dat; }

}

private Knoten head; private Knoten tail;

/* Testfunktion */ public static void main(String[] args) { Scanner scan = new Scanner(System.in);

int choice; String tempel; int max; boolean terminate = false; Listeeinfach testListe = new Listeeinfach(); while(!terminate) { System.out.print("1: Element hinzufuegen\n" + "2: Element entfernen\n" + "3: Liste ausgeben\n" + "4: Eine Liste anhaengen\n" + "5: Beenden"); choice = scan.nextInt(); switch(choice) { case 1: System.out.print("1: Vorne einfuegen\n" + "2: Ganz woanders einfuegen\n"); choice = scan.nextInt(); System.out.println("Element(String) eingeben:"); tempel = scan.next(); if (choice == 1) testListe.fuegeVorneEin(tempel); else { System.out.println("Vor welchem Element einfuegen?"); String tmp = scan.next(); testListe.fuegeEin(tempel, testListe.suche(tmp)); } break; case 2: System.out.println("Zu entfernendes Element:"); tempel = scan.next(); testListe.entferne(testListe.suche(tempel)); break;

case 3: System.out.print(testListe.toString()); break; case 4: Listeeinfach testListe2 = new Listeeinfach(); System.out.println("Laenge der anzuhaengenden Liste"); max = scan.nextInt(); for (int i=1; i...


Similar Free PDFs