public void deplacerDisques() { int disque = 0; if (prendre_tour == 1) { System.out.println("-- POP Pile 1 --"); disque = stackTower1.head(); stackTower1.pop(); } else if (prendre_tour == 2) { System.out.println("-- POP Pile 2 --"); disque = stackTower2.head(); stackTower2.pop(); } else if (prendre_tour == 3) { System.out.println("-- POP Pile 3 --"); disque = stackTower3.head(); stackTower3.pop(); } else { } if (deposer_tour == 1) { System.out.println("-- PUSH Pile 1 --"); stackTower1.push(disque); } else if (deposer_tour == 2) { System.out.println("-- PUSH Pile 2 --"); stackTower2.push(disque); } else if (deposer_tour == 3) { System.out.println("-- PUSH Pile 3 --"); stackTower3.push(disque); } else { } }
public void initialiserAttributs() { this.stackTower1 = new Pile(3); this.stackTower2 = new Pile(3); this.stackTower3 = new Pile(3); stackTower1.push(3); stackTower1.push(2); stackTower1.push(1); this.nombre_coups = 0; this.prendre_tour = 0; this.deposer_tour = 0; this.fin = false; this.tower1TopLeft = 50; this.tower2TopLeft = 350; this.tower3TopLeft = 650; fen = new JFrame(); fen.setSize(900, 700); fen.setLocationRelativeTo(null); fen.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); fen.setResizable(false); pan = new JPanel(); pan.setBackground(Color.white); process = new JLabel("JEU : LES TOURS DE HANOI"); process.setHorizontalAlignment(SwingConstants.CENTER); process.setSize(800, 50); process.setOpaque(true); process.setBackground(new Color(234, 195, 138)); process.setForeground(Color.WHITE); infos = new JLabel("TEST"); infos.setHorizontalAlignment(SwingConstants.CENTER); infos.setSize(400, 50); infos.setOpaque(true); infos.setBackground(Color.RED); infos.setForeground(Color.WHITE); infos_coups = new JLabel("Coups : 0"); infos_coups.setHorizontalAlignment(SwingConstants.CENTER); infos_coups.setSize(100, 50); infos_coups.setOpaque(true); infos_coups.setBackground(Color.RED); infos_coups.setForeground(Color.WHITE); imageTower1 = new JLabel(""); imageTower1.setSize(200, 400); imageTower1.setOpaque(true); imageTower1.setIcon(new ImageIcon("tour.png")); imageTower2 = new JLabel(""); imageTower2.setSize(200, 400); imageTower2.setOpaque(true); imageTower2.setIcon(new ImageIcon("tour.png")); imageTower3 = new JLabel(""); imageTower3.setSize(200, 400); imageTower3.setOpaque(true); imageTower3.setIcon(new ImageIcon("tour.png")); discBig = new JLabel(""); discBig.setSize(160, 40); discBig.setOpaque(true); discBig.setBackground(Color.RED); discMeduim = new JLabel(""); discMeduim.setSize(130, 40); discMeduim.setOpaque(true); discMeduim.setBackground(Color.GREEN); discSmall = new JLabel(""); discSmall.setSize(100, 40); discSmall.setOpaque(true); discSmall.setBackground(Color.BLUE); buttonTower1 = new JButton(" Tour 1"); buttonTower1.setSize(150, 50); buttonTower1.addActionListener(this); buttonTower2 = new JButton(" Tour 2"); buttonTower2.setSize(150, 50); buttonTower2.addActionListener(this); buttonTower3 = new JButton(" Tour 3 "); buttonTower3.setSize(150, 50); buttonTower3.addActionListener(this); this.activerBoutonModePrendre(); }