F
freshprinz
Gast
Hi....Hoffe ihr könnt mir weiter helfen.....hab folgenden Code geschrieben und habe nun das problem dass Eclipse mir eine Fehlermeldung bei folgenden Code ausspuckt......Der Fehler ist: "Screen cannot resolved to a type" obwohl ich gelesen habe, dass es so eigentlich gehen sollte!
Code:
public class CoolGraphicDisplay
{
GraphicThing a[];
// Screen myScreen;
public CoolGraphicDisplay()
{
Screen myScreen = new Screen();
a=new GraphicThing[0];
//Es wird ein Array vom Typ GraphicThing erzeugt, in dem
//sowhohl Kreis, Rechteck und Dreieck gespeichert werden können
}
public void draw()
{
// myScreen.clearScreen();
if(a.length > 0)
{
for(int i = 0; i < a.length; i++) {
a[i].draw(myScreen);
}
}
myScreen.show();
}
public void clear(){
myScreen.clearScreen();
myScreen.show();
}
public void addRectangle(Rectangle newRect)
{
GraphicThing oldG[] = a;
a = new Rectangle[oldG.length + 1];
int i;
for (i = 0; i < oldG.length; i++) {
a[i] = oldG[i];
}
a[i] = newRect;
a[i].draw(myScreen);
myScreen.show();
}
public void addTriangle(Triangle newTri)
{
GraphicThing oldG[] = a;
a = new GraphicThing[oldG.length + 1];
int i;
for (i = 0; i < oldG.length; i++) {
a[i] = oldG[i];
}
a[i] = newTri;
a[i].draw(myScreen);
myScreen.show();
}
public void addCircle(Circle newCirc)
{
GraphicThing oldG[] = a;
a = new GraphicThing[oldG.length + 1];
int i;
for (i = 0; i < oldG.length; i++) {
a[i] = oldG[i];
}
a[i] = newCirc;
a[i].draw(myScreen);
myScreen.show();
}
public void deleteDrawed(){
GraphicThing a[]=new GraphicThing[0];
clear();
}
}