diff --git a/NetBeans Projects/shape/nbproject/private/private.properties b/NetBeans Projects/shape/nbproject/private/private.properties index e17ea87..a2ad8bd 100644 --- a/NetBeans Projects/shape/nbproject/private/private.properties +++ b/NetBeans Projects/shape/nbproject/private/private.properties @@ -1,2 +1,2 @@ compile.on.save=true -user.properties.file=/home/gicorada/.netbeans/17/build.properties +user.properties.file=/home/giacomo/.netbeans/17/build.properties diff --git a/NetBeans Projects/shape/nbproject/private/private.xml b/NetBeans Projects/shape/nbproject/private/private.xml index b79dd47..452ba67 100644 --- a/NetBeans Projects/shape/nbproject/private/private.xml +++ b/NetBeans Projects/shape/nbproject/private/private.xml @@ -3,10 +3,7 @@ - file:/home/gicorada/NetBeansProjects/shape/src/shape/Shape.java - file:/home/gicorada/NetBeansProjects/shape/src/shape/Circle.java - file:/home/gicorada/NetBeansProjects/shape/src/shape/Rectangle.java - file:/home/gicorada/NetBeansProjects/shape/src/shape/Tester.java + file:/home/giacomo/Scrivania/Scuola/Informatica/java-scuola/NetBeans%20Projects/shape/src/shape/Shape.java diff --git a/NetBeans Projects/shape/nbproject/project.properties b/NetBeans Projects/shape/nbproject/project.properties index a8b4a4a..a0200a4 100644 --- a/NetBeans Projects/shape/nbproject/project.properties +++ b/NetBeans Projects/shape/nbproject/project.properties @@ -75,7 +75,7 @@ main.class=shape.Tester manifest.file=manifest.mf meta.inf.dir=${src.dir}/META-INF mkdist.disabled=false -platform.active=Zulu_17.0.6_10 +platform.active=Oracle_OpenJDK_20_36 run.classpath=\ ${javac.classpath}:\ ${build.classes.dir} diff --git a/NetBeans Projects/shape/src/shape/Circle.java b/NetBeans Projects/shape/src/shape/Circle.java index 7a1d389..9cc6e77 100644 --- a/NetBeans Projects/shape/src/shape/Circle.java +++ b/NetBeans Projects/shape/src/shape/Circle.java @@ -1,43 +1,41 @@ -/* - * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license - * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template - */ package shape; /** * - * @author gicorada + * @author radaelli11353 */ public class Circle extends Shape { - private int xc, yc, r; + private double xc; + private double yc; + private double r; - public Circle(int xc, int yc, int r) { + public Circle(double xc, double yc, double r) { this.xc = xc; this.yc = yc; this.r = r; } - public void setRadius(int r) { + public void setRadius(double r) { this.r = r; } @Override - public int width() { + public double width() { return r*2; } @Override - public int height() { + public double height() { return r*2; } @Override - public int posX() { + public double posX() { return xc - r; } @Override - public int posY() { + public double posY() { return yc - r; } @@ -55,6 +53,6 @@ public class Circle extends Shape { if (o == null) return false; if (getClass() != o.getClass()) return false; Circle c = (Circle) o; - return (xc == c.xc && yc == c.yc) && r == c.r; + return Double.compare(xc, c.xc) && Double.compare(yc, c.yc) && Double.compare(r, c.r); } } diff --git a/NetBeans Projects/shape/src/shape/Rectangle.java b/NetBeans Projects/shape/src/shape/Rectangle.java index 0d43785..90b827e 100644 --- a/NetBeans Projects/shape/src/shape/Rectangle.java +++ b/NetBeans Projects/shape/src/shape/Rectangle.java @@ -1,17 +1,16 @@ -/* - * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license - * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template - */ package shape; /** * - * @author gicorada + * @author radaelli11353 */ public class Rectangle extends Shape { - private int x, y, w, h; + private double x; + private double y; + private double w; + private double h; - public Rectangle(int x, int y, int w, int h) { + public Rectangle(double x, double y, double w, double h) { this.x = x; this.y = y; this.w = w; @@ -19,22 +18,22 @@ public class Rectangle extends Shape { } @Override - public int width() { + public double width() { return w; } @Override - public int height() { + public double height() { return h; } @Override - public int posX() { + public double posX() { return x; } @Override - public int posY() { + public double posY() { return y; } @@ -53,8 +52,6 @@ public class Rectangle extends Shape { if (o == null) return false; if (getClass() != o.getClass()) return false; Rectangle r = (Rectangle) o; - return w == r.w && h == r.h && x == r.x && y == r.y; - } - - + return Double.compare(r, r.w) && Double.compare(h, r.h) && Double.compare(x, r.x) && Double.compare(y, r.y); + } } diff --git a/NetBeans Projects/shape/src/shape/Shape.java b/NetBeans Projects/shape/src/shape/Shape.java index 9827f1c..b3ca0e4 100644 --- a/NetBeans Projects/shape/src/shape/Shape.java +++ b/NetBeans Projects/shape/src/shape/Shape.java @@ -1,23 +1,17 @@ -/* - * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license - * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template - */ package shape; /** * - * @author gicorada + * @author radaelli11353 */ public abstract class Shape implements Comparable { - private int w, h, x, y; - - public abstract int width(); - public abstract int height(); - public abstract int posX(); - public abstract int posY(); + public abstract double width(); + public abstract double height(); + public abstract double posX(); + public abstract double posY(); @Override public int compareTo(Shape o) { - return width()*height() - o.width()*o.height(); + return Double.compare(width() * height(), o.width() * o.height()); } -} \ No newline at end of file +}