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

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
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
pf3
pf4
pf5

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 StudentM { class University { public string Name { get; set; } List Students { get; set; } public University() { Students = new List(); } public University(string name, List students) { Name = name; Students = students; } public University(string name) { Name=name; Students = new List { 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)

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(); } } }

Class classID

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; } } }

Class Program:

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(); } } }

Class program

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(); } } }