Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package home;
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.FlowLayout;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.GridLayout;
- import java.awt.event.KeyAdapter;
- import java.awt.event.KeyEvent;
- import java.awt.event.KeyListener;
- import java.time.LocalTime;
- import java.util.ArrayList;
- import javax.swing.JComponent;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- import javax.swing.JTabbedPane;
- import javax.swing.JTextArea;
- public class lastgui extends JFrame {
- private static ArrayList<Menu> sal= Ordered.odr;
- private JLabel lbl = null;
- private static int totsal=0;
- private static int ch=0;
- private static int coc=0;
- private static int chcon=0;
- private static int coccon=0;
- static String tosal=null;
- static String chsal=null;
- static String chco=null;
- static String cocsal=null;
- static String cocco=null;
- private lastgui() {
- setBounds(700, 400, 500, 500);
- setDefaultCloseOperation(EXIT_ON_CLOSE);
- setLayout(null);
- addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent e) {
- switch(e.getKeyCode()) {
- case KeyEvent.VK_1:
- sales();
- break;
- }
- }
- });
- setVisible(true);
- }
- private void sales() {
- JPanel pane1= new JPanel();
- JPanel pane2= new JPanel();
- JPanel pane3= new JPanel();
- JTabbedPane tpane = new JTabbedPane();
- JTextArea txt1 = new JTextArea();
- JTextArea txt2 = new JTextArea();
- JTextArea txt3 = new JTextArea();
- Container root = getContentPane();
- tpane.setBounds(300, 300, 300, 300);
- txt1.setColumns(20);
- txt2.setColumns(20);
- txt3.setColumns(20);
- txt1.setRows(10);
- txt2.setRows(10);
- txt3.setRows(10);
- txt1.setFont(new Font("고딕",0,20));
- txt2.setFont(new Font("고딕",0,20));
- txt3.setFont(new Font("고딕",0,20));
- txt1.setLineWrap(true);
- txt2.setLineWrap(true);
- txt3.setLineWrap(true);
- txt1.setText("판매 횟수 \t"+"매출\n"+
- chco+"\t"+chsal+"\n");
- txt2.setText("판매 횟수\t"+"매출\n"+cocco+"\t"+cocsal+"\n");
- txt3.setText("총 매출액은 : "+tosal+"원 입니다");
- pane1.add(txt1);
- pane2.add(txt2);
- pane3.add(txt3);
- tpane.add("치킨 ", pane1);
- tpane.add("콜라 ", pane2);
- tpane.add("총 매출 ", pane3);
- root.add(tpane);
- newJFrame(tpane);
- }
- private void newJFrame(JComponent c) {
- JFrame frame = new JFrame("매출정보");
- frame.setBounds(800, 300, 400, 400);
- frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
- JPanel panel1 = new JPanel();
- panel1.add(c);
- frame.getContentPane().add(panel1);
- frame.setVisible(true);
- }
- public static void main(String[] args) {
- lastgui sal = new lastgui();
- Ordered.initodr();
- for(int i=0; i<4; i++) {
- ArrayList<Integer> pricelist = new ArrayList<Integer>();
- int pri = Ordered.odr.get(i).price;
- // System.out.println( (i+1) +"번째 팔리고 : " + pri+"원" );
- pricelist.add(Ordered.odr.get(i).price);
- ch+=pri;
- chcon++;
- }
- System.out.printf("치킨은 %d번 팔리고, 매출은 %d 원입니다.\n", chcon, ch);
- for(int i=0; i<2; i++) {
- ArrayList<Integer> pricelist = new ArrayList<Integer>();
- int pri = Ordered.odr.get(i).price;
- // System.out.println( (i+1) +"번째 팔리고 : " + pri+"원" );
- pricelist.add(Ordered.odr.get(i).price);
- coc+=pri;
- coccon++;
- }
- System.out.printf("콜라는 %d번 팔리고, 매출은 %d 원입니다.\n", coccon, coc); //占쏙옙 占쌨댐옙占쏙옙 占쏙옙占쏙옙 횟占쏙옙
- int totalSales = sal.calculateSales();
- System.out.println("총 매출액은 : " + totalSales + "원 입니다.");
- tosal = Integer.toString(totalSales);
- chsal = Integer.toString(ch);
- chco =Integer.toString(chcon);
- cocsal = Integer.toString(coc);
- cocco = Integer.toString(coccon);
- }
- public int calculateSales() {
- totsal+=ch+coc;
- int totalSales = totsal;
- System.out.println("==================");
- return totalSales;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement