6 | public class CameraShop{ |
7 | protected static final String[] PRODUCT_NAMES = {"デジショットC6","メモリーメディア128M"}; |
8 | protected static final int PRODUCT_TYPE_CAMERA = 0; |
〜省略〜 |
14 | int memoryStock; |
15 | |
16 | public static void main(String[] args){ |
17 | CameraShop myCameraShop = new CameraShop(); |
18 | myCameraShop.open(); |
19 | myCameraShop.doBusiness(); |
20 | myCameraShop.close(); |
21 | } |
〜省略〜 |
67 | protected int sell(int type) throws Exception { |
〜省略〜 |
71 | switch(type){ |
72 | case PRODUCT_TYPE_CAMERA: |
73 | numberRequired=getOrder(PRODUCT_NAMES[PRODUCT_TYPE_CAMERA] |
〜省略〜 |
76 | cameraStock = cameraStock - numberRequired; |
77 | sales = PRODUCT_BASIC_PRICES[PRODUCT_TYPE_CAMERA]*numberRequired |
78 | break; |
79 | case PRODUCT_TYPE_MEMORY: |
〜省略〜 |
86 | default: |
87 | throw new Exception("DON'T EXIST THIS TYPE"); |
88 | } |
〜省略〜 |
91 | } |