Are there obvious improvements that could be made here with respect the software design for Squares and Circles? What programming constructs were you familiar with, and which did you need to look up? Assume we used a separate array for Squares and for Circles rather than one unifying Object array. How would this complicate the task of adding a new Shape (say, a Triangle) to our ObjectList class?

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
  1. Are there obvious improvements that could be made here with respect the software design for Squares and Circles?
  2. What programming constructs were you familiar with, and which did you need to look up?
  3. Assume we used a separate array for Squares and for Circles rather than one unifying Object array.
    • How would this complicate the task of adding a new Shape (say, a Triangle) to our ObjectList class?
public class Square {
private int x;
private int y;
private double sidelength;
private String shape ="(i";
public Square() {
public Square (int nx, int ny) {
x = nx;
y = ny;
}
public Square (int nx, int ny, double len) {
x = nx;
y = ny;
sidelength = len;
}
public void draw() {
System.out.println(shape);
public int getX() {
return x;
}
public void setX(int nX) {
x = nX;
}
public void setWidth(int nX) {
x = nX;
}
public int getY() {
return y;
public void setY(int nY) {
y = ny;
}
public void setHeight(int nY) {
y = nY;
public double getSidelength() {
return sidelength;
}
public void setsidelength(double sl) {
sidelength = si;
}
public double getArea() {
return sidelength * sidelength;
public String tostring() {
return shape;
}
public boolean equals (Square that) {
if (this.x == that.x & this.y == that.y && this.sidelength ==
that.sidelength) {
return true;
}
Transcribed Image Text:public class Square { private int x; private int y; private double sidelength; private String shape ="(i"; public Square() { public Square (int nx, int ny) { x = nx; y = ny; } public Square (int nx, int ny, double len) { x = nx; y = ny; sidelength = len; } public void draw() { System.out.println(shape); public int getX() { return x; } public void setX(int nX) { x = nX; } public void setWidth(int nX) { x = nX; } public int getY() { return y; public void setY(int nY) { y = ny; } public void setHeight(int nY) { y = nY; public double getSidelength() { return sidelength; } public void setsidelength(double sl) { sidelength = si; } public double getArea() { return sidelength * sidelength; public String tostring() { return shape; } public boolean equals (Square that) { if (this.x == that.x & this.y == that.y && this.sidelength == that.sidelength) { return true; }
public class Circle {
private int x;
private int y;
private double radius;
private String shape = "0";
public Circle(O {
public Circle (int nx, int ny) {
x = nx;
y = ny;
}
public Circle (int nx, int ny, double len) {
x = nx;
y = ny;
radius = len;
}
public void draw() {
System.out.println(shape);
}
public int getX() {
return x;
public void setX(int nX) {
x = nX;
}
public int getY() {
return y;
public void setY(int nY) {
y = ny;
}
public double getRadius () {
return radius;
public void setRadius (double r) {
radius = r;
public double getArea() {
return Math.PI * radius * radius;
}
public String tostring() {
return shape;
public boolean equals(Circle that) {
if (this.x == that.x & this.y == that.y && this.radius == that.radius) {
return true;
return false;
}
Transcribed Image Text:public class Circle { private int x; private int y; private double radius; private String shape = "0"; public Circle(O { public Circle (int nx, int ny) { x = nx; y = ny; } public Circle (int nx, int ny, double len) { x = nx; y = ny; radius = len; } public void draw() { System.out.println(shape); } public int getX() { return x; public void setX(int nX) { x = nX; } public int getY() { return y; public void setY(int nY) { y = ny; } public double getRadius () { return radius; public void setRadius (double r) { radius = r; public double getArea() { return Math.PI * radius * radius; } public String tostring() { return shape; public boolean equals(Circle that) { if (this.x == that.x & this.y == that.y && this.radius == that.radius) { return true; return false; }
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education