Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Rechner {
- public static void main(String[] args) {
- int tabelle[][] = new int [4][15];
- int gesamtproduktionMet=0, gesamtproduktionKris=0, gesamtproduktionDeut=0, maximaltemperatur, stundenPunkte, tagesPunkte;
- System.out.println("Anzahl der Planeten eingeben: ");
- Scanner eingabe = new Scanner(System.in); // Eingabe wird in Scanner eingelesen
- String anzahl = eingabe.nextLine(); // Scanner übergibt Eingabe an String
- int planetenanzahl = Integer.parseInt(anzahl); // String wird in Integervariable umgewandelt
- System.out.println("Spielgeschwindigkeit eingeben: ");
- String spielgeschwindigkeit = eingabe.nextLine(); // Scanner übergibt Eingabe an String
- int geschwindigkeit = Integer.parseInt(spielgeschwindigkeit); // String wird in Integervariable umgewandelt
- int n = 0;
- for(int i=0; i < planetenanzahl; i++){ // Schleife fragt für alle Planeten Minen und
- // Temperatur ab und schreibt sie ins Array
- System.out.println("Planet " + (i+1) + ":");
- System.out.println("Metallmine:");
- String umstaendlich = eingabe.nextLine(); // Scanner übergibt Eingabe an String
- tabelle[0][n] = Integer.parseInt(umstaendlich); // String wird in Integervariable umgewandelt
- System.out.println("Kristallmine:");
- String umstaendlicher = eingabe.nextLine(); // Scanner übergibt Eingabe an String
- tabelle[1][n] = Integer.parseInt(umstaendlicher); // String wird in Integervariable umgewandelt
- System.out.println("Deuteriumsynthetisierer:");
- String amUmstaendlichsten = eingabe.nextLine(); // Bla bla bla
- tabelle[2][n] = Integer.parseInt(amUmstaendlichsten); // Bla bla bla
- System.out.println("Temperatur:");
- String nochVieeelUmstaendlicher = eingabe.nextLine(); // Bla bla bla
- tabelle[3][n] = Integer.parseInt(nochVieeelUmstaendlicher); // Bla bla bla
- n++;
- }
- for(int i=n; i != 0; i--){ // Entnimmt die Minenstufen aus dem Array, legt Objekte für bis zu 15 Planeten an, fragt die Produktionsmengen der Objekte ab und übergibt diese an die Gesamtproduktion.
- if(n==1) {
- Planet planet01;
- planet01 = new Planet(n, tabelle[0][n-1], tabelle[1][n-1], tabelle[2][n-1], tabelle[3][n-1]);
- gesamtproduktionMet = gesamtproduktionMet + planet01.produktionMet();
- gesamtproduktionKris = gesamtproduktionKris + planet01.produktionKris();
- gesamtproduktionDeut = gesamtproduktionDeut + planet01.produktionDeut();
- }
- else if(n==2) {
- Planet planet02;
- planet02 = new Planet(n, tabelle[0][n-1], tabelle[1][n-1], tabelle[2][n-1], tabelle[3][n-1]);
- gesamtproduktionMet = gesamtproduktionMet + planet02.produktionMet();
- gesamtproduktionKris = gesamtproduktionKris + planet02.produktionKris();
- gesamtproduktionDeut = gesamtproduktionDeut + planet02.produktionDeut();
- }
- else if(n==3) {
- Planet planet03;
- planet03 = new Planet(n, tabelle[0][n-1], tabelle[1][n-1], tabelle[2][n-1], tabelle[3][n-1]);
- gesamtproduktionMet = gesamtproduktionMet + planet03.produktionMet();
- gesamtproduktionKris = gesamtproduktionKris + planet03.produktionKris();
- gesamtproduktionDeut = gesamtproduktionDeut + planet03.produktionDeut();
- }
- else if(n==4) {
- Planet planet04;
- planet04 = new Planet(n, tabelle[0][n-1], tabelle[1][n-1], tabelle[2][n-1], tabelle[3][n-1]);
- gesamtproduktionMet = gesamtproduktionMet + planet04.produktionMet();
- gesamtproduktionKris = gesamtproduktionKris + planet04.produktionKris();
- gesamtproduktionDeut = gesamtproduktionDeut + planet04.produktionDeut();
- }
- else if(n==5) {
- Planet planet05;
- planet05 = new Planet(n, tabelle[0][n-1], tabelle[1][n-1], tabelle[2][n-1], tabelle[3][n-1]);
- gesamtproduktionMet = gesamtproduktionMet + planet05.produktionMet();
- gesamtproduktionKris = gesamtproduktionKris + planet05.produktionKris();
- gesamtproduktionDeut = gesamtproduktionDeut + planet05.produktionDeut();
- }
- else if(n==6) {
- Planet planet06;
- planet06 = new Planet(n, tabelle[0][n-1], tabelle[1][n-1], tabelle[2][n-1], tabelle[3][n-1]);
- gesamtproduktionMet = gesamtproduktionMet + planet06.produktionMet();
- gesamtproduktionKris = gesamtproduktionKris + planet06.produktionKris();
- gesamtproduktionDeut = gesamtproduktionDeut + planet06.produktionDeut();
- }
- else if(n==7) {
- Planet planet07;
- planet07 = new Planet(n, tabelle[0][n-1], tabelle[1][n-1], tabelle[2][n-1], tabelle[3][n-1]);
- gesamtproduktionMet = gesamtproduktionMet + planet07.produktionMet();
- gesamtproduktionKris = gesamtproduktionKris + planet07.produktionKris();
- gesamtproduktionDeut = gesamtproduktionDeut + planet07.produktionDeut();
- }
- else if(n==8) {
- Planet planet08;
- planet08 = new Planet(n, tabelle[0][n-1], tabelle[1][n-1], tabelle[2][n-1], tabelle[3][n-1]);
- gesamtproduktionMet = gesamtproduktionMet + planet08.produktionMet();
- gesamtproduktionKris = gesamtproduktionKris + planet08.produktionKris();
- gesamtproduktionDeut = gesamtproduktionDeut + planet08.produktionDeut();
- }
- else if(n==9) {
- Planet planet09;
- planet09 = new Planet(n, tabelle[0][n-1], tabelle[1][n-1], tabelle[2][n-1], tabelle[3][n-1]);
- gesamtproduktionMet = gesamtproduktionMet + planet09.produktionMet();
- gesamtproduktionKris = gesamtproduktionKris + planet09.produktionKris();
- gesamtproduktionDeut = gesamtproduktionDeut + planet09.produktionDeut();
- }
- else if(n==10) {
- Planet planet10;
- planet10 = new Planet(n, tabelle[0][n-1], tabelle[1][n-1], tabelle[2][n-1], tabelle[3][n-1]);
- gesamtproduktionMet = gesamtproduktionMet + planet10.produktionMet();
- gesamtproduktionKris = gesamtproduktionKris + planet10.produktionKris();
- gesamtproduktionDeut = gesamtproduktionDeut + planet10.produktionDeut();
- }
- else if(n==11) {
- Planet planet11;
- planet11 = new Planet(n, tabelle[0][n-1], tabelle[1][n-1], tabelle[2][n-1], tabelle[3][n-1]);
- gesamtproduktionMet = gesamtproduktionMet + planet11.produktionMet();
- gesamtproduktionKris = gesamtproduktionKris + planet11.produktionKris();
- gesamtproduktionDeut = gesamtproduktionDeut + planet11.produktionDeut();
- }
- else if(n==12) {
- Planet planet12;
- planet12 = new Planet(n, tabelle[0][n-1], tabelle[1][n-1], tabelle[2][n-1], tabelle[3][n-1]);
- gesamtproduktionMet = gesamtproduktionMet + planet12.produktionMet();
- gesamtproduktionKris = gesamtproduktionKris + planet12.produktionKris();
- gesamtproduktionDeut = gesamtproduktionDeut + planet12.produktionDeut();
- }
- else if(n==13) {
- Planet planet13;
- planet13 = new Planet(n, tabelle[0][n-1], tabelle[1][n-1], tabelle[2][n-1], tabelle[3][n-1]);
- gesamtproduktionMet = gesamtproduktionMet + planet13.produktionMet();
- gesamtproduktionKris = gesamtproduktionKris + planet13.produktionKris();
- gesamtproduktionDeut = gesamtproduktionDeut + planet13.produktionDeut();
- }
- else if(n==14) {
- Planet planet14;
- planet14 = new Planet(n, tabelle[0][n-1], tabelle[1][n-1], tabelle[2][n-1], tabelle[3][n-1]);
- gesamtproduktionMet = gesamtproduktionMet + planet14.produktionMet();
- gesamtproduktionKris = gesamtproduktionKris + planet14.produktionKris();
- gesamtproduktionDeut = gesamtproduktionDeut + planet14.produktionDeut();
- }
- else if(n==15) {
- Planet planet15;
- planet15 = new Planet(n, tabelle[0][n-1], tabelle[1][n-1], tabelle[2][n-1], tabelle[3][n-1]);
- gesamtproduktionMet = gesamtproduktionMet + planet15.produktionMet();
- gesamtproduktionKris = gesamtproduktionKris + planet15.produktionKris();
- gesamtproduktionDeut = gesamtproduktionDeut + planet15.produktionDeut();
- }
- n--;
- }
- stundenPunkte = ((gesamtproduktionMet + gesamtproduktionKris + gesamtproduktionDeut)*geschwindigkeit);
- tagesPunkte = stundenPunkte * 24;
- System.out.println("Die Gesamtproduktion pro Stunde beträgt: " + (gesamtproduktionMet)*geschwindigkeit + " Metall, " + (gesamtproduktionKris)*geschwindigkeit + " Kristall und " + (gesamtproduktionDeut)*geschwindigkeit + " Deuterium.");
- System.out.println("Entspricht "+ (stundenPunkte / 1000) + " Punkten.");
- System.out.println("Die Gesamtproduktion pro Tag beträgt: " + (((gesamtproduktionMet)*geschwindigkeit) * 24) + " Metall, " + ((gesamtproduktionKris)*geschwindigkeit) * 24 + " Kristall und " + ((gesamtproduktionDeut)*geschwindigkeit) * 24 + " Deuterium.");
- System.out.println("Entspricht "+ (tagesPunkte / 1000) + " Punkten.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement