class Person{
private String name;
int alter;
static int anzahl=0;
private String geb="tt.mm.jjjj";
final double pi;
Person(String name, int alter){
pi=3.14159;
this.name=name;
this.alter=alter;
anzahl++;
}
Person(){
anzahl++; pi=3.14159;
}
void drucken(){
System.out.println(name);
System.out.println(alter);
System.out.println(anzahl);
System.out.println();
}
public static void main(String[] args){
Person p1= new Person("Bernd",26);
p1.drucken();
Person p2= new Person("Barbara",30);
p2.drucken();
p1.drucken();
}
}
class BinaryNode {
private BinaryNode leftSon, rightSon;
private int value;
public BinaryNode(int i) {
leftSon = rightSon = null;
value = i;
}
public boolean contains(int v) {
BinaryNode zeiger= this;
while (zeiger != null) {
if (v==zeiger.value) {
return true;
} // end of if
if (v < zeiger.value) {
zeiger=zeiger.leftSon;
} // end of if
else {
zeiger=zeiger.rightSon;
} // end of if-else
} // end of while
return false;
}
public void insert(int v) {
BinaryNode zeiger= this;
BinaryNode neu=new BinaryNode(v);
while (zeiger != null) {
if (v < zeiger.value) {
if (zeiger.leftSon==null) {
zeiger.leftSon=neu; zeiger=null;
} // end of if
else {
zeiger=zeiger.leftSon;
} // end of if-else
} // end of if
else {
if (zeiger.rightSon==null) {
zeiger.rightSon=neu; zeiger=null;
} // end of if
else {
zeiger=zeiger.rightSon;
} // end of if-else
} // end of if-else
} // end of while
}
public void inorder(BinaryNode n) {
if (n != null) {
inorder(n.leftSon);
System.out.println(n.value);
inorder(n.rightSon);
} // end of if
}
}
public class TestTree {
public static void main(String[] args) {
BinaryNode myTree = new BinaryNode(6);
myTree.insert(5);
myTree.insert(4);
myTree.insert(12);
myTree.insert(11);
myTree.insert(10);
myTree.inorder(myTree);
System.out.println(myTree.contains(117));
}
}
class Entry<ET>{
ET element;
Entry next;
Entry previous;
Entry(){
}
} class Queue{
Entry<String> first;
Queue(int groesse){
Entry<String> neu= new Entry<String>();
Entry<String> erster,letzter;
first=neu;
neu.next=neu;
neu.previous=neu;
for (int i=1; i<groesse; i++) {
erster= first;
letzter=first.previous;
neu= new Entry<String>();
neu.next= erster;
neu.previous= letzter;
letzter.next=neu;
erster.previous=neu;
// neu= new Entry();
// neu.next= first;
// neu.previous= first.previous;
// first.previous.next=neu;
// first.previous=neu;
} // end of while
}
void insert(String s){
first.element=s;
first=first.next;
}
void print(){
Entry<String> zeiger;
zeiger=first.previous;
while (zeiger!=first) {
System.out.println(String.valueOf(zeiger.element));
zeiger=zeiger.previous ;
} // end of while
System.out.println(String.valueOf(zeiger.element));
}
public static void main(String[] args){
Queue puffer = new Queue(4);
puffer.insert("a");
puffer.insert("b");
puffer.insert("c");
puffer.insert("d");
puffer.insert("e");
puffer.print();
}
class Entry<ET>{
ET element;
Entry next;
Entry previous;
Entry(){
}
}
}