-
Notifications
You must be signed in to change notification settings - Fork 0
/
Administrator(singelton).cs
117 lines (113 loc) · 4.71 KB
/
Administrator(singelton).cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tourism_System__Sda_Project_
{
internal class Administrator_singelton
{
private string name;
private string Gender;
private string userType = "Admin";
private string username = "administrator";
private string userPassword = "admin123";
static int TotalOverallRevenue = 0;
static int TotalTrips = 0;
private Administrator_singelton()
{
}
public bool CheckCredentials(string tempaname, string tempapass)
{
if (tempaname == username && tempapass == userPassword)
{
return true;
}
else
{
return false;
}
}
public string getName()
{
return name;
}
private Administrator_singelton(string tempname, string tempGender)
{
name = tempname;
Gender = tempGender;
}
private static Administrator_singelton Admin = null;
private static int objectCount = 0;
public static Administrator_singelton getObjectInstance()
{
string A_name=null;
string A_gender=null;
if (Admin == null)
{
Console.WriteLine("Seems Like You Are A New Recruit..!");
Console.Write("What is your name Admin: ");
A_name = Console.ReadLine();
Console.Write("What is your gender Admin: ");
A_gender = Console.ReadLine();
Admin = new Administrator_singelton(A_name, A_gender);
objectCount++;
}
else
{
Console.WriteLine("Unable to create the 2nd object of singleton class");
}
return Admin;
}
public int calculateTotalRevenue(int Gcount, int Pcount, int Hcount, GoldenPackage temp_Package1, PlatinumPackage temp_Package2, HoneymoonPackage temp_Package3)
{
// Dependency Injection Implementation
TourManager manager;
manager = new TourManager(temp_Package1);
int revpackage1 = manager.CalculateTourRevenue(Gcount);
manager = new TourManager(temp_Package2);
int revpackage2 = manager.CalculateTourRevenue(Pcount);
manager = new TourManager(temp_Package3);
int revpackage3 = manager.CalculateTourRevenue(Hcount);
TotalOverallRevenue = revpackage1 + revpackage2 + revpackage3;
return TotalOverallRevenue;
}
public void DisplayRevenueofIndividualPackages(GoldenPackage tempPackage_1, PlatinumPackage tempPackage_2, HoneymoonPackage tempPackage_3)
{
// Dependency Injection Implementation
TourManager manager;
manager = new TourManager(tempPackage_1);
manager.DisplayPackageRevIndividual();
manager = new TourManager(tempPackage_2);
manager.DisplayPackageRevIndividual();
manager = new TourManager(tempPackage_3);
manager.DisplayPackageRevIndividual();
}
public int calculateTotalTrips(GoldenPackage temp_Package1, PlatinumPackage temp_Package2, HoneymoonPackage temp_Package3)
{
// Dependency Injection Implementation
TourManager manager;
manager = new TourManager(temp_Package1);
int TripCount1 = manager.CalculateTripsCount();
manager = new TourManager(temp_Package2);
int TripCount2 = manager.CalculateTripsCount();
manager = new TourManager(temp_Package3);
int TripCount3 = manager.CalculateTripsCount();
TotalTrips = TripCount1 + TripCount2 + TripCount3;
return TotalTrips;
}
public void generateMonthlyReport(int G_count, int P_count, int H_count, GoldenPackage tempPackage1, PlatinumPackage tempPackage2, HoneymoonPackage tempPackage3)
{
double Revenue = calculateTotalRevenue(G_count, P_count, H_count, tempPackage1, tempPackage2, tempPackage3);
int TotalTripsSent = calculateTotalTrips(tempPackage1, tempPackage2, tempPackage3);
Console.WriteLine("--------- Monthly Report ---------");
Console.WriteLine("TotalRevenueGenerated: " + Revenue);
Console.WriteLine("TotalTripsSent: " + TotalTripsSent);
Console.WriteLine("--------- Revenue Comparison Stats ---------");
DisplayRevenueofIndividualPackages(tempPackage1, tempPackage2, tempPackage3);
Console.WriteLine();
}
}
}