Sie sind auf Seite 1von 11

UNIVERSITI KUALA LUMPUR

MALAYSIAN INSTITUTE OF INFORMATION TECHNOLOGY

ADVANCED PROGRAMMING - ISB42603


ASSIGNMENT 1

PREPARED BY:
NAME
MOHAMAD FAROOQ NIZAM BIN ISMAIL
MUHD ZUBIR BIN ABDUL WAHID

STUDENT ID NO.
52243113733
52243113773

PREPARED FOR:
DR. SHAMSUL ANUAR MOKHTAR

Table of Contents
1.0.

Form .............................................................................................................................................. 3

1.1.

frmOption.................................................................................................................................. 3

1.2.

frmType ..................................................................................................................................... 3

1.3.

frmMain .................................................................................................................................... 4

2.0.

Source code................................................................................................................................... 6

2.1.

frmOption.................................................................................................................................. 6

2.2.

frmType ..................................................................................................................................... 7

2.3.

frmMain .................................................................................................................................... 8

Page | 2

1.0.

Form

1.1.

frmOption

1.2.

frmType

Page | 3

1.3.

frmMain

LRT Enquiry tab

LRT Fares tab

Page | 4

LRT Map tab

Page | 5

2.0.

Source code

2.1.

frmOption

using
using
using
using
using
using
using
using
using
using

System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows.Forms;
MetroFramework.Forms;

namespace lrt_v2
{
public partial class frmOption : MetroForm
{
public frmOption()
{
InitializeComponent();
}
private void frmOption_Load(object sender, EventArgs e)
{
//load
}
private void btnStandard_Click(object sender, EventArgs e)
{
frmMain fm = new frmMain();
this.Hide();
fm.LabelText = this.btnStandard.Text;
fm.Show();
}
private void btnCard_Click(object sender, EventArgs e)
{
frmType ft = new frmType();
this.Hide();
ft.Show();
}
}
}

Page | 6

2.2.
using
using
using
using
using
using
using
using
using
using

frmType
System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows.Forms;
MetroFramework.Forms;

namespace lrt_v2
{
public partial class frmType : MetroForm
{
public frmType()
{
InitializeComponent();
}
private void frmType_Load(object sender, EventArgs e)
{
//load
}
private void btnAdult_Click(object sender, EventArgs e)
{
frmMain fm = new frmMain();
this.Hide();
fm.LabelText = this.btnAdult.Text;
fm.Show();
}
private void btnSenior_Click(object sender, EventArgs e)
{
frmMain fm = new frmMain();
this.Hide();
fm.LabelText = this.btnSenior.Text;
fm.Show();
}
private void btnStudent_Click(object sender, EventArgs e)
{
frmMain fm = new frmMain();
this.Hide();
fm.LabelText = this.btnStudent.Text;
fm.Show();
}
private void btnWtcs_Click(object sender, EventArgs e)
{
frmMain fm = new frmMain();
this.Hide();
fm.LabelText = this.btnWtcs.Text;
fm.Show();
}

Page | 7

private void btnBack_Click(object sender, EventArgs e)


{
frmOption fo = new frmOption();
this.Hide();
fo.Show();
}
}
}

2.3.
using
using
using
using
using
using
using
using
using
using

frmMain
System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows.Forms;
MetroFramework.Forms;

namespace lrt_v2
{
public partial class frmMain : MetroForm
{
double[,] fareRate =
{{0,1.30,1.30,1.30,1.30,1.30,1.30,1.50,1.50,1.50,1.50,1.50,1.50,1.50},
{1.30,0,1.30,1.30,1.30,1.30,1.30,1.50,1.50,1.50,1.50,1.50,1.30,1.30},
{1.30,1.30,0,1.30,1.30,1.30,1.30,1.30,1.50,1.50,1.50,1.30,1.30,1.30},
{1.30,1.30,1.30,0,1.30,1.30,1.30,1.30,1.30,1.50,1.30,1.30,1.30,1.30},
{1.30,1.30,1.30,1.30,0,1.30,1.30,1.30,1.30,1.30,1.30,1.30,1.30,1.30},
{1.30,1.30,1.30,1.30,1.30,0,1.30,1.30,1.30,1.30,1.30,1.30,1.30,1.30},
{1.30,1.30,1.30,1.30,1.30,1.30,0,1.30,1.30,1.30,1.30,1.30,1.30,1.30},
{1.50,1.50,1.30,1.30,1.30,1.30,1.30,0,1.30,1.30,1.30,1.30,1.30,1.30},
{1.50,1.50,1.50,1.30,1.30,1.30,1.30,1.30,0,1.30,1.30,1.30,1.30,1.30},
{1.50,1.50,1.50,1.50,1.30,1.30,1.30,1.30,1.30,0,1.30,1.30,1.30,1.30},
{1.50,1.50,1.50,1.30,1.30,1.30,1.30,1.30,1.30,1.30,0,1.30,1.30,1.30},
{1.50,1.50,1.30,1.30,1.30,1.30,1.30,1.30,1.30,1.30,1.30,0,1.30,1.30},
{1.50,1.30,1.30,1.30,1.30,1.30,1.30,1.30,1.30,1.30,1.30,1.30,0,1.30},
{1.50,1.30,1.30,1.30,1.30,1.30,1.30,1.30,1.30,1.30,1.30,1.30,1.30,0}};
string[,] fare = {{"Choa Chu Kang (BP1)"," ","$ 1.30","$ 1.30","$ 1.30","$
1.30","$ 1.30","$ 1.30","$ 1.50","$ 1.50","$ 1.50","$ 1.50","$ 1.50","$ 1.50","$ 1.50"},
{"South View (BP2)","$ 1.30 "," ","$ 1.30","$ 1.30","$
1.30","$ 1.30","$ 1.30","$ 1.50","$ 1.50","$ 1.50","$ 1.50","$ 1.50","$ 1.30","$ 1.30"},
{"Keat Hong (BP3)","$ 1.30 ","$ 1.30 "," ","$ 1.30","$
1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.50","$ 1.50","$ 1.50","$ 1.30","$ 1.30","$ 1.30"},

Page | 8

{"Teck Whye (BP4)","$ 1.30","$ 1.30","$ 1.30"," ","$


1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.50","$ 1.30","$ 1.30","$ 1.30","$ 1.30"},
{"Phoenix (BP5)","$ 1.30","$ 1.30","$ 1.30","$ 1.30","
","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30"},
{"Bukit Panjang (BP6)","$ 1.30","$ 1.30","$ 1.30","$
1.30","$ 1.30"," ","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$
1.30"},
{"Petir (BP7)","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$
1.30","$ 1.30"," ","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30"},
{"Pending (BP8)","$ 1.50","$ 1.50","$ 1.30","$ 1.30","$
1.30","$ 1.30","$ 1.30"," ","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30"},
{"Bangkit (BP9)","$ 1.50","$ 1.50","$ 1.50","$ 1.30","$
1.30","$ 1.30","$ 1.30","$ 1.30"," ","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30"},
{"Fajar (BP10)","$ 1.50","$ 1.50","$ 1.50","$ 1.50","$
1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30"," ","$ 1.30","$ 1.30","$ 1.30","$ 1.30"},
{"Segar (BP11)","$ 1.50","$ 1.50","$ 1.50","$ 1.30","$
1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30"," ","$ 1.30","$ 1.30","$ 1.30"},
{"Jelapang (BP12)","$ 1.50","$ 1.50","$ 1.30","$ 1.30","$
1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30"," ","$ 1.30","$ 1.30"},
{"Senja (BP13)","$ 1.50","$ 1.30","$ 1.30","$ 1.30","$
1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30"," ","$ 1.30"},
{"Ten Mile Junction (BP14)","$ 1.50","$ 1.30","$ 1.30","$
1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30","$ 1.30","
"}};
double farePrice = 0.0;
public frmMain()
{
InitializeComponent();
}
private void frmMain_Load(object sender, EventArgs e)
{
int max_row = fare.GetUpperBound(0);
int max_col = fare.GetUpperBound(1);
for (int row = 0; row <= max_row; row++) {
ListViewItem new_item = lvFare.Items.Add(fare[row, 0]); ;
for (int col = 0; col <= max_col; col++)
{
new_item.UseItemStyleForSubItems = false;
if (lvFare.Items[row].SubItems[col].Text.ToString() == " ")
lvFare.Items[row].SubItems[col].BackColor = Color.Black;
new_item.SubItems.Add(fare[row,
new_item.SubItems.Add(fare[row,
new_item.SubItems.Add(fare[row,
new_item.SubItems.Add(fare[row,
new_item.SubItems.Add(fare[row,
new_item.SubItems.Add(fare[row,
new_item.SubItems.Add(fare[row,
new_item.SubItems.Add(fare[row,
new_item.SubItems.Add(fare[row,
new_item.SubItems.Add(fare[row,
new_item.SubItems.Add(fare[row,

1]);
2]);
3]);
4]);
5]);
6]);
7]);
8]);
9]);
10]);
11]);

Page | 9

new_item.SubItems.Add(fare[row, 12]);
new_item.SubItems.Add(fare[row, 13]);
new_item.SubItems.Add(fare[row, 14]);
btnPay.Hide();
txtAmount.Hide();
}
}
}
private void btnCheck_Click(object sender, EventArgs e)
{
int boardIndex, alightIndex;
boardIndex = lstBoard.SelectedIndex;
alightIndex = lstAlight.SelectedIndex;
if (boardIndex != -1 && alightIndex != -1) {
double quantity = Convert.ToDouble(numPerson.Value);
if (lblFaretype.Text == "Adult")
farePrice = fareRate[boardIndex, alightIndex] * 0.58 * quantity;
else if (lblFaretype.Text == "Senior Citizen / PWD")
farePrice = fareRate[boardIndex, alightIndex] * 0.43 * quantity;
else if (lblFaretype.Text == "Student")
farePrice = fareRate[boardIndex, alightIndex] * 0.29 * quantity;
else if (lblFaretype.Text == "WTCS")
farePrice = fareRate[boardIndex, alightIndex] * 0.5 * quantity;
else {
farePrice = fareRate[boardIndex, alightIndex] * quantity;
btnPay.Show();
txtAmount.Show();
}
lblFareprice.Text = farePrice.ToString("SD 0.00");
}
else
MetroFramework.MetroMessageBox.Show(this, "Please choose your
destination.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
string board = lstBoard.GetItemText(lstBoard.SelectedItem);
string alight = lstAlight.GetItemText(lstAlight.SelectedItem);
lblIndexboard.Text = board;
lblIndexalight.Text = alight;
}
private void btnBack_Click(object sender, EventArgs e)
{
frmOption fo = new frmOption();
this.Hide();
fo.Show();
}
public string LabelText //set the <faretype>
{
get {
return this.lblFaretype.Text;

Page | 10

}
set {
this.lblFaretype.Text = value;
}
}
private void btnPay_Click(object sender, EventArgs e)
{
double returnAmount;
returnAmount = double.Parse(txtAmount.Text) - farePrice;
if (double.Parse(txtAmount.Text) < farePrice)
MetroFramework.MetroMessageBox.Show(this, "Please enter the right
amount.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
else
MetroFramework.MetroMessageBox.Show(this, "Please take your balance: SD
"+returnAmount.ToString("0.00"), "Thanks!", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
}
}

Page | 11

Das könnte Ihnen auch gefallen