Project
School/Student Phonebook
Your task is to create the classes School, Student and Phonebook, such that the following Main( ) function should compile and execute correctly:
Implementation hints:
• Create the classes Phonebook, School and Student. You will need to write a constructor for School that accepts a single string which is the name of the school.
• Create properties for the class School. The class School needs only one property which stores the name of the school (of type string). It also needs a class member variable which stores a collection of students. The best way to do that is to use a class similar to C++'s std::vector, called List<>. It can be found in the namespace System.Collections.Generic, so you will need to add a using statement at the top of the School.cs file. Then, you should initialize this variable in the class constructor:
Students = new List( );
• Similarly you have to add one class member variable (property of the List)to the class PhoneBook which stores a collection of schools. You could use the same method as for studens for this property.
• Add a function to the class School called AddStudent. It should accept a single parameter of type Student. It should simply store the student instance in the List member variable (use the Add( ) function which works similarly to the push_back( ) function in std::vector).
• Add properties to the class Student. You will need two properties: SSN, Name and Age. I'll leave it to you to figure out the type of these properties.
• Override the ToString functions in both classes (see the book for details). The Student version of ToString is quite simple, while the School implementation will need the following:
o A local string variable that will contain the end result. You can then use the += operator to concatenate to this variable, and use System.Environment.NewLine; to add a newline to the string. Example:
string result = "Some string" + System.Environment.NewLine; result += "some other string";
o A loop that walks through all students in the collection (also, see the book about foreach statements), and adds each student to the string. Note: you can either call the ToString method for each student explicitly, or use a syntax similar to the one seen inside Main above, where the School instance is printed out explicitly.
• You will new to added the following functions to the PhoneBook class in order to comply with the main program given:
o AddNewSchool:
- Ask user for name. Create new school and add to PhoneBook schools.
o AddNewStudentToSchool:
- For this part you will have to figure out how to ask the user for which school to add the student to. One solution could be to ask the user for the index of the school and then ask user for ssn, name and age, and add the student to chosen school.
o EditStudentInSchool:
- Very similar for when adding new students to schools, you will have to figure out how to ask the user for which school to look for the student in as well as how to ask the user for which student to edit. Both could be solved by asking the user for index of school and then index of student in the corresponding list. Then just ask user for update ssn, name and age, and update the chosen student.
o Override the ToString:
- Simililar to the School class, you could have a loop that walks through all school in the phonebook and call the ToString method for each school explicitly. The printout example above should give you a good idea this should look like
o Html:
- This function should be very similar to sample printout, e.i. it should return a string containing the printout for the entire phonebook. The only difference being that output should be valid HTML.
- This could be an example for the HTML function:
public string Html()
{
StringBuilder result = new StringBuilder();
//...
result.Append(" append html some content ");
//...
//Create and save file a project root
using (StreamWriter writer = new StreamWriter("result.html"))
{
writer.WriteLine(result);
}
//return HTML
return result.ToString();
}
- You will also need to implement the following requirements:
• Make sure to have a single table in the body of the document
• ,
,
, and are mandatory
• all tags must be properly nested
• all tags are in lowercase (
instead of )
• all tags are properly closed, and empty elements have a trailing slash
• (, and )
• all attribute values are properly quoted ( instead of )
• all attribute names must be in lower case
Hand in
The deadline for this assignment can be seen on myschool. Hand in a single .zip/.rar/.7z file containing the .cs files plus the .exe file:
• School.cs
• Student.cs
• PhoneBook.cs
• Program.cs
• PhoneBookApp.exe
Please note that this is an individual assignment.
Attachment:- Project.pdf