Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class square {
- private int length, width;
- public square(int length, int width) {
- this.length = length;
- this.width = width;
- }
- public square() {
- length = 10;
- width = 10;
- }
- public int getLength() {
- return length;
- }
- public void setLength(int length) {
- this.length = length;
- }
- public int getWidth() {
- return width;
- }
- public void setWidth(int width) {
- this.width = width;
- }
- public String scope() {
- String calc = width > 0 && length > 0 ? "the scope of the Square is: " + ((width * 2) + (length * 2)) : "the number is under 0";
- return calc;
- }
- public String area() {
- String calc = width > 0 && length > 0 ? "the area of the Square is: " + (width * length) : "the number is under 0";
- return calc;
- }
- public void printstars() {
- for (int i = 0; i < length; i++) {
- for (int j = 0; j < width; j++) {
- System.out.print("*");
- }
- System.out.println();
- }
- }
- public void printuserch(char ch) {
- for (int i = 0; i < length; i++) {
- for (int j = 0; j < width; j++) {
- System.out.print(ch);
- }
- System.out.println();
- }
- }
- }
Add Comment
Please, Sign In to add comment