지비 백화점에 가전매장과 의류매장, 식품매장이 있습니다.
가전매장에는 TV, 냉장고, 컴퓨터를 판매합니다.
각각 500원, 200원, 100원 입니다.
의류매장에는 청바지, T셔츠, 치마를 판매합니다.
각각 300원, 200원, 800원 입니다.
식품매장에는 사과, 바나나, 포도를 판매합니다.
각각 300원, 400원, 500원입니다.
가전매장에서 TV와 냉장고를 판매했습니다.
의류매장에서 청바지와 치마를 판매했습니다.
식품매장에서 사과와 포도를 판매했습니다.
각각의 매장에서 판매한 매출금액을 출력합니다.
지비 백화점의 전체 매출금액을 출력합니다.
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | package mypackage; public class Variables { public static void main(String[] args) { JiviDepartment jivi = new JiviDepartment(); jivi.em.sellTV(jivi.em.tv); jivi.em.sellRef(jivi.em.ref); jivi.clo.sellJeans(jivi.clo.jn); jivi.clo.sellSkirt(jivi.clo.sk); jivi.food.sellApple(jivi.food.apple); jivi.food.sellGrapes(jivi.food.grapes); jivi.em.displayMoney(); jivi.clo.displayMoney(); jivi.food.displayMoney(); jivi.displayMoney(); } } class JiviDepartment{ JiviDepartment(){} ElectronMart em = new ElectronMart(); ClothingMart clo = new ClothingMart(); FoodMart food = new FoodMart(); static int output; void displayMoney(){ System.out.println("지비백화점 전체 매출금액 : "+output+"원"); } } class ElectronMart{ ElectronMart(){} Tv tv = new Tv(); Refrigerator ref = new Refrigerator(); Coumpter cou = new Coumpter(); int output; void sellTV(Tv tv) { output = output+ tv.price; JiviDepartment.output = JiviDepartment.output + tv.price; } void sellRef(Refrigerator ref) { output = output+ ref.price; JiviDepartment.output = JiviDepartment.output + ref.price; } void displayMoney(){ System.out.println("가전매장의 매출금액 : "+output+"원"); } class Tv{int price = 500;} class Refrigerator{int price = 200;} class Coumpter{int price = 100;} } class ClothingMart{ ClothingMart(){} Jeans jn = new Jeans(); Tshirt ts = new Tshirt(); Skirt sk = new Skirt(); int output; void sellJeans(Jeans jn) { output = output + jn.price; JiviDepartment.output = JiviDepartment.output + jn.price; } void sellSkirt(Skirt sk) { output = output + sk.price; JiviDepartment.output = JiviDepartment.output + sk.price; } void displayMoney(){ System.out.println("가전매장의 매출금액 : "+output+"원"); } class Jeans{int price = 300;} class Tshirt{int price = 200;} class Skirt{int price = 800;} } class FoodMart{ FoodMart(){} Apple apple = new Apple(); Banana banana = new Banana(); Grapes grapes = new Grapes(); int output; void sellApple(Apple apple) { output = output + apple.price; JiviDepartment.output = JiviDepartment.output + apple.price; } void sellGrapes(Grapes grapes) { output = output + grapes.price; JiviDepartment.output = JiviDepartment.output + apple.price; } void displayMoney(){ System.out.println("가전매장의 매출금액 : "+output+"원"); } class Apple{int price = 300;} class Banana{int price = 400;} class Grapes{int price = 500;} } | cs |
'개발' 카테고리의 다른 글
[java] 지비 모터스 자동차 판매 매출 (0) | 2013.04.05 |
---|---|
[java] 김길동 백화점 물건 구매 (0) | 2013.04.05 |
[java] 사과를 구매한 홍길동의 돈과 지갑의 돈 확인 (0) | 2013.04.05 |
[java] Instance VS static (0) | 2013.04.05 |
[java] for문 구구단 (0) | 2013.04.05 |