import java.io.* ;
class Main
{
public static void main (String[] args)
{
String comando = "" ; Triangolo t1 = new Triangolo( 0.0 , 0.0 , 1.0 , 0.0 , 1.0 , 1.0 ) ;
BufferedReader in = new BufferedReader( new InputStreamReader(System.in) ) ;
System.out.println( "\n GEOMETRIA PIANA\n Digita: \"aiuto\" per la guida, \"esci\" per uscire." ) ;
while ( true )
{
System.out.print("\n > ") ;
try
{
comando = in.readLine() ;
}
catch ( Exception e ) { e.printStackTrace() ; }
if ( comando.equals("esci") ) break ;
if ( comando.equals("stampa") )
{
System.out.println( "\n\t"+t1.getPoint(0).x+"\t"+t1.getPoint(0).y ) ;
System.out.println( "\t"+t1.getPoint(1).x+"\t"+t1.getPoint(1).y ) ;
System.out.println( "\t"+t1.getPoint(2).x+"\t"+t1.getPoint(2).y ) ;
}
}
}
}
import java.util.* ;
class Poligono
{
Vector P = new Vector() ;
void addPoint( double x , double y )
{
P.add( new Punto2d(x,y) ) ;
}
void addPoint( Punto2d punto2d )
{
P.add( punto2d );
}
Punto2d getPoint( int i )
{
return (Punto2d)( P.get( i ) ) ;
}
}
class Triangolo extends Poligono
{
int npti = 3 ;
Triangolo()
{
addPoint( 0.0 , 0.0 ) ; super.addPoint( 3.0 , 0.0 ) ; super.addPoint( 3.0 , 4.0 ) ;
}
Triangolo( double xA , double yA , double xB , double yB , double xC , double yC )
{
super.addPoint( xA , yA ) ; super.addPoint( xB , yB ) ; super.addPoint( xC , yC ) ;
}
Punto2d getPoint( int i )
{
if ( i>=0 && i<=2 ) return super.getPoint(i) ; else return null ;
}
}
class Punto2d
{
public double x , y ;
Punto2d()
{
x = y = 0.0 ;
}
Punto2d( double x , double yy )
{
this.x = x ; y = yy ;
}
}