3109 (dtest)

some ls-kind experiment

#!/bin/bash
#going through some tests with dirs
#todo basename $0, set scriptname from basename, switch case (if/elseif/else) ./dir/file
FILE=$1
DIR=`dirname $FILE`
FILES=`ls $DIR`

echo "Filename specified: $FILE"
echo "Parent directory: $DIR"

for f in $FILES; do
echo "- $f"
done

3107 (n-queen-problem, graphical)

graphical solution for the n-queen-problem in java

package nq2;

import java.util.Stack;
import comp102x.Canvas;
import comp102x.ColorImage;

public class NQueens {

    public static Stack<Integer> s = new Stack<Integer>();
    public static int n; 
    public static int total; 
    private static Canvas canvas;
    private static ColorImage board;
    private static int gridSize = 80;
    private static ColorImage queen = new ColorImage("/home/evemat/Dokumente/javaio/workspace/nq2/nq2/bq80.png");
    private static ColorImage wq = new ColorImage("/home/evemat/Dokumente/javaio/workspace/nq2/nq2/wq80.png");
    private static ColorImage[] queens;
    
    public NQueens(int size) {
        
        n = size;
        int iSize = gridSize*n;
        canvas = new Canvas(iSize+10, iSize+10);
        board = new ColorImage(iSize, iSize);
        queens = new ColorImage[n];
        for (int i = 0; i<iSize; i++)
            for (int j = 0; j<iSize; j++){
                int r = i/gridSize;
                int c = j/gridSize;
                if ((r+c)/2*2 == (r+c)) board.setRGB(i, j, 0, 0, 255);
                    else board.setRGB(i, j, 255, 255, 255);
                }
                
        for (int i=0; i<n; i++)
            queens[i] = new ColorImage(queen);
            
        canvas.add(board);
        displayI(wq, n+1, n+1);
    }
            
      //finds and prints out all solutions to the n-queens problem
    public static int solve(){
        
        int i = 0;   // i goes through each row to place a queen
        int x = 0;   // x goes through the columns within each row 
        total = 0;
    
        while ( i < n ) {        
            while (x < n) {
                moveI(wq, x, i);
                if(isConflict(i, x) == false){ 
                    s.push(x); // no conflict, push x
                    moveI(wq, n+1, n+1);
                    displayI(queens[i], x, i);
                    //was commented out
                    pause(200);
                    break; //break out of loop to next row
                }
                else 
                    x++;
            }
              
            if (s.isEmpty() == true) break;
              
            if (x >= n) {
                moveI(wq, n+1, n+1);
                x = s.pop() + 1;
                i--;
                removeI(queens[i]);
                //was commented out
                pause(200);
            }
            
            else {
                i++;
                x = 0;
            }
              
            if (s.size()==n){ 
                total++; 
                pause(200);
                System.out.println(total + ": " + s);
                //if (total == 1) printSolution(s);
                removeI(queens[n-1]);
                x = s.pop() + 1;
                i--;                    
            }
        } 
        return total; 
    }

    public static boolean isConflict(int row, int col){
        int diff = row-col;
        int sum = row+col;
        for (int i = 0; i < row; i++) {
            int t = s.get(i);
            if (t==col || i-t == diff || i+t == sum) return true;
          }
          return false;
    }
    
    private static void printSolution(Stack<Integer> s) {
        for (int i = 0; i < s.size(); i ++) {
            for (int j = 0; j < s.size(); j ++) {
                if (j == s.get(i))
                    System.out.print("Q ");
                else
                    System.out.print("* ");
            }//for
            System.out.println();
        }//for
        System.out.println();  
    }//printSolution()

    public static void displayI(ColorImage image, int x, int y){
      x = x * gridSize;
      y = y * gridSize;
      canvas.add(image, x, y);
    }
    
    public static void removeI(ColorImage image){
       canvas.remove(image);
    }
    
    public static void moveI(ColorImage image, int x, int y){
        image.setX(x*gridSize);
        image.setY(y*gridSize);
    }
  
    public static void pause(int sleepTime){
        try {
            Thread.sleep(sleepTime);
        }catch (InterruptedException e) {
            System.err.println("Error in running animation!");
            System.exit(-1);
        }
    }

