File tree Expand file tree Collapse file tree 7 files changed +325
-1
lines changed Expand file tree Collapse file tree 7 files changed +325
-1
lines changed Original file line number Diff line number Diff line change
1
+ [
2
+ {
3
+ "StudentNumber" : 1 ,
4
+ "Lesson" : " DB" ,
5
+ "Score" : 14.63433486
6
+ },
7
+ {
8
+ "StudentNumber" : 1 ,
9
+ "Lesson" : " AP" ,
10
+ "Score" : 12.0218272
11
+ },
12
+ {
13
+ "StudentNumber" : 1 ,
14
+ "Lesson" : " DA" ,
15
+ "Score" : 18.98081619
16
+ },
17
+ {
18
+ "StudentNumber" : 1 ,
19
+ "Lesson" : " DS" ,
20
+ "Score" : 15.52422954
21
+ },
22
+ {
23
+ "StudentNumber" : 2 ,
24
+ "Lesson" : " DB" ,
25
+ "Score" : 19.9984161
26
+ },
27
+ {
28
+ "StudentNumber" : 2 ,
29
+ "Lesson" : " AP" ,
30
+ "Score" : 17.51669733
31
+ },
32
+ {
33
+ "StudentNumber" : 2 ,
34
+ "Lesson" : " DA" ,
35
+ "Score" : 10.26295696
36
+ },
37
+ {
38
+ "StudentNumber" : 2 ,
39
+ "Lesson" : " DS" ,
40
+ "Score" : 10.01975171
41
+ },
42
+ {
43
+ "StudentNumber" : 3 ,
44
+ "Lesson" : " DB" ,
45
+ "Score" : 16.607692
46
+ },
47
+ {
48
+ "StudentNumber" : 3 ,
49
+ "Lesson" : " AP" ,
50
+ "Score" : 12.2630708
51
+ },
52
+ {
53
+ "StudentNumber" : 3 ,
54
+ "Lesson" : " DA" ,
55
+ "Score" : 18.02715037
56
+ },
57
+ {
58
+ "StudentNumber" : 3 ,
59
+ "Lesson" : " DS" ,
60
+ "Score" : 14.12720018
61
+ },
62
+ {
63
+ "StudentNumber" : 4 ,
64
+ "Lesson" : " DB" ,
65
+ "Score" : 17.70425414
66
+ },
67
+ {
68
+ "StudentNumber" : 4 ,
69
+ "Lesson" : " AP" ,
70
+ "Score" : 17.57739023
71
+ },
72
+ {
73
+ "StudentNumber" : 4 ,
74
+ "Lesson" : " DA" ,
75
+ "Score" : 16.22962447
76
+ },
77
+ {
78
+ "StudentNumber" : 4 ,
79
+ "Lesson" : " DS" ,
80
+ "Score" : 17.45579008
81
+ },
82
+ {
83
+ "StudentNumber" : 5 ,
84
+ "Lesson" : " DB" ,
85
+ "Score" : 10.69591387
86
+ },
87
+ {
88
+ "StudentNumber" : 5 ,
89
+ "Lesson" : " AP" ,
90
+ "Score" : 13.74945505
91
+ },
92
+ {
93
+ "StudentNumber" : 5 ,
94
+ "Lesson" : " DA" ,
95
+ "Score" : 10.47906005
96
+ },
97
+ {
98
+ "StudentNumber" : 5 ,
99
+ "Lesson" : " DS" ,
100
+ "Score" : 10.64942138
101
+ },
102
+ {
103
+ "StudentNumber" : 6 ,
104
+ "Lesson" : " DB" ,
105
+ "Score" : 15.89915904
106
+ },
107
+ {
108
+ "StudentNumber" : 6 ,
109
+ "Lesson" : " AP" ,
110
+ "Score" : 10.45254317
111
+ },
112
+ {
113
+ "StudentNumber" : 6 ,
114
+ "Lesson" : " DA" ,
115
+ "Score" : 19.92515277
116
+ },
117
+ {
118
+ "StudentNumber" : 6 ,
119
+ "Lesson" : " DS" ,
120
+ "Score" : 14.2964831
121
+ },
122
+ {
123
+ "StudentNumber" : 7 ,
124
+ "Lesson" : " DB" ,
125
+ "Score" : 19.99800627
126
+ },
127
+ {
128
+ "StudentNumber" : 7 ,
129
+ "Lesson" : " AP" ,
130
+ "Score" : 17.89393279
131
+ },
132
+ {
133
+ "StudentNumber" : 7 ,
134
+ "Lesson" : " DA" ,
135
+ "Score" : 10.28261242
136
+ },
137
+ {
138
+ "StudentNumber" : 7 ,
139
+ "Lesson" : " DS" ,
140
+ "Score" : 11.97554454
141
+ },
142
+ {
143
+ "StudentNumber" : 8 ,
144
+ "Lesson" : " DB" ,
145
+ "Score" : 14.11228504
146
+ },
147
+ {
148
+ "StudentNumber" : 8 ,
149
+ "Lesson" : " AP" ,
150
+ "Score" : 18.17301775
151
+ },
152
+ {
153
+ "StudentNumber" : 8 ,
154
+ "Lesson" : " DA" ,
155
+ "Score" : 12.03562658
156
+ },
157
+ {
158
+ "StudentNumber" : 8 ,
159
+ "Lesson" : " DS" ,
160
+ "Score" : 11.91781334
161
+ }
162
+ ]
Original file line number Diff line number Diff line change
1
+ [
2
+ {
3
+ "StudentNumber" : 1 ,
4
+ "FirstName" : " Mahdi" ,
5
+ "LastName" : " Malverdi"
6
+ },
7
+ {
8
+ "StudentNumber" : 2 ,
9
+ "FirstName" : " Mohammad" ,
10
+ "LastName" : " Haghighat"
11
+ },
12
+ {
13
+ "StudentNumber" : 3 ,
14
+ "FirstName" : " Mohammad Hossein" ,
15
+ "LastName" : " Mostmand"
16
+ },
17
+ {
18
+ "StudentNumber" : 4 ,
19
+ "FirstName" : " Hossein" ,
20
+ "LastName" : " Behbodi"
21
+ },
22
+ {
23
+ "StudentNumber" : 5 ,
24
+ "FirstName" : " Ahmad" ,
25
+ "LastName" : " Salimi"
26
+ },
27
+ {
28
+ "StudentNumber" : 6 ,
29
+ "FirstName" : " Hadi" ,
30
+ "LastName" : " EsnaAshari"
31
+ },
32
+ {
33
+ "StudentNumber" : 7 ,
34
+ "FirstName" : " Alireza" ,
35
+ "LastName" : " Ziaei"
36
+ },
37
+ {
38
+ "StudentNumber" : 8 ,
39
+ "FirstName" : " Mohammad Hossein" ,
40
+ "LastName" : " Ghesarieh"
41
+ }
42
+ ]
Original file line number Diff line number Diff line change
1
+ namespace StdAvgCal . Model . Existence
2
+ {
3
+ public class Student
4
+ {
5
+ public string StudentNumber { get ; set ; }
6
+ public string FirstName { get ; set ; }
7
+ public string LastName { get ; set ; }
8
+
9
+ public string FullName
10
+ {
11
+ get
12
+ {
13
+ return FirstName + " " + LastName ;
14
+ }
15
+ }
16
+
17
+
18
+ }
19
+ }
Original file line number Diff line number Diff line change
1
+ using System ;
2
+
3
+ namespace StdAvgCal . Model . Existence
4
+ {
5
+ public class StudentScore
6
+ {
7
+ public int StudentNumber { get ; set ; }
8
+ public string Lesson { get ; set ; }
9
+
10
+ private double _score ;
11
+ private int _roundingBound = 2 ;
12
+
13
+ public int RoundingBound
14
+ {
15
+ set
16
+ {
17
+ _roundingBound = value ;
18
+ }
19
+ }
20
+
21
+ public double Score
22
+ {
23
+ get
24
+ {
25
+ return RoundDouble ( _score , _roundingBound ) ;
26
+ }
27
+
28
+ set
29
+ {
30
+ _score = value ;
31
+ }
32
+ }
33
+
34
+ private double RoundDouble ( double number , int roundingBound )
35
+ {
36
+ int temp = ( int ) ( _score * PowerInteger ( 10 , roundingBound ) ) ;
37
+ double score = ( ( double ) temp ) / PowerInteger ( 10 , roundingBound ) ;
38
+ return score ;
39
+ }
40
+
41
+ private int PowerInteger ( int number , int pow )
42
+ {
43
+ int answer = 1 ;
44
+ for ( int i = 0 ; i < pow ; i ++ )
45
+ {
46
+ answer *= number ;
47
+ }
48
+
49
+ return answer ;
50
+ }
51
+
52
+ }
53
+ }
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . IO ;
4
+ using System . Linq ;
5
+ using Newtonsoft . Json ;
6
+ using StdAvgCal . Model . Existence ;
7
+
8
+ namespace StdAvgCal . Model
9
+ {
10
+ public class FileReader
11
+ {
12
+ private static readonly string DocUrl = GetSlnDir ( ) + "Docs\\ " ;
13
+ private static readonly string ScoresFileName = "Scores.json" ;
14
+ private static readonly string StudentsFileName = "Students.json" ;
15
+
16
+ public static List < StudentScore > GetAllScores ( )
17
+ {
18
+ string json = File . ReadAllText ( DocUrl + ScoresFileName ) ;
19
+ StudentScore [ ] scores = JsonConvert . DeserializeObject < StudentScore [ ] > ( json ) ;
20
+ return scores . ToList ( ) ;
21
+ }
22
+
23
+ public static List < Student > GetAllStudents ( )
24
+ {
25
+ string json = File . ReadAllText ( DocUrl + StudentsFileName ) ;
26
+ Student [ ] students = JsonConvert . DeserializeObject < Student [ ] > ( json ) ;
27
+ return students . ToList ( ) ;
28
+ }
29
+
30
+ private static string GetSlnDir ( )
31
+ {
32
+ string path = System . IO . Directory . GetCurrentDirectory ( ) ;
33
+ for ( int i = 0 ; i < 4 ; i ++ )
34
+ {
35
+ path = Path . GetDirectoryName ( path ) ;
36
+ }
37
+
38
+ return path + "\\ " ;
39
+ }
40
+ }
41
+ }
Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using System . Collections . Generic ;
3
+ using StdAvgCal . Model ;
4
+ using StdAvgCal . Model . Existence ;
2
5
3
6
namespace StdAvgCal
4
7
{
5
8
class Program
6
9
{
7
10
static void Main ( string [ ] args )
8
11
{
9
- Console . WriteLine ( "Hello World!" ) ;
12
+
10
13
}
11
14
}
12
15
}
Original file line number Diff line number Diff line change 5
5
<TargetFramework >netcoreapp3.1</TargetFramework >
6
6
</PropertyGroup >
7
7
8
+ <ItemGroup >
9
+ <PackageReference Include =" Newtonsoft.Json" Version =" 12.0.3" />
10
+ </ItemGroup >
11
+
8
12
</Project >
You can’t perform that action at this time.
0 commit comments