mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-08 02:04:31 +08:00
Formatted with Google Java Formatter
This commit is contained in:
@ -1,8 +1,8 @@
|
|||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.Timer;
|
import javax.swing.Timer;
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.*;
|
|
||||||
|
|
||||||
public class Hanoi extends JFrame {
|
public class Hanoi extends JFrame {
|
||||||
|
|
||||||
@ -18,7 +18,6 @@ public class Hanoi extends JFrame{
|
|||||||
public JButton replay_button = new JButton();
|
public JButton replay_button = new JButton();
|
||||||
public JButton auto_button = new JButton();
|
public JButton auto_button = new JButton();
|
||||||
|
|
||||||
|
|
||||||
/* BACKEND COMPONENTS */
|
/* BACKEND COMPONENTS */
|
||||||
public ArrayList<String> movements = new ArrayList<String>();
|
public ArrayList<String> movements = new ArrayList<String>();
|
||||||
public StringBuilder stringBuilder = new StringBuilder();
|
public StringBuilder stringBuilder = new StringBuilder();
|
||||||
@ -51,8 +50,7 @@ public class Hanoi extends JFrame{
|
|||||||
int x = Stack2.get(Stack2.size() - 1);
|
int x = Stack2.get(Stack2.size() - 1);
|
||||||
Stack2.remove(Stack2.size() - 1);
|
Stack2.remove(Stack2.size() - 1);
|
||||||
Stack3.add(x);
|
Stack3.add(x);
|
||||||
}
|
} else if (temp.charAt(2) == 'A') {
|
||||||
else if(temp.charAt(2)=='A') {
|
|
||||||
int x = Stack2.get(Stack2.size() - 1);
|
int x = Stack2.get(Stack2.size() - 1);
|
||||||
Stack2.remove(Stack2.size() - 1);
|
Stack2.remove(Stack2.size() - 1);
|
||||||
Stack1.add(x);
|
Stack1.add(x);
|
||||||
@ -131,7 +129,8 @@ public class Hanoi extends JFrame{
|
|||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
// MOVE BUTTON ACTION LISTENER
|
// MOVE BUTTON ACTION LISTENER
|
||||||
move_button.addActionListener(new ActionListener() {
|
move_button.addActionListener(
|
||||||
|
new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
updateStacks();
|
updateStacks();
|
||||||
@ -139,7 +138,8 @@ public class Hanoi extends JFrame{
|
|||||||
});
|
});
|
||||||
|
|
||||||
// EXIT BUTTON ACTION LISTENER
|
// EXIT BUTTON ACTION LISTENER
|
||||||
exit_button.addActionListener(new ActionListener() {
|
exit_button.addActionListener(
|
||||||
|
new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
@ -147,7 +147,8 @@ public class Hanoi extends JFrame{
|
|||||||
});
|
});
|
||||||
|
|
||||||
// REPLAY BUTTON ACTION LISTENER
|
// REPLAY BUTTON ACTION LISTENER
|
||||||
replay_button.addActionListener(new ActionListener() {
|
replay_button.addActionListener(
|
||||||
|
new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
startGame();
|
startGame();
|
||||||
@ -156,7 +157,8 @@ public class Hanoi extends JFrame{
|
|||||||
});
|
});
|
||||||
|
|
||||||
// AUTOMATIC PLAY BUTTON ACTION LISTENER
|
// AUTOMATIC PLAY BUTTON ACTION LISTENER
|
||||||
auto_button.addActionListener(new ActionListener() {
|
auto_button.addActionListener(
|
||||||
|
new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
timer.start();
|
timer.start();
|
||||||
@ -167,7 +169,10 @@ public class Hanoi extends JFrame{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer timer = new Timer(ONE_SECOND,new ActionListener() {
|
Timer timer =
|
||||||
|
new Timer(
|
||||||
|
ONE_SECOND,
|
||||||
|
new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
updateStacks();
|
updateStacks();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user