Created
August 13, 2019 11:50
-
-
Save 0ryant/25cf8679ed62491d5bbcb173a214d8cd to your computer and use it in GitHub Desktop.
Java - Coding Challenge - Classes; Wall Area
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Wall { | |
// Params | |
private double width; | |
private double height; | |
// Constructors | |
public Wall() { | |
} | |
public Wall(double width,double height){ | |
this.width=width; | |
this.height=height; | |
if (width<0){ | |
this.width=0; | |
} | |
if (height<0){ | |
this.height=0; | |
} | |
} | |
// Getters | |
public double getWidth() { | |
return width; | |
} | |
public double getHeight() { | |
return height; | |
} | |
// Setters | |
public void setWidth(double width) { | |
if (width<0){ | |
this.width=0; | |
} else { | |
this.width = width; | |
} | |
} | |
public void setHeight(double height) { | |
if (height<0){ | |
this.height=0; | |
} else { | |
this.height = height; | |
} | |
} | |
// Extra Methods | |
public double getArea(){ | |
return (this.height*this.width); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment