From da959a5cd3c28380e03b3ee83e6ca3b14e8f6bbc Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Mon, 7 Dec 2020 03:24:46 +0300 Subject: [PATCH] simple Street table --- src/MakkahCity.java | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/MakkahCity.java b/src/MakkahCity.java index ad8128e..77632ca 100644 --- a/src/MakkahCity.java +++ b/src/MakkahCity.java @@ -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()) {