|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Dec 2004
Messaggi: 1218
|
[JAVA] esercitazione help!! please!!
Ragazzi aiutatemi devo fare questo esercizio qui
sono niubbo in java (è la prima volta che lo uso) utilizzo netbeans ed ho installato le jdk... Codice:
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
/**
08: Una forma di auto posizionabile posizionabibile in un
un punto qualunque di una finestra.
09: */
public class Car
{
/** Costruisce una auto a partire da una data origine
14: @param x la coordinata x dell’origine
15: @param y la coordinata y dell’origine
16: */
//File Car.java
public Car(int x, int y)
{
xLeft = x;
yTop = y;
}
/**
24: Disegna l’auto.
25: @param g2 il contesto grafico per il disegno
26: */
public void draw(Graphics2D g2)
{
Rectangle scocca
= new Rectangle(xLeft, yTop + 10, 60, 10);
Ellipse2D.Double ruotaAnteriore
= new Ellipse2D.Double(xLeft + 10, yTop
+ 20, 10, 10);
Ellipse2D.Double ruotaPosteriore
= new Ellipse2D.Double(xLeft + 40, yTop
+ 20, 10, 10);
// estremo inferiore del parabrezza
Point2D.Double p1
= new Point2D.Double(xLeft + 10, yTop + 10);
// estremo anteriore del tetto
Point2D.Double p2
= new Point2D.Double(xLeft + 20, yTop);
// estremo posteriore del tetto
Point2D.Double p3
= new Point2D.Double(xLeft + 40, yTop);
Point2D.Double p4
= new Point2D.Double(xLeft + 50, yTop + 10);
Line2D.Double frontWindshield
= new Line2D.Double(p1, p2);
Line2D.Double roofTop = new Line2D.Double(p2, p3);
Line2D.Double rearWindshield
= new Line2D.Double(p3, p4);
g2.draw(scocca);
g2.draw(ruotaAnteriore);
g2.draw(ruotaPosteriore);
g2.draw(roofTop);
g2.draw(rearWindshield);
g2.draw(frontWindshield);
}
public static int WIDTH = 60;
public static int HEIGHT = 30;
private int xLeft;
private int yTop;
}
poi come faccio ad unire 3 file?? per esempio come faccio per eseguire questo codice?: link
__________________
Athlon64 3500 (Winchester), Asus A8V-E Deluxe, X700Pro 256MB, Maxtor 200GB Sata,Ali Enermax 400W, Mast. Pionner 109,Lettore dvd LG, Creative 2.1 3200, LG 1980q, Canon Pixma mp500. |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 17:22.



















