Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbuysse/14f0777cb6424485ec04085b4344ff35 to your computer and use it in GitHub Desktop.
Save rbuysse/14f0777cb6424485ec04085b4344ff35 to your computer and use it in GitHub Desktop.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Module8
{
class Program
{
static void Main(string[] args)
{
Student student0 = new Student("Dave", "Jones", "Jan 7");
Student student1 = new Student("Jessica", "Clark", "Feb 29");
Student student2 = new Student("Jesus", "(no last name)", "Dec 25");
Course course0 = new Course("Programming with C#", "1", "Cool Course Bro");
student0.Grades.Push("A");
student0.Grades.Push("A+");
student0.Grades.Push("B");
student0.Grades.Push("A");
student0.Grades.Push("F");
student1.Grades.Push("C");
student1.Grades.Push("C+");
student1.Grades.Push("C");
student1.Grades.Push("C");
student1.Grades.Push("C");
student2.Grades.Push("F");
student2.Grades.Push("F");
student2.Grades.Push("F");
student2.Grades.Push("F");
student2.Grades.Push("F");
course0.StudentList.Add(student0);
course0.StudentList.Add(student1);
course0.StudentList.Add(student2);
course0.ListStudents();
}
}
class Person
{
public Person(string pfname, string plname)
{
this.Firstname = pfname;
this.Lastname = plname;
}
private string _firstname;
public string Firstname
{
get { return _firstname; }
set { _firstname = value; }
}
private string _lastname;
public string Lastname
{
get { return _lastname; }
set { _lastname = value; }
}
}
class Student : Person
{
private static int studentcount = 0;
public Student(string fname, string lname, string bday)
: base(fname, lname)
{
this.Birthday = bday;
this.Grades = new Stack<String>();
Interlocked.Increment(ref studentcount);
}
~Student()
{
Interlocked.Decrement(ref studentcount);
}
private string _birthday;
private Stack<String> _grades;
public Stack<String> Grades
{
get { return _grades; }
set { _grades = value; }
}
public string Birthday
{
get { return _birthday; }
set { _birthday = value; }
}
public static int GetStudentCount()
{
return studentcount;
}
public void takeTest()
{
throw new NotImplementedException();
}
}
class Course
{
public Course(string cname, string ccreds, string cdesc)
{
this.courseName = cname;
this.courseCredits = ccreds;
this.courseDescript = cdesc;
this.StudentList = new List<Student>();
}
private string _courseName;
public string courseName
{
get { return _courseName; }
set { _courseName = value; }
}
private string _courseCredits;
public string courseCredits
{
get { return _courseCredits; }
set { _courseCredits = value; }
}
private string _courseDescript;
public string courseDescript
{
get { return _courseDescript; }
set { _courseDescript = value; }
}
private List<Student> _studentList;
public List<Student> StudentList
{
get { return _studentList; }
set { _studentList = value; }
}
public void ListStudents()
{
foreach (Student student in _studentList)
{
Console.WriteLine("{0} {1}", student.Firstname, student.Lastname);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment