1
0

oskar design

This commit is contained in:
Oskar
2020-12-11 16:38:35 +01:00
committed by Joel Baldauf
parent 09dbfc9660
commit 1b2f5029fb
+72 -116
View File
@@ -1,6 +1,6 @@
//Import der für die GUI benötigten Bibliotheken
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.EventQueue; import java.awt.EventQueue;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
@@ -23,21 +23,22 @@ import javax.swing.table.DefaultTableModel;
import java.awt.Font; import java.awt.Font;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import javax.swing.SpinnerModel; import javax.swing.SpinnerModel;
import java.awt.Color;
import javax.swing.UIManager;
import java.awt.SystemColor;
import javax.swing.border.LineBorder;
public class frame extends JFrame { public class frame extends JFrame {
//Deklaration von Content Pane, der Tabelle sowie des Scroll Panes; werden später gefüllt
private JPanel contentPane; private JPanel contentPane;
private JTable table; private JTable table;
private JScrollPane scrollPane; private JScrollPane scrollPane;
// Array mit den IHK-Noten. Das jeweilige Arrayfeld entspricht der Prozentanzahl. Schlüsselwort final entspricht const (Konstante) // Array mit den IHK-Noten als Konstante. Das jeweilige Arrayfeld entspricht der Prozentanzahl
public static final double marksIHK[] = {6.0,6.0,6.0,6.0,6.0,6.0,5.9,5.9,5.9,5.9,5.9,5.9,5.8,5.8,5.8,5.8,5.8,5.7,5.7,5.7,5.7,5.7,5.7,5.6,5.6,5.6,5.6,5.6,5.6,5.5,5.4,5.4,5.3,5.3,5.2,5.2,5.1,5.1,5.0,5.0,5.0,4.9,4.9,4.8,4.8,4.7,4.7,4.6,4.6,4.5,4.4,4.4,4.3,4.3,4.2,4.1,4.1,4.0,4.0,3.9,3.9,3.8,3.7,3.7,3.6,3.6,3.5,3.4,3.3,3.3,3.2,3.1,3.1,3.0,2.9,2.9,2.8,2.7,2.7,2.6,2.5,2.4,2.3,2.2,2.1,2.0,2.0,1.9,1.8,1.7,1.6,1.5,1.4,1.4,1.3,1.3,1.2,1.2,1.1,1.1,1.0}; public static final double marksIHK[] = {6.0,6.0,6.0,6.0,6.0,6.0,5.9,5.9,5.9,5.9,5.9,5.9,5.8,5.8,5.8,5.8,5.8,5.7,5.7,5.7,5.7,5.7,5.7,5.6,5.6,5.6,5.6,5.6,5.6,5.5,5.4,5.4,5.3,5.3,5.2,5.2,5.1,5.1,5.0,5.0,5.0,4.9,4.9,4.8,4.8,4.7,4.7,4.6,4.6,4.5,4.4,4.4,4.3,4.3,4.2,4.1,4.1,4.0,4.0,3.9,3.9,3.8,3.7,3.7,3.6,3.6,3.5,3.4,3.3,3.3,3.2,3.1,3.1,3.0,2.9,2.9,2.8,2.7,2.7,2.6,2.5,2.4,2.3,2.2,2.1,2.0,2.0,1.9,1.8,1.7,1.6,1.5,1.4,1.4,1.3,1.3,1.2,1.2,1.1,1.1,1.0};
/** /**
* Launch the application. - automatisch generiert vom Eclipse Windowsbuilder * Launch the application.
*/ */
public static void main(String[] args) { public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() { EventQueue.invokeLater(new Runnable() {
@@ -52,114 +53,69 @@ public class frame extends JFrame {
}); });
} }
//Methode zum Berechnen der Prozente + IHK-Noten
//Übergeben werden: die maximale Punktanzahl + wieviel Prozent die maximalen Punkte entsprechen
//Ausgegeben wird ein Array, was später in die Tabellenspalten geschrieben wird
public static String[][] calculateMarks (int maxPoints, int totalPercentage) { public static String[][] calculateMarks (int maxPoints, int totalPercentage) {
int pointPercentage = 0; int pointPercentage = 0;
double markIHK = 0.0; double markIHK = 0.0;
String[][] output = new String[maxPoints+1][4]; String[][] output = new String[maxPoints+1][4];
//Ausrechnen und Aufbereiten der Ergebnisse als Array für die Tabelle
for (int point=maxPoints; point>=0; point--) { for (int point=maxPoints; point>=0; point--) {
pointPercentage = (int) (((double)point/(double)maxPoints)*(double)totalPercentage); pointPercentage = (int) (((double)point/(double)maxPoints)*(double)totalPercentage);
markIHK = marksIHK[pointPercentage]; markIHK = marksIHK[pointPercentage];
if (totalPercentage == 100) { if (totalPercentage == 100) {
output[maxPoints-point][0] = String.format("%d", point); //Punkte output[maxPoints-point][0] = Integer.toString(point);
output[maxPoints-point][1] = String.format("%d %%", pointPercentage); //Prozente output[maxPoints-point][1] = Integer.toString(pointPercentage) + " %";
output[maxPoints-point][2] = String.format("%.1f", markIHK); //IHK-Note output[maxPoints-point][2] = String.format("%.1f", markIHK);
output[maxPoints-point][3] = String.format("%.0f", markIHK); //ganze Note output[maxPoints-point][3] = String.format("%.0f", markIHK);
} }
else { else {
output[maxPoints-point][0] = String.format("%d", point); //Punkte output[maxPoints-point][0] = Integer.toString(point);
output[maxPoints-point][1] = String.format("%d %%", pointPercentage); //Prozente output[maxPoints-point][1] = Integer.toString(pointPercentage) + " %";
} }
} }
return output; //Rückgabe des Arrays return output;
} }
//Methode zum Anzeigen bzw. Aktualisieren der Tabelle public void updateTable(JSpinner spMaxPoints, JSpinner spTotalPercentage) {
//Übergeben werden: Die eingegebenen Werte für die Maximale Punktezahl und für die Prozente String[][] resWiso = calculateMarks((int)spMaxPoints.getValue(), (int)spTotalPercentage.getValue());
public void updateTable(int maxPoints, int totalPercentage) { String[] columnNames = {"Punkte",
String[][] res = calculateMarks(maxPoints, totalPercentage); //Aufruf der Methode zum Berechnen und Zwischenspeicherung in res "Prozente",
String[] columnNames = {"Punkte", "Prozente", "IHK-Note", "ganze Note"}; //Spaltennamen für die Tabelle "IHK-Note",
"ganze Note"
};
table = new JTable(res, columnNames) { table = new JTable(resWiso, columnNames) {
@Override @Override
public boolean isCellEditable(int row, int column) { //Editieren der Tabelle für alle Zellen deaktivieren public boolean isCellEditable(int row, int column) {
return false; return false;
} }
}; };
table.setRowSelectionAllowed(false); //Zeilenauswahl für die Tabelle deaktivieren table.setRowSelectionAllowed(false);
scrollPane.setViewportView(table); //Anzeigen der Tabelle im ScrollPane scrollPane.setViewportView(table);
} }
//Methode zum Zusammenrechnen eines A- und B-Teils einer AP1 oder AP2
//Übergeben werden: die erreichten Punkte im A-Teil, die erreichten Punkte im B-Teil, die erreichbaren Punkte im A-Teil, die erreichbaren Punkte im B-Teil, die prozentuale Gewichtung des A-Teils, die prozentuale Gewichtung des B-Teils public String[] calculatePart(int pointsA, int pointsB, int maxPointsA, int maxPointsB, int percentageA, int percentageB, boolean mitIHK) {
public String[] calculatePart(int pointsA, int pointsB, int maxPointsA, int maxPointsB, int percentageA, int percentageB) {
//Umrechnung der übergebenen Prozente in Faktoren
double calcPercentageA = (double)percentageA/(double)100; double calcPercentageA = (double)percentageA/(double)100;
double calcPercentageB = (double)percentageB/(double)100; double calcPercentageB = (double)percentageB/(double)100;
//Berechnung der gewichteten erreichten Prozente in Teil A und B
double percentagePartA = (calcPercentageA*(double)pointsA/(double)maxPointsA)*(double)100; double percentagePartA = (calcPercentageA*(double)pointsA/(double)maxPointsA)*(double)100;
double percentagePartB = (calcPercentageB*(double)pointsB/(double)maxPointsB)*(double)100; double percentagePartB = (calcPercentageB*(double)pointsB/(double)maxPointsB)*(double)100;
//Zusammenrechnen zu einem Gesamtergebnis (max. 100%)
double totalPercentage = percentagePartA + percentagePartB; double totalPercentage = percentagePartA + percentagePartB;
//heraussuchen der entsprechenden IHK-Note aus dem Array
double markIHK = marksIHK[(int)totalPercentage]; double markIHK = marksIHK[(int)totalPercentage];
//Initialisierung eines Arrays zum zwischenspeichern der Ergebnisse
String[] res = new String[6]; String[] res = new String[6];
//Speichern der Ergebnisse im Array
res[0] = String.format("%.2f", percentagePartA); res[0] = String.format("%.2f", percentagePartA);
res[1] = String.format("%.2f", percentagePartB); res[1] = String.format("%.2f", percentagePartB);
res[2] = String.format("%.2f", totalPercentage); res[2] = String.format("%.2f", totalPercentage);
res[3] = String.format("%.0f", totalPercentage); res[3] = String.format("%.0f", totalPercentage);
res[4] = String.format("%.1f", markIHK); res[4] = String.format("%.2f", markIHK);
res[5] = String.format("%.0f", markIHK); res[5] = String.format("%.0f", markIHK);
return res; //Rückgabe der Ergebnisse als Array return res;
} }
//Methode zum Zusammenrechnen der einzelnen AP2-Teile
//Übergaben werden: Ein Array mit den Gewichtungen der einzelnen Teile, ein Array mit den erreichten Prozenten der einzelnen Teile (ungewichtet)
public int calculateTotal(int[]w, int percentage[]) {
String[] res = new String[6]; //Array zum Speichern der Ergebnisse
double[] temp = new double[w.length]; //Array für Zwischenergebnisse
int totalPercentage = 0; //Variable für das Endergebnis
// For-Schleife für alle Prüfungsteile
for (int i=0; i<w.length; i++) {
//Prozente in Faktoren umwandeln
temp[i] = (double)w[i]/(double)100;
//gewichtete erreichte Prozente des jeweiligen Teils
temp[i] = (double)temp[i]*(double)percentage[i];
//hinzurechnen des Teilergebnisses zum Gesamtergebnis
totalPercentage += temp[i];
}
return totalPercentage; //Rückgabe der gesamten erreichten Prozente
}
//Methode für das Zusammenbauen der Ausgabe für AP1
public String buildOutString (String title, String[] res, JSpinner spPartA, JSpinner spPartB) {
String out = String.format("%s \n\nAnzahl der richtig gelösten gebundenen Aufgaben %d:0,5 = %s"
+ "Erreichte Punkte bei den ungebundenen Aufgaben %d:1,6 = %s\n"
+ "Ergebnis in Punkten (max.100) \t%s \n \t\t\t%s\n"
+ "IHK-Note:%s\nganze Note:%s", title, (int)spPartA.getValue(), res[0], (int)spPartB.getValue(), res[1], res[2], res[3], res[4], res[5]);
return out;
}
/** /**
* Create the frame. * Create the frame.
*/ */
public frame() { public frame() {
setResizable(false);
//maximal Erreichbare Punkte in den einzelnen Prüfungsteilen (für eine Anpassung müssen diese nur hie geändert werden)
final int pointsAP1PartA = 20; final int pointsAP1PartA = 20;
final int pointsAP1PartB = 80; final int pointsAP1PartB = 80;
final int pointsAP2_SEPartA = 25; final int pointsAP2_SEPartA = 25;
@@ -169,10 +125,10 @@ public class frame extends JFrame {
final int pointsAP2_FusPartA = 25; final int pointsAP2_FusPartA = 25;
final int pointsAP2_FusPartB = 80; final int pointsAP2_FusPartB = 80;
// Hier folgen die GUI-Elemente welche vom Eclipse WindowBuilder generiert wurden
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 815, 529); setBounds(100, 100, 815, 529);
contentPane = new JPanel(); contentPane = new JPanel();
contentPane.setBackground(SystemColor.controlHighlight);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane); setContentPane(contentPane);
contentPane.setLayout(null); contentPane.setLayout(null);
@@ -182,72 +138,70 @@ public class frame extends JFrame {
contentPane.add(lblTotalPercentage); contentPane.add(lblTotalPercentage);
JLabel lblMaxPoints = new JLabel("Gesamtpunktzahl"); JLabel lblMaxPoints = new JLabel("Gesamtpunktzahl");
lblMaxPoints.setBounds(14, 48, 131, 20); lblMaxPoints.setBounds(25, 48, 131, 20);
contentPane.add(lblMaxPoints); contentPane.add(lblMaxPoints);
// 0 als Startwert, von 0 bis ..., Schrittweite 1 // 0 als Startwert, von 0 bis ..., Schrittweite 1
SpinnerNumberModel modelMaxPoints = new SpinnerNumberModel(0, 0, null, 1); SpinnerNumberModel modelMaxPoints = new SpinnerNumberModel(0, 0, null, 1);
JSpinner spMaxPoints = new JSpinner(modelMaxPoints); JSpinner spMaxPoints = new JSpinner(modelMaxPoints);
spMaxPoints.setBounds(14, 74, 58, 26); spMaxPoints.setBounds(65, 75, 60, 25);
contentPane.add(spMaxPoints); contentPane.add(spMaxPoints);
// 100 als Startwert, von 0 bis 100, Schrittweite 1 // 100 als Startwert, von 0 bis 100, Schrittweite 1
SpinnerNumberModel modelTotalPercentage = new SpinnerNumberModel(100, 0, 100, 10); SpinnerNumberModel modelTotalPercentage = new SpinnerNumberModel(100, 0, 100, 10);
JSpinner spTotalPercentage = new JSpinner(modelTotalPercentage); JSpinner spTotalPercentage = new JSpinner(modelTotalPercentage);
spTotalPercentage.setBounds(160, 74, 58, 26); spTotalPercentage.setBounds(160, 75, 58, 26);
contentPane.add(spTotalPercentage); contentPane.add(spTotalPercentage);
//Tabelle aktualisieren wenn Punkte geändert werden
spMaxPoints.addChangeListener(new ChangeListener() { spMaxPoints.addChangeListener(new ChangeListener() {
@Override @Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
updateTable((int)spMaxPoints.getValue(), (int)spTotalPercentage.getValue()); updateTable(spMaxPoints, spTotalPercentage);
} }
}); });
scrollPane = new JScrollPane(); scrollPane = new JScrollPane();
scrollPane.setBounds(399, 16, 379, 422); scrollPane.setBounds(399, 16, 379, 453);
scrollPane.setBorder(null);
contentPane.add(scrollPane); contentPane.add(scrollPane);
Button btnCalc = new Button("Berechnen"); Button btnCalc = new Button("Berechnen");
//Event Listener, der wenn der Button gedrückt wird, die Tabelle aktualisiert
btnCalc.addActionListener(new ActionListener() { btnCalc.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
updateTable((int)spMaxPoints.getValue(), (int)spTotalPercentage.getValue()); updateTable(spMaxPoints, spTotalPercentage);
} }
}); });
btnCalc.setBounds(272, 73, 91, 27); btnCalc.setBounds(270, 73, 91, 27);
contentPane.add(btnCalc); contentPane.add(btnCalc);
JLabel lblTest = new JLabel("Test"); JLabel lblTest = new JLabel("Test");
lblTest.setFont(new Font("Tahoma", Font.BOLD, 18)); lblTest.setFont(new Font("Tahoma", Font.BOLD, 18));
lblTest.setBounds(15, 12, 69, 20); lblTest.setBounds(15, 15, 69, 20);
contentPane.add(lblTest); contentPane.add(lblTest);
JLabel lblAP1 = new JLabel("AP1"); JLabel lblAP1 = new JLabel("AP1");
lblAP1.setFont(new Font("Tahoma", Font.BOLD, 18)); lblAP1.setFont(new Font("Tahoma", Font.BOLD, 18));
lblAP1.setBounds(14, 132, 69, 20); lblAP1.setBounds(15, 135, 69, 20);
contentPane.add(lblAP1); contentPane.add(lblAP1);
// 0 als Startwert, von 0 bis 20, Schrittweite 1 // 0 als Startwert, von 0 bis 20, Schrittweite 1
SpinnerNumberModel modelAP1_PartA = new SpinnerNumberModel(0, 0, pointsAP1PartA, 1); SpinnerNumberModel modelAP1_PartA = new SpinnerNumberModel(0, 0, pointsAP1PartA, 1);
JSpinner spAP1_PartA = new JSpinner(modelAP1_PartA); JSpinner spAP1_PartA = new JSpinner(modelAP1_PartA);
spAP1_PartA.setBounds(14, 183, 58, 26); spAP1_PartA.setBounds(65, 180, 58, 26);
contentPane.add(spAP1_PartA); contentPane.add(spAP1_PartA);
// 0 als Startwert, von 0 bis ..., Schrittweite 1 // 0 als Startwert, von 0 bis ..., Schrittweite 1
SpinnerNumberModel modelAP1_PartB = new SpinnerNumberModel(0, 0, pointsAP1PartB, 1); SpinnerNumberModel modelAP1_PartB = new SpinnerNumberModel(0, 0, pointsAP1PartB, 1);
JSpinner spAP1_PartB = new JSpinner(modelAP1_PartB); JSpinner spAP1_PartB = new JSpinner(modelAP1_PartB);
spAP1_PartB.setBounds(160, 183, 58, 26); spAP1_PartB.setBounds(160, 180, 58, 26);
contentPane.add(spAP1_PartB); contentPane.add(spAP1_PartB);
JLabel lblAP1_PartA = new JLabel("Teil A"); JLabel lblAP1_PartA = new JLabel("Teil A");
lblAP1_PartA.setBounds(14, 157, 131, 20); lblAP1_PartA.setBounds(65, 157, 131, 20);
contentPane.add(lblAP1_PartA); contentPane.add(lblAP1_PartA);
JLabel lblAP1_PartB = new JLabel("Teil B"); JLabel lblAP1_PartB = new JLabel("Teil B");
@@ -260,7 +214,7 @@ public class frame extends JFrame {
contentPane.add(lblAP2); contentPane.add(lblAP2);
JLabel lblAP2_SE_PartA = new JLabel("Teil A"); JLabel lblAP2_SE_PartA = new JLabel("Teil A");
lblAP2_SE_PartA.setBounds(40, 247, 131, 20); lblAP2_SE_PartA.setBounds(65, 245, 131, 20);
contentPane.add(lblAP2_SE_PartA); contentPane.add(lblAP2_SE_PartA);
JLabel lblAP2_SE_PartB = new JLabel("Teil B"); JLabel lblAP2_SE_PartB = new JLabel("Teil B");
@@ -270,34 +224,34 @@ public class frame extends JFrame {
// 0 als Startwert, von 0 bis 20, Schrittweite 1 // 0 als Startwert, von 0 bis 20, Schrittweite 1
SpinnerNumberModel modelAP2_SE_PartA = new SpinnerNumberModel(0, 0, pointsAP2_SEPartA, 1); SpinnerNumberModel modelAP2_SE_PartA = new SpinnerNumberModel(0, 0, pointsAP2_SEPartA, 1);
JSpinner spAP2_SE_PartA = new JSpinner(modelAP2_SE_PartA); JSpinner spAP2_SE_PartA = new JSpinner(modelAP2_SE_PartA);
spAP2_SE_PartA.setBounds(40, 273, 58, 26); spAP2_SE_PartA.setBounds(65, 270, 58, 26);
contentPane.add(spAP2_SE_PartA); contentPane.add(spAP2_SE_PartA);
// 0 als Startwert, von 0 bis 20, Schrittweite 1 // 0 als Startwert, von 0 bis 20, Schrittweite 1
SpinnerNumberModel modelAP2_SE_PartB = new SpinnerNumberModel(0, 0, pointsAP2_SEPartB, 1); SpinnerNumberModel modelAP2_SE_PartB = new SpinnerNumberModel(0, 0, pointsAP2_SEPartB, 1);
JSpinner spAP2_SE_PartB = new JSpinner(modelAP2_SE_PartB); JSpinner spAP2_SE_PartB = new JSpinner(modelAP2_SE_PartB);
spAP2_SE_PartB.setBounds(160, 271, 58, 26); spAP2_SE_PartB.setBounds(160, 270, 58, 26);
contentPane.add(spAP2_SE_PartB); contentPane.add(spAP2_SE_PartB);
JLabel lblAP2_SE = new JLabel("SE"); JLabel lblAP2_SE = new JLabel("SE");
lblAP2_SE.setFont(new Font("Tahoma", Font.BOLD, 15)); lblAP2_SE.setFont(new Font("Tahoma", Font.BOLD, 15));
lblAP2_SE.setBounds(14, 277, 69, 20); lblAP2_SE.setBounds(15, 270, 69, 26);
contentPane.add(lblAP2_SE); contentPane.add(lblAP2_SE);
JLabel lblAP2_Fus = new JLabel("Fus"); JLabel lblAP2_Fus = new JLabel("Fus");
lblAP2_Fus.setFont(new Font("Tahoma", Font.BOLD, 15)); lblAP2_Fus.setFont(new Font("Tahoma", Font.BOLD, 15));
lblAP2_Fus.setBounds(14, 347, 69, 20); lblAP2_Fus.setBounds(15, 340, 69, 25);
contentPane.add(lblAP2_Fus); contentPane.add(lblAP2_Fus);
JLabel lblAP2_Fus_PartA = new JLabel("Teil A"); JLabel lblAP2_Fus_PartA = new JLabel("Teil A");
lblAP2_Fus_PartA.setBounds(40, 317, 131, 20); lblAP2_Fus_PartA.setBounds(65, 317, 131, 20);
contentPane.add(lblAP2_Fus_PartA); contentPane.add(lblAP2_Fus_PartA);
// 0 als Startwert, von 0 bis 20, Schrittweite 1 // 0 als Startwert, von 0 bis 20, Schrittweite 1
SpinnerNumberModel modelAP2_Fus_PartA = new SpinnerNumberModel(0, 0, pointsAP2_FusPartA, 1); SpinnerNumberModel modelAP2_Fus_PartA = new SpinnerNumberModel(0, 0, pointsAP2_FusPartA, 1);
JSpinner spAP2_Fus_PartA = new JSpinner(modelAP2_Fus_PartA); JSpinner spAP2_Fus_PartA = new JSpinner(modelAP2_Fus_PartA);
spAP2_Fus_PartA.setBounds(40, 343, 58, 26); spAP2_Fus_PartA.setBounds(65, 340, 58, 26);
contentPane.add(spAP2_Fus_PartA); contentPane.add(spAP2_Fus_PartA);
JLabel lblAP2_Fus_PartB = new JLabel("Teil B"); JLabel lblAP2_Fus_PartB = new JLabel("Teil B");
@@ -307,23 +261,23 @@ public class frame extends JFrame {
// 0 als Startwert, von 0 bis 20, Schrittweite 1 // 0 als Startwert, von 0 bis 20, Schrittweite 1
SpinnerNumberModel modelAP2_Fus_PartB = new SpinnerNumberModel(0, 0, pointsAP2_FusPartB, 1); SpinnerNumberModel modelAP2_Fus_PartB = new SpinnerNumberModel(0, 0, pointsAP2_FusPartB, 1);
JSpinner spAP2_Fus_PartB = new JSpinner(modelAP2_Fus_PartB); JSpinner spAP2_Fus_PartB = new JSpinner(modelAP2_Fus_PartB);
spAP2_Fus_PartB.setBounds(160, 341, 58, 26); spAP2_Fus_PartB.setBounds(160, 340, 58, 26);
contentPane.add(spAP2_Fus_PartB); contentPane.add(spAP2_Fus_PartB);
JLabel lblAP2_Wiso = new JLabel("Wiso"); JLabel lblAP2_Wiso = new JLabel("Wiso");
lblAP2_Wiso.setFont(new Font("Tahoma", Font.BOLD, 15)); lblAP2_Wiso.setFont(new Font("Tahoma", Font.BOLD, 15));
lblAP2_Wiso.setBounds(3, 418, 69, 20); lblAP2_Wiso.setBounds(15, 410, 69, 28);
contentPane.add(lblAP2_Wiso); contentPane.add(lblAP2_Wiso);
JLabel lblAP2_Wiso_PartA = new JLabel("Teil A"); JLabel lblAP2_Wiso_PartA = new JLabel("Teil A");
lblAP2_Wiso_PartA.setBounds(40, 389, 131, 20); lblAP2_Wiso_PartA.setBounds(65, 389, 131, 20);
contentPane.add(lblAP2_Wiso_PartA); contentPane.add(lblAP2_Wiso_PartA);
// 0 als Startwert, von 0 bis 20, Schrittweite 1 // 0 als Startwert, von 0 bis 20, Schrittweite 1
SpinnerNumberModel modelAP2_Wiso_PartA = new SpinnerNumberModel(0, 0, pointsAP2_WisoPartA, 1); SpinnerNumberModel modelAP2_Wiso_PartA = new SpinnerNumberModel(0, 0, pointsAP2_WisoPartA, 1);
JSpinner spAP2_Wiso_PartA = new JSpinner(modelAP2_Wiso_PartA); JSpinner spAP2_Wiso_PartA = new JSpinner(modelAP2_Wiso_PartA);
spAP2_Wiso_PartA.setBounds(40, 415, 58, 26); spAP2_Wiso_PartA.setBounds(65, 410, 58, 26);
contentPane.add(spAP2_Wiso_PartA); contentPane.add(spAP2_Wiso_PartA);
JLabel lblAP2_Wiso_PartB = new JLabel("Teil B"); JLabel lblAP2_Wiso_PartB = new JLabel("Teil B");
@@ -334,36 +288,34 @@ public class frame extends JFrame {
// 0 als Startwert, von 0 bis 20, Schrittweite 1 // 0 als Startwert, von 0 bis 20, Schrittweite 1
SpinnerNumberModel modelAP2_Wiso_PartB = new SpinnerNumberModel(0, 0, pointsAP2_WisoPartB, 1); SpinnerNumberModel modelAP2_Wiso_PartB = new SpinnerNumberModel(0, 0, pointsAP2_WisoPartB, 1);
JSpinner spAP2_Wiso_PartB = new JSpinner(modelAP2_Wiso_PartB); JSpinner spAP2_Wiso_PartB = new JSpinner(modelAP2_Wiso_PartB);
spAP2_Wiso_PartB.setBounds(160, 413, 58, 26); spAP2_Wiso_PartB.setBounds(160, 410, 58, 26);
contentPane.add(spAP2_Wiso_PartB); contentPane.add(spAP2_Wiso_PartB);
Button btnCalcAP1 = new Button("Berechnen"); Button btnCalcAP1 = new Button("Berechnen");
//Event Listener, der wenn der Button gedrückt wird, die Ergebnisse ausgibt
btnCalcAP1.addActionListener(new ActionListener() { btnCalcAP1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
String[] resWiso = calculatePart((int)spAP1_PartA.getValue(), (int)spAP1_PartB.getValue(), pointsAP1PartA, pointsAP1PartB, 50, 50); String[] resWiso = calculatePart((int)spAP1_PartA.getValue(), (int)spAP1_PartB.getValue(), pointsAP1PartA, pointsAP1PartB, 50, 50, true);
JTextPane txtpnGesamt = new JTextPane(); JTextPane txtpnGesamt = new JTextPane();
txtpnGesamt.setText(buildOutString("AP1", resWiso, spAP1_PartA, spAP1_PartB)); txtpnGesamt.setText("AP1 \n\nAnzahl der richtig gelösten gebundenen Aufgaben " + spAP1_PartA.getValue() + ": 0,5 = " + resWiso[0] + "\n"
+ "Erreichte Punkte bei den ungebundenen Aufgaben " + spAP1_PartB.getValue() + ": 1,6 =" + resWiso[1] + "\n"
+ "Ergebnis in Punkten (max.100) \t" + resWiso[2] + "\n \t\t\t" + resWiso[3] + "\n"
+ "IHK-Note:" + resWiso[4] + "\nganze Note:" + resWiso[5]);
txtpnGesamt.setEditable(false); txtpnGesamt.setEditable(false);
txtpnGesamt.setBackground(getBackground()); txtpnGesamt.setBackground(getBackground());
scrollPane.setViewportView(txtpnGesamt); scrollPane.setViewportView(txtpnGesamt);
} }
}); });
btnCalcAP1.setBounds(272, 183, 91, 27); btnCalcAP1.setBounds(270, 183, 91, 27);
contentPane.add(btnCalcAP1); contentPane.add(btnCalcAP1);
Button btnCalcAP2 = new Button("Berechnen"); Button btnCalcAP2 = new Button("Berechnen");
//Event Listener, der wenn der Button gedrückt wird, die Ergebnisse ausgibt
btnCalcAP2.addActionListener(new ActionListener() { btnCalcAP2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
String[] resSE = calculatePart((int)spAP2_SE_PartA.getValue(), (int)spAP2_SE_PartB.getValue(), pointsAP2_SEPartA, pointsAP2_SEPartB, 50, 50); String[] resSE = calculatePart((int)spAP2_SE_PartA.getValue(), (int)spAP2_SE_PartB.getValue(), pointsAP2_SEPartA, pointsAP2_SEPartB, 50, 50, false);
String[] resFus = calculatePart((int)spAP2_Fus_PartA.getValue(), (int)spAP2_Fus_PartB.getValue(), pointsAP2_FusPartA, pointsAP2_FusPartB, 50, 50); String[] resFus = calculatePart((int)spAP2_Fus_PartA.getValue(), (int)spAP2_Fus_PartB.getValue(), pointsAP2_FusPartA, pointsAP2_FusPartB, 50, 50, false);
String[] resWiso = calculatePart((int)spAP2_Wiso_PartA.getValue(), (int)spAP2_Wiso_PartB.getValue(), pointsAP2_WisoPartA, pointsAP2_WisoPartB, 40, 60); String[] resWiso = calculatePart((int)spAP2_Wiso_PartA.getValue(), (int)spAP2_Wiso_PartB.getValue(), pointsAP2_WisoPartA, pointsAP2_WisoPartB, 40, 60, false);
int[] partsPercentage = {40, 40, 20}; String textSE = "AP2\n\nSystementwurf\n=============\n"
int[] resParts = {Integer.valueOf(resSE[3]), Integer.valueOf(resFus[3]), Integer.valueOf(resWiso[3])};
int totalPercentage = calculateTotal(partsPercentage, resParts);
String textSE = "Systementwurf\n=============\n"
+ "Anzahl der richtig gelösten gebundenen Aufgaben " + spAP2_SE_PartA.getValue() + ": 0,5 = " + resSE[0] + "\n" + "Anzahl der richtig gelösten gebundenen Aufgaben " + spAP2_SE_PartA.getValue() + ": 0,5 = " + resSE[0] + "\n"
+ "Erreichte Punkte bei den ungebundenen Aufgaben " + spAP2_SE_PartB.getValue() + ": 1,6 =" + resSE[1] + "\n" + "Erreichte Punkte bei den ungebundenen Aufgaben " + spAP2_SE_PartB.getValue() + ": 1,6 =" + resSE[1] + "\n"
+ "Ergebnis in Punkten (max.100) \t" + resSE[2] + "\n \t\t\t" + resSE[3] + "\n" + "Ergebnis in Punkten (max.100) \t" + resSE[2] + "\n \t\t\t" + resSE[3] + "\n"
@@ -378,8 +330,7 @@ public class frame extends JFrame {
+ "Erreichte Punkte bei den ungebundenen Aufgaben " + spAP2_Wiso_PartB.getValue() + "* 1,2 =" + resWiso[1] + "\n" + "Erreichte Punkte bei den ungebundenen Aufgaben " + spAP2_Wiso_PartB.getValue() + "* 1,2 =" + resWiso[1] + "\n"
+ "Ergebnis in Punkten (max.100) \t" + resWiso[2] + "\n \t\t\t" + resWiso[3] + "\n" + "Ergebnis in Punkten (max.100) \t" + resWiso[2] + "\n \t\t\t" + resWiso[3] + "\n"
+ "IHK-Note:" + resWiso[4] + "\nganze Note:" + resWiso[5]; + "IHK-Note:" + resWiso[4] + "\nganze Note:" + resWiso[5];
String textGes = String.format("Gesamtergebnis\n=============\n%d%%\nIHK-Note: %.1f", totalPercentage, marksIHK[totalPercentage]); String output = textSE + "\n\n" + textFus + "\n\n" + textWiso + "\n";
String output = "AP2\n\n" + textGes + "\n\n" + textSE + "\n\n" + textFus + "\n\n" + textWiso + "\n";
JTextPane txtpnGesamt = new JTextPane(); JTextPane txtpnGesamt = new JTextPane();
txtpnGesamt.setText(output); txtpnGesamt.setText(output);
txtpnGesamt.setEditable(false); txtpnGesamt.setEditable(false);
@@ -387,8 +338,13 @@ public class frame extends JFrame {
scrollPane.setViewportView(txtpnGesamt); scrollPane.setViewportView(txtpnGesamt);
} }
}); });
btnCalcAP2.setBounds(272, 325, 91, 27); btnCalcAP2.setBounds(270, 340, 91, 27);
contentPane.add(btnCalcAP2); contentPane.add(btnCalcAP2);
JPanel panel = new JPanel();
panel.setBackground(SystemColor.control);
panel.setBounds(0, 0, 379, 482);
contentPane.add(panel);
} }
} }