This project explores the empirical differences between Sequential Execution and Concurrent Multi-threading in Java by benchmarking the time taken to process numbers up to one million.
- Sequential Logic (
toMillion.java): A standard iterative loop that prints numbers 0 to 1,000,000 in a single thread across three independent trials. - Concurrent Logic (
MultiThread.java): Splits the workload into two specialized threads—EvenNumberandOddNumber—which run simultaneously using thestart()andjoin()methods. - Thread Implementation:
- EvenNumber: Processes even values (0, 2, 4...) and outputs to the standard error stream (
System.err). - OddNumber: Processes odd values (1, 3, 5...) and outputs to the standard output stream (
System.out).
This project demonstrates advanced Object-Oriented Programming (OOP) concepts, specifically focusing on Generic Types, Enums, and Abstract Classes to model a zoo environment.
- Domain Modeling: Uses an abstract base
AAnimalclass with a nestedGroupEnum (MAMMAL, BIRD, AMPHIBIAN, INSECT) to categorize species. - Generics (
Enclosure<T>): Implements a generic enclosure system that can be restricted to specific animal types (e.g.,Enclosure<Lion>) or remain heterogeneous. - Role-Based Logic: Features a
Workerclass with specialized behaviors forfeedAnimal()andcleanAnimal(), demonstrating how actors interact with domain objects.
A system focused on Unique Data Generation (VINs) and Relational Mapping between vehicle owners, mechanics, and repair histories.
- VIN Generator: Implements a custom utility to generate unique 17-character Vehicle Identification Numbers using a specific pool of allowed alphanumeric characters.
- Repair Tracking: The
Mechanicclass tracks repair frequency per car using aMap<Car1, Integer>, allowing the system to report exactly how many times a specific VIN has been serviced by a specific mechanic. - Ownership Mapping: Uses a
HashMap<Person, List<Car>>to associate owners with multiple vehicles and filter results by registration number patterns (e.g., matching "WA" prefixes).
A modular framework for vehicle behavior using Interfaces, Functional Interfaces, and Lambda-ready operations.
-
Interface-Driven Design:
-
Turnable: Defines methods for directional control (turnLeft,turnRight,headTowards). -
Refuelable: Manages fuel levels and refueling logic for motorized units. -
Functional Programming: Includes
VehicleOperation, a@FunctionalInterfacedesigned to apply specific logic to aVehicleinstance via theapply()method. -
Implementation (
Bicycle.java): A concrete class that implementsTurnableandComparable, featuring bitwise-style modulus logic (% 360) to manage a 360-degree compass for direction tracking.
This documentation covers Java projects focused on advanced Object-Oriented Programming (OOP) structures, including complex interface hierarchies, the Comparable interface for sorting, and modular vehicle simulations.
- Advanced Interface Hierarchies
- Interface Inheritance: The project demonstrates multiple inheritance.
IAllextends bothMyInterfaceandOurInterface, creating a unified contract requiring implementation ofprint(),sayBye(), andsayHello(). - Concrete Implementation: Class
Aimplements theIAllinterface, providing the actual logic for the inherited methods.
- Comparative Logic & Sorting (
Person.java)
- Comparable Interface:
PersonimplementsComparable<Person>to define a "natural ordering." - Logic: The
compareTomethod is overridden to compare individuals based onbirthYear, allowing automatic sorting viaCollections.sort().
- Vehicle Simulation Framework
- Abstract Base (
Vehicle.java): Defines essential attributes like make, model, and year, while mandatingstart(),stop(), andgetStatusDescription(). - Behavioral Interfaces:
Drivable(movement/speed) andTurnable(directional logic). - Concrete Class (
Car.java): Integrates all interfaces with complex fuel consumption and mileage tracking logic.
This project contains modules demonstrating key OOP principles including Interface Default Methods, Abstract Classes, and Method Overriding.
- Default Methods and Interface Conflict Resolution
- Conflict Resolution (
Amphibious.java): Implements bothICarandIBoat. Resolves the "Diamond Problem" by overridingmove()and using a state flag (inWater) to call the appropriate super-interface method.
- Abstract Classes for Domain Modeling
- Animal (Abstract): Defines a private name and an abstract
speak()method. - Lion (Concrete): Provides the specific implementation of
speak().
- Geometric Shape Calculation
- AShape: A high-level abstraction mandating
getArea(). - Square & Rectangle: Specialized implementations using specific area formulas.
Focuses on fundamental data structures (Stacks, Queues, Linked Lists) and advanced string processing using Regular Expressions (Regex).
- Data Structures: Linear Collections
- Singly Linked List (SLL): Implements core list operations via a
Nodebuilding block. - Stacks (
MyStack.java): Implements both Array-based and Linked List-based stacks with overflow/underflow protection. - Queues (
MyQueue.java): A wrapper aroundjava.util.LinkedListfor enqueue/dequeue operations.
- Regular Expressions (Regex)
- Pattern & Matcher: Demonstrates
matches()vsfind(). - Search & Replace: Tools for locating indices (
B_Where) and mass-replacing text (C_Find_Replace). - Data Extraction: Complex patterns for extracting emails and URLs (
https?://\S+).
- Computational Logic (
PPJANG.java)
- Validation: Static methods for Hexadecimal and Binary pattern checking.
- Threading: Run
MultiThread.mainto observe how the OS interweaves streams. - Data Structures: Run
Main.javain thesllpackage orMyStack.mainto test collection behaviors. - Regex: Execute
D_TakeElement.javato test pattern extraction against custom strings. - Simulation: Instantiate the
AmphibiousorCarclasses to test state-based movements and fuel logic.
Person.java:Comparableimplementation.- **
Vehicle.java/Car.java/Bicycle.java**: Vehicle simulation logic. - **
SLL.java/MyStack.java/MyQueue.java**: Linear Data Structures. PPJANG.java: Regex validation utilities.- **
AShape.java/Square.java/Rectangle.java**: Geometric modeling.