Professional Documents
Culture Documents
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
class Bus {
constructor(
Id,
source,
destination,
noOfSeats,
noOfBeds,
fare,
startTime,
endTime,
boardingPoints,
droppingPoints
) {
this.Id = Id;
this.source = source;
this.destination = destination;
this.noOfSeats = noOfSeats;
this.noOfBeds = noOfBeds;
this.fare = fare;
this.startTime = startTime;
this.endTime = endTime;
this.boardingPoints = boardingPoints;
this.droppingPoints = droppingPoints;
let rowsFilled = 0;
function addBus() {
if (rowsFilled >= 4) {
return;
buses.push(newBus);
rowsFilled++;
if (rowsFilled === 4) {
function modifyBusById() {
Object.keys(modifiedBus).forEach(key => {
delete modifiedBus[key];
});
} else {
}
function displayAllBuses() {
buses.forEach(bus => {
tableHtml += `
<tr>
<td>${bus.Id}</td>
<td>${bus.source}</td>
<td>${bus.destination}</td>
<td>${bus.noOfSeats}</td>
<td>${bus.noOfBeds}</td>
<td>${bus.fare}</td>
<td>${bus.startTime}</td>
<td>${bus.endTime}</td>
<td>${bus.boardingPoints.join(', ')}</td>
<td>${bus.droppingPoints.join(', ')}</td>
</tr>
`;
});
tableHtml += '</table>';
document.getElementById('busTable').innerHTML = tableHtml;
function displayBusById() {
if (bus) {
const message = `
Source: ${bus.source}
Destination: ${bus.destination}
Fare: ${bus.fare}
`;
alert(message);
} else {
}
}
</script>
<div id="busTable"></div>
</body>
</html>