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
10 changes: 10 additions & 0 deletions src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package src;

public class Main {
public static void main(String[] args) {
Rectangle myRectangle = new Rectangle(10, 5);
myRectangle.getperimeter();
myRectangle.getarea();
}
}

25 changes: 25 additions & 0 deletions src/Rectangle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package src;

public class Rectangle {
public int length;
public int width;
public int perimeter;
public int area;


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

}
public void getperimeter(){
perimeter = 2 * (length+width);
System.out.println("Периметр прямокутника = " + perimeter + " (см).");
}
public void getarea(){
area = length * width;
System.out.println("Площа прямокутника = " + area + " (см²).");
}
}