Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package oef3_alternatief;
- import java.net.URL;
- import java.util.ResourceBundle;
- import javafx.fxml.FXML;
- import javafx.fxml.Initializable;
- import javafx.scene.control.Button;
- import javafx.scene.control.TextArea;
- import javafx.scene.control.TextField;
- import javafx.scene.input.MouseEvent;
- /**
- * FXML Controller class
- *
- * @author Amadeo
- */
- public class FXML3_extraController implements Initializable {
- @FXML
- private TextField txtAantal;
- @FXML
- private Button btnInvoer;
- @FXML
- private TextArea txtResultaat;
- /**
- * Initializes the controller class.
- */
- @Override
- public void initialize(URL url, ResourceBundle rb) {
- // TODO
- }
- @FXML
- private void clicked_invoer(MouseEvent event) {
- //opvragen ingegven getallen
- String sGetallen = txtAantal.getText();
- int iGrootste =0;
- //huidig getal uit reeks getallen
- int iGetal;
- int iAantalGetallen=1;
- int iKomma =0;
- //aantal komma's in sGetallen
- //vb. 1,2,3,4
- for (int i = 0; i < sGetallen.length(); i++) {
- // is huidige positie in sGetallen een komma?
- if(sGetallen.charAt(i) == ',')
- {
- iAantalGetallen++;
- }
- }
- for (int i = 0; i < iAantalGetallen; i++) {
- //1,2,3,4
- if(sGetallen.contains(","))
- {
- //positie komma
- iKomma = sGetallen.indexOf(",");
- //ikomma = 1
- iGetal = Integer.parseInt(sGetallen.substring(0,iKomma));
- //overschrijven van sGetallen zodat het gedeelte na de komma nog overblijft
- //ikomma + 1 want anders wordt sGetallen: ,2,3,4
- sGetallen = sGetallen.substring(iKomma+1);
- }
- else
- {
- iKomma = 0;
- iGetal = Integer.parseInt(sGetallen);
- }
- if(iGetal>=iGrootste)
- {
- iGrootste = iGetal;
- }
- }
- txtResultaat.setText("Grootste getal: " + String.valueOf(iGrootste));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement