//----------------------------------------------------------------------- // Store this program in file program2.java. In the same directory, create // another directory Geometry in which you store Point.java, Triangle.java. // This forms the package Geometry. Note that in each of the // files of directory Geometry we mention the line "package Geometry" to // convey that the corresponding class is a part of the package Geometry. // Compile and run this program with command line arguments. // // The files Point.java, Triangle.java are different from those posted on // lecture 22. In particular, we have rewritten the methods using "this" // operator, introduced method Area() in Triangle.java. We also wrote methods // to access the attributes of Point and Triangle. Please go through these // files carefully and try to write similar class for Circle.java and add it // to package Geometry. //------------------------------------------------------------------------ // Try to realize that the following program for computing area of // a triangle is now just a toy program. Just think how complex it would have // been if we had used structured programming aproach only. //----------------------------------------------------------------------- import Geometry.Triangle; class program2 { public static void main(String args[]) { int x1 = Integer.parseInt(args[0]); int y1 = Integer.parseInt(args[1]); int x2 = Integer.parseInt(args[2]); int y2 = Integer.parseInt(args[3]); int x3 = Integer.parseInt(args[4]); int y3 = Integer.parseInt(args[5]); Triangle T = new Triangle(x1,y1,x2,y2,x3,y3); double area = T.Area(); System.out.println("Area of triangle T is "+area); } }