    public void demo() {
        //NQueens nQ = new NQueens(n);

        int number = solve();
        System.out.println("There are " + number + " solutions to the " + n + "-queens problem.");
    }
	public static void main (String[] args)
	{
	int ein = 0;
	ein = eingabe.readInt ("anzahl queens:");
	NQueens nQ = new NQueens (ein);
	nQ.demo();
	}
}

3105 (array histogram special case max 3)

public class hist
{
    
    public static int[] histogram (int [][] arrayA)
    {  // nested for loop to go through the array.
        int max = 0;
       for ( int row = 0; row<arrayA.length; row++)
		{
           for ( int col=0; col < arrayA[row].length; col++)
			{

               if ( arrayA[row][col]> max )
				{
                   max = arrayA[row][col];
            	}
        	}
    	}
	System.out.println("max:"+max);
    int histA[] = new int [max+1];
	int lauf = 0;
	for (lauf=0;lauf<max+1;lauf++)
	{
    for ( int row = 0; row<arrayA.length; row++)
		{
           for ( int col=0; col < arrayA[row].length; col++)
			{
				if (arrayA[row][col] == lauf)
				{
					histA[lauf]++;
				}
               //histA[arrayA[row][col]]++;
            }
        }
	}
        //System.out.println(histA);
        return histA;
    }
	public static void main (String[]args)
    {
        // declearing and initializing a 2D array.
        int [][] arrayA = {{0,1,2},{3,0,2},{3,3,0}};
		int erg[]={};
        erg = histogram(arrayA);
		for (int i = 0; i<=3; i++)
		{
			System.out.println(i+":"+erg[i]);
		}

    }
}

3101 (some convertingtools)

4 javapieces int_to_bin/bin_to_int/int_to_hex/hex_to_int

int_to_bin

class dec_bin
{
public static String b0(int n) {

        if (n == 0) return "0";
        if (n == 1) return "1";
        
        return b0(n / 2) + (n % 2);
}
public static void main (String[] args)
{
int ein=0;
String erg="";
ein=eingabe.readInt("Integer:");
erg= b0(ein);
System.out.println(erg);
}
}

bin_to_int

class bin_dec
{
public static void main (String[] args)
{
String ein = "";
int foo=0;
ein=eingabe.readString("String(bin):");
foo = Integer.parseInt(ein, 2);
System.out.println(foo);
}
}

int_to_hex

class dec_hex
{
public static String intToHexStr(int i){
    return "0x"+String.format("%2s", Integer.toHexString(i)).replace(' ', '0');
}
public static void main (String[] args)
{
int ein=0;
String erg="";
ein=eingabe.readInt("Integer:");
erg=intToHexStr(ein);
System.out.println(erg);
}
}

hex_to_int

class hex_dec
{
public static void main (String[] args)
{
String ein = "";
String foo="";
String bar="";
int value=0;
ein=eingabe.readString("String(hex):");
foo=ein.substring(0,2);
if (foo.equals("0x")) { bar = ein.substring(2); }
else { bar = ein; }
value = Integer.parseInt(bar, 16);
System.out.println(value);
}
}

3097

drei 3D-arrays bilden eine entwicklung ueber die zeit ab. the values were coincidentally chosen (random), ausser des startpunktes einer 2D-nullkoordinate.

class time
{
	//main method, arguments may be passed on commandline execution
	public static void main(String args[])
	{
		// declare and initialize 4D array
		int arr[][][][] = {
								{
									{ {0,0,0},{2,6,6},{7,4,2} },
									{ {0,0,0},{9,6,2},{9,1,3} },
									{ {0,0,0},{4,5,6},{2,5,2} }
								},
								{
									{ {0,4,2},{2,6,1},{9,3,1} },
									{ {3,7,9},{9,6,2},{0,1,5} },
									{ {5,8,4},{4,7,6},{6,5,2} }
								},
								{
									{ {7,5,2},{2,6,2},{6,5,5} },
									{ {6,8,9},{7,5,2},{8,5,9} },
									{ {2,8,5},{3,7,7},{4,5,8} }
								}
							};
		// print time array in four nested for-loops
		for (int l = 0; l<3; l++)		
		{	
			//print 3D-element number
			System.out.println(l);
			for (int i=0; i< 3 ; i++)
			{
				for (int j=0; j < 3 ; j++)
				{
					for (int k=0; k < 3; k++)
					{
						//print element
						System.out.print(arr[l][i][j][k] + " ");
					}
					//print whitespaces
					System.out.print("     ");
				}
				//newline
				System.out.println();
			}
		}
	}
}

3060 (lab03)

hong kong university edx comp102x lab3 solution

import comp102x.ColorImage;
import comp102x.Canvas;

public class Lab03
{  
    
    public void loadAnImage() 
    {
        // Please write your code after this line
        ColorImage labimg1 = new ColorImage();        
        int w, h;
        w = labimg1.getWidth();
        h = labimg1.getHeight();
        Canvas canvas = new Canvas (w, h);
        canvas.add(labimg1);
        
    }
    
    public void loadTwoImagesOnTheSameCanvas()
    {
        // Please write your code after this line
        int w1, w2, h1, h2;
        ColorImage labimg2 = new ColorImage();
        ColorImage labimg3 = new ColorImage();
        w1 = labimg2.getWidth();
        h1 = labimg2.getHeight();
        w2 = labimg3.getWidth();
        h2 = labimg3.getHeight();
        Canvas canvas2 = new Canvas ((2 * w1), h1);
        canvas2.add(labimg2, 0, 0);
        canvas2.add(labimg3, w1, 0);
        
    }
    
    public void imageAddition() 
    {    
        // Please write your code after this line
        int ww1, ww2, hh1, hh2;
        ColorImage labimg4 = new ColorImage();
        ColorImage labimg5 = new ColorImage();
        ColorImage labimg6 = labimg4.add(labimg5);
        ww1 = labimg4.getWidth();
        hh1 = labimg4.getHeight();
        ww2 = labimg5.getWidth();
        hh2 = labimg5.getHeight();
        Canvas canvas3 = new Canvas (((3 * ww1) + 20), hh1);
        canvas3.add(labimg4, 0, 0);
        canvas3.add(labimg5, (ww1 + 10), 0);
        canvas3.add(labimg6, ((ww1 * 2) + 20), 0);
        
        
    }
   
    public void imageMultiplication() 
    {
        // Please write your code after this line
        int width1, width2, height1, height2;
        ColorImage labimg7 = new ColorImage();
        ColorImage labimg8 = new ColorImage();
        ColorImage labimg9 = labimg7.multiply(labimg8);
        width1 = labimg7.getWidth();
        height1 = labimg7.getHeight();
        width2 = labimg8.getWidth();
        height2 = labimg8.getHeight();
        Canvas canvas4 = new Canvas (((3 * width1) + 20), height1);
        canvas4.add(labimg7, 0, 0);
        canvas4.add(labimg8, (width1 + 10), 0);
        canvas4.add(labimg9, ((width1 * 2) + 20), 0);
        
        
        
    }
    
    public void changeColor()
    {
        ColorImage image = new ColorImage();
        image.increaseRed(40);
        Canvas canvas = new Canvas(image.getWidth(), image.getHeight());
        canvas.add(image);
        
        image.save();
    }
}

3058 (Car1.java/edx.org-week3-java-intro)

Car1.java – sample object from week3 java comp102x @ edx.org

import comp102x.Canvas;
import comp102x.ColorImage;
import java.io.PrintStream;







public class Car1
{
  String owner = "NoName";
  ColorImage carImage = new ColorImage("c5.png");
  ColorImage wImage = new ColorImage(800, 600);
  int odometer = 0;
  
  public Car1() {
    Canvas canvas = new Canvas();
    canvas.add(wImage);
    canvas.add(carImage, 200, 200);
  }
  
  public Car1(String nameOfOwner)
  {
    owner = nameOfOwner;
    carImage = new ColorImage();
    Canvas canvas = new Canvas();
    canvas.add(wImage);
    canvas.add(carImage, 200, 200);
  }
  
  public void move(int dist)
  {
    double radian = Math.toRadians(carImage.getRotation());
    double distX = dist * Math.cos(radian);
    double distY = dist * Math.sin(radian);
    odometer += dist;
    
    carImage.setX(carImage.getX() + (int)distX);
    carImage.setY(carImage.getY() + (int)distY);
  }
  
  public void moveCar(int dist) {
    int unit = 10;
    int steps = Math.abs(dist / unit);
    if (dist < 0) unit = -unit;
    for (int i = 0; i < steps; i++) {
      move(unit);
      pause(20);
    }
  }
  
  public void turnCar(int rotateAngle) {
    double rAngleRadian = Math.toRadians(1.0D);
    double radius = carImage.getWidth() * 2.0D;
    while (rotateAngle > 0) {
      carImage.setRotation((int)(carImage.getRotation() + 1.0D) % 360);
      double moveDist = Math.abs(2.0D * radius * Math.sin(rAngleRadian / 2.0D));
      move((int)moveDist);
      rotateAngle--;
      
      pause(10);
    }
  }
  
  public static void pause(int sleepTime)
  {
    try {
      Thread.sleep(sleepTime);
    } catch (InterruptedException e) {
      System.err.println("Error in running rotation animation!");
      System.exit(-1);
    }
  }
}

3047 (datum_app, java, wiwi2005)

das programm besteht aus 2 klassen(application and dateobject) (eine dritte, die eingabeklasse ist nicht aufgeführt und an einer anderen stelle zu finden) und berechnet gedöns mit jahren und werktagen zwischen 1901-01-01 und 2100-12-31.

application

import java.util.*;

