Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
public class Main {
public static void main(String[] args) {
Rectangle rect = new Rectangle();
rect.square();
rect.perimeter();
rect.announce();
}
}
25 changes: 25 additions & 0 deletions src/Rectangle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
public class Rectangle {
int length;
int width;

Rectangle(int length, int width){
this.length = length;
this.width = width;
}

Rectangle() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or _this( 5, 5); _

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good suggestion

this.length = 5;
this.width = 5;
}

int square(){
return length * width;
}

int perimeter(){
return (length + width) * 2;
}
void announce(){
System.out.println("Площа прямокутника = " + square() + "\nПериметр прямокутника = " + perimeter());
}
}