Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace AcademicTranscript
- {
- class Student
- {
- private string _firstName;
- private string _lastName;
- private int _studentID;
- public string FirstName { get { return this._firstName; } }
- public string LastName { get { return this._lastName; } }
- public int StudentID { get { return this._studentID; } }
- public Student (string firstName, string lastName, int studentID)
- {
- this._firstName = firstName;
- this._lastName = lastName;
- this._studentID = studentID;
- }
- public string FullName()
- {
- return this._firstName + " " + this._lastName;
- }
- }
- class AcademicQuarter
- {
- private QuarterEnum _currentQuarter;
- private int _year;
- private double _gpa;
- private Course[] _courseList;
- public QuarterEnum CurrentQuarter { get { return this._currentQuarter; } }
- public int Year { get { return this._year; } }
- public double GPA
- {
- get
- {
- double crsGPA = 0;
- foreach (Course crs in this.CourseList)
- {
- crsGPA += crs.Grade;
- }
- this._gpa = (crsGPA / this.CourseList.Length);
- return this._gpa;
- }
- }
- public Course[] CourseList
- {
- get
- {
- return this._courseList;
- }
- set
- {
- this._courseList = value;
- }
- }
- public enum QuarterEnum
- {
- Fall = 0,
- Winter,
- Spring,
- Summer
- }
- public AcademicQuarter(QuarterEnum qType, int year)
- {
- this._currentQuarter = qType;
- this._year = year;
- }
- public AcademicQuarter(QuarterEnum qType, int year, Course[] cList)
- {
- this._currentQuarter = qType;
- this._year = year;
- this.CourseList = cList;
- }
- }
- class Course
- {
- private int _id;
- private string _title;
- private int _credits;
- private double _grade;
- public int ID { get { return this._id; } }
- public string Title { get { return this._title; } }
- public int Credits { get { return this._credits; } }
- public double Grade
- {
- get
- {
- return this._grade;
- }
- set
- {
- this._grade = value;
- }
- }
- public Course(int cID, string title, int credits)
- {
- this._id = cID;
- this._title = title;
- this._credits = credits;
- }
- public void PrintCourses()
- {
- Console.WriteLine("Course: {0}\tCredits: {1} Grade: {2}", this.ID, this.Title, this.Credits);
- }
- }
- class AcademicTranscript
- {
- private Student _student;
- private AcademicQuarter[] _quarterArray;
- public AcademicTranscript(Student student)
- {
- this._student = student;
- }
- public Student CurrentStudent
- {
- get
- {
- return this._student;
- }
- }
- public AcademicQuarter[] QuarterArray
- {
- get
- {
- if (this._quarterArray == null)
- {
- this._quarterArray = new AcademicQuarter[4];
- }
- return this._quarterArray;
- }
- }
- /// <summary>
- /// student name: leif
- /// student id: 2342
- ///
- /// quarter: fall of 2013
- /// course: phys 221 credits: 5 grade: 3.9
- /// GPA: 3.9
- /// Cumulative GPA: 3.9
- ///
- /// API Documentation (Look this up!!!!)
- /// </summary>
- public void PrintTranscript()
- {
- StringBuilder printOutput = new StringBuilder();
- printOutput.Append("Student Name: ");
- printOutput.Append(this.CurrentStudent.FullName());
- printOutput.AppendLine();
- printOutput.Append("Student ID: ");
- printOutput.Append(this.CurrentStudent.StudentID);
- printOutput.AppendLine();
- double cumulativeGpa = 0;
- int currentQuarterCount = 1;
- foreach (AcademicQuarter aq in this.QuarterArray)
- {
- if (aq != null)
- {
- printOutput.AppendLine(aq.CurrentQuarter.ToString()); //add .ToString() to print out enum as "Fall"
- printOutput.AppendLine(aq.Year.ToString());
- foreach (Course crse in aq.CourseList)//add number of elements, divide total by number of elements in array
- {
- printOutput.AppendLine(crse.Title + " " + crse.ID.ToString() + " " + crse.Credits.ToString() + " " + crse.Grade.ToString());
- }
- printOutput.AppendLine("GPA: " + aq.GPA.ToString());
- cumulativeGpa += aq.GPA;
- printOutput.AppendLine("Cumulative GPA: " + (cumulativeGpa / currentQuarterCount).ToString());
- currentQuarterCount++;
- }
- }
- Console.Write(printOutput.ToString());
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- AcademicTranscript transcript = PopulateData();
- transcript.PrintTranscript();
- Console.ReadKey();
- }
- /// <summary>
- /// create a transcript.AddQuarter that takes academic quarter as argument
- ///
- /// AddQuarter(Quarter quarter)
- /// {
- /// what is the next available index QuarterArray
- /// fill quarter into next available index
- /// }
- /// </summary>
- /// <returns></returns>
- static AcademicTranscript PopulateData()
- {
- Student student = new Student("Leif", "Svensson", 960019422);
- AcademicTranscript transcript = new AcademicTranscript(student);
- AcademicQuarter quarterFall = new AcademicQuarter(AcademicQuarter.QuarterEnum.Fall, 2012);
- quarterFall.CourseList = new Course[3];
- Course course1 = new Course(221, "Physics", 5);
- course1.Grade = 4.0;
- quarterFall.CourseList[0] = course1;
- Course course2 = new Course(152, "Calc", 5);
- course2.Grade = 3.8;
- quarterFall.CourseList[1] = course2;
- Course course3 = new Course(143, "BIT", 5);
- course3.Grade = 3.9;
- quarterFall.CourseList[2] = course3;
- transcript.QuarterArray[0] = quarterFall;//repeat for each quarter
- return transcript;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement