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