
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | package infohiding09; public class Info090101 { public static void main(String[] args) { System.out.println("1"); Rectangle rec = new Rectangle(-1,2,3,4); System.out.println(""); System.out.println("2"); Rectangle rec2 = new Rectangle(5,2,3,4); System.out.println(""); System.out.println("3"); Rectangle rec3 = new Rectangle(5,2,9,4); System.out.println(""); rec.showArea(); rec2.showArea(); rec3.showArea(); } } class Rectangle { private int ux,uy; private int lx,ly; public Rectangle(int a, int b,int s, int d) { if(a<100&& a>0){ if((a>=s) && (b>=d)){ System.out.println("a가 더 크다."); } if((a<s)&&(b<d)){ ux= a; uy= b; lx = s; ly =d; System.out.println("범위 통과."); } } else{ System.out.println("값이 잘못되었다. 100이하0이상"); } } public void showArea() { System.out.println(""+lx+ly+ux+uy); int xlen= lx-ux; int ylen= ly -uy; System.out.println("넓이: "+ (xlen*ylen)); } } | cs |
'Python > Python Training' 카테고리의 다른 글
[Python] 화씨 섭씨 (0) | 2018.01.15 |
---|---|
[Python] 자료형, 변수문제 (0) | 2018.01.15 |
[Python] 8단원 (0) | 2018.01.10 |
[Python] 5단원 (0) | 2018.01.09 |
[Python] 7단원 함수만들기 (0) | 2018.01.09 |