Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

nothing is harder than this subject, Cheat Sheet of Technology

better listen to your tutor and parents

Typology: Cheat Sheet

2020/2021

Uploaded on 06/29/2023

tran-hoang-phuc-fgw-dn
tran-hoang-phuc-fgw-dn 🇻🇳

5 documents

Partial preview of the text

Download nothing is harder than this subject and more Cheat Sheet Technology in PDF only on Docsity! Class university: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace StudentM2 { class University { public string Name { get; set; } List<Student> Students { get; set; } public University() { Students = new List<Student>(); } public University(string name, List<Student> students) { Name = name; Students = students; } public University(string name) { Name=name; Students = new List<Student> { new Student (1,"Binh",8.9,"L01"), new Student (2,"Name",3.5,"L01"), new Student (3,"Name",7.9,"L02"), new Student (4,"Name",5.2,"L02") }; } public int FindStudentID(int id) { int positon = -1; for (int i = 0; i < Students.Count; i++) { if (Students[i].Id == id) { positon = i; return positon; } } return positon; } public void ViewStudentList() { foreach(var item in Students) { item.printInformation(); } } // them 1 sinh vien vao list, nhap tu ban phim, //phai kiem tra id cos ton tai truoc khi them 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) { ClasID = clasID; Name = name; } } } Class Program: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace StudentM2 { 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(); } } } Class program using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace StudentM2 { 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(); } } }
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved