simple Street table

This commit is contained in:
HeshamTB 2020-12-07 03:24:46 +03:00
parent 6720b412e6
commit da959a5cd3
Signed by: Hesham
GPG Key ID: 74876157D199B09E

View File

@ -1,4 +1,9 @@
import java.util.*;
import javax.swing.*;
import javax.swing.table.TableColumn;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.*;
public class MakkahCity {
@ -47,6 +52,34 @@ public class MakkahCity {
makeRoutes();
Object[][] streetData = new Object[stdStreet.length][6];
String[] colNames = new String[]{
"Street name",
"Street Load",
"Total",
"Buses",
"Local Vehicles",
"Avg. Time"
};
for (int i = 0; i < stdStreet.length; i++) {
streetData[i][0] = stdStreet[i].getName().name();
streetData[i][1] = stdStreet[i].getPercentRemainingCapacity();
streetData[i][2] = stdStreet[i].getVehicles().size();
streetData[i][3] = stdStreet[i].getNumberOfBuses();
streetData[i][4] = stdStreet[i].getNumberOfLocalCars();
streetData[i][5] = avgTimeOnStreet(stdStreet[i]);
}
JFrame frame = new JFrame("Streets");
JPanel panel = new JPanel(new GridLayout());
JTable table = new JTable(streetData,colNames);
Button btn = new Button("OK");
panel.add(table);
panel.add(btn);
frame.add(panel);
frame.setSize(500,500);
frame.setVisible(true);
//Set Routes for Campaigns
setRoutesForCampaigns(Mashier.ARAFAT);
while(!firstDayTimeMan.isEnded()) {