View difference between Paste ID: NXrqnJY4 and KMVZYSAX
SHOW: | | - or go back to the newest paste.
1
namespace AcademicTranscript
2
{
3
    class Student
4
    {
5
        private string _firstName;
6
        private string _lastName;
7
        private int _studentID;
8
9
        public string FirstName { get { return this._firstName; } }
10
        public string LastName { get { return this._lastName; } }
11
        public int StudentID { get { return this._studentID; } }
12
13
        public Student (string firstName, string lastName, int studentID)
14
        {
15
            this._firstName = firstName;
16
            this._lastName = lastName;
17
            this._studentID = studentID;
18
        }
19
20
        public string FullName()
21
        {
22
            return this._firstName + " " + this._lastName;
23
        }
24
    }
25
26
    class AcademicQuarter
27
    {
28
        private QuarterEnum _currentQuarter;
29
        private int _year;
30
        private double _gpa;
31
        private Course[] _courseList;
32
33
        public QuarterEnum CurrentQuarter { get { return this._currentQuarter; } }
34
        public int Year { get { return this._year; } }
35
        public double GPA 
36
        { 
37
            get 
38
            {
39
                double crsGPA = 0;
40
                foreach (Course crs in this.CourseList)
41
                {
42
                    crsGPA += crs.Grade;
43
                }
44
                this._gpa = (crsGPA / this.CourseList.Length);
45
                return this._gpa; 
46
            }
47
        }
48
        public Course[] CourseList 
49
        { 
50
            get 
51
            { 
52
                return this._courseList; 
53
            }
54
            set
55
            {
56
                this._courseList = value;
57
            }
58
        }
59
60
        public enum QuarterEnum 
61
        {
62
            Fall = 0,
63
            Winter,
64
            Spring,
65
            Summer
66
        }
67
68
        public AcademicQuarter(QuarterEnum qType, int year)            
69
        {
70
            this._currentQuarter = qType;
71
            this._year = year;
72
        }
73
74
        public AcademicQuarter(QuarterEnum qType, int year, Course[] cList)
75
        {
76
            this._currentQuarter = qType;
77
            this._year = year;
78
            this.CourseList = cList;
79
        }            
80
    }
81
82
    class Course
83
    {
84
        private int _id;
85
        private string _title;
86
        private int _credits;
87
        private double _grade;
88
89
        public int ID { get { return this._id; } }
90
        public string Title { get { return this._title; } }
91
        public int Credits { get { return this._credits; } }        
92
        public double Grade 
93
        { 
94
            get 
95
            { 
96
                return this._grade; 
97
            } 
98
            set 
99
            { 
100
                this._grade = value; 
101
            } 
102
        }
103
104
105
        public Course(int cID, string title, int credits)
106
        {
107
            this._id = cID;
108
            this._title = title;
109
            this._credits = credits;
110
        }
111
112
113
        public void PrintCourses()
114
        {
115
            Console.WriteLine("Course: {0}\tCredits: {1} Grade: {2}", this.ID, this.Title, this.Credits);
116
        }
117
    }
118
119
    class AcademicTranscript
120
    {
121
        private Student _student;
122
        private AcademicQuarter[] _quarterArray;
123
124
        public AcademicTranscript(Student student)
125
        {
126
            this._student = student;
127
        }
128
129
        public Student CurrentStudent 
130
        {
131
            get
132
            {
133
                return this._student;
134
            }
135
        }
136
137
        public AcademicQuarter[] QuarterArray 
138
        { 
139
            get 
140
            {
141
                if (this._quarterArray == null)
142
                {
143
                    this._quarterArray = new AcademicQuarter[4];
144
                }
145
146
                return this._quarterArray;
147
            } 
148
        }
149
        /// <summary>
150
        /// student name: leif
151
        /// student id: 2342
152
        /// 
153
        /// quarter: fall of 2013
154
        /// course: phys 221 credits: 5 grade: 3.9
155
        /// GPA: 3.9
156-
        /// Cumulative GPA: 3.9
156+
        /// Cumulative GPA: 3.9 blah blah blah
157
	///
158-
        /// API Documentation (Look this up!!!!)
158+
159
        public void PrintTranscript()
160
        {
161
            StringBuilder printOutput = new StringBuilder();
162
            printOutput.Append("Student Name: ");
163
            printOutput.Append(this.CurrentStudent.FullName());
164
            printOutput.AppendLine();
165
            printOutput.Append("Student ID: ");
166
            printOutput.Append(this.CurrentStudent.StudentID);
167
            printOutput.AppendLine();
168
169
            double cumulativeGpa = 0;
170
            int currentQuarterCount = 1;
171
            foreach (AcademicQuarter aq in this.QuarterArray)
172
            {
173
                if (aq != null)
174
                {
175
                    printOutput.AppendLine(aq.CurrentQuarter.ToString()); //add .ToString() to print out enum as "Fall"
176
                    printOutput.AppendLine(aq.Year.ToString());
177
178
                    foreach (Course crse in aq.CourseList)//add number of elements, divide total by number of elements in array
179
                    {
180
                        printOutput.AppendLine(crse.Title + " " + crse.ID.ToString() + " " + crse.Credits.ToString() + " " + crse.Grade.ToString());
181
                    }
182
183
                    printOutput.AppendLine("GPA: " + aq.GPA.ToString());
184
                    cumulativeGpa += aq.GPA;
185
                    printOutput.AppendLine("Cumulative GPA: " + (cumulativeGpa / currentQuarterCount).ToString());
186
                    currentQuarterCount++;
187
                }
188
            }
189
190
            Console.Write(printOutput.ToString());
191
        }
192
    }
193
194
    class Program
195
    {
196
        static void Main(string[] args)
197
        {
198
            AcademicTranscript transcript = PopulateData();
199
            transcript.PrintTranscript();
200
            Console.ReadKey();
201
        }
202
203
        /// <summary>
204
	/// Possibly use a sorting algo for this...
205
	///
206
        /// create a transcript.AddQuarter that takes academic quarter as argument
207-
        /// AddQuarter(Quarter quarter)
207+
208
        /// AddQuarter(Quarter quarter)   
209
        /// {
210
        ///     what is the next available index QuarterArray
211
        ///     fill quarter into next available index
212
        /// }
213
        /// </summary>
214
        /// <returns></returns>
215
        static AcademicTranscript PopulateData()
216
        {
217
            Student student = new Student("Leif", "Svensson", 960019422);
218
            AcademicTranscript transcript = new AcademicTranscript(student);
219
            AcademicQuarter quarterFall = new AcademicQuarter(AcademicQuarter.QuarterEnum.Fall, 2012);
220
            quarterFall.CourseList = new Course[3];
221
            Course course1 = new Course(221, "Physics", 5);
222
            course1.Grade = 4.0;
223
            quarterFall.CourseList[0] = course1;
224
            Course course2 = new Course(152, "Calc", 5);
225
            course2.Grade = 3.8;
226
            quarterFall.CourseList[1] = course2;
227
            Course course3 = new Course(143, "BIT", 5);
228
            course3.Grade = 3.9;
229
            quarterFall.CourseList[2] = course3;
230
            
231
            transcript.QuarterArray[0] = quarterFall;//repeat for each quarter
232
233
            return transcript;
234
235
        }
236
    }
237
}