class datum_app {
	public static void main (String[] args) {
		int l = 6;
		int m = 10;
		int n = 1909;
		int nowtag = 0;
		int nowmonat = 0;
		int nowjahr = 0;
		int s,t,u,diff,nsumme,msumme,x,y,z,i,help,whelp,dhelp;
		int wzaehler = 0;
	
		GregorianCalendar GC = new GregorianCalendar();
		
		System.out.println("Dieses Programm loest eine wiwi-Programmieraufgabe von 2005 (Stand: 17.12.2007), laeuft sequentiell ab und erwartet vom Benutzer einige Parameter.");
		System.out.println("Zunaechst werden zwei Daten zwischen 1901-01-01 und 2100-12-31 im Format yyyy<return>mm<return>dd<return> erwartet.");
		System.out.println("Es folgen einige debug-parameter der Datumsobjekte.");
		System.out.println("Die zu loesenden Bedingungen werden angezeigt.");
		System.out.println("Der Gregorianische Kalender wird nur zur HEUTE-Feststellung benutzt.");
		System.out.println("Ein drittes Datum YYYY-MM-DD wird erwartet");
	
		n = eingabe.readInt("Erstes Datum, Jahr:");
		m = eingabe.readInt("Erstes Datum, Monat:");
		l = eingabe.readInt("Erstes Datum, Tag:");
		u = eingabe.readInt("Zweites Datum, Jahr:");
		t = eingabe.readInt("Zweites Datum, Monat:");
		s = eingabe.readInt("Zweites Datum, Tag:");
	
		Datum ndatum = new Datum (l,m,n);
		System.out.println("n");
		System.out.println ("gueltig : " + ndatum.gueltig);
		System.out.println (ndatum.jahr + "-" + ndatum.monat + "-" + ndatum.tag);
		System.out.println (ndatum.tagesdiff);
		System.out.println (ndatum.wochentag);
		System.out.println ("Werktag : " + ndatum.werktag);
		if (ndatum.schaltjahr) { System.out.println ("Schaltjahr"); }
		else { System.out.println ("kein Schaltjahr"); }
		System.out.println();
		
		nowtag = GC.get(Calendar.DATE);
		nowmonat = GC.get(Calendar.MONTH) + 1;
		nowjahr = GC.get(Calendar.YEAR);
		Datum heute = new Datum (nowtag, nowmonat, nowjahr);
		System.out.println("und jetzt heute");
		System.out.println ("gueltig : " + heute.gueltig);
		System.out.println (heute.jahr + "-" + heute.monat + "-" + heute.tag);
		System.out.println (heute.tagesdiff);
		System.out.println (heute.wochentag);
		System.out.println ("Werktag : " + heute.werktag);
		if (ndatum.schaltjahr) { System.out.println ("Schaltjahr"); }
		else { System.out.println ("kein Schaltjahr"); }
		System.out.println();
		
		Datum mdatum = new Datum (s,t,u);
		System.out.println("m");
		System.out.println ("gueltig : " + mdatum.gueltig);
		System.out.println (mdatum.jahr + "-" + mdatum.monat + "-" + mdatum.tag);
		System.out.println (mdatum.tagesdiff);
		System.out.println (mdatum.wochentag);
		System.out.println ("Werktag : " + mdatum.werktag);
		if (ndatum.schaltjahr) { System.out.println ("Schaltjahr"); }
		else { System.out.println ("kein Schaltjahr"); }
		System.out.println();
		
		if ((ndatum.gueltig == true) && (mdatum.gueltig ==	true)) {
			if (ndatum.tagesdiff == mdatum.tagesdiff) help = 0;
			else if (ndatum.tagesdiff < mdatum.tagesdiff) help = 1;
			else help = 2;
			switch (help) {
				case 0	:	{
									System.out.println("(Punkt2)Beide Tage identisch. Differenz 0");
								}
				case 1	:	
				case 2	:	{
									diff = Math.abs(mdatum.tagesdiff - ndatum.tagesdiff);
									System.out.println("(Punkt2)Die Differenz betraegt " + diff + " Tage");
								}
				default	:	{
									break;	
								}
			}//switch--help
		}//if
		else {
			System.out.println ("(mindestens) eines der Daten ist ungueltig");
		}
					
		nsumme = ndatum.tagesdiff - ndatum.jahrsumme;
		msumme = mdatum.tagesdiff - mdatum.jahrsumme;
		
		System.out.println ("(Punkt 1) :");
		System.out.println ("Tage seit 1. Januar " + ndatum.jahr + " (n) " + nsumme);
		System.out.println ("Tage seit 1. Januar " + mdatum.jahr + " (m) " + msumme);
		
		System.out.println ("Eingabe eines Datums in der Vergangenheit (Punkt 3)");
		z = eingabe.readInt ("Jahr");
		y = eingabe.readInt ("Monat");
		x = eingabe.readInt ("Tag");
		Datum past = new Datum (x,y,z);
		if (!past.gueltig) System.out.println("Datum nicht gueltig");
		else if (past.tagesdiff > heute.tagesdiff) {
			System.out.println ("Datum liegt nicht in der Vergangenheit. Identische Daten hier kein Fehlerfall.");
		}//if
		else if (past.tagesdiff == heute.tagesdiff) {
			if (heute.werktag == true) System.out.println("Daten identisch. Werktag.");
			else System.out.println("Daten identisch. kein Werktag.");	
		}//else-if1
		else	if (Math.abs(past.tagesdiff - heute.tagesdiff) < 3) {
			diff = (heute.tagesdiff - past.tagesdiff);
				switch (diff) {
					case 1	:	{
										if (past.werktag && heute.werktag) wzaehler = 2;
										else if (past.werktag || heute.werktag) wzaehler = 1;
										else wzaehler = 0;
										break;
									}
					case 2	:	{
										dhelp = past.wtag;
										switch (dhelp)		{
											case 1	:
											case 2	:
											case 3	:
											case 4	:	wzaehler = 2;
															break;
											case 5	:	wzaehler = 1;
															break;
											case 6	:	wzaehler = 0;
															break;
											case 7	:	wzaehler = 1;
															break;
											default	: break;
										}//switch--dhelp
									}
					default	:	{
										break;
									}
				}//switch--diff
			}//else-if_diff3
		else {
			wzaehler = 1;
			for (i=past.tagesdiff; i<heute.tagesdiff; i++) {
				whelp = i;
				Datum idate = new Datum (whelp);
				if (idate.werktag) { wzaehler+=1; }
			}//for
		}//else
		System.out.println ("Werktage von " + past.jahr + "-" + past.monat + "-" + past.tag + " bis heute (Punkt 3): " + wzaehler);
		System.out.println ("Programmende. success");
	}//main
}//class

objectclass

class Datum {
	
	Boolean gueltig;
	int tag;
	int monat;
	int jahr;
	String wochentag;
	Boolean werktag;
	Boolean schaltjahr;
	int tagesdiff;
	int jahrsumme;
	int wtag;
	
//Standard-Konstruktor
	public Datum () {
		gueltig = true;
		tag = 6;
		monat = 10;
		jahr = 2012;
		wochentag = "Samstag";
		werktag = false;
		schaltjahr = true;
		tagesdiff = 40822;
	}//Standard-Konstruktor
	
	public Datum (int neuerTag, int neuerMonat, int neuesJahr) {
		int i = 0;
		int jahrdiff = 0;
	
		tag = neuerTag;
		monat = neuerMonat;
		jahr = neuesJahr;
		if ((jahr < 1901) || (jahr > 2100)) {
			gueltig = false;
			tag = 0;
			monat = 0;
			jahr = 0;
			werktag = false;
			schaltjahr = false;
		}
		else {
			if ((jahr % 4) == 0) {
				if ((jahr % 100) == 0) {
					if ((jahr % 400) == 0) {
						schaltjahr = true;
					}//400
					else { schaltjahr = false; }				
				}//100
				else { schaltjahr = true; }
			}//4	
			else { schaltjahr = false; }
			switch (monat) {
				case 1 :
				case 3 :
				case 5 :
				case 7 :
				case 8 :
				case 10:
				case 12 :	{
									if ((tag < 1) || (tag > 31)) { 
										gueltig = false;
										tag = 0;
										monat = 0;
										jahr = 0;
									}//if
									else { gueltig = true; }
									break;
								}
				case 4:
				case 6 :
				case 9 :
				case 11 :	{
									if ((tag < 1) || (tag > 30)) { 
										gueltig = false;
										tag = 0;
										monat = 0;
										jahr = 0;
									}//if
									else { gueltig = true; }
									break;
								}
				case 2 :		{
									if (schaltjahr) { i = 29; }
									else { i = 28; }
									if ((tag < 1) || (tag > i)) {
										gueltig = false;
										tag = 0;
										monat = 0;
										jahr = 0;
									}//if
									else { gueltig = true; }
									break;
								}
				default :		{
									gueltig = false;
									break;
								}
			}//switch--monat
			//Referenztag
			if ((tag == 1) && (monat == 1) && (jahr == 1901)) { wochentag = "Dienstag"; werktag = true; tagesdiff = 1; }
			else {
				jahrdiff = jahr - 1901;
				for (i=1901; i<jahr; i++) {
					if ((i % 4) == 0) {
						if ((i % 100) == 0) {
							if ((i % 400) == 0) {
								tagesdiff += 366;
							}//400
							else { tagesdiff += 365; }				
						}//100
						else { tagesdiff += 366; }
					}//4
					else tagesdiff += 365;	
				}//for	
				jahrsumme = tagesdiff;
				switch (monat) {
					case 1 :		{ 
										tagesdiff += tag; 
										break;
									}
					case 3 : 	{
										if (schaltjahr) {
											tagesdiff += 31;
											tagesdiff += 29;
											tagesdiff += tag;
										}
										else {
											tagesdiff += 31;
											tagesdiff += 28;
											tagesdiff += tag;
										}
										break;
									}
					case 5 :		{
										if (schaltjahr) {
											tagesdiff += 31;
											tagesdiff += 29;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += tag;	
										}
										else {
											tagesdiff += 31;
											tagesdiff += 28;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += tag;
										}
										break;
									}
					case 7 :		{
										if (schaltjahr) {
											tagesdiff += 31;
											tagesdiff += 29;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += tag;	
										}
										else {
											tagesdiff += 31;
											tagesdiff += 28;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += tag;
										}
										break;
									}
					case 8 :		{
										if (schaltjahr) {
											tagesdiff += 31;
											tagesdiff += 29;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += tag;	
										}
										else {
											tagesdiff += 31;
											tagesdiff += 28;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += tag;
										}
										break;
									}
					case 10 :	{
										if (schaltjahr) {
											tagesdiff += 31;
											tagesdiff += 29;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += tag;	
										}
										else {
											tagesdiff += 31;
											tagesdiff += 28;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += tag;
										}
										break;
									}
					case 12 : 	{
										if (schaltjahr) {
											tagesdiff += 31;
											tagesdiff += 29;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += tag;	
										}
										else {
											tagesdiff += 31;
											tagesdiff += 28;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += tag;
										}
										break;
									}
									
					case 4 :		{
										if (schaltjahr) {
											tagesdiff += 31;
											tagesdiff += 29;
											tagesdiff += 31;
											tagesdiff += tag;
										}
										else {
											tagesdiff += 31;
											tagesdiff += 28;
											tagesdiff += 31;
											tagesdiff += tag;
										}
										break;
									}
					case 6 :		{
										if (schaltjahr) {
											tagesdiff += 31;
											tagesdiff += 29;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += tag;
										}
										else {
											tagesdiff += 31;
											tagesdiff += 28;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += tag;
										}
										break;
									}
					case 9 :		{
										if (schaltjahr) {
											tagesdiff += 31;
											tagesdiff += 29;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += 31;
											tagesdiff += tag;	
										}
										else {
											tagesdiff += 31;
											tagesdiff += 28;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += 31;
											tagesdiff += tag;
										}
										break;
									}
					case 11 :	{
										if (schaltjahr) {
											tagesdiff += 31;
											tagesdiff += 29;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += tag;	
										}
										else {
											tagesdiff += 31;
											tagesdiff += 28;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += 31;
											tagesdiff += 30;
											tagesdiff += 31;
											tagesdiff += tag;
										}
										break;
									}
					
					case 2 :		{
										tagesdiff += 31;
										tagesdiff += tag;
									}
					
					default :		{
										break;
									}
				}//switch--monat	
				i = tagesdiff % 7;
				switch (i) {
					case 0 : 	{
										wochentag = "Montag";
										wtag = 1;
										break;
									}
					case 1 :		{
										wochentag = "Dienstag";
										wtag = 2;
										break;
									}
					case 2 :		{
										wochentag = "Mittwoch";
										wtag = 3;
										break;
									}
					case 3 :		{
										wochentag = "Donnerstag";
										wtag = 4;
										break;
									}
					case 4:		{
										wochentag = "Freitag";
										wtag = 5;
										break;
									}
					case 5 :		{
										wochentag = "Samstag";
										wtag = 6;
										break;
									}
					case 6 :		{
										wochentag = "Sonntag";
										wtag = 7;
										break;
									}
					default : 	{ 	
										wtag = -1;
										break; 
									}
				}//switch--i
				switch (wtag) {
					case 1		:
					case 2		:
					case 3 		:
					case 4	 	:
					case 5 		: 	{ 
											werktag = true;
											break; 
										}
					case 6		:
					case 7		:	{
											werktag = false;
											break;
										}
					default		:	{
											break;
										}
				}//switch--wtag
			}//Referenztag-else
		}//gueltiger Bereich
	}//Konstruktor
	
	public Datum (int tageszaehler) {
		int i = 0;
		if ((tageszaehler < 1) || (tageszaehler > 73049)) {
			gueltig = false;
		}
		else {
			i = tageszaehler % 7;
			switch (i) {
				case 0	:	{
									wtag = 2;
									wochentag = "Dienstag";
									werktag = true;
									break;
								}
				case 1	:	{
									wtag = 3;
									wochentag = "Mittwoch";
									werktag = true;
									break;
								}
				case 2	:	{
									wtag = 4;
									wochentag = "Donnerstag";
									werktag = true;
									break;
								}
				case 3	:	{
									wtag = 5;
									wochentag = "Freitag";
									werktag = true;
									break;
								}
				case 4	:	{
									wtag = 6;
									wochentag = "Samstag";
									werktag = false;
									break;
								}
				case 5	:	{
									wtag = 7;
									wochentag = "Sonntag";
									werktag = false;
									break;
								}
				case 6	:	{
									wtag = 1;
									wochentag = "Montag";
									werktag = true;
									break;
								}
				default	:	{
									break;
								}
			}//switch--i
		}//gueltig
	}//Konstruktor2
}//class Datum