Can someone help me understand why I'm getting an error code? I think it has to do with the driver class.

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Can someone help me understand why I'm getting an error code? I think it has to do with the driver class.

Post by answerhappygod »

Can someone help me understand why I'm getting an error code? Ithink it has to do with the driver class.
Can Someone Help Me Understand Why I M Getting An Error Code I Think It Has To Do With The Driver Class 1
Can Someone Help Me Understand Why I M Getting An Error Code I Think It Has To Do With The Driver Class 1 (98.8 KiB) Viewed 48 times
Can Someone Help Me Understand Why I M Getting An Error Code I Think It Has To Do With The Driver Class 2
Can Someone Help Me Understand Why I M Getting An Error Code I Think It Has To Do With The Driver Class 2 (36.36 KiB) Viewed 48 times
public class Rectangle color) { double x; double y; double width; double height; String color; public Rectangle (double x, double y, double height, double width, String if(x < 0 || x > 1) { x = 0.0; if (y < 0 || y > 1) { y = 0.0; if (width <0 || width > 1) {width = 1; } if (height <0 || height > 1) {height = 1;} if (!color.equals("black") && !color.equals("red")! color.equals("green") && ! color.equals("blue")){ } color="red"; this.x = x; this.y = y; this.width = width; this.height = height; this.color= color; //given value will not break the rectangles outside the boundary public double getX() { return this.x; } public double getY() { return this.y; } public double getWidth() { return this.width; } public double getHeight() { return this.height; } public String getColor() { return this.color; } //This allows checking to occur public void setX(double x) { if (x + this.width <= 1) { this.x = x; public void sety (double y) { if (y + this.height<= 1) { this.y = y; public void setWidth(double w) { if (w > 0 && x + w <= 1) { this.width = w; public void setHeight (double h) { if (h> 0 && y + h <= 1) { this.height = h; public void setColor(String c) { if (!c.equals("black") && !c.equals("red") !c.equals("green") && ! c.equals("blue")) { return; this.color = c; public static boolean isValid (double x, double y, double w, double h) { if (x < 0 || x > 1) { return false if (y < 0 || y > 1) { return false; if (width <0 || width > 1) { return false; if (height <0 || height > 1) { return false; if (!color.equals("black") && !color.equals("red")! color.equals("green") && !color.equals("blue")){ return false; return true; public String toString() { String str += ""; str + "X = " + this.x +", str + "Y = " + this.y + ", str + "W = " + this.width + str + "H= " + this.height + str += "C = " + this.color; return str;
public class Driver { public static void main(String[] args) { Rectangle rect = new Rectangle(0, 0, 0.5, 0.5, "Blue"); rect.setWidth (10); rect.setHeight (10); }} System.out.println (rect.getX() + + rect.getY() + + rect.getWidth() + |||| + rect.getHeight() + "");
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply