Apu Computer
Apu Computer
> Algorithm 9
> Testing 20
> Features 22
> Bibliography 33
INTRODUCTION
Pseudocode:
python
Copy code
function bookSeat():
bus_number = input("Enter bus number for
book:")
booked_seats = getBookedSeatsCount(bus_number)
capacity = getBusCapacity(bus_number)
updateBusCapacityInDatabase(bus_number,
new_capacity) print("Bus
capacity updated!")
function updateBusCapacityInDatabase(bus_number,
new_capacity):
// Connect to the database
// Update the 'buses' table with the new capacity
for the specified bus number
Project goals
Technologies Used:
Key Features:
Console-Based Interface:
The user interacts with the system through a
console-based interface, ensuring simplicity
and ease of use.
Menu-Driven Navigation:
A menu-driven navigation system guides
users through various functionalities,
allowing them to perform actions like adding
buses, viewing all buses, updating capacity,
deleting buses, and booking seats.
Input Validation:
User inputs for critical operations such as
adding a bus, updating capacity, and
booking a seat are validated to ensure data
integrity and prevent invalid entries.
.
Security Implementation
try:
cursor.execute(sql, val)
mydb.commit() print("Bus
added successfully!") except
mysql.connector.Error as err:
print(f"Error adding bus: {err}")
Data Encryption:
1. Unit Testing:
- Bus Class: Test individual methods/functions
within the Bus class.
- Test bus initialization with proper attributes.
- Test methods like
add_passenger(),remove_passenger(),
update_location(), etc., for expected behavior.
2. Integration Testing:
- Database Connectivity: Test database
connections and
CRUD (Create, Read, Update, Delete) operations.
Ensure data is stored, retrieved, and updated
correctly.
- API Endpoints: If your code interacts with external
APIs
(for tracking or data retrieval), test the endpoints'
functionality and response handling.
3. Functional Testing:
- Use Case Scenarios: Test the code against
various use case scenarios to ensure it meets
functional requirements.
For example:
- Simulate bus route planning and validate the
output against expected routes and schedules.
- Simulate passenger booking, tracking, and
cancellation processes to verify correct system
responses.
4. Error Handling:
- Boundary Conditions: Test the code with edge
cases, invalid inputs, or unexpected scenarios to
ensure it handles errors gracefully without
crashing.
- Exception Handling: Verify that exceptions and
errors are caught, logged appropriately, and do
not cause system
instability.
5. Performance Testing:
- Load Testing: If applicable, simulate
heavy usage scenarios to check how the
system handles increased load and verify
response times.
- Resource Utilization: Monitor memory
usage, CPU usage, and other resources
during different operations to ensure
efficiency.
FEATURES
Buses Table:
Stores information about each bus in the fleet.
Columns:
bus_id (Primary Key): Unique identifier for
each bus. bus_number: The identifying
number for the bus.
capacity: Maximum number of seats on the
bus.
Code:
CREATE TABLE buses
( bus_id INT AUTO_INCREMENT
PRIMARY KEY, bus_number
VARCHAR(255) NOT NULL, capacity
INT NOT NULL) Bookings Table:
Records information about seat bookings for
each bus.
Columns: booking_id (Primary Key):
Unique identifier for each booking.
bus_number (Foreign Key): References the
bus_id from the buses table.
seat_number: The seat number booked.
Code:
CREATE TABLE bookings
(booking_id INT AUTO_INCREMENT
PRIMARY KEY, bus_number
VARCHAR(255), seat_number INT,
FOREIGN KEY (bus_number) REFERENCES
buses(bus_id)) Sample Data:
Code:
INSERT INTO buses (bus_number, capacity)
VALUES
('BUS001', 50),
('BUS002', 40),
('BUS003', 60);
Bookings Table:
Code:
INSERT INTO bookings (bus_number, seat_number)
VALUES
('BUS001', 10),
('BUS001', 15),
('BUS002', 5),
('BUS003', 30);
Relationships:
One-to-Many Relationship (Buses to Bookings):
Each bus in the buses table can have
multiple entries in the bookings table.
Indexing:
Index on bus_number in the buses table:
To optimize searches based on the bus number.
Code:
CREATE INDEX idx_bus_number ON
buses(bus_number);
Flow diagram
Start
User --> Login Screen --> Authenticate Credentials -->
Dashboard
----> Invalid Credentials --> Error Message
----> Register --> User Details --> Dashboard
Dashboard --> View Routes --> Fetch Routes from
Database
–--> Display Routes
----> Book Bus --> Select Bus --> Confirm Booking -->
Generate Ticket
----> Payment --> Update Database (Transaction
Record)
----> Success --> Confirmation Message
----> Cancel Booking --> Update Database
(Cancellation) -->
Refund --> Confirmation Message
----> Track Bus --> Enter Bus Number --> Fetch
Location from
Database --> Display Location
import mysql.connector
cursor = mydb.cursor()
def add_bus():
bus_number = input("Enter bus number: ")
capacity = input("Enter capacity: ")
try:
cursor.execute(sql, val)
mydb.commit() print("Bus
added successfully!")
except mysql.connector.Error as err:
print(f"Error adding bus: {err}")
def view_all_buses():
try:
cursor.execute("SELECT * FROM
buses") result = cursor.fetchall() for
bus in result:
print(bus)
except mysql.connector.Error as err:
print(f"Error viewing buses: {err}")
def update_bus_capacity():
bus_number = input("Enter bus number to update
capacity:
")
new_capacity = input("Enter new capacity: ")
try:
cursor.execute(sql, val)
mydb.commit() print("Bus
capacity updated!")
except mysql.connector.Error as err:
print(f"Error updating bus capacity:
{err}")
def delete_bus():
bus_number = input("Enter bus number to delete: ")
sql = "DELETE FROM buses WHERE bus_number =
%s" val = (bus_number,)
try:
cursor.execute(sql,
val) mydb.commit()
print("Bus deleted!")
except mysql.connector.Error as err:
print(f"Error deleting bus: {err}")
def
display_seat_availability(bus_number
): try:
cursor.execute("SELECT capacity FROM buses
WHERE
bus_number = %s", (bus_number,))
capacity = cursor.fetchone()[0]
try:
display_seat_availability(bus_number)
seat_to_book = int(input("Enter the seat number
to book:
"))
def bus_management_system():
while True:
print("\nBus Management
System") print("1. Add Bus")
print("2. View All Buses")
print("3. Update Bus
Capacity") print("4. Delete
Bus") print("5. Book a Seat")
print("6. Exit") choice =
input("Enter choice: ")
if choice == '1':
add_bus()
elif choice == '2':
view_all_buses()
elif choice == '3':
update_bus_capacity()
elif choice == '4':
delete_bus()
elif choice == '5':
book_seat()
elif choice == '6':
break
else: print("Invalid choice. Please enter a
valid option.")
cursor.close()
mydb.close()
Sample Output
1. Add Bus
2. View All Buses
3. Update Bus Capacity
4. Delete Bus
5. Book a Seat
6. Exit
Enter choice: 1
Enter bus number: BUS001
Enter capacity: 50
Bus added
successfully!
Enter choice: 2
(Displays information about all buses)
Enter choice: 3
Enter bus number to update
capacity: BUS001 Enter new
capacity: 60 Bus capacity updated!
Enter choice: 4
Enter bus number to delete:
BUS001 Bus deleted!
Bibilography