Skip to content

psyminsays/World-Water-Comparison

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 

Repository files navigation

🌊 Water World Comparison GUI

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.


🚀 Features

  • 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.


🧱 Class Structure

✅ Core Classes

YearlyWaterRecord.java

  • Stores water service data for a specific year.
  • Fields:
    • isoYear
    • basicPlusPct
    • limitedPct
    • unimprovedPct
    • surfacePct
  • Implements Comparable<YearlyWaterRecord> using isoYear.
  • Overrides equals() and hashCode() for consistency.

SortedArrayListInterface.java

  • Interface defining a sorted list.
  • Extends Iterable<E> for use in enhanced for loops.
  • Key methods:
    • add(E element)
    • remove(E element)
    • get(int index)
    • indexOf(E element) (uses binary search)

SortedArrayList.java

  • Implements SortedArrayListInterface.
  • Maintains elements in natural sorted order.
  • Uses binary search for O(log n) efficiency.
  • Generic for type safety.

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


#### `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
  1. Run Main.java
    java Main

About

Java OOP project: Sorted array list implementation with binary search, custom iterators, and GUI visualization for UN water service data comparison between countries and years.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages