



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
better listen to your tutor and parents
Typology: Cheat Sheet
1 / 6
This page cannot be seen from the preview
Don't miss anything!




Class university: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace StudentM { class University { public string Name { get; set; } List
public void addNewStudent() { var student = new Student(); Console.WriteLine("Input information of a new student!!!!"); Console.Write("Input student ID: "); int ID = -1; bool isAvailableID = false; while (isAvailableID == false) try { ID = int.Parse(Console.ReadLine()); if (FindStudentID(ID) == -1) isAvailableID = true; else Console.Write("Student ID exists, please reenter the Student ID: "); } catch (Exception) { Console.Write("Wrong Student ID, please reenter the ID: "); } Console.Write("Input stiudent name: "); string name = Console.ReadLine(); Console.Write("Input GPA of student: "); double GPA= double.Parse(Console.ReadLine()); Console.Write("Input class ID: "); string classID = Console.ReadLine(); if (FindStudentID(ID) == -1) { Students.Add(new Student(ID,name,GPA,classID)); } else { Console.WriteLine("ID Student exists!!!!"); } } // Xoa thong tin mot sinh vien theo ID public void Delete() { Console.Write("Enter ID to delete student: "); int If =int.Parse(Console.ReadLine()); foreach(var item in Students) { if (FindStudentID(If) != -1) { Students.Remove(new Student()); } } } // cap nhat thong tin: input: ID, ten moi public void FindTheIDAndFix() { Console.Write("Enter ID to find : "); int id = int.Parse(Console.ReadLine()); foreach (var item in Students) { if (item.Id == id)
namespace StudentM { internal class Student { public int Id { get; set; } public string Name { get; set; } public double GPA { get; set; } public string ClassID { get; set; } public Student() { } public Student(int id, string name, double gPA, string classID) { Id = id; Name = name; GPA = gPA; ClassID=classID; } public void printInformation() { Console.WriteLine($" ID: {Id} - Name: {Name} - GPA: {GPA} ClassId: {ClassID}"); } public override string ToString() { return ($" ID: {Id} - Name: {Name} - GPA: {GPA} ClassId: {ClassID}"); } public void Input() { Console.WriteLine("Enter Student information: "); Console.Write("ID: "); Id = int.Parse(Console.ReadLine()); Console.Write("name : "); Name = Console.ReadLine(); Console.Write("GPA : "); string st = Console.ReadLine(); GPA = double.Parse(st); Console.Write("ClassID : "); ClassID = Console.ReadLine(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace StudentM { internal class ClassName { public String ClasID { get; set; } public string Name { get; set; } public ClassName(string clasID, string name)
ClasID = clasID; Name = name; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace StudentM { internal class Program { static void Main(string[] args) { University university = new University("Greenwich"); university.ViewStudentList(); //university.addNewStudent(); university.ViewStudentList(); university.FindTheIDAndFix(); university.ViewStudentList(); Console.ReadLine(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace StudentM { internal class Program { static void Main(string[] args) { University university = new University("Greenwich"); university.ViewStudentList(); //university.addNewStudent(); university.ViewStudentList(); university.FindTheIDAndFix(); university.ViewStudentList(); Console.ReadLine(); } } }