Colindapieman

Lab9.1 Geometric

Apr 9th, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 19.82 KB | None | 0 0
  1. package cse1102.geometry;
  2.  
  3. public class GeometryApp {
  4.     private static Recorder recorder = new Recorder("McNeil_Colin.txt");
  5.     public static void main(String[] args)
  6.     {
  7.        
  8.        
  9.         recorder.writeln("Welcome to the geometric application",true);
  10.         recorder.writeln("Interface Version.",true);
  11.         printInstances();
  12.        
  13.         recorder.writeln("*****Create the shapes*****",true);
  14.         Rectangle Rect1 = new Rectangle(10,10,10,5);
  15.         Rect1.setLineColor("Green");
  16.         Rect1.setFillColor("White");
  17.         Rectangle Rect2 = new Rectangle(15,15,10,5);
  18.         Rect2.setLineColor("White");
  19.         Rect2.setFillColor("Green");
  20.         printInstances();
  21.         Triangle Tri1 = new Triangle(30,30,10,5,0);
  22.         Tri1.setLineColor("Black");
  23.         Tri1.setFillColor("Green");
  24.         Triangle Tri2 = new Triangle(50,50,10,20,10);
  25.         Tri2.setLineColor("Green");
  26.         Tri2.setFillColor("Black");
  27.        
  28.         Triangle Tri3 = new Triangle(40,40,10,20,10);
  29.         Tri3.setLineColor("Green");
  30.         Tri3.setFillColor("Black");
  31.        
  32.         Circle cir1 = new Circle(100,100,4);
  33.         cir1.setLineColor("Blue");
  34.         cir1.setFillColor("Grey");
  35.         printInstances();
  36.         Square sqr1 = new Square(60,60,20);
  37.         sqr1.setLineColor("Black");
  38.         sqr1.setFillColor("Orange");
  39.         printInstances();
  40.         if (Tri1.equals(Tri2)){
  41.             recorder.writeln("Triangle 1 = Triangle 2", true);
  42.         }
  43.         else{
  44.             recorder.writeln("Triangle 1 != Triangle 2", true);
  45.         }
  46.         if (Tri2.equals(Tri3)){
  47.             recorder.writeln("Triangle 2 = Triangle 3", true);
  48.         }
  49.         else{
  50.             recorder.writeln("Triangle 2 != Triangle 3", true);
  51.         }
  52.         if (Tri1.equals(Tri3)){
  53.             recorder.writeln("Triangle 1 = Triangle 3", true);
  54.         }
  55.         else{
  56.             recorder.writeln("Triangle 1 != Triangle 3", true);
  57.         }
  58.    
  59.         recorder.writeln("*****Display descriptions of the shapes*****",true);
  60.         Definable d1 = Rect1;
  61.         recorder.writeln("~~~Rectangle 1~~~",true);
  62.         recorder.writeln(d1,true);
  63.         d1 = Rect2;
  64.         recorder.writeln("~~~Rectangle 2~~~",true);
  65.         recorder.writeln(d1,true);
  66.         d1 = Tri1;
  67.         recorder.writeln("~~~Triangle 1~~~",true);
  68.         recorder.writeln(d1,true);
  69.         d1 = Tri2;
  70.         recorder.writeln("~~~Triangle 2~~~",true);
  71.         recorder.writeln(d1,true);
  72.         d1= Tri3;
  73.         recorder.writeln("~~~Triangle 3~~~",true);
  74.         recorder.writeln(d1,true);
  75.         d1 = sqr1;
  76.         recorder.writeln("~~~Square 1~~~",true);
  77.         recorder.writeln(d1,true);
  78.         recorder.writeln("~~~Circle 1~~~",true);
  79.         recorder.writeln(cir1,true);
  80.        
  81.         recorder.writeln("*****Move the shapes*****",true);
  82.         Rect1.deltaMove(10, 5);
  83.         Rect2.deltaMove(10, 5);
  84.         Tri1.deltaMove(10, 5);
  85.         Tri2.deltaMove(10, 5);
  86.         cir1.deltaMove(10, 5);
  87.         sqr1.deltaMove(10, 5);
  88.        
  89.         recorder.writeln("*****Display the descriptions of the shapes (casts)*****",true);
  90.         d1= (Definable) (Rect1);
  91.         recorder.writeln("~~~Rectangle 1~~~",true);
  92.         recorder.writeln(d1,true);
  93.         d1= (Definable) (Rect2);
  94.         recorder.writeln("~~~Rectangle 2~~~",true);
  95.         recorder.writeln(d1,true);
  96.         d1= (Definable) (Tri1);
  97.         recorder.writeln("~~~Triangle 1~~~",true);
  98.         recorder.writeln(d1,true);
  99.         d1= (Definable) (Tri2);
  100.         recorder.writeln("~~~Triangle 2~~~",true);
  101.         recorder.writeln(d1,true);
  102.         d1=(Definable) (Tri3);
  103.         recorder.writeln("~~~Triangle 3~~~",true);
  104.         recorder.writeln(d1,true);
  105.         d1= (Definable) (sqr1);
  106.         recorder.writeln("~~~Square~~~",true);
  107.         recorder.writeln(d1,true);
  108.        
  109.         recorder.writeln("~~~Circle~~~",true);
  110.         recorder.writeln(cir1,true);
  111.        
  112.         recorder.writeln("*****Display the area and perimeter of the shapes*****",true);
  113.         ShapesUser su = (ShapesUser)(Rect1);
  114.         recorder.writeln("Rectangle 1 perimeter: "+su.getPerimeter() +" Area: "+su.getArea(),true);
  115.         su = (ShapesUser)(Rect2);
  116.         recorder.writeln("Rectangle 2 perimeter: "+su.getPerimeter() +" Area: "+su.getArea(),true);
  117.         su = (ShapesUser)(Tri1);
  118.         recorder.writeln("Triangle 1 perimeter: "+su.getPerimeter() +" Area: "+su.getArea(),true);
  119.         su = (ShapesUser)(Tri2);
  120.         recorder.writeln("Triangle 2 perimeter: "+su.getPerimeter() +" Area: "+su.getArea(),true);
  121.         su = (ShapesUser)(Tri3);
  122.         recorder.writeln("Triangle 3 perimeter: "+su.getPerimeter() +" Area: "+su.getArea(),true);
  123.         su = (ShapesUser)(cir1);
  124.         recorder.writeln("Circle perimeter: "+su.getPerimeter() +" Area: "+su.getArea(),true);
  125.         su = (ShapesUser) (sqr1);
  126.         recorder.writeln("Square perimeter: "+su.getPerimeter() +" Area: "+su.getArea(),true);
  127.         recorder.close();
  128.     }
  129.     public static void printInstances(){
  130.         recorder.writeln("# of rectangles: "+Rectangle.getObjectCount(),true);
  131.         recorder.writeln("# of triangles: "+Triangle.getObjectCount(),true);
  132.         recorder.writeln("# of circles: "+Circle.getObjectCount(),true);
  133.         recorder.writeln("# of squares: "+Square.getObjectCount(),true);
  134.         recorder.writeln("********************",true);
  135.     }
  136.    
  137. }
  138. --Definable--
  139. package cse1102.geometry;
  140.  
  141. public interface Definable {
  142.  
  143.     String getObjectDefinition();
  144.  
  145. }
  146. --ShapesUser--
  147. package cse1102.geometry;
  148.  
  149. public interface ShapesUser {
  150.     public abstract void deltaMove(int deltaX,int deltaY);
  151.     public abstract Double getArea();
  152.     public abstract Double getPerimeter();
  153. }
  154. --Shape--
  155. package cse1102.geometry;
  156.  
  157. public class Shape {
  158.     private String type;
  159.     private String lineColor;
  160.     private String fillColor;
  161.     public void Shape(){
  162.         this.type="";
  163.         this.lineColor="";
  164.         this.fillColor="";
  165.     }
  166.    
  167.     public String toString(){
  168.         String message = this.type +"\n" +
  169.     "lineColor  = " + this.lineColor + "\n" +
  170.     "fillColor  = " + this.fillColor + "\n";
  171.         return message;
  172.     }
  173.  
  174.     public String getType() {
  175.         return type;
  176.     }
  177.  
  178.     public void setType(String type) {
  179.         this.type = type;
  180.     }
  181.  
  182.     public String getLineColor() {
  183.         return lineColor;
  184.     }
  185.  
  186.     public void setLineColor(String lineColor) {
  187.         this.lineColor = lineColor;
  188.     }
  189.  
  190.     public String getFillColor() {
  191.         return fillColor;
  192.     }
  193.  
  194.     public void setFillColor(String fillColor) {
  195.         this.fillColor = fillColor;
  196.     }
  197. }
  198. --Rectangle--
  199. package cse1102.geometry;
  200.  
  201. public class Rectangle extends Shape implements Definable, ShapesUser{
  202.     private Vertex vertex1;
  203.     private Vertex vertex2;
  204.     private Vertex vertex3;
  205.     private Vertex vertex4;
  206.     private int length;
  207.     private int width;
  208.    
  209.     private static int instances = 0;
  210.     public Rectangle(){
  211.         super();
  212.         instances++;       
  213.         super.setType("Rectangle");
  214.     }
  215.     public Rectangle(int originX, int originY, int length, int width){
  216.         this();
  217.         this.vertex1=new Vertex(originX, originY);
  218.         this.vertex2=new Vertex(originX,originY+width);
  219.         this.vertex3=new Vertex(originX+length,originY+width);
  220.         this.vertex4=new Vertex(originX+length,originY);
  221.         this.length=length;
  222.         this.width=width;
  223.     }
  224.     @Override
  225.     public void deltaMove(int deltaX, int deltaY){
  226.         vertex1.deltaMove(deltaX, deltaY);
  227.         vertex2.deltaMove(deltaX, deltaY);
  228.         vertex3.deltaMove(deltaX, deltaY);
  229.         vertex4.deltaMove(deltaX, deltaY);
  230.     }
  231.     @Override
  232.     public Double getArea(){
  233.         return (double) (length*width);
  234.     }
  235.     @Override
  236.     public Double getPerimeter(){
  237.         return (double) (2*length+2*width);
  238.     }
  239.  
  240.     public static int getObjectCount(){
  241.         return instances;
  242.     }
  243.     public int getLength() {
  244.         return length;
  245.     }
  246.     public int getWidth() {
  247.         return width;
  248.     }
  249.     public Vertex getVertex1() {
  250.         return vertex1;
  251.     }
  252.     public Vertex getVertex2() {
  253.         return vertex2;
  254.     }
  255.     public Vertex getVertex3() {
  256.         return vertex3;
  257.     }
  258.     public Vertex getVertex4() {
  259.         return vertex4;
  260.     }
  261.  
  262.     public String getObjectDefinition() {
  263.         String message = super.toString() + "\n" +
  264.                  "origin        = " + this.vertex1.getX() + " , " + this.vertex1.getY() + "\n" +
  265.                  "vertex 2 x,y  = " + this.vertex2.getX() + " , " + this.vertex2.getY() + "\n" +
  266.                  "vertex 3 x,y  = " + this.vertex3.getX() + " , " + this.vertex3.getY() + "\n" +
  267.                  "vertex 4 x,y  = " + this.vertex4.getX() + " , " + this.vertex4.getY() + "\n" +
  268.                  "width         = " + this.width + "\n" +
  269.               "length        = " + this.length + "\n";
  270.         return message;
  271.     }
  272. }
  273. --Triangle--
  274. package cse1102.geometry;
  275.  
  276. public class Triangle extends Shape implements ShapesUser, Definable{
  277.     private static int instances = 0;
  278.     private Vertex vertex1;
  279.     private Vertex vertex2;
  280.     private Vertex vertex3;
  281.     private int base;
  282.     private int offset;
  283.     private int height;
  284.     public Triangle(){
  285.         super();
  286.         instances++;       
  287.         super.setType("Triangle");
  288.     }
  289.     public Triangle(int originX, int originY, int height, int base, int offset){
  290.         this();
  291.         this.vertex1=new Vertex(originX, originY);
  292.         this.vertex2=new Vertex(originX+offset,originY+height);
  293.         this.vertex3=new Vertex(originX+base,originY);
  294.         this.base=base;
  295.         this.offset=offset;
  296.         this.height=height;
  297.     }
  298.     public Vertex getVertex1() {
  299.         return vertex1;
  300.     }
  301.     public Vertex getVertex2() {
  302.         return vertex2;
  303.     }
  304.     public Vertex getVertex3() {
  305.         return vertex3;
  306.     }
  307.     public int getBase() {
  308.         return base;
  309.     }
  310.     public int getOffset() {
  311.         return offset;
  312.     }
  313.     public int getHeight() {
  314.         return height;
  315.     }
  316.     @Override
  317.     public void deltaMove(int deltaX, int deltaY){
  318.         vertex1.deltaMove(deltaX, deltaY);
  319.         vertex2.deltaMove(deltaX, deltaY);
  320.         vertex3.deltaMove(deltaX, deltaY);
  321.     }
  322.     @Override
  323.     public Double getArea(){
  324.         return (double) (base*height/2);
  325.     }
  326.     @Override
  327.     public Double getPerimeter(){
  328.         double side1 = Math.sqrt(Math.pow(offset,2)+Math.pow(height,2));
  329.         double side2 = Math.sqrt(Math.pow(base-offset,2)+Math.pow(height,2));
  330.         return (base+side1+side2);
  331.     }
  332.  
  333.     public boolean equals(Triangle t2){
  334.         boolean tests = false;
  335.         if (this.base==t2.base) {
  336.             if (this.offset==t2.offset){
  337.                 if(this.height==t2.height){
  338.                     tests=true;
  339.                 }
  340.             }
  341.         }
  342.         else{
  343.             tests=false;
  344.         }
  345.         return tests;
  346.        
  347.     }
  348.     public static int getObjectCount() {
  349.         return instances;
  350.     }
  351.     public String getObjectDefinition() {
  352.         String message = super.toString() + "\n" +
  353.                 "origin         = " + this.vertex1.getX() + " , " + this.vertex1.getY() + "\n" +
  354.                 "vertex 2 x,y   = " + this.vertex2.getX() + " , " + this.vertex2.getY() + "\n" +
  355.             "vertex 3 x,y   = " + this.vertex3.getX() + " , " + this.vertex3.getY() + "\n" +
  356.             "height         = " + this.height + "\n" +
  357.             "base           = " + this.base + "\n" +
  358.             "offset         = " + this.offset + "\n";
  359.         return message;
  360.     }
  361. }
  362. --Circle--
  363. package cse1102.geometry;
  364.  
  365. public class Circle extends Shape implements ShapesUser, Definable{
  366.     private static int instances=0;
  367.     private Vertex vertex1;
  368.     private double radius;
  369.  
  370.     public Circle(){
  371.         super();
  372.         instances++;       
  373.         super.setType("Circle");
  374.     }
  375.     public Circle(int originX, int originY, double radius){
  376.         this();
  377.         this.vertex1 = new Vertex(originX,originY);
  378.         this.radius=radius;
  379.     }
  380.     public void deltaMove(int deltaX, int deltaY){
  381.         vertex1.deltaMove(deltaX, deltaY);
  382.     }
  383.     @Override
  384.     public Double getArea(){
  385.         Double area = (Math.sqrt(this.radius)*Math.PI);
  386.         return area;
  387.     }
  388.     @Override
  389.     public Double getPerimeter(){
  390.         double perimeter = (this.radius*2*Math.PI);
  391.         return perimeter;
  392.     }
  393.     public static int getObjectCount(){
  394.         return instances;
  395.     }
  396.     public double getRadius() {
  397.         return radius;
  398.     }
  399.     public void setRadius(double radius) {
  400.         this.radius = radius;
  401.     }
  402.     public Vertex getVertex1() {
  403.         return vertex1;
  404.     }
  405.     public String getObjectDefinition() {
  406.         String message = super.toString() +
  407.                 "origin         = " + this.vertex1.getX() + " , " + this.vertex1.getY() + "\n" +
  408.                 "radius         = " + this.radius + "\n" ;
  409.             return message;
  410.     }
  411.  
  412.  
  413. }
  414. --Square--
  415. package cse1102.geometry;
  416.  
  417. public class Square extends Shape implements ShapesUser, Definable{
  418.     private static int instances=0;
  419.     private Vertex vertex1;
  420.     private Vertex vertex2;
  421.     private Vertex vertex3;
  422.     private Vertex vertex4;
  423.     private int length;
  424.     public Square(){
  425.         super();
  426.         instances++;       
  427.         super.setType("Square");
  428.     }
  429.     public Square(int originX, int originY, int length){
  430.         this();
  431.         this.vertex1=new Vertex(originX, originY);
  432.         this.vertex2=new Vertex(originX,originY+length);
  433.         this.vertex3=new Vertex(originX+length,originY+length);
  434.         this.vertex4=new Vertex(originX+length,originY);
  435.         this.length=length;
  436.     }
  437.     @Override
  438.     public void deltaMove(int deltaX, int deltaY){
  439.         vertex1.deltaMove(deltaX, deltaY);
  440.         vertex2.deltaMove(deltaX, deltaY);
  441.         vertex3.deltaMove(deltaX, deltaY);
  442.         vertex4.deltaMove(deltaX, deltaY);
  443.     }
  444.     @Override
  445.     public Double getArea(){
  446.         return (Math.pow(length,2));
  447.     }
  448.     @Override
  449.     public Double getPerimeter(){
  450.         return (double) (4*length);
  451.     }
  452.     public static int getObjectCount(){
  453.         return instances;
  454.     }
  455.     public int getLength() {
  456.         return length;
  457.     }
  458.     public int getWidth() {
  459.         return length;
  460.     }
  461.     public Vertex getVertex1() {
  462.         return vertex1;
  463.     }
  464.     public Vertex getVertex2() {
  465.         return vertex2;
  466.     }
  467.     public Vertex getVertex3() {
  468.         return vertex3;
  469.     }
  470.     public Vertex getVertex4() {
  471.         return vertex4;
  472.     }
  473.     public String getObjectDefinition() {
  474.         String message = super.toString() + "\n" +
  475.                  "origin        = " + this.vertex1.getX() + " , " + this.vertex1.getY() + "\n" +
  476.                  "vertex 2 x,y  = " + this.vertex2.getX() + " , " + this.vertex2.getY() + "\n" +
  477.                  "vertex 3 x,y  = " + this.vertex3.getX() + " , " + this.vertex3.getY() + "\n" +
  478.                  "vertex 4 x,y  = " + this.vertex4.getX() + " , " + this.vertex4.getY() + "\n" +
  479.                  "width         = " + this.length + "\n" +
  480.               "length        = " + this.length + "\n";
  481.         return message;
  482.     }
  483. }
  484. --Vertex--
  485. package cse1102.geometry;
  486.  
  487. public class Vertex {
  488.     private int x;
  489.     private int y;
  490.     public Vertex(){
  491.         this.x=0;
  492.         this.y=0;
  493.     }
  494.     public Vertex(int x, int y){
  495.         this.x=x;
  496.         this.y=y;
  497.     }
  498.    
  499.     public int getX() {
  500.         return x;
  501.     }
  502.     public void setX(int x) {
  503.         this.x = x;
  504.     }
  505.     public int getY() {
  506.         return y;
  507.     }
  508.     public void setY(int y) {
  509.         this.y = y;
  510.     }
  511.    
  512.     public void deltaMove(int deltaX, int deltaY){
  513.         this.x+=deltaX;
  514.         this.y+=deltaY;
  515.     }
  516.    
  517.     public String toString(){
  518.         String message = "Type = Vertex" + "\n" +
  519.                         "X coordinate   = " + this.x + "\n" +
  520.                         "Y coordinate   = " + this.y + "\n";
  521.         return message;
  522.     }
  523. }
  524. --Recorder--
  525. //  Program Name: Recorder
  526. //  Purpose: Write a string to a file and optionally to the console
  527. //  Revision History
  528. //  Revision    Date        Author      Comment
  529. //  1.0         2/26/13     W. Beacham  Initial Release
  530. //
  531.  
  532. /*
  533.  * How to use this class.
  534.  * 1. Call the constructor with the name of the file as the argument. Omit the path,
  535.  * just supply the file name and extension. The file will be created in the same
  536.  * directory that contains the project src directory in your workspace.
  537.  * 2. The write() method writes the supplied string to the file without adding a
  538.  * final "\n". Similar to System.out.print() method. If the second argument = true,
  539.  * the same content is written to the console.
  540.  * 3. The writeln() method writes the supplied string to the file and also adds a
  541.  * final "\n". Similar to System.out.println() method. If the second argument = true,
  542.  * the same content is written to the console.
  543.  * 4. The close() method closes the file and ensure that any buffered content is written. Using
  544.  * this method is required for stable operation.
  545.  */
  546.  
  547. package cse1102.geometry;
  548.  
  549. /******************************************************
  550.  * The <code>Recorder</code> class represents a recorder that
  551.  * is used to print strings or object descriptions to a
  552.  * data file and, if so directed, to the console window.
  553.  *
  554.  * How to use this class.
  555.  * 1. Call the constructor with the name of the file as the argument. Omit the path,
  556.  * just supply the file name and extension. The file will be created in the same
  557.  * directory that contains the project src directory in your workspace.
  558.  * 2. The write() method writes the supplied string to the file without adding a
  559.  * final "\n". Similar to System.out.print() method. If the second argument = true,
  560.  * the same content is written to the console.
  561.  * 3. The writeln() method writes the supplied string to the file and also adds a
  562.  * final "\n". Similar to System.out.println() method. If the second argument = true,
  563.  * the same content is written to the console.
  564.  * 4. The close() method closes the file and ensure that any buffered content is written. Using
  565.  * this method is required for stable operation.
  566.  *
  567.  *  @author W.Beacham
  568.  *  @version 2.0
  569.  */
  570.  
  571. import java.io.BufferedWriter;
  572. import java.io.FileWriter;
  573. import java.io.IOException;
  574. import java.io.PrintWriter;
  575.  
  576. public class Recorder {
  577.     /*******************************************************
  578.     * Instance variables
  579.     ********************************************************/
  580.     private String filename;
  581.     private PrintWriter pw;
  582.     private boolean successfulCreation;
  583.    
  584.     /******************************************************
  585.      * Creates a recorder object
  586.      * @param filename the name of the file to store data. See
  587.      * project directory
  588.      *******************************************************/
  589.     public Recorder(String filename){
  590.         this.filename = filename;
  591.         try{
  592.             FileWriter fw = new FileWriter(this.filename);
  593.             BufferedWriter bw = new BufferedWriter(fw, 8192);
  594.             pw = new PrintWriter(bw);
  595.         }
  596.         catch (IOException e){
  597.             System.out.println(e);
  598.         }
  599.     }
  600.    
  601.     //getter for the success flag
  602.     /*********************************************************
  603.      * Returns a <code>Boolean</code> that indicates if the file
  604.      * was successfully created
  605.      * @return True if file successfully created
  606.      **********************************************************/
  607.     public boolean isSuccessfulCreation() {
  608.         return successfulCreation;
  609.     }
  610.  
  611.     //regular method to write content w/o a final new line
  612.     /***********************************************************
  613.      * Writes a string to the data file and console window.
  614.      * @param content String of data to store
  615.      * @param console If set to true, write to the console also
  616.      ***********************************************************/
  617.     public void write(String content, boolean console){
  618.             pw.write(content);
  619.             if (console) {
  620.                 System.out.print(content);
  621.             }
  622.     }
  623.    
  624.     //regular method to write content with a final new line
  625.     /*************************************************************
  626.      * Writes a string with a trailing \n to the data file and
  627.      * console window.
  628.      * @param content String of data to store
  629.      * @param console If set to true, write to the console also
  630.      *************************************************************/
  631.     public void writeln(String content, boolean console){
  632.         pw.write(content + "\n");
  633.         if (console) {
  634.             System.out.println(content);
  635.         }
  636.     }
  637.    
  638.     //regular method to the content of a Shape
  639.     /***************************************************************
  640.      * Invokes the toString method of the shape that is passed in to
  641.      * print the shape description with a trailing \n to the data file
  642.      * and console window.
  643.      * @param definable Object of type definable or a sub class
  644.      * @param console if set to true, write to the console also
  645.      ***************************************************************/
  646.     public void writeln(Definable definable, boolean console){
  647.         pw.write(definable.getObjectDefinition() + "\n");
  648.         if (console) {
  649.             System.out.println(definable.getObjectDefinition());
  650.         }
  651.     }
  652.     public void writeObject(Definable d){
  653.         System.out.println(d.getObjectDefinition());
  654.     }
  655.     //regular method to print the content of a Shape
  656.     /****************************************************************
  657.      * Invokes the toString method of the shape that is passed in to
  658.      * print the shape description with a trailing \n to the console
  659.      * window only.
  660.      * @param shape Object of tyope shape or a sub class
  661.      ****************************************************************/
  662.     public void writeln(Shape shape){
  663.             System.out.println(shape.toString());
  664.     }
  665.  
  666.     //regular method to close the file
  667.     /****************************************************************
  668.      * Closes out the data file. THis will force any remaining buffered
  669.      * data to be written.
  670.      ****************************************************************/
  671.     public void close(){
  672.         pw.close();
  673.     }
  674. }
Advertisement
Add Comment
Please, Sign In to add comment