Question: Needs to be done using C# Compare Lists of Objects Update the Collections program by doing the following: Compare two lists of Student objects. Assume

Needs to be done using C#

Compare Lists of Objects

Update the Collections program by doing the following:

Compare two lists of Student objects. Assume the newStudentList is an update of the oldStudentList. There are methods to retrieve both the old list and the new list.

Figure and show the following information:

Additions to the old list.

Changes to the old list. IDs do not change, but for instance, a name might.

Removals from old list.

Do this in an efficient manner. Create your own methods in the module as needed.

Do not change the Student class.

-Here is the source code for the Collections Program

-Program.cs

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

namespace Collections { class Program { static void Main(string[] args) { List numbers = new List(5); List ourCustomers = new List(); SortedList custBalances = new SortedList();

Console.WriteLine(numbers.Capacity); numbers.Add(25.5M); numbers.Add(33.23M); numbers.Add(55.5M); numbers.Add(13.23M); numbers.Add(65.5M); numbers.Add(3.23M); Console.WriteLine(numbers.Capacity);

Console.WriteLine(numbers[1]); Console.WriteLine(numbers[3]);

numbers.Sort();

foreach(decimal n in numbers) { Console.WriteLine(n); } ourCustomers.Add(new Customer("Zelda", "437-1257", 555)); ourCustomers.Add(new Customer("Bob", "437-2803", 788)); ourCustomers.Add(new Customer("Bob", "437-3333", 600)); ourCustomers.Add(new Customer("Jack", "437-2233", 488)); ourCustomers.Add(new Customer("Allan", "455-2424", 777));

foreach (Customer c in ourCustomers) { custBalances.Add(c.Name + c.Phone,c); }

foreach (KeyValuePair customer in custBalances) { Console.WriteLine( customer.Value); }

//ourCustomers.Sort(); //foreach(Customer c in ourCustomers) //{ // Console.WriteLine(String.Format("{0} {1} {2} ",c.Name,c.Phone, c.CreditRating)); //}

Console.ReadLine();

} } }

-Customer.cs

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

namespace Collections { class Customer { public string Name { get; set; } public string Phone { get; set; } public int CreditRating { get; set; }

public Customer() {

} public Customer(string theName, string thePhone, int rating) { this.Name = theName; this.Phone = thePhone; this.CreditRating = rating;

}

public override string ToString() { return string.Format("{0} {1} {2} ",Name,Phone, CreditRating); } } }

Source code for Old and New Students program

-Student.cs

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

namespace OldandNewStudents { public class Student { // Sample Student class // Each student has a first name, a last name, a class year, and a rank // that indicates academic ranking in the student body.

public string ID { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public string StudentYear { get; set; } public int StudentRank { get; set; }

public Student(string idNumber, string firstName, string lastName, string studentYear, int studentRank) { ID = idNumber; FirstName = firstName; LastName = lastName; StudentYear = studentYear; StudentRank = studentRank; }

public override string ToString() { return ID + " " + FirstName + " " + LastName + " " + StudentYear + " " + StudentRank; } } }

-Program.cs

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

namespace OldandNewStudents { class Program { static void Main(string[] args) { //Display lists of students Console.WriteLine("Here is the list of old students: "); ShowStudents(GetStudentsOld()); Console.WriteLine("Here is the list of new students: "); ShowStudents(GetStudentsNew());

//Show the additions Console.WriteLine("Here is the list Additions: ");

//Show the changes Console.WriteLine("Here is the list of Changes: ");

//Show the removed students Console.WriteLine("Here is the list of removed students: ");

Console.ReadLine(); }

public static List GetStudentsOld() { List students = new List(); students.Add(new Student("111", "Michael", "Tucker", "Junior", 10)); students.Add(new Student("222", "Svetlana", "Omelchenko", "Senior", 2)); students.Add(new Student("333", "Michiko", "Osada", "Senior", 7)); students.Add(new Student("444", "Hugo", "Garcia", "Junior", 16)); students.Add(new Student("555", "Cesar", "Garcia", "Freshman", 4)); students.Add(new Student("666", "Fadi", "Fakhouri", "Senior", 72)); students.Add(new Student("777", "Hanying", "Feng", "Senior", 11)); students.Add(new Student("888", "Debra", "Garcia", "Junior", 41)); students.Add(new Student("999", "Terry", "Adams", "Senior", 6)); students.Add(new Student("211", "Bob", "Stephenson", "Junior", 150)); return students; }

public static List GetStudentsNew() { List students = new List(); students.Add(new Student("111", "Michael", "Tucker", "Junior", 10)); students.Add(new Student("222", "Svetlana", "Omelchenko", "Senior", 2)); students.Add(new Student("333", "Michiko", "Osada", "Senior", 7)); students.Add(new Student("311", "Sven", "Mortensen", "Freshman", 53)); students.Add(new Student("444", "Hugo", "Garcia", "Freshman", 16)); students.Add(new Student("555", "Cesar", "Garcia", "Freshman", 4)); students.Add(new Student("666", "Fadi", "Fakhouri", "Senior", 72)); students.Add(new Student("777", "Hanying", "Feng", "Senior", 11)); students.Add(new Student("888", "Debra", "Garcia", "Junior", 41)); students.Add(new Student("411", "Lance", "Tucker", "Junior", 60)); students.Add(new Student("999", "Terry", "Adams", "Senior", 6)); return students; }

public static void ShowStudents(List stuList) { Console.WriteLine();

foreach (Student s in stuList) { Console.WriteLine(s); } Console.WriteLine(); } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!