Я пытаюсь напечатать всего 3 плоскости, и рядом с ними напечатаны разные данные для каждой плоскости. Моя проблема в том, что 6 самолетов печатают, и все данные для самолетов располагаются друг над другом во всех трех точках. Я новичок в программировании на Java, так что любая помощь будет полезна в определении проблемы.
import java.awt.Graphics;
import java.awt.Color;
public class Aircraft implements Drawable
{
//fields
private String manufacturer;
private String model;
private double span;//wing span (length) in ft
private double chord;//wing cord (width) in ft
private double mtow;//max take off weight in lbs
private int x,y;
//default construtor
public Aircraft()
{
this.manufacturer= "Cessna";
this.model= "172R";
this.span= 32;
this.chord= 4.5;
this.mtow= 2600;
this.x=50;
this.y=50;
}//default constructor end
//OP constructor
public Aircraft(String manufacturer, String model, double span, double chord, double mtow)
{
this.manufacturer=manufacturer;
this.model=model;
this.span=span;
this.chord=chord;
this.mtow=mtow;
}//end OP constructor
//accessors
public String getManufacturer() {return manufacturer;}//gives access to manufacturer that is a private field
public String getModel() {return model;}
public double getSpan() {return span;}
public double getChord() {return chord;}
//mutators
public void setMtow(double newMtow){this.mtow=newMtow;}
public void draw( Graphics g)
{
g.setColor(Color.BLACK);
g.drawString(manufacturer + " " + model,x+210,y+50);
g.drawString("Span: " + span,x+210,y+65);
g.drawString("Chord: " + chord,x+210,y+80);
g.drawString("Maximum Takeoff Weight: " + mtow,x+210,y+95);
g.fillOval(x+100,y+100,100,25);//plane body
g.fillRect(x+150,y+40,30,150);//plane wings
g.drawString(manufacturer + " " + model,x+600,y+180);
g.drawString("Span: " + span,x+600,y+195);
g.drawString("Chord: " + chord,x+600,y+210);
g.drawString("Maximum Takeoff Weight: " + mtow,x+600,y+225);
g.fillOval(x+500,y+250,100,25);//plane body
g.fillRect(x+550,y+190,30,150);//plane wings
g.drawString(manufacturer + " " + model,x+460,y+430);
g.drawString("Span: " + span,x+460,y+445);
g.drawString("Chord: " + chord,x+460,y+460);
g.drawString("Maximum Takeoff Weight: " + mtow,x+460,y+475);
g.fillOval(x+350,y+500,100,25);//plane body
g.fillRect(x+400,y+440,30,150);//plane wings
}//end draw method
}//end aircraft class
, а вот класс производителя самолетов:
public class AircraftDriver
{
public static void main(String[] args)
{
System.out.println("");
GraphicsFrame gf = new GraphicsFrame();
Aircraft aircraft1 = new Aircraft();
gf.add(aircraft1);
Aircraft aircraft2 = new Aircraft("Cirrus","SR22",38.4,4.03,3400);
gf.add(aircraft2);
Aircraft aircraft3 = new Aircraft("Bombardier","Challenger 850",69.6,7.48,52999);
gf.add(aircraft3);
}//end main
}//end aircraft driver