se_assignment's People
se_assignment's Issues
print a few lines of code that says pass successfully extended and set end month...
print a few lines of code that says pass successfully extended and set end month of season pass according to input
SE_Assignment/SeasonPassState.cs
Line 59 in ea65517
//validstate class
class ValidState : ISeasonPassState {
private SeasonPass vsp;
public ValidState(SeasonPass sp)
{
vsp = sp;
}
public void Renew()
{
if(vsp.StartDate <= vsp.EndDate)
{
// # TODO print a few lines of code that says pass successfully extended and set end month of season pass according to input
// asssginees: yongfarm
//dont have to set state to valid as it is already at valid state
vsp.SetCurrentState(vsp.GetValidState());
}
// implementation here
}
156e9d9dbc0bdd3fc46bc9f2aceae840c13cf00a
calculate the total amount for the month
calculate the total amount for the month
Line 109 in 244bad0
}
public void GenerateReport(List<CarPark> cpList)
{
// code to generatereport function -- # TODO calculate the total amount for the month
int currentMonth = DateTime.Now.Month; //set currentMonth as this month
double totalAmount = 0;
int totalVehicleEntry = 0;
int countCars = 0;
int countMotorBike = 0;
int countLorry = 0;
double ta = 0;
// prompt user for what month should the report be generated
Console.Write("Enter Month in numbers to Generate Report for: ");
string month = Console.ReadLine();
int months;
bool c = Int32.TryParse(month, out months);
if (!c)
{
Console.WriteLine();
Console.WriteLine("Please Enter Interger Input only!");
return;
}
if (months < 0 || months > 12)
{
Console.WriteLine("Please enter a valid month between 1 - 12");
return;
}
//prompt user whether to generate report for all carparks or only 1 carpark
Console.Write("Do you want to display ALL carpark generated revenue? [Y/N] ");
string confirmation = Console.ReadLine();
if (confirmation.ToUpper() == "N") //display one carpark only
{
//list all carpark and prompt for user to select one carpark
Console.WriteLine();
Console.WriteLine("======= Listing All Carparks =======");
Console.WriteLine();
foreach (var cp in cpList)
{
Console.WriteLine("{0}. {1}", cp.CarParkID, cp.CarParkName);
}
// prompt for input of carpark #
Console.WriteLine();
Console.Write("Select Carpark: ");
string cpNumber = Console.ReadLine();
int cpn;
c = Int32.TryParse(cpNumber, out cpn);
if (!c)
{
Console.WriteLine();
Console.WriteLine("Please Enter an Interger Input only!");
return;
}
if (cpn < 0 || cpn > 3)
{
Console.WriteLine("Please enter a valid Carpark number between 1 - 3");
return;
}
// code to generate report for one carpark
// cast the carpark into a local object
CarPark currentCP = cpList[Convert.ToInt32(cpNumber) - 1];
Console.WriteLine();
Console.WriteLine("Generating Financial Report...");
Thread.Sleep(TimeSpan.FromSeconds(2));
Console.WriteLine();
Console.WriteLine("=========== " + DateTime.Now + " ===========");
Console.WriteLine();
Console.WriteLine("Financial Report for the Month of {0} for {1}", currentCP.PastRevenue.ElementAt(months - 1).Key, currentCP.CarParkName);
// if month entered is the same as the current month in the computer, the printed revenue will be for the current month as well
// put the generatedrevenue into the current month
if (currentMonth == months) // add to pastrevenue if month matches
{
string o_i = currentCP.PastRevenue.ElementAt(months - 1).Value;
// concatenate the year and value together
string amount = "," + DateTime.Now.Year.ToString() + ": $" + currentCP.GeneratedRevenue;
// concatenate the original input of the month with new generated revenue
currentCP.PastRevenue[currentCP.PastRevenue.ElementAt(months - 1).Key] = o_i + amount;
}
// count the number of cars and motorcycle that entered the carpark
List<ParkingSession> psList = currentCP.vehicleParkingList; // cast the parkingsession list into a ParkingSession object first
foreach (var ps in psList)
{ // not efficient way to doing it but too bad!
if (ps.Vehicle.VehicleType == "Car") { countCars += 1; }
else if (ps.Vehicle.VehicleType == "Motorbike") { countMotorBike += 1; }
else if (ps.Vehicle.VehicleType == "Lorry") { countLorry += 1; }
}
// print the number of vehicles that entered
Console.WriteLine("No. of Vehicles entered to {0}: {1}", currentCP.carParkName, currentCP.vehicleParkingList.Count());
// print number of vehicles that entered, split between the count of cars and motorbikes
Console.WriteLine("No. of Cars: {0} | Number of Motorcycles: {1} | Number of Lorries: {2}", countCars, countMotorBike, countLorry);
// print the carpark name and the generated revenue for the month of each year
Console.WriteLine("Total amount of revenue generated from " + currentCP.CarParkName + " for the month of {0} is...", currentCP.pastRevenue.ElementAt(months - 1).Key);
//split the string by comma and print it out line by line for better visibility
string[] yearofRevenue = currentCP.PastRevenue.ElementAt(months - 1).Value.Split(",");
foreach (var x in yearofRevenue)
{
string y = x.Substring(7);
double amount = Convert.ToDouble(y);
totalAmount = amount + totalAmount;
Console.WriteLine(x);
}
Console.WriteLine("The total amount of revenue generated over the years are {0}", Math.Round(totalAmount, 2));
}
// code to generate report for ALL carpark
else
{
Console.WriteLine();
Console.WriteLine("Generating Financial Report...");
Thread.Sleep(TimeSpan.FromSeconds(2));
Console.WriteLine();
Console.WriteLine("=========== " + DateTime.Now + " ===========");
Console.WriteLine();
Console.WriteLine("Financial Report for the Month of {0} for all carparks", cpList[0].PastRevenue.ElementAt(months - 1).Key);
// print the carpark name and the generated revenue for the month of each year
Console.WriteLine("Total amount of revenue generated for all carparks are for the month of {0} is...", cpList[0].pastRevenue.ElementAt(months - 1).Key);
Console.WriteLine();
// Calculate the parking charges for ALL carparks.
// Calculate and print carpark by carpark
foreach (var ccp in cpList)
{
countLorry = 0;
countCars = 0;
countMotorBike = 0;
totalVehicleEntry = 0;
ta = 0;
// if month entered is the same as the current month in the computer, the printed revenue will be for the current month as well
// put the generatedrevenue into the current month, add to past revenue for current month if the revenue matches
if (currentMonth == months)
{
string o_i = ccp.PastRevenue.ElementAt(months - 1).Value;
// concatenate the year and value together
string amount = "," + DateTime.Now.Year.ToString() + ": $" + ccp.GeneratedRevenue;
// concatenate the original input of the month with new generated revenue
ccp.PastRevenue[ccp.PastRevenue.ElementAt(months - 1).Key] = o_i + amount;
}
//get the year's revenue in double datatype
string[] yearofRevenue = ccp.PastRevenue.ElementAt(months - 1).Value.Split(",");
foreach (var x in yearofRevenue)
{
string y = x.Substring(7);
double amount = Convert.ToDouble(y);
totalAmount = amount + totalAmount;
ta = amount + ta;
}
totalVehicleEntry = ccp.vehicleParkingList.Count() + totalVehicleEntry;
Console.WriteLine("============================ " + ccp.CarParkName + " ============================");
Console.WriteLine("No. of Vehicles entered: {0}", ccp.vehicleParkingList.Count());
// count the number of cars and motorcycle that entered the carpark
List<ParkingSession> psList = ccp.vehicleParkingList; // cast the parkingsession list into a ParkingSession object first
foreach (var ps in psList)
{ // not efficient way to doing it but too bad!
if (ps.Vehicle.VehicleType == "Car") { countCars += 1; }
else if (ps.Vehicle.VehicleType == "Motorbike") { countMotorBike += 1; }
else if (ps.Vehicle.VehicleType == "Lorry") { countLorry += 1; }
}
Console.WriteLine("No. of Cars: {0} | Number of Motorcycles: {1} | Number of Lorries: {2}", countCars, countMotorBike, countLorry);
Console.WriteLine("The total number of Vehicle entered across all carparks are {0}", totalVehicleEntry);
//print the amount generated in total for all Carparks
Console.WriteLine("Total Generated Revenue: {0}", Math.Round(ta, 2));
Console.WriteLine();
}
Console.WriteLine("Total Generated Revenue for all carparks: ${0}", Math.Round(totalAmount, 2));
}
}
public void ShowCarParkFares() { //print parking charges
ndex dbf4c01..92dbbd1 100644
++ b/Program.cs
5ce7ea4977c07f64ade3a512f6a30edff6daaff3
calculate the total amount for the month
calculate the total amount for the month
Line 398 in fbd113a
}
// ====================================================================
// ======================= End of Main Program ========================
// ====================================================================
// --------------------------------------------------------------------
// ====================================================================
// ============================= Menus ================================
// ====================================================================
void StudentMenu()
{
bool condition = true;
while (condition)
{
Console.WriteLine();
Console.WriteLine("=== Student Landing Page ===");
Console.WriteLine("1) View Season Parking Pass");
Console.WriteLine("2) Renew Season Parking Pass");
Console.WriteLine("3) Terminate Season Parking Pass");
Console.WriteLine("4) Transfer Season Parking Pass");
Console.WriteLine("5) Logout");
Console.WriteLine();
//validation to ensure the input are NUMBERS ONLY
int stud_choice;
Console.Write("Enter choice: ");
string choice = Console.ReadLine();
bool success = Int32.TryParse(choice, out stud_choice);
if (!success) //checks if 'choice' input is valid
{
Console.WriteLine("Please Enter Interger Input only!");
continue;
}
switch (stud_choice)
{
case 1: // view season parking pass
Console.WriteLine("Viewing Your Season Parking Pass");
//viewSeasonPass();
break;
case 2: //renew season parking pass
//renewSeasonPass();
break;
case 3: // terminate season parking pass
//terminateSeasonPass();
break;
case 4: // transfer season parking pass
//transferSeasonPass();
break;
case 5: //log out of student
Console.WriteLine();
Console.WriteLine("Logging out...");
Console.WriteLine();
condition = false;
break;
default: // if wrong option is entered
Console.WriteLine();
Console.WriteLine("Please enter a valid option!!");
Console.WriteLine();
break;
}
}
}
void LecturerMenu()
{
bool condition = true;
while (condition)
{
Console.WriteLine();
Console.WriteLine("===Lecturer Landing Page===");
Console.WriteLine("1) View Season Parking Pass");
Console.WriteLine("2) Renew Season Parking Pass");
Console.WriteLine("3) Terminate Season Parking Pass");
Console.WriteLine("4) Transfer Season Parking Pass");
Console.WriteLine("5) Logout");
Console.WriteLine();
int lecturer_choice;
Console.Write("Enter choice: ");
string choice = Console.ReadLine();
bool success = Int32.TryParse(choice, out lecturer_choice);
if (!success)
{
Console.WriteLine("Please Enter an Interger Input only!");
continue;
}
switch (lecturer_choice)
{
case 1: // view season parking pass
Console.WriteLine();
Console.WriteLine("Viewing Your Season Parking Pass");
//viewSeasonPass();
break;
case 2: //renew season parking pass
//renewSeasonPass();
break;
case 3: // terminate season parking pass
//terminateSeasonPass();
break;
case 4: // transfer season parking pass
//transferSeasonPass();
break;
case 5: //log out of lecturer
Console.WriteLine();
Console.WriteLine("Logging out...");
condition = false;
Console.WriteLine();
break;
default: // if wrong option is entered
Console.WriteLine();
Console.WriteLine("Please enter a valid option!!");
Console.WriteLine();
break;
}
}
}
void ManagerMenu()
{
bool condition = true;
while (condition)
{
Console.WriteLine();
//Console.WriteLine("Testing something");
Console.WriteLine("=== Manager Landing Page ===");
Console.WriteLine("1) Process Season Parking Pass");
Console.WriteLine("2) Generate Report for Specific Car Park");
Console.WriteLine("3) Logout");
Console.WriteLine();
int manager_choice;
Console.Write("Enter choice: ");
string choice = Console.ReadLine();
bool success = Int32.TryParse(choice, out manager_choice);
if (!success)
{
Console.WriteLine("Please Enter Interger Input only!");
continue;
}
switch (manager_choice)
{
case 1: // process season parking pass
//processSeasonParking();
break;
case 2: // generate report for specific car park
// Retrieve list of Carparks
Console.WriteLine();
Console.WriteLine("======= Listing All Carparks =======");
Console.WriteLine();
foreach (var cp in cpList) {
Console.WriteLine("{0}. {1}", cp.CarParkID, cp.CarParkName);
}
// prompt for input of carpark #
Console.WriteLine();
Console.Write("Select Carpark: ");
string cpNumber = Console.ReadLine();
int cpn;
bool c = Int32.TryParse(cpNumber, out cpn);
if (!c)
{
Console.WriteLine();
Console.WriteLine("Please Enter an Interger Input only!");
continue;
}
if (cpn < 0 || cpn > 3)
{
Console.WriteLine("Please enter a valid Carpark number between 1 - 3");
continue;
}
// code to generatereport function -- # TODO calculate the total amount for the month
Console.Write("Enter Month in numbers to Generate Report for: ");
string month = Console.ReadLine();
int months;
c = Int32.TryParse(month, out months);
if (!c)
{
Console.WriteLine();
Console.WriteLine("Please Enter Interger Input only!");
continue;
}
if (months < 0 || months > 12) {
Console.WriteLine("Please enter a valid month between 1 - 12");
continue;
}
switch (cpn) { //execute according to carpark number - probably the wrong way to do this but idrc
case 1:
cp1.GenerateReport(months);
break;
case 2:
cp2.GenerateReport(months);
break;
case 3:
cp3.GenerateReport(months);
break;
}
break; //finish generating report
case 3: // log out of manager
Console.WriteLine();
Console.WriteLine("Logging out...");
condition = false;
Console.WriteLine();
break;
default: // if wrong option is entered
Console.WriteLine();
Console.WriteLine("Please enter a valid option!!");
break;
}
}
}
}
}
}
ndex a5dc9c1..30cd048 100644
++ b/SeasonPass.cs
260e8a4d900715e91379e1480730d0c3224ecf69
check with Mr Victor whether getter setter is needed for this
check with Mr Victor whether getter setter is needed for this
SE_Assignment/ParkingSession.cs
Line 38 in 7a9d5c4
}
// may not need getter and setter for vehicle and vehiclecarpark - idk see how for now
// # TODO check with Mr Victor whether getter setter is needed for this
// # labels: check-with-teacher
public Vehicle Vehicle
{
get { return vehicle; }
set { vehicle = value; }
}
public CarPark VehicleCarPark
{
get { return vehicleCarPark; }
set { vehicleCarPark = value; }
}
public ParkingSession(int sid, DateTime cd, DateTime co, Vehicle v, CarPark vcp) {
sessionID = sid;
checkInDate = cd;
checkOutDate = co;
vehicle = v;
vehicleCarPark = vcp;
}
}
}
ndex 60dfd29..ce7be6a 100644
++ b/Program.cs
08910e65fb9b525d63e1b205fe29ab7646544dc8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.