(Anfänger) problem Programm lässt sich nicht öffnen!

Status
Nicht offen für weitere Antworten.

Sh_adow

Mitglied
hi,
ich bin ziemlich neu in java und hab für nen freund ein programm für sein rpg entwickelt:
Code:
package pk1;
import javax.swing.*;

public class Sr2 {

  // Anfang Attribute
  // Ende Attribute




  // Anfang Methoden
  public static void main(String[] args, float V1, float V2, float V3, float V4, float V5 )
  {

	String Formel = JOptionPane.showInputDialog
 	("Art des Angriffs");
	if (Formel.equals("Abwehr"));
	String Angriff = JOptionPane.showInputDialog
	("Angriff");
	String Abwehr = JOptionPane.showInputDialog
	("Abwehr");
	String Stärke = JOptionPane.showInputDialog
	("Stärke");
	String Level = JOptionPane.showInputDialog
	("Level");
	float Zufall = (float) (Math.random()+1);

	float Att = Float.parseFloat(Angriff);
	float Abw = Float.parseFloat(Abwehr);
	float Str = Float.parseFloat(Stärke);
	float Lvl = Float.parseFloat(Level);

	V1 = (Att * Zufall - Abw);
	V2 = (1 + Str);
	V3 = (Lvl + Str / 256);
	V4 = (V2 * V3);
	V5 = (V4 * V1);

	JOptionPane.showMessageDialog
	(null, "Der Schaden beträgt" + V5);

 	if (Formel.equals("Agilität"));
	String Angriff1 = JOptionPane.showInputDialog
	("Angriff");
	String Abwehr1 = JOptionPane.showInputDialog
	("Abwehr");
	String Stärke1 = JOptionPane.showInputDialog
	("Stärke");
	String Level1 = JOptionPane.showInputDialog
	("Level");
	String Agilität = JOptionPane.showInputDialog
	("Agilität");
	float Zufall1 = (float) (Math.random()+1);

	float Att1 = Float.parseFloat(Angriff1);
	float Abw1 = Float.parseFloat(Abwehr1);
	float Str1 = Float.parseFloat(Stärke1);
	float Lvl1 = Float.parseFloat(Level1);
	float Agl = Float.parseFloat(Agilität);

	V1 = (Att1 * Zufall1 - Abw1);
	V2 = (1 + Str1);
	V3 = (Lvl1 + Agl / 218);
	V4 = (V2 * V3);
	V5 = (V4 * V1);

 	JOptionPane.showMessageDialog
	(null, "Der Schaden beträgt" + V5);

	if (Formel.equals("Magieabh"));
	String Angriff7 = JOptionPane.showInputDialog
	("Angriff");
	String Abwehr7 = JOptionPane.showInputDialog
	("Abwehr");
	String Magie = JOptionPane.showInputDialog
	("Magie");
	String Level7 = JOptionPane.showInputDialog
	("Level");
	float Zufall7 = (float) (Math.random()+1);

	float Att7 = Float.parseFloat(Angriff7);
	float Abw7 = Float.parseFloat(Abwehr7);
	float Mag7 = Float.parseFloat(Magie);
	float Lvl7 = Float.parseFloat(Level7);

	V1 = (Att7 * Zufall7 - Abw7);
	V2 = (1 + Mag7);
	V3 = (Lvl7 + Mag7 / 256);
	V4 = (V2 * V3);
	V5 = (V4 * V1);

	JOptionPane.showMessageDialog
	(null, "Der Schaden beträgt" + V5);


	if (Formel.equals("Magieabwehr"));
	String Angriff8 = JOptionPane.showInputDialog
	("Angriff");
	String Stärke8 = JOptionPane.showInputDialog
	("Stärke8");
	String Magieabwehr = JOptionPane.showInputDialog
	("Magieabwehr");
	String Level8 = JOptionPane.showInputDialog
	("Level");
	float Zufall8 = (float) (Math.random()+1);

	float Att8 = Float.parseFloat(Angriff8);
	float Maga = Float.parseFloat(Magieabwehr);
	float Lvl8 = Float.parseFloat(Level8);
	float Str8 = Float.parseFloat(Stärke8);

	V1 = (Att8 * Zufall8 - Maga);
	V2 = (1 + Str8);
	V3 = (Lvl8 + Str8 / 256);
	V4 = (V2 * V3);
	V5 = (V4 * V1);

	JOptionPane.showMessageDialog
	(null, "Der Schaden beträgt" + V5);


	if (Formel.equals("Magie"));
	String Angriff9 = JOptionPane.showInputDialog
	("Angriff");
	String Magieabwehr9 = JOptionPane.showInputDialog
	("Magieabwehr");
	String Magie9 = JOptionPane.showInputDialog
	("Magie");
	String Level9 = JOptionPane.showInputDialog
	("Level");
	float Zufall9 = (float) (Math.random()+1);

	float Atk = Float.parseFloat(Angriff9);
	float Magab = Float.parseFloat(Magieabwehr9);
	float Mag9 = Float.parseFloat(Magie9);
	float Lvl9 = Float.parseFloat(Level9);

	V1 = (Atk * Zufall9 - Magab);
	V2 = (1 + Str);
	V3 = (Lvl9 + Mag9 / 256);
	V4 = (V2 * V3);
	V5 = (V4 * V1);

	JOptionPane.showMessageDialog
	(null, "Der Schaden beträgt" + V5);
  }
  // Ende Methoden

}
ich hab den code in eclipse in ne ausfürbare jar datei exportiert, gespeichert und mit der bin/javaw.exe vercknüpft. wenn ich auf das programm clicke kommt kurz ne sanduhr und ein es passiert nichts.
wie krieg ich das programm jetzt zum laufen?
schonmal danke im vorraus
 
Du hast ja nichtmal ne funktionierende main-methode, das kann ja so nicht gehen.
Eine main-methode sieht immer so aus:
Code:
public static void main(String[] args)
{
...
}

Sonstige Übergabeparameter musst du in args[] unterbringen.
Wenn du floats übergeben willst, musst du du sie dir aus dem args[] herausparsen
Code:
public static void main(String[] args)
{
float V1 = Float.parseFloat(args[0]);
...

edit:
Variablennamen schreibt man klein und verzichtet möglichst auf Umlaute im Variablennamen
 
Zuletzt bearbeitet:
ok danke für die antwort aber check das iwie nich!

is es richtig wenn ich das jetz so mache?
Code:
public static void main(String[] args)
  {

    String formel = JOptionPane.showInputDialog
     ("Art des Angriffs");
    if (Formel.equals("Abwehr"));
    String angriff = JOptionPane.showInputDialog
    ("Angriff");
    String abwehr = JOptionPane.showInputDialog
    ("Abwehr");
    String atärke = JOptionPane.showInputDialog
    ("Stärke");
    String level = JOptionPane.showInputDialog
    ("Level");
    float zufall = (float) (Math.random()+1);

    float V1 = (Att * Zufall - Abw);
    float V1 = Float.parseFloat(args [0])
    float V2 = (1 + Str);
    float V2 = Float.parseFloat(args [1])
    float V3 = (Lvl + Str / 256);
    float V3 = Float.parseFloat(args [2])
    float V4 = (V2 * V3);
    float V4 = Float.parseFloat(args [3])
    float V5 = (V4 * V1);
    float V5 = Float.parseFloat(args [4])
    JOptionPane.showMessageDialog
    (null, "Der Schaden beträgt" + V5);

oder was muss ich noch anders machen ( sorry für meine dummheit aber ich mach das erst seit n paar wochen)?
 
in jedem Fall solltest du immer nur sehr wenig auf einmal machen,
was ist denn jetzt die Frage?

funktioniert der Programmstart aus dem Jar?
wenn nicht, mit EINFACHER main-Methode wie
public static void main(String[] args)
{
System.out.println("Hello World");
}
testen

-----

funktioniert das Parsen so wie du es willst?
EINEN Float zu parsen würde doch reichen,
wenn es nicht geht, welche Fehlermeldung?, welche Eingabe?
 
Code:
public static void main(String[] args)
  {
    ...
    String formel = JOptionPane.showInputDialog;
    if (Formel.equals("Abwehr"));
[/QUOTE]

Du schreibst in der Abfrage Formel groß obwohll sie kleingeschrieben deklariert ist. ???:L

Außerdem führt das abschließende Semikolon dazu, daß nur eine Leeranweisung
ausgeführt wird. :shock:

Übrigens wärst du schon auf den 1. Fehler gestoßen, wenn du vor dem
Posten wenigstens einmal probiert hättest, zu kompilieren!
 
ich hab den quelltext eben einfach nur schnell geändert um zu wissen ob ich s verstanden hab oder nich und dabei hab ich aus vergessen die variable klein zu machen und hab aus versehen das semikolon dahin gemacht! und als ich das teil compilert hab hat das programm nur erfolgreich compilert gesagt!

der progstart funktioniert nich! ich hab das mit dem hallo welt prog ma versucht und das funktioniert auch nich! ich hab keine ahnung ob das parsen funkitoniert weil ich das programm in eclipse auch nich runnen kann. die fehlermeldung is immer "editor does not contain a main type".
 
Status
Nicht offen für weitere Antworten.

Zurück
Oben