Browse Source

Windows Probleme beim Erstellen von einer File, deshalb schlaegt Test fehl.

remotes/origin/develop
fdai6040 2 years ago
parent
commit
70b86284a4
  1. 63
      src/main/java/src/TasksFrame.java

63
src/main/java/src/TasksFrame.java

@ -6,6 +6,7 @@ import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.LinkedList;
public class TasksFrame extends JFrame {
@ -72,6 +73,68 @@ public class TasksFrame extends JFrame {
setupLeibnizR(1000);
setupEulerschePhiFunk();
}
private void setupEulerschePhiFunk() {
JPanel jPanel = setupPanel("Eulersche Phi Funktion");
Button button = new Button("Calc Phi");
button.setVisible(true);
button.setBounds(120, 50, 100, 30);
JTextField jTextField = new JTextField();
jTextField.setVisible(true);
jTextField.setBounds( 10, 40, 60, 20);
JLabel jLabel = new JLabel();
jLabel.setVisible(true);
jLabel.setBounds(10, 90, 60, 30);
jPanel.add(button);
jPanel.add(jTextField);
jPanel.add(jLabel);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int r = ePhi(Integer.valueOf(jTextField.getText()));
jLabel.setText(String.valueOf(r));
}
});
}
private int ePhi(Integer n) {
LinkedList<Object> menge = new LinkedList<>();
for(int k =1; k<=n; k++){
if(ggt(k, n)== 1){
menge.add(k);
}
}
return menge.size();
}
private int ggt(int a, int b) {
int h;
if (a == 0) return 0;
if (b == 0) return 0;
do {
h = a % b;
a = b;
b = h;
} while (b != 0);
return a;
}
private void setupHelloWorld() {

Loading…
Cancel
Save