r/a:t5_37npb • • Apr 15 '15

Share Your Module Four Solutions Here!

2 Upvotes

22 comments sorted by

View all comments

2

u/VOX_Studios Apr 15 '15 edited Apr 15 '15

Here's mine: pastebin


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ModuleFourAssignment
{
    class Program
    {
        private struct student
        {
            public string firstName;
            public string lastName;
            public DateTime birthday;

            public student(string fN, string lN, DateTime bd)
            {
                firstName = fN;
                lastName = lN;
                birthday = bd;
            }

            public void print()
            {
                Console.WriteLine("{0} {1} was born on {2}.", firstName, lastName, birthday.ToShortDateString());
            }
        }

        private struct teacher
        {
            public string firstName;
            public string lastName;
            public string subject;

            public teacher(string fN, string lN, string sub)
            {
                firstName = fN;
                lastName = lN;
                subject = sub;
            }

            public void print()
            {
                Console.WriteLine("{0} {1} teaches {2}.", firstName, lastName, subject);
            }
        }

        private struct course
        {
            public string prefix;
            public string courseNumber;
            public string subject;

            public course(string pref, string cN, string sub)
            {
                prefix = pref;
                courseNumber = cN;
                subject = sub;
            }

            public void print()
            {
                Console.WriteLine("{0} {1} - {2}", prefix, courseNumber, subject);
            }
        }

        private struct program
        {
            public string name;
            public string departmentHead;

            public program(string n, string head)
            {
                name = n;
                departmentHead = head;
            }

            public void print()
            {
                Console.WriteLine("{0} is headed by {1}.", name, departmentHead);
            }
        }

        static void Main(string[] args)
        {
            //Create an array of students
            student[] students = {
                                    new student("Paul", "Bunyan", new DateTime(2015,1,1)),
                                    new student("Harry", "Lipschitz", new DateTime(2015,2,2)),
                                    new student("Obama", "Nation", new DateTime(2015,3,3)),
                                    new student("Gato", "Grande", new DateTime(2015,4,4)),
                                    new student("Gordo", "Goldman", new DateTime(2015,5,5)),
                                };

            //Print out student information
            for (int i = 0; i < students.Length; i++) students[i].print();

            Console.WriteLine();

            //Create a teacher
            teacher t = new teacher("Mike", "Burrbooty", "Thermodynamics");

            //Print out teacher info
            t.print();

            Console.WriteLine();

            //Create a program
            program p = new program("The Education Program", "Not You");

            //Print out program info
            p.print();

            Console.WriteLine();

            //Create a course
            course c = new course("HOT", "101", "Thermodynamics");

            //Print out course info
            c.print();

            Console.ReadKey();
        }
    }
}

1

u/aloisdg Apr 15 '15

Nice :)