Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.03 KB | None | 0 0
  1. package home;
  2. import java.awt.Container;
  3. import java.awt.Dimension;
  4. import java.awt.FlowLayout;
  5. import java.awt.Font;
  6. import java.awt.Graphics;
  7. import java.awt.GridLayout;
  8. import java.awt.event.KeyAdapter;
  9. import java.awt.event.KeyEvent;
  10. import java.awt.event.KeyListener;
  11. import java.time.LocalTime;
  12. import java.util.ArrayList;
  13.  
  14. import javax.swing.JComponent;
  15. import javax.swing.JFrame;
  16. import javax.swing.JLabel;
  17. import javax.swing.JPanel;
  18. import javax.swing.JTabbedPane;
  19. import javax.swing.JTextArea;
  20.  
  21. public class lastgui extends JFrame {
  22.  
  23. private static ArrayList<Menu> sal= Ordered.odr;
  24. private JLabel lbl = null;
  25. private static int totsal=0;
  26. private static int ch=0;
  27. private static int coc=0;
  28. private static int chcon=0;
  29. private static int coccon=0;
  30. static String tosal=null;
  31. static String chsal=null;
  32. static String chco=null;
  33. static String cocsal=null;
  34. static String cocco=null;
  35.  
  36. private lastgui() {
  37. setBounds(700, 400, 500, 500);
  38. setDefaultCloseOperation(EXIT_ON_CLOSE);
  39. setLayout(null);
  40.  
  41. addKeyListener(new KeyAdapter() {
  42. @Override
  43. public void keyPressed(KeyEvent e) {
  44.  
  45. switch(e.getKeyCode()) {
  46. case KeyEvent.VK_1:
  47. sales();
  48. break;
  49. }
  50. }
  51. });
  52. setVisible(true);
  53. }
  54. private void sales() {
  55. JPanel pane1= new JPanel();
  56. JPanel pane2= new JPanel();
  57. JPanel pane3= new JPanel();
  58. JTabbedPane tpane = new JTabbedPane();
  59. JTextArea txt1 = new JTextArea();
  60. JTextArea txt2 = new JTextArea();
  61. JTextArea txt3 = new JTextArea();
  62. Container root = getContentPane();
  63.  
  64. tpane.setBounds(300, 300, 300, 300);
  65. txt1.setColumns(20);
  66. txt2.setColumns(20);
  67. txt3.setColumns(20);
  68. txt1.setRows(10);
  69. txt2.setRows(10);
  70. txt3.setRows(10);
  71. txt1.setFont(new Font("고딕",0,20));
  72. txt2.setFont(new Font("고딕",0,20));
  73. txt3.setFont(new Font("고딕",0,20));
  74. txt1.setLineWrap(true);
  75. txt2.setLineWrap(true);
  76. txt3.setLineWrap(true);
  77.  
  78.  
  79. txt1.setText("판매 횟수 \t"+"매출\n"+
  80. chco+"\t"+chsal+"\n");
  81. txt2.setText("판매 횟수\t"+"매출\n"+cocco+"\t"+cocsal+"\n");
  82. txt3.setText("총 매출액은 : "+tosal+"원 입니다");
  83. pane1.add(txt1);
  84. pane2.add(txt2);
  85. pane3.add(txt3);
  86. tpane.add("치킨 ", pane1);
  87. tpane.add("콜라 ", pane2);
  88. tpane.add("총 매출 ", pane3);
  89.  
  90. root.add(tpane);
  91.  
  92. newJFrame(tpane);
  93. }
  94. private void newJFrame(JComponent c) {
  95. JFrame frame = new JFrame("매출정보");
  96. frame.setBounds(800, 300, 400, 400);
  97. frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
  98. JPanel panel1 = new JPanel();
  99. panel1.add(c);
  100. frame.getContentPane().add(panel1);
  101. frame.setVisible(true);
  102. }
  103.  
  104. public static void main(String[] args) {
  105.  
  106. lastgui sal = new lastgui();
  107.  
  108. Ordered.initodr();
  109. for(int i=0; i<4; i++) {
  110. ArrayList<Integer> pricelist = new ArrayList<Integer>();
  111. int pri = Ordered.odr.get(i).price;
  112. // System.out.println( (i+1) +"번째 팔리고 : " + pri+"원" );
  113. pricelist.add(Ordered.odr.get(i).price);
  114. ch+=pri;
  115. chcon++;
  116. }
  117. System.out.printf("치킨은 %d번 팔리고, 매출은 %d 원입니다.\n", chcon, ch);
  118.  
  119. for(int i=0; i<2; i++) {
  120. ArrayList<Integer> pricelist = new ArrayList<Integer>();
  121. int pri = Ordered.odr.get(i).price;
  122. // System.out.println( (i+1) +"번째 팔리고 : " + pri+"원" );
  123. pricelist.add(Ordered.odr.get(i).price);
  124. coc+=pri;
  125. coccon++;
  126.  
  127. }
  128. System.out.printf("콜라는 %d번 팔리고, 매출은 %d 원입니다.\n", coccon, coc); //占쏙옙 占쌨댐옙占쏙옙 占쏙옙占쏙옙 횟占쏙옙
  129.  
  130.  
  131. int totalSales = sal.calculateSales();
  132. System.out.println("총 매출액은 : " + totalSales + "원 입니다.");
  133. tosal = Integer.toString(totalSales);
  134. chsal = Integer.toString(ch);
  135. chco =Integer.toString(chcon);
  136. cocsal = Integer.toString(coc);
  137. cocco = Integer.toString(coccon);
  138. }
  139. public int calculateSales() {
  140. totsal+=ch+coc;
  141. int totalSales = totsal;
  142. System.out.println("==================");
  143. return totalSales;
  144. }
  145.  
  146. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement