Please help me with this using java. If yo can't do all of them just do #1 and #3
1. Create a bubble sort code
2. Create a matching games like the on below. And add a reset button ( refer to image below)
3. please add comments to the tower of Hanoi java code below
import java.util.Scanner; public class TowerOfHanoi { public static void shift(int n, String startPole, String intermediatePole, String endPole) { if (n == 0) { return; } shift(n - 1, startPole, endPole, intermediatePole); System.out.println("Move \"" + n + "\" from " + startPole + " --> " + endPole); shift(n - 1, intermediatePole, startPole, endPole); } public static void main(String[] args) { System.out.print("Enter number of discs: "); Scanner scanner = new Scanner(System.in); int numberOfDiscs = scanner.nextInt(); shift(numberOfDiscs, "Pole1", "Pole2", "Pole3"); } }
Transcribed Image Text:# Halloween Matching
## Instructions:
1. Add the array to make these pictures.
2. Add a reset button. Change its font and color. Its actionCommand must be “Reset”.
3. Add a title. Change its font.
### Visual Explanation:
- On the left, there is a grid showing a 4x3 arrangement of Halloween-themed images, such as pumpkins, vampires, and monsters.
- On the right, there is an empty 4x3 grid with cards faced down, indicating the game setup where players match pairs.
### Starter Code:
```java
import javax.swing.*;
import java.applet.*;
import java.awt.event.*;
import java.awt.*;
public class halloween extends Applet implements ActionListener {
int hallow[] = new int[12];
int rows = 4;
int cols = 3;
JButton pics[] = new JButton[rows * cols];
public void init() {
Panel grid = new Panel(new GridLayout(rows, cols));
int n = 0;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
pics[n] = new JButton(createImageIcon("back.png"));
pics[n].addActionListener(this);
pics[n].setActionCommand(n + "");
pics[n].setPreferredSize(new Dimension(128, 128));
grid.add(pics[n]);
n++;
}
}
}
}
```
### Icons:
- Small icons representing different images like `hal1.png`, `hal2.png`, `hal3.png`, `hal4.png`, etc., show possible image choices for the game.
### Explanation:
- This code sets up a basic Halloween-themed matching game using a grid layout.
- Each cell in the grid is implemented as a `JButton`, initially displaying a "back" image indicating the card is faced down.
- Images are to be revealed based on actions triggered by player interaction (clicks).
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.