在Java编辑器中遇到了“找不到符号”错误。

huangapple go评论57阅读模式
英文:

Getting "Cannot find symbol" error in Java Editor

问题

以下是翻译好的内容:

public class EventUI {
  
  public static void main(String[] args) {
    Event e = new Event();
    
    // 添加艺术家
    e.addArtist("Eminem  ", 1);
    
    // 添加访客
    e.addBesucher("Eniss D.  ", 1);
    
    // 添加团队成员
    e.addCrew("Max  ", 1);
    
    // 添加组织者
    e.addVeranstalter("Gruppe 1");
    
    // 添加VIP
    e.addVip("Lara  ", 1);
    
    // 显示
    System.out.println(e.zeigeArtistListe());
    System.out.println(e.zeigeBesucherListe());
    System.out.println(e.zeigeCrewListe());
    System.out.println(e.zeigeVeranstalterListe());
    System.out.println(e.zeigeVipListe());
    
  } 
}
public class Event {
  
  // 属性
  private String nameVeranstalter;      
  private ArrayList<Artist> ArtistListe;  
  private ArrayList<Besucher> BesucherListe;
  private ArrayList<Crew> CrewListe;
  private ArrayList<Veranstalter> VeranstalterListe;
  private ArrayList<Vip> VipListe;
  
  // 方法
  public Event(){
    ArtistListe = new ArrayList<Artist>();  
    BesucherListe = new ArrayList<Besucher>();
    CrewListe = new ArrayList<Crew>();
    VeranstalterListe = new ArrayList<Veranstalter>();
    VipListe = new ArrayList<Vip>();   
  }
  
  public ArrayList<Artist> getArtistListe(){
    return ArtistListe;
  }
  
  public ArrayList<Besucher> getBesucherListe(){
    return BesucherListe;
  }
  
  public ArrayList<Crew> getCrewListe(){
    return CrewListe;
  }
  
  public ArrayList<Veranstalter> getVeranstalterListe(){
    return VeranstalterListe;
  }
  
  public ArrayList<Vip> getVipListe(){
    return VipListe;
  }
  
  public void addArtist(String name, int artistId){       
    ArtistListe.add(new Artist(name, artistId));
  }
  
  public void addBesucher(String bes, int besucherId){
    BesucherListe.add(new Besucher(bes, besucherId ));
  }  
  
  public void addCrew(String name, int crewId ){
    CrewListe.add(new Crew(name, crewId ));
  }   
  
  public void addVeranstalter(String name){
    VeranstalterListe.add(new Veranstalter(name));
  }   
  
  public void addVip(String name, int vipId ){
    VipListe.add(new Vip(name, vipId ));
  }
  
  public String zeigeArtistListe() {
    String ergebnis = "";
    for(Artist a : ArtistListe) {
      ergebnis += a.toString() + "\n";
    }
    if( ergebnis.equals("")){
      ergebnis = "没有艺术家。";
    }
    return ergebnis;
  }
          
  public String zeigeBesucherListe() {
    String ergebnis = "";
    for(Besucher b : BesucherListe) {
      ergebnis += b.toString() + "\n";
    }
    if( ergebnis.equals("")){
      ergebnis = "没有访客。";
    }
    return ergebnis;
  }

  public String zeigeCrewListe() {
    String ergebnis = "";
    for(Crew c : CrewListe) {
      ergebnis += c.toString() + "\n";
    }
    if( ergebnis.equals("")){
      ergebnis = "没有团队成员。";
    }
    return ergebnis;
  }          
  public String zeigeVeranstalterListe() {
    String ergebnis = "";
    for(Veranstalter v : VeranstalterListe) {
      ergebnis += v.toString() + "\n";
    }
    if( ergebnis.equals("")){
      ergebnis = "没有组织者。";
    }
    return ergebnis;
  }  
  public String zeigeVipListe() {
    String ergebnis = "";
    for(Vip vp : VipListe) {
      ergebnis += vp.toString() + "\n";
    }
    if( ergebnis.equals("")){
      ergebnis = "没有VIP。";
    }
    return ergebnis;
  }  

}
英文:

I'm working on a school project with the purpose to create a program to manage and organize an event.
I have several classes that all work fine and don't have any errors.
Unfortunately this is not the case for my EventUI.java :

Fixed all the errors I could solve but I don't understand the remaining 3 errors:

*

Compiliere EventUI.java mit Java-Compiler
EventUI.java:27:6: error: cannot find symbol
e.addCrewListe(&quot;Max  &quot;,1);
^
symbol:   method addCrewListe(String,int)
location: variable e of type Event
EventUI.java:31:6: error: cannot find symbol
e.addVeranstalterListe(&quot;Gruppe 1&quot;);
^
symbol:   method addVeranstalterListe(String)
location: variable e of type Event
EventUI.java:35:6: error: cannot find symbol
e.addVipListe(&quot;Lara  &quot;,1);
^
symbol:   method addVipListe(String,int)
location: variable e of type Event
3 errors

*

Any idea how to solve this? Or does anyone know a possible solution for this?
Thank you!

Here's the EventUI.java:

/**
*
* Beschreibung
*
* @version 1.0 vom 11.03.2020
* @author 
*/
import static java.lang.System.*;
import java.util.Scanner;
public class EventUI {
public static void main(String[] args) {
Event e = new Event();
//System.out.println(e.zeigeArtistListe());
//Hinzuf&#252;gen von Artists
e.addArtist(&quot;Eminem  &quot;,1);
//System.out.println(e.zeigeBesucherListe());
//Hinzuf&#252;gen von Besuchern
e.addBesucher(&quot;Eniss D.  &quot;,1);
//System.out.println(e.zeigeCrewListe());
//Hinzuf&#252;gen von Crewmitgliedern
e.addCrewListe(&quot;Max  &quot;,1);
//System.out.println(e.zeigeVeranstalterListe());
//Hinzuf&#252;gen von Veranstaltern
e.addVeranstalterListe(&quot;Gruppe 1&quot;);
//System.out.println(e.zeigeVipListe());
//Hinzuf&#252;gen von VIP&#39;s
e.addVipListe(&quot;Lara  &quot;,1);
//Anzeige
System.out.println(e.zeigeArtistListe() );  
System.out.println(e.zeigeBesucherListe() );
System.out.println(e.zeigeCrewListe() );
System.out.println(e.zeigeVeranstalterListe() );
System.out.println(e.zeigeVipListe() );
} 
} // end of EventUI

And here is the Event Class:

/**
*
* Beschreibung
*
* @version 1.0 vom 26.02.2020
* @author 
*/
import java.util.ArrayList;
import java.io.*; 
import static java.lang.System.*;
public class Event {
// Anfang Attribute
private String nameVeranstalter;      
//ArrayList 
private ArrayList&lt;Artist&gt; ArtistListe;  
private ArrayList&lt;Besucher&gt; BesucherListe;
private ArrayList&lt;Crew&gt; CrewListe;
private ArrayList&lt;Veranstalter&gt; VeranstalterListe;
private ArrayList&lt;Vip&gt; VipListe;
//Anfang Methoden
public Event(){
ArtistListe = new ArrayList&lt;Artist&gt;();  
BesucherListe = new ArrayList&lt;Besucher&gt;();
CrewListe = new ArrayList&lt;Crew&gt;();
VeranstalterListe = new ArrayList&lt;Veranstalter&gt;();
VipListe = new ArrayList&lt;Vip&gt;();   
}
public ArrayList&lt;Artist&gt; getArtistListe(){
return ArtistListe;
}
public ArrayList&lt;Besucher&gt; getBesucherListe(){
return BesucherListe;
}
public ArrayList&lt;Crew&gt; getCrewListe(){
return CrewListe;
}
public ArrayList&lt;Veranstalter&gt; getVeranstalterListe(){
return VeranstalterListe;
}
public ArrayList&lt;Vip&gt; getVipListe(){
return VipListe;
}
//Hinzuf&#252;gen
public void addArtist(String name, int artistId){       
ArtistListe.add(new Artist(name, artistId));
}
public void addBesucher(String bes, int besucherId){
BesucherListe.add(new Besucher(bes, besucherId ));
}  
public void addCrew(String name, int crewId ){
CrewListe.add(new Crew(name, crewId ));
}   
public void addVeranstalter(String name){
VeranstalterListe.add(new Veranstalter(name));
}   
public void addVip(String name, int vipId ){
VipListe.add(new Vip(name, vipId ));
}
//Zeige Inhalt Nach Gruppen bzw Klassen
public String zeigeArtistListe() {
String ergebnis = &quot;&quot;;
for(Artist a : ArtistListe) {
ergebnis += a.toString() + &quot;\n&quot;;
}
if( ergebnis.equals(&quot;&quot;)){
ergebnis = &quot;Keine K&#252;nstler da.&quot;;
}
return ergebnis;
}
public String zeigeBesucherListe() {
String ergebnis = &quot;&quot;;
for(Besucher b : BesucherListe) {
ergebnis += b.toString() + &quot;\n&quot;;
}
if( ergebnis.equals(&quot;&quot;)){
ergebnis = &quot;Keine Besucher da.&quot;;
}
return ergebnis;
}
public String zeigeCrewListe() {
String ergebnis = &quot;&quot;;
for(Crew c : CrewListe) {
ergebnis += c.toString() + &quot;\n&quot;;
}
if( ergebnis.equals(&quot;&quot;)){
ergebnis = &quot;Die Crew ist nicht anwesend.&quot;;
}
return ergebnis;
}          
public String zeigeVeranstalterListe() {
String ergebnis = &quot;&quot;;
for(Veranstalter v : VeranstalterListe) {
ergebnis += v.toString() + &quot;\n&quot;;
}
if( ergebnis.equals(&quot;&quot;)){
ergebnis = &quot;Die Veranstalter sind nicht da.&quot;;
}
return ergebnis;
}  
public String zeigeVipListe() {
String ergebnis = &quot;&quot;;
for(Vip vp : VipListe) {
ergebnis += vp.toString() + &quot;\n&quot;;
}
if( ergebnis.equals(&quot;&quot;)){
ergebnis = &quot;Kein VIP anwesend.&quot;;
}
return ergebnis;
}  
// Ende Methoden
} // end of Event

答案1

得分: 0

在你的EventUI类中,你调用了几个e.add&lt;something&gt;Liste()的方法,但是这些方法在Event类中是不存在的。相反,你应该调用e.add&lt;something&gt;()方法,下面是对EventUI类进行修正的示例代码:

/**
 *
 * 描述
 *
 * @version 1.0 于 2020年3月11日
 * 作者
 */
import static java.lang.System.*;
import java.util.Scanner;

public class EventUI {

  public static void main(String[] args) {
    Event e = new Event();

    //System.out.println(e.zeigeArtistListe());
    //添加艺术家
    e.addArtist("Eminem", 1);

    //System.out.println(e.zeigeBesucherListe());
    //添加访客
    e.addBesucher("Eniss D.", 1);

    //System.out.println(e.zeigeCrewListe());
    //添加工作人员
    e.addCrew("Max", 1); //已修正

    //System.out.println(e.zeigeVeranstalterListe());
    //添加主办方
    e.addVeranstalter("Gruppe 1"); //已修正

    //System.out.println(e.zeigeVipListe());
    //添加贵宾
    e.addVip("Lara", 1); //已修正

    //显示
    System.out.println(e.zeigeArtistListe());
    System.out.println(e.zeigeBesucherListe());
    System.out.println(e.zeigeCrewListe());
    System.out.println(e.zeigeVeranstalterListe());
    System.out.println(e.zeigeVipListe());

  }
}

基本上,错误提示表明你试图在Event类上调用不存在的方法。

英文:

In your EventUI class, you call several e.add&lt;something&gt;Liste()&#39;, but these methods don&#39;t exist on the Eventclass. Instead you should call thee.add<something>()` methods, with corrections shown below for the EventUI class:

/**
*
* Beschreibung
*
* @version 1.0 vom 11.03.2020
* @author 
*/
import static java.lang.System.*;
import java.util.Scanner;
public class EventUI {
public static void main(String[] args) {
Event e = new Event();
//System.out.println(e.zeigeArtistListe());
//Hinzuf&#252;gen von Artists
e.addArtist(&quot;Eminem  &quot;,1);
//System.out.println(e.zeigeBesucherListe());
//Hinzuf&#252;gen von Besuchern
e.addBesucher(&quot;Eniss D.  &quot;,1);
//System.out.println(e.zeigeCrewListe());
//Hinzuf&#252;gen von Crewmitgliedern
e.addCrew(&quot;Max  &quot;,1); //CORRECTED
//System.out.println(e.zeigeVeranstalterListe());
//Hinzuf&#252;gen von Veranstaltern
e.addVeranstalter(&quot;Gruppe 1&quot;); //CORRECTED
//System.out.println(e.zeigeVipListe());
//Hinzuf&#252;gen von VIP&#39;s
e.addVip(&quot;Lara  &quot;,1); //CORRECTED
//Anzeige
System.out.println(e.zeigeArtistListe() );  
System.out.println(e.zeigeBesucherListe() );
System.out.println(e.zeigeCrewListe() );
System.out.println(e.zeigeVeranstalterListe() );
System.out.println(e.zeigeVipListe() );
} 
} 

Basically, the errors were indicating that you were trying to call methods on the Event class that do not exist.

答案2

得分: 0

如果您从其他地方获得了该类,您还需要选择其他相关的类。您遇到导入错误,因为Java编译器找不到您尝试调用的某些类/方法。

英文:

If you got that class from somewhere else, you also need to pick other related classes. You are having an import error because the java compiler could not find some of the classes/methods you're trying to call

答案3

得分: 0

import static java.lang.System.*;
import java.util.Scanner;

public class EventUI {

  public static void main(String[] args) {
    Event e = new Event();

    e.addArtist("Eminem", 1);

    e.addBesucher("Eniss D.", 1);

    e.addCrew("Max", 1);

    e.addVeranstalter("Gruppe 1");

    e.addVip("Lara", 1);

    System.out.println(e.zeigeArtistListe());
    System.out.println(e.zeigeBesucherListe());
    System.out.println(e.zeigeCrewListe());
    System.out.println(e.zeigeVeranstalterListe());
    System.out.println(e.zeigeVipListe());
  }
}
英文:
import static java.lang.System.*;
import java.util.Scanner;

public class EventUI {

  public static void main(String[] args) {
    Event e = new Event();

    //System.out.println(e.zeigeArtistListe());
    //Hinzuf&#252;gen von Artists
    e.addArtist(&quot;Eminem  &quot;,1);

    //System.out.println(e.zeigeBesucherListe());
    //Hinzuf&#252;gen von Besuchern
    e.addBesucher(&quot;Eniss D.  &quot;,1);

    //System.out.println(e.zeigeCrewListe());
    //Hinzuf&#252;gen von Crewmitgliedern
    e.addCrew(&quot;Max  &quot;,1); //CORRECTED

    //System.out.println(e.zeigeVeranstalterListe());
    //Hinzuf&#252;gen von Veranstaltern
    e.addVeranstalter(&quot;Gruppe 1&quot;); //CORRECTED

    //System.out.println(e.zeigeVipListe());
    //Hinzuf&#252;gen von VIP&#39;s
    e.addVip(&quot;Lara  &quot;,1); //CORRECTED

    //Anzeige
    System.out.println(e.zeigeArtistListe() );  
    System.out.println(e.zeigeBesucherListe() );
    System.out.println(e.zeigeCrewListe() );
    System.out.println(e.zeigeVeranstalterListe() );
    System.out.println(e.zeigeVipListe() );
  } 
} 

huangapple
  • 本文由 发表于 2020年4月5日 04:53:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/61034643.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定