# Getting Started

This repository is a small Java Swing desktop app for demonstrating classic sorting algorithms. A user opens the menu window, picks an algorithm, enters a space-separated list of integers, and sees the sorted output in a second window. There is also an "Open Code" shortcut that launches the matching `.txt` file for the selected algorithm.

## What This Project Does

The project is a GUI-based algorithm calculator focused on sorting. It exists to let users compare bubble sort, selection sort, insertion sort, merge sort, quick sort, and heap sort in one place. The app is educational and self-contained: all sorting happens in memory, and the UI is built with standard Swing components.

## Recommended Reading Order

1. [`README.md`](README.md) — start here for the project’s original description and screenshots.
2. [`src/algo_Calc/Frame.java`](src/algo_Calc/Frame.java) — understand the menu window and how algorithm selection works.
3. [`src/algo_Calc/Sortingss.java`](src/algo_Calc/Sortingss.java) — read this next to see input parsing, dispatch, and the sorting implementations.
4. [`src/algo_Calc/Sortingss.java`](src/algo_Calc/Sortingss.java) helper classes — `quiks`, `merg`, and `heaps` implement quick sort, merge sort, and heap sort.

## Key Entry Points

The main classes to understand first are:

- [`Frame`](src/algo_Calc/Frame.java) — the launcher and algorithm picker.
- [`Sortingss`](src/algo_Calc/Sortingss.java) — the main sorter window and dispatch logic.
- [`quiks`](src/algo_Calc/Sortingss.java) — quick sort helper.
- [`merg`](src/algo_Calc/Sortingss.java) — merge sort helper.
- [`heaps`](src/algo_Calc/Sortingss.java) — heap sort helper.

`Frame` creates the six algorithm buttons and passes a numeric key into `Sortingss.vis(...)`. `Sortingss` owns the input/output UI and decides which algorithm to run based on that key.

## Project Structure

The codebase is organized around a single Java package:

- `src/algo_Calc/` — primary source code
  - `Frame.java` — first window, algorithm selection
  - `Sortingss.java` — second window, input/output, and sorting logic
- `bin/algo_Calc/` — compiled class files
- `Images/` — screenshots used in the README
- `*.txt` files in the repo root — sample or companion text files opened from the UI
- `.settings/`, `.classpath`, `.project` — Eclipse project metadata

A simplified flow looks like this:

```mermaid
flowchart TD
Frame["Frame"] --> Sortingss["Sortingss"]
Sortingss --> Quiks["quiks"]
Sortingss --> Merg["merg"]
Sortingss --> Heaps["heaps"]
```

## Configuration

Key files to know:

- `.project` and `.classpath` — Eclipse project metadata and source/classpath settings.
- `.settings/org.eclipse.jdt.core.prefs` — Java compiler preferences for the Eclipse setup.
- `README.md` — contains the original usage notes and screenshots.
- `bubble.txt`, `selection.txt`, `quicksort.txt`, `insertion.txt`, `merge.txt`, `maxheap.txt` — text files opened by the "Open Code" button.

There is no separate runtime configuration layer, database, or environment file. Behavior is mostly controlled by the selected algorithm key and the current text field input.

## Common Patterns

- **Swing event-driven UI** — button clicks are handled with `ActionListener` callbacks.
- **Absolute positioning** — the frames use `setLayout(null)` and manual bounds instead of a layout manager.
- **Simple algorithm dispatch** — the selected algorithm is represented by an integer key passed from `Frame` into `Sortingss`.
- **In-place sorting** — the helper algorithms mutate the input array directly.
- **Minimal state** — the main shared state is the selected key and display title.
- **Windows-specific open-file action** — the code-opening shortcut uses `ProcessBuilder` with Notepad, so it is tied to a Windows desktop environment.

## Where to Start Reading Code

If you only have time for one pass, read in this order:

1. `Frame.main(...)` and `Frame.initialize()` to see how the app starts.
2. `Sortingss.vis(...)` to see how the selected algorithm is stored.
3. The submit handler inside `Sortingss.initialize()` to see how input is parsed and sorted.
4. The helper classes `quiks`, `merg`, and `heaps` for the recursive sorting logic.

## Practical Tips for New Engineers

- Input is expected to be a space-separated list of integers.
- The submit action does not appear to do much validation, so malformed input will likely fail at parse time.
- Bubble sort, selection sort, and insertion sort are implemented inline in the UI handler, while quick sort, merge sort, and heap sort are delegated to helper classes.
- If you add a new algorithm, you must update both the menu buttons in `Frame` and the key-based dispatch in `Sortingss`.
- The app is easiest to understand by tracing one user journey end to end: click a button in `Frame`, then follow the key into `Sortingss`, then inspect the corresponding sort routine.
