Skip to content

Instantly share code, notes, and snippets.

@WilliamGarrow
Created November 16, 2015 01:57
Show Gist options
  • Save WilliamGarrow/6ef9112a52db59d3ffc4 to your computer and use it in GitHub Desktop.
Save WilliamGarrow/6ef9112a52db59d3ffc4 to your computer and use it in GitHub Desktop.
DEV204x Programming with C# - Module Four Assignment
/// Module Four Assignment
using System;
namespace ModuleFourAssignment
{
// Create a struct to represent a student
struct Student
{
public string firstName;
public string lastName;
public DateTime birthDate;
public char gender;
public string declaredMajor;
public string streetAddress;
public string city;
public string stateProvince;
public string zipcodePostal;
public Student(string studentFirstName, string studentLastName, DateTime studentBirthDate,
char studentGender, string studentDeclared, string studentAddress, string studentCity,
string studentStateProv, string studentPostal)
{
this.firstName = studentFirstName;
this.lastName = studentLastName;
this.birthDate = studentBirthDate;
this.gender = studentGender;
this.declaredMajor = studentDeclared;
this.streetAddress = studentAddress;
this.city = studentCity;
this.stateProvince = studentStateProv;
this.zipcodePostal = studentPostal;
}
}
// Create a struct to represent a teacher
struct Teacher
{
public string firstName;
public string lastName;
public string credentials;
public string assignedCurriculum;
public string streetAddress;
public string city;
public string stateProvince;
public string zipcodePostal;
public Teacher(string teacherFirstName, string teacherLastName, string teacherCredentials,
string teacherAssigned, string teacherAddress, string teacherCity,
string teacherStateProv, string teacherPostal)
{
this.firstName = teacherFirstName;
this.lastName = teacherLastName;
this.credentials = teacherCredentials;
this.assignedCurriculum = teacherAssigned;
this.streetAddress = teacherAddress;
this.city = teacherCity;
this.stateProvince = teacherStateProv;
this.zipcodePostal = teacherPostal;
}
}
// Create a struct to represent a program
struct Programme
{
public string title;
public string association;
public string facilitator;
public bool prereq;
public Programme(string programmeTitle, string programmeAssociation,
string programmeFacilitator, bool programmePrereq)
{
this.title = programmeTitle;
this.association = programmeAssociation;
this.facilitator = programmeFacilitator;
this.prereq = programmePrereq;
}
}
// Create a struct to represent a course
struct Course
{
public string title;
public string association;
public int credits;
public string facilitator;
public bool prereq;
public Course(string courseTitle, string courseAssociation, int numberOfCredits,
string courseFacilitator, bool coursePrereq)
{
this.title = courseTitle;
this.association = courseAssociation;
this.credits = numberOfCredits;
this.facilitator = courseFacilitator;
this.prereq = coursePrereq;
}
}
class Program
{
static void Main(string[] args)
{
// Create an array to hold 5 student structs.
Student[] students = new Student[5];
// Assign values to the fields in at least one of the student structs in the array.
Student student = new Student("Johnny", "Bravo", new DateTime(1997, 7, 14), 'M',
"Humanities", "123 Main Street", "Las Vegas", "Nevada", "999999");
students[0] = student;
// Using a series of Console.WriteLine() statements, output the values for the
// student struct that you assigned in the previous step.
Console.WriteLine("--- Student Information ---");
Console.WriteLine("Name:\t\t " + students[0].firstName + " " + students[0].lastName);
Console.WriteLine("BirthDate:\t " + students[0].birthDate.Year);
Console.WriteLine("Gender:\t\t " + students[0].gender);
Console.WriteLine("Major:\t\t " + students[0].declaredMajor);
Console.WriteLine("Address:\t " + students[0].streetAddress);
Console.WriteLine("City:\t\t " + students[0].city);
Console.WriteLine("State:\t\t " + students[0].stateProvince);
Console.WriteLine("Zip:\t\t " + students[0].zipcodePostal);
}
}
}
// Module Four Assignment
// For this assignment, complete the following tasks. For the structs, just include
// member variables and a constructor.Do not create properties at this time.Include
// all the variables that you have created up to this point in time.
// - Create a struct to represent a student
// - Create a struct to represent a teacher
// - Create a struct to represent a program
// - Create a struct to represent a course
// - Create an array to hold 5 student structs.
// - Assign values to the fields in at least one of the student structs in the array
// - Using a series of Console.WriteLine() statements, output the values for the student
// struct that you assigned in the previous step
// When complete, submit your code in the peer review section.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment