浏览代码

WS0910 Aufgabe_3

Jakob Kienegger 6 年之前
父节点
当前提交
d48217931a

二进制
Aufgabe_3/Angestellter.class


+ 7 - 0
Aufgabe_3/Angestellter.ctxt

@@ -0,0 +1,7 @@
+#BlueJ class context
+comment0.target=Angestellter
+comment1.params=name\ anschrift\ gehalt
+comment1.target=Angestellter(java.lang.String,\ java.lang.String,\ int)
+comment2.params=
+comment2.target=int\ gibVerdienst()
+numComments=3

+ 15 - 0
Aufgabe_3/Angestellter.java

@@ -0,0 +1,15 @@
+public class Angestellter extends Mitarbeiter
+{
+    private int gehalt;
+    
+    public Angestellter(String name, String anschrift, int gehalt)
+    {
+        super(name, anschrift);
+        this.gehalt = gehalt;
+    }
+    
+    public int gibVerdienst()
+    {
+        return gehalt;
+    }
+}

二进制
Aufgabe_3/Freiberufler.class


+ 9 - 0
Aufgabe_3/Freiberufler.ctxt

@@ -0,0 +1,9 @@
+#BlueJ class context
+comment0.target=Freiberufler
+comment1.params=name\ anschrift\ stundensatz
+comment1.target=Freiberufler(java.lang.String,\ java.lang.String,\ int)
+comment2.params=
+comment2.target=int\ gibVerdienst()
+comment3.params=stunden
+comment3.target=void\ setzeStunden(int)
+numComments=4

+ 21 - 0
Aufgabe_3/Freiberufler.java

@@ -0,0 +1,21 @@
+public class Freiberufler extends Mitarbeiter
+{
+    private int stundensatz;
+    private int stunden;
+    
+    public Freiberufler(String name, String anschrift, int stundensatz)
+    {
+        super(name, anschrift);
+        this.stundensatz = stundensatz;
+    }
+    
+    public int gibVerdienst()
+    {
+        return stunden * stundensatz;
+    }
+    
+    public void setzeStunden(int stunden)
+    {
+        this.stunden += stunden;
+    }
+}

二进制
Aufgabe_3/Mitarbeiter.class


+ 9 - 0
Aufgabe_3/Mitarbeiter.ctxt

@@ -0,0 +1,9 @@
+#BlueJ class context
+comment0.target=Mitarbeiter
+comment1.params=name\ anschrift
+comment1.target=Mitarbeiter(java.lang.String,\ java.lang.String)
+comment2.params=
+comment2.target=int\ gibVerdienst()
+comment3.params=
+comment3.target=void\ druckeVerdienst()
+numComments=4

+ 20 - 0
Aufgabe_3/Mitarbeiter.java

@@ -0,0 +1,20 @@
+
+public abstract class Mitarbeiter
+{
+   private String name;
+   private String anschrift;
+   
+   public Mitarbeiter(String name, String anschrift)
+   {
+       this.name = name;
+       this.anschrift = anschrift;
+   }
+   
+   public abstract int gibVerdienst();
+   
+   public void druckeVerdienst()
+   {
+       System.out.println( name + ", " + gibVerdienst() + " Euro");
+   }
+    
+}

二进制
Aufgabe_3/Personalverwaltung.class


+ 13 - 0
Aufgabe_3/Personalverwaltung.ctxt

@@ -0,0 +1,13 @@
+#BlueJ class context
+comment0.target=Personalverwaltung
+comment1.params=
+comment1.target=Personalverwaltung()
+comment2.params=
+comment2.target=void\ generiere()
+comment3.params=
+comment3.target=void\ statistik()
+comment4.params=
+comment4.target=void\ verdienstListe()
+comment5.params=args
+comment5.target=void\ main(java.lang.String[])
+numComments=6

+ 64 - 0
Aufgabe_3/Personalverwaltung.java

@@ -0,0 +1,64 @@
+import java.util.ArrayList;
+import java.util.Iterator;
+
+public class Personalverwaltung
+{
+    private ArrayList<Mitarbeiter> datensammlung;
+
+    public Personalverwaltung()
+    {
+        datensammlung = new ArrayList<Mitarbeiter>();
+    }
+
+    public void generiere()
+    {
+        Angestellter Lilli = new Angestellter("Lilli Marten", "Anschrift 1", 3500);
+        Angestellter Willy = new Angestellter("Willy Wichtig", "Anschrift 2", 3250);
+        Freiberufler Marc = new Freiberufler("Marc Hopfner", "Anschrift 3", 50);
+        Marc.setzeStunden(60);
+        Freiberufler Elke = new Freiberufler("Elke Stratmann", "Anschrift 4", 80);
+        Elke.setzeStunden(40);
+
+        datensammlung.add(Lilli);
+        datensammlung.add(Willy);
+        datensammlung.add(Marc);
+        datensammlung.add(Elke);
+    }
+
+    public void statistik()
+    {
+        Iterator<Mitarbeiter> it = datensammlung.iterator();
+        int anzahlAngestellter = 0;
+        int anzahlFreiberufler = 0;
+        while(it.hasNext())
+        {
+            Mitarbeiter mitarbeiter = it.next();
+            if(mitarbeiter instanceof Angestellter)
+            {
+                anzahlAngestellter++;
+            }
+            if(mitarbeiter instanceof Freiberufler)
+            {
+                anzahlFreiberufler++;
+            }
+        }
+        System.out.println("Anzahl Angestellte: " + anzahlAngestellter);
+        System.out.println("Anzahl Freiberufler: " + anzahlFreiberufler);
+    }
+
+    public void verdienstListe()
+    {
+        for(Mitarbeiter mitarbeiter : datensammlung)
+        {
+            mitarbeiter.druckeVerdienst();
+        }
+    }
+
+    public static void main(String[] args)
+    {
+        Personalverwaltung personal = new Personalverwaltung();
+        personal.generiere();
+        personal.statistik();
+        personal.verdienstListe();
+    }
+}

+ 12 - 0
Aufgabe_3/README.TXT

@@ -0,0 +1,12 @@
+------------------------------------------------------------------------
+This is the project README file. Here, you should describe your project.
+Tell the reader (someone who does not know anything about this project)
+all he/she needs to know. The comments should usually include at least:
+------------------------------------------------------------------------
+
+PROJECT TITLE:
+PURPOSE OF PROJECT:
+VERSION or DATE:
+HOW TO START THIS PROJECT:
+AUTHORS:
+USER INSTRUCTIONS:

+ 62 - 0
Aufgabe_3/package.bluej

@@ -0,0 +1,62 @@
+#BlueJ package file
+dependency1.from=Personalverwaltung
+dependency1.to=Mitarbeiter
+dependency1.type=UsesDependency
+dependency2.from=Personalverwaltung
+dependency2.to=Angestellter
+dependency2.type=UsesDependency
+dependency3.from=Personalverwaltung
+dependency3.to=Freiberufler
+dependency3.type=UsesDependency
+editor.fx.0.height=873
+editor.fx.0.width=1440
+editor.fx.0.x=0
+editor.fx.0.y=0
+objectbench.height=94
+objectbench.width=746
+package.divider.horizontal=0.530281690140845
+package.divider.vertical=0.8705128205128205
+package.editor.height=672
+package.editor.width=1310
+package.editor.x=0
+package.editor.y=0
+package.frame.height=873
+package.frame.width=1440
+package.numDependencies=3
+package.numTargets=4
+package.showExtends=true
+package.showUses=true
+project.charset=UTF-8
+readme.height=58
+readme.name=@README
+readme.width=47
+readme.x=10
+readme.y=10
+target1.height=50
+target1.name=Mitarbeiter
+target1.showInterface=false
+target1.type=AbstractTarget
+target1.width=110
+target1.x=110
+target1.y=10
+target2.height=50
+target2.name=Angestellter
+target2.showInterface=false
+target2.type=ClassTarget
+target2.width=120
+target2.x=190
+target2.y=210
+target3.height=50
+target3.name=Freiberufler
+target3.showInterface=false
+target3.type=ClassTarget
+target3.width=110
+target3.x=30
+target3.y=210
+target4.height=50
+target4.name=Personalverwaltung
+target4.showInterface=false
+target4.type=ClassTarget
+target4.width=170
+target4.x=320
+target4.y=100

二进制
Lin_Algebra/Eingabe.class


+ 11 - 13
Lin_Algebra/Eingabe.ctxt

@@ -4,16 +4,14 @@ comment1.params=
 comment1.target=Eingabe()
 comment2.params=
 comment2.target=void\ einlesen()
-comment3.params=zahl
-comment3.target=double\ faktorCheck(Element)
-comment4.params=zahl\ multi
-comment4.target=double\ rechnen(Element,\ double)
-comment5.params=a
-comment5.target=void\ zeilenFaktor(int)
-comment6.params=
-comment6.target=void\ ausgabe()
-comment7.params=
-comment7.target=void\ gauss()
-comment8.params=args
-comment8.target=void\ main(java.lang.String[])
-numComments=9
+comment3.params=
+comment3.target=void\ ausgabe()
+comment4.params=zeile
+comment4.target=void\ zeileMulti(int)
+comment5.params=zeileStatic\ zeileChange
+comment5.target=void\ zeilenAddition(int,\ int)
+comment6.params=zeilenZahl\ spaltenZahl
+comment6.target=void\ gaussAlgorithmus(int,\ int)
+comment7.params=args
+comment7.target=void\ main(java.lang.String[])
+numComments=8

+ 44 - 75
Lin_Algebra/Eingabe.java

@@ -9,29 +9,30 @@ import java.util.*;
 
 public class Eingabe
 {
-    private Element[][] matrix;
+    public Element[][] matrix;
     private double multi = 1;
-    private int n;
-    private int m;
+    private int zeilenZahl;
+    private int spaltenZahl;
+    private double zahl;
 
     public Eingabe()
     {
-        n = 3;
-        m = 4;
+        zeilenZahl = 3;
+        spaltenZahl = 4;
     }
 
     public void einlesen() throws IOException {
         
         //InputStreamReader isr = null;
         BufferedReader br = null;
-        matrix = new Element[n][m];
-        for(int i = 0; i < n; i++) {
-            for(int j = 0; j < m; j++) {
+        matrix = new Element[zeilenZahl][spaltenZahl];
+        for(int i = 0; i < zeilenZahl; i++) {
+            for(int j = 0; j < spaltenZahl; j++) {
                 try {
                     br = new BufferedReader(new InputStreamReader(System.in));
                     System.out.print(+ i + "," + j + ": ");
                     String eingabe = br.readLine();
-                    matrix[i][j] = new Element(Double.parseDouble(eingabe));
+                    matrix[i][j] = new Element(Integer.parseInt(eingabe));
                 } catch (IOException e) {
                     e.printStackTrace();
                 }
@@ -46,41 +47,14 @@ public class Eingabe
             }
         }
     }
-    public double faktorCheck(Element zahl)
-    {
-        int value = (int) zahl.gibZahl();
-        if(value != 1)
-        {
-            multi = 1/(zahl.gibZahl());
-            zahl.multiZahl(multi);
-        }
-        return multi;
-    }
-    
-    public double rechnen(Element zahl, double multi)
-    {
-        zahl.multiZahl(multi);
-        return zahl.gibZahl();
-    }
+  
    
-    public void zeilenFaktor(int a)
-    {
-        for(int i=0; i<n; i++)
-        {
-            multi = faktorCheck(matrix[i][a]);
-            for(int j=1; j<m; j++)
-            {
-                matrix[i][j].multiZahl(multi); 
-            }
-        }   
-        
-    }
     
     public void ausgabe()
     {
-        for(int j=0; j<n; j++)
+        for(int j=0; j<zeilenZahl; j++)
         {
-            for(int i=0; i<m; i++)
+            for(int i=0; i<spaltenZahl; i++)
             {
                 System.out.print( matrix[j][i].gibZahl() + ", ");
             }
@@ -88,67 +62,62 @@ public class Eingabe
         }
     }
     
+    public void zeileMulti(int zeile)
+    {
+        for(int i=0; i<spaltenZahl; i++)
+        {
+            matrix[zeile][i].multiZahl(this.multi);
+        }
+    }
     
-    public void gauss() throws IOException
+    public void zeilenAddition(int zeileStatic, int zeileChange)
     {
-        //einlesen(m, n);
-        zeilenFaktor(0);
-        for(int j=1; j<3; j++)
+        for(int i=0; i<spaltenZahl; i++)
         {
-            for(int i=0; i<m; i++)
-            {
-                double a = matrix[0][i].gibZahl();
-                double b = matrix[j][i].gibZahl();
-                
-                matrix[j][i].changeZahl(b-a);
-            }
+            this.zahl = matrix[zeileChange][i].gibZahl() - matrix[zeileStatic][i].gibZahl();
+            matrix[zeileChange][i].changeZahl(this.zahl);
         }
-        zeilenFaktor(1);
-        for(int i=1; i<m; i++)
-            {
-                double a = matrix[1][i].gibZahl();
-                double b = matrix[0][i].gibZahl();
-                
-                matrix[0][i].changeZahl(b-a);
-            }
-        for(int i=1; i<m; i++)
+    }
+    
+    public void gaussAlgorithmus(int zeilenZahl, int spaltenZahl)
+    {
+        for(int i=0; i<zeilenZahl; i++)
+        {
+            this.multi = 1/(matrix[i][i].gibZahl());
+            for(int k=0; k<zeilenZahl; k++)
             {
-                double a = matrix[1][i].gibZahl();
-                double b = matrix[2][i].gibZahl();
-                
-                matrix[2][i].changeZahl(b-a);
+                zeileMulti(k);
             }
-        zeilenFaktor(2);
-        for(int j=0; j<2; j++)
-        {
-            for(int i=2; i<m; i++)
+            
+            for(int j=0; j<i | j>i; j++)
             {
-                double a = matrix[2][i].gibZahl();
-                double b = matrix[j][i].gibZahl();
-                
-                matrix[j][i].changeZahl(b-a);
+                zeilenAddition(i, j);
             }
+            
         }
-        ausgabe();
     }
 
+      
+
     public static void main (String[] args) {
 
         Eingabe a = new Eingabe();
+        //Gauss b = new Gauss(3, 4);
 
         try {
             a.einlesen();
-            a.gauss();
+            a.gaussAlgorithmus(3, 4);
+            a.ausgabe();
         } catch (IOException e) {
             e.printStackTrace();
         }
 
-        //a.ausgabe();
+        
     }
     
   /*
     
     */
    
-   
+    
 }

二进制
Lin_Algebra/Element.class


+ 1 - 1
Lin_Algebra/Element.ctxt

@@ -7,7 +7,7 @@ comment1.text=\n\ Konstruktor\ f\u00FCr\ Objekte\ der\ Klasse\ Element\n
 comment2.params=
 comment2.target=double\ gibZahl()
 comment3.params=multi
-comment3.target=double\ multiZahl(double)
+comment3.target=void\ multiZahl(double)
 comment4.params=zahl
 comment4.target=void\ changeZahl(double)
 numComments=5

+ 2 - 2
Lin_Algebra/Element.java

@@ -21,10 +21,10 @@ public class Element
        return zahl;
    }
    
-    public double multiZahl(double multi)
+    public void multiZahl(double multi)
    {
        zahl = zahl * multi;
-       return zahl;
+       //return zahl;
    }
     
     public void changeZahl(double zahl)

二进制
Lin_Algebra/Gauss.class


+ 13 - 0
Lin_Algebra/Gauss.ctxt

@@ -0,0 +1,13 @@
+#BlueJ class context
+comment0.target=Gauss
+comment0.text=\n\ @author\ (Jakob\ Kienegger)\n\ @version\ (29.04.19)\n
+comment1.params=zeilenZahl\ spaltenZahl
+comment1.target=Gauss(int,\ int)
+comment1.text=\n\ Constructor\ for\ objects\ of\ class\ Gauss\n
+comment2.params=zeile
+comment2.target=void\ zeileMulti(int)
+comment3.params=zeileStatic\ zeileChange
+comment3.target=void\ zeilenAddition(int,\ int)
+comment4.params=zeilenZahl\ spaltenZahl
+comment4.target=void\ gaussAlgorithmus(int,\ int)
+numComments=5

+ 59 - 0
Lin_Algebra/Gauss.java

@@ -0,0 +1,59 @@
+
+/**
+ * @author (Jakob Kienegger)
+ * @version (29.04.19)
+ */
+public class Gauss
+{
+    private int zeilenZahl;
+    private int spaltenZahl;
+    private double multi;
+    private double zahl;
+    public Element[][] matrix;
+    
+    
+    /**
+     * Constructor for objects of class Gauss
+     */
+    public Gauss(int zeilenZahl, int spaltenZahl)
+    {
+        this.zeilenZahl = zeilenZahl;
+        this.spaltenZahl = spaltenZahl;
+    }
+
+    public void zeileMulti(int zeile)
+    {
+        for(int i=0; i<spaltenZahl; i++)
+        {
+            matrix[zeile][i].multiZahl(this.multi);
+        }
+    }
+    
+    public void zeilenAddition(int zeileStatic, int zeileChange)
+    {
+        for(int i=0; i<spaltenZahl; i++)
+        {
+            this.zahl = matrix[zeileChange][i].gibZahl() - matrix[zeileStatic][i].gibZahl();
+            matrix[zeileChange][i].changeZahl(this.zahl);
+        }
+    }
+    
+    public void gaussAlgorithmus(int zeilenZahl, int spaltenZahl)
+    {
+        for(int i=0; i<zeilenZahl; i++)
+        {
+            this.multi = 1/(matrix[i][i].gibZahl());
+            for(int k=0; k<zeilenZahl; k++)
+            {
+                zeileMulti(k);
+            }
+            
+            for(int j=0; j<i | j>i; j++)
+            {
+                zeilenAddition(i, j);
+            }
+            
+        }
+    }
+    
+}

+ 15 - 8
Lin_Algebra/package.bluej

@@ -2,13 +2,13 @@
 dependency1.from=Eingabe
 dependency1.to=Element
 dependency1.type=UsesDependency
-editor.fx.0.height=873
-editor.fx.0.width=720
+editor.fx.0.height=0
+editor.fx.0.width=0
 editor.fx.0.x=0
 editor.fx.0.y=0
 objectbench.height=93
-objectbench.width=845
-package.divider.horizontal=0.6
+objectbench.width=763
+package.divider.horizontal=0.5422535211267606
 package.divider.vertical=0.8717948717948718
 package.editor.height=673
 package.editor.width=1310
@@ -17,7 +17,7 @@ package.editor.y=0
 package.frame.height=873
 package.frame.width=1440
 package.numDependencies=1
-package.numTargets=2
+package.numTargets=3
 package.showExtends=true
 package.showUses=true
 project.charset=UTF-8
@@ -34,9 +34,16 @@ target1.width=90
 target1.x=370
 target1.y=90
 target2.height=50
-target2.name=Eingabe
+target2.name=Gauss
 target2.showInterface=false
 target2.type=ClassTarget
 target2.width=80
-target2.x=70
-target2.y=190
+target2.x=272
+target2.y=283
+target3.height=50
+target3.name=Eingabe
+target3.showInterface=false
+target3.type=ClassTarget
+target3.width=80
+target3.x=70
+target3.y=190