Journey Assistant is a Java application that helps users manage and plan their travel using different types of vehicles. It provides functionality to insert, delete, update, and view journey data stored in a MySQL database.
A simple Java program which is connected to the database via JDBC and illustrates all core fundamentals of Java OOP.
- Insert journey data for cars and bikes
- Delete the last record from the database
- Update vehicle names in the database
- View all journey records in the database
- Calculate fuel quantity required for a journey
- Calculate fuel price based on fuel type and quantity
- Handle exceptions for invalid seat numbers
Before you begin, ensure you have met the following requirements:
- Java Development Kit (JDK) 8 or higher
- MySQL Server
- MySQL Connector/J (JDBC driver for MySQL)
-
Clone the repository:
git clone https://github.com/your-username/journey-assistant.git cd journey-assistant
-
Set up the MySQL database:
- Create a new database
- Update the database connection details in the
Main.java
file:String url = "jdbc:mysql://localhost:3306/your-database-name"; String uname = "your_username"; String password = "your_password";
-
Compile the Java files:
javac Project/*.java
To run the Journey Assistant application:
- Navigate to the project directory
- Run the main class:
java Project.Main
- Follow the on-screen prompts to interact with the application
The application uses a table named Journey
with the following structure:
- SL_No (INT): Serial number (Primary Key)
- Name (VARCHAR): Vehicle name
- Type (VARCHAR): Vehicle type (Car or Bike)
- Manufacturer (VARCHAR): Vehicle manufacturer
- Fuel_Type (VARCHAR): Type of fuel used
- Mileage (FLOAT): Vehicle mileage
- Distance (FLOAT): Travel distance
- Fuel_Required (FLOAT): Quantity of fuel required
- Price (FLOAT): Total fuel price for the journey
Main
: The main class that handles user interaction and database operationsAutomobile
: Base class for vehiclesCar
: Subclass of Automobile for car-specific operationsBike
: Subclass of Automobile for bike-specific operations
The application includes a custom exception Invalid_seat
to handle cases where the number of persons exceeds the available seats in the vehicle.
Contributions to the Journey Assistant project are welcome. Please ensure that your code adheres to the project's coding standards and includes appropriate error handling.