A Java-based graphical user interface (GUI) application that allows users to compare water service data across different countries and years. The app visualizes water service levels including basic services, limited services, unimproved services, and surface water usage.
-
Interactive GUI
Compare water data between two countries and selected years. -
Visual Data Representation
Color-coded bar charts for intuitive comparisons. -
Comprehensive Dataset
Includes data for 233 countries. -
Year-over-Year Analysis
Supports data from multiple years for trend analysis. -
Efficient Data Structures
Uses sorted lists and binary search for fast access.
- Stores water service data for a specific year.
- Fields:
isoYearbasicPlusPctlimitedPctunimprovedPctsurfacePct
- Implements
Comparable<YearlyWaterRecord>usingisoYear. - Overrides
equals()andhashCode()for consistency.
- Interface defining a sorted list.
- Extends
Iterable<E>for use in enhancedforloops. - Key methods:
add(E element)remove(E element)get(int index)indexOf(E element)(uses binary search)
- Implements
SortedArrayListInterface. - Maintains elements in natural sorted order.
- Uses binary search for O(log n) efficiency.
- Generic for type safety.
- Main GUI component (do not modify).
- Displays bar charts comparing selected countries and years.
- Handles user inputs and rendering.
- Application entry point.
- Loads data files and initializes the GUI.
-
Comparable<E>
Enables natural ordering of objects viacompareTo(). -
Iterator<E>
Provides standard iteration methods:hasNext(),next(),remove(). -
Iterable<E>
Allows enhancedfor-eachloop usage by implementingiterator().
#### `WaterComparisonGui.java`
- Main GUI component (**do not modify**).
- Displays bar charts comparing selected countries and years.
- Handles user inputs and rendering.
---
#### `Main.java`
- Application entry point.
- Loads data files and initializes the GUI.
---
### 🔌 Supporting Interfaces
- **`Comparable<E>`**
Enables natural ordering of objects via `compareTo()`.
- **`Iterator<E>`**
Provides standard iteration methods: `hasNext()`, `next()`, `remove()`.
- **`Iterable<E>`**
Allows enhanced `for-each` loop usage by implementing `iterator()`.
---
## 📁 File Structure
/src │ ├── YearlyWaterRecord.java ├── SortedArrayListInterface.java ├── SortedArrayList.java ├── WaterComparisonGui.java ← Do not modify └── Main.java
## 🛠️ How to Run
1. **Compile the project**
```bash
javac *.java
- Run Main.java
java Main