-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSession3.dart
More file actions
189 lines (150 loc) · 5.46 KB
/
Session3.dart
File metadata and controls
189 lines (150 loc) · 5.46 KB
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
// material.IO
// regex cheat Sheet
// https://www.covid19india.org/
//CovidCases
import 'dart:io';
void main()
{
Map Maharashtra={'Confirmed': 6229596, 'Active':94593,'Recovered':6000911, 'Deceased':130753, 'Tested':5546565};
Map Kerala={'Confirmed': 3187716, 'Active':126396,'Recovered':3045310, 'Deceased':15512,'Tested':554665};
Map Karanataka={'Confirmed': 2886702, 'Active':26256,'Recovered':2824197, 'Deceased':36226,'Tested':56565};
Map TamilNadu={'Confirmed': 2539277, 'Active':26717,'Recovered':2478778, 'Deceased':33782,'Tested':554685};
Map AndhraPradesh={'Confirmed': 1946749, 'Active':23939,'Recovered':1909613, 'Deceased':13197,'Tested':554667565};
Map UttarPradesh={'Confirmed': 1708005, 'Active':1036,'Recovered':1684230, 'Deceased':22739,'Tested':553565};
var states={'Maharashtra': Maharashtra,'Kerala': Kerala, 'Karanataka': Karanataka, 'TamilNadu':TamilNadu, 'AndhraPradesh':AndhraPradesh,'UttarPradesh': UttarPradesh};
List stateskeys=states.keys.toList();
List statesvalues=states.values.toList();
// print(stateskeys);
// print(statesvalues);
print("################################################################################################################################################");
print("\t\t\t\t\tStates with number of cases ");
print("##############################################################################################################################################");
List caseskeys=statesvalues[0].keys.toList();
//formatting
int max=0;
for(int u=0;u<statesvalues.length;u++)
{
for(int w=0;w<caseskeys.length;w++)
{
if (max<statesvalues[u][caseskeys[w]].toString().length)
{
max=statesvalues[u][caseskeys[w]].toString().length;
}
}
}
int maxlength=0;
for(int v=0;v<caseskeys.length;v++)
{
if (maxlength<caseskeys[v].length)
{
maxlength=caseskeys[v].length;
}
}
if (max>maxlength)
{
maxlength=max;
}
else if(maxlength>max)
{
max=maxlength;
}
stdout.write("| \t States \t |");
for(int r=0;r<caseskeys.length;r++)
{
stdout.write(" \t ${caseskeys[r]}");
if ([caseskeys[r]].length<maxlength)
{
int temp4=caseskeys[r].length;
int temp5=maxlength-temp4;
for(int y=0;y<temp5;y++)
{
stdout.write(" ");
}
}
stdout.write("\t|");
}
for(int i=0;i<statesvalues.length;i++)
{
stdout.write("\n| \t ${stateskeys[i]} \t |");
for(int s=0;s<caseskeys.length;s++)
{
stdout.write(" \t ${statesvalues[i][caseskeys[s]]}");
if (statesvalues[i][caseskeys[s]].toString().length<max)
{
var temp9=statesvalues[i][caseskeys[s]].toString();
var temp10=temp9.length;
int temp3=max-temp10;
for(int y=0;y<temp3;y++)
{
stdout.write(" ");
}
}
stdout.write("\t|");
}
}
print("\n\n");
print("****************************************************************************************************************************");
print("Types of cases are : ${caseskeys}");
for(int p=0;p<caseskeys.length;p++)
{
print("${caseskeys[p]}: ${p}");
}
print("put variable typeofcases value to 0/1/2/3 according to what you need for sorting according to that cases.");
//Sorting starts
int typeofcases=1;
print("for the time being, typeofcases=${typeofcases}--> ${caseskeys[typeofcases]}");
print("******************************************************************************************************************************");
print("\n\n\n");
for (int j=0;j<statesvalues.length;j++)
{
for (int k=0; k<statesvalues.length;k++)
{
if (statesvalues[k][caseskeys[typeofcases]]<statesvalues[j][caseskeys[typeofcases]])
{
var temp=statesvalues[j];
statesvalues[j]=statesvalues[k];
statesvalues[k]=temp;
String temp2=stateskeys[j];
stateskeys[j]=stateskeys[k];
stateskeys[k]=temp2;
}
}
}
print("###################################################################################################################################");
print("\t\t\t\t\tAfter sorting according to the ${caseskeys[typeofcases]} cases in descending order.");
print("#######################################################################################################################################");
stdout.write("| \t States \t |");
for(int r=0;r<caseskeys.length;r++)
{
stdout.write(" \t ${caseskeys[r]}");
if ([caseskeys[r]].length<maxlength)
{
int temp4=caseskeys[r].length;
int temp5=maxlength-temp4;
for(int y=0;y<temp5;y++)
{
stdout.write(" ");
}
}
stdout.write("\t|");
}
for(int i=0;i<statesvalues.length;i++)
{
stdout.write("\n| \t ${stateskeys[i]} \t |");
for(int s=0;s<caseskeys.length;s++)
{
stdout.write(" \t ${statesvalues[i][caseskeys[s]]}");
if (statesvalues[i][caseskeys[s]].toString().length<max)
{
var temp9=statesvalues[i][caseskeys[s]].toString();
var temp10=temp9.length;
int temp3=max-temp10;
for(int y=0;y<temp3;y++)
{
stdout.write(" ");
}
}
stdout.write("\t|");
}
}
}