Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Main
- public class Main {
- public static void main(String[] args){
- new Beete();
- }
- }
- //Class Beete
- import javax.swing.*;
- import java.util.ArrayList;
- import java.util.Random;
- public class Beete {
- private static final int BLAU = 0;
- private static final int GELB = 1;
- private static final int GRUN = 2;
- private static final int ROT = 3;
- private static final int ORANGE = 4;
- private static final int ROSA = 5;
- private static final int TURKIS = 6;
- private int beet[][];
- private int anzahlblumen;
- private int wunsche;
- private ArrayList<Integer> combis = new ArrayList();
- private ArrayList<Integer> blumen = new ArrayList();
- public Beete(){
- anzahlblumen = Integer.parseInt(JOptionPane.showInputDialog(null,"Wie viele Blumen", "Eingaben", JOptionPane.PLAIN_MESSAGE));
- wunsche = Integer.parseInt(JOptionPane.showInputDialog(null,"Wie viele Wünsche ?", "Eingaben", JOptionPane.PLAIN_MESSAGE));
- //Platzhalten um durch 3 teilen zu können
- combis.add(9);
- for (int i = 0; i < wunsche; i++){
- JTextField f1 = new JTextField();
- JTextField blume1 = new JTextField();
- JTextField blume2 = new JTextField();
- JTextField punkte = new JTextField();
- f1.setText("Blau="+BLAU+ " Gelb="+GELB+" Grun="+GRUN+" ROT="+ROT+ " Orange="+ORANGE+" Rosa="+ROSA+ " Turkis="+TURKIS);
- Object[] message = {"info", f1, "blume1", blume1, "blume2", blume2, "punkte", punkte};
- JOptionPane pane = new JOptionPane( message,
- JOptionPane.PLAIN_MESSAGE,
- JOptionPane.OK_CANCEL_OPTION);
- pane.createDialog(null, "Combis").setVisible(true);
- combis.add(Integer.valueOf(blume1.getText()));
- combis.add(Integer.valueOf(blume2.getText()));
- combis.add(Integer.valueOf(punkte.getText()));
- }
- System.out.println("Eingelesen:");
- System.out.println(anzahlblumen+" vercchiedene Blumen: ");
- System.out.println(wunsche+" Wünsche, nämlich");
- for (int i = 1; i < combis.size(); i++){
- if ((i%3)==0){
- System.out.println("gibt "+combis.get(i)+" Punkte");
- } else {
- System.out.println("Blume " + combis.get(i));
- }
- }
- if (anzahlblumen <= 7){
- while (blumen.size() < anzahlblumen){
- for (int i = 1; i < combis.size(); i++){
- if (((i%3)==0)&&(combis.get(i)==3)){
- if (!blumen.contains(combis.get(i-1))) {
- blumen.add(combis.get(i - 1));
- }
- if (!blumen.contains(combis.get(i-2))) {
- blumen.add(combis.get(i - 2));
- }
- }
- }
- for (int i = 1; i < combis.size(); i++){
- if (((i%3)==0)&&(combis.get(i)==2)){
- if (!blumen.contains(combis.get(i-1))) {
- blumen.add(combis.get(i - 1));
- }
- if (!blumen.contains(combis.get(i-2))) {
- blumen.add(combis.get(i - 2));
- }
- }
- }
- for (int i = 1; i < combis.size(); i++) {
- if (((i % 3) == 0) && (combis.get(i) == 1)) {
- if (!blumen.contains(combis.get(i-1))) {
- blumen.add(combis.get(i - 1));
- }
- if (!blumen.contains(combis.get(i-2))) {
- blumen.add(combis.get(i - 2));
- }
- }
- }
- int randint = new Random().nextInt(7);
- if (!blumen.contains(randint)){
- blumen.add(randint);
- }
- }
- }
- System.out.println("Es wurden folgende Blumenfarben ausgewählt:");
- for (int i = 0; i < blumen.size(); i++){
- System.out.println(blumen.get(i)+" ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement