ToString() public method

public ToString ( ) : string
return string
示例#1
0
        public static void Main()
        {
            Student firstStudent = new Student("Pesho", "Georgiev", "Ivanov", "Sofia", "+3849384398",
                "*****@*****.**", 3122, Specialties.Telecommunications, Universities.TU, Faculties.Law);

            Student secondStudent = new Student("Dancho", "Ivanov", "Petrov", "Plovdiv", "039483439",
                "*****@*****.**", 23453, Specialties.IT, Universities.NBU, Faculties.Mathematics);

            Console.WriteLine("First student HashCode: " + firstStudent.GetHashCode());
            Console.WriteLine("Second student HashCode: " + secondStudent.GetHashCode());
            Console.WriteLine("First student equals second student: " + firstStudent.Equals(secondStudent));
            Console.WriteLine("First student == second student: " + (firstStudent == secondStudent));
            Console.WriteLine("First student != second student: " + (firstStudent != secondStudent));
            Console.WriteLine();
            Console.WriteLine(secondStudent.ToString());
            Console.WriteLine();

            Student thirdStudent = (Student)secondStudent.Clone();

            Console.WriteLine("Second student == third student: " + (secondStudent == thirdStudent));
            Console.WriteLine("Second student != third student: " + (secondStudent != thirdStudent));
            Console.WriteLine("Second student.CompareTo(third student): " + secondStudent.CompareTo(thirdStudent));
            Console.WriteLine("First student.CompareTo(Second student): " + firstStudent.CompareTo(secondStudent));
            Console.WriteLine(firstStudent.ToString());
            Console.WriteLine(secondStudent.ToString());
            Console.WriteLine(thirdStudent.ToString());
        }
        static void Main()
        {
            Student s1 = new Student("Borislav", "Borisov", 6004399);
            Console.WriteLine(s1.ToString());

            Student s2 = new Student("Ivan", "Borisov", 600123);

            //Hashcode of student 1
            Console.WriteLine(s2.GetHashCode());

            //Doing shadow clone of s1
            Student s3 = (Student)s1.Clone();
            s3.FirstName = "Robert";

            Console.WriteLine(s1.ToString());
            Console.WriteLine(s3.ToString());

            int result = s1.CompareTo(s3);
            if (result < 0)
            {
                Console.WriteLine("s1 is smaller");
            }
            else if (result > 0)
            {
                Console.WriteLine("s2 is smaller");
            }
            else
            {
                Console.WriteLine("they are equal");
            }
            Console.WriteLine(s1 == s2);
        }
示例#3
0
        static void Main()
        {
            var student1 = new Student("John", "Atanasov", "421586353");

            var studentEqual = new Student("John", "Atanasov", "421586353");
            Console.WriteLine("Different objects with the same properties are equal: {0}",student1.Equals(studentEqual));
            Console.WriteLine();

            Student student1DeepCopy = student1.Clone();
            Console.WriteLine("The copy and the original are the same: {0}", student1.Equals(student1DeepCopy));
            Console.WriteLine("The copy reference the original -> " + ReferenceEquals(student1, student1DeepCopy));
            Console.WriteLine();

            var student2 = new Student("John", "Atanasov", "421586353");
            var student3 = new Student("Peter", "Nikolov", "245124749");
            CompareStudents(student1, student2);
            CompareStudents(student1, student3);
            CompareStudents(student2, student3);
            Console.WriteLine();

            Console.WriteLine(student1.ToString());
            Console.WriteLine();

            student1.MiddleName = "Ivanov";
            student1.MobilePhone = "0885123456";
            student1.Faculty = Faculty.Bachelor;
            student1.University = University.SU;
            Console.WriteLine(student1.ToString());
            Console.WriteLine();
        }
示例#4
0
        private static void Main()
        {
            try
            {
                Student pesho = new Student("Pesho Georgiev");
                Student gosho = new Student("Gosho Ivanov");
                Student misho = new Student("Misho Cekov");
                Student sasho = new Student("Sasho Kostov");

                Course telerikAcademy = new Course("Telerik Academy");
                Course webProgramming = new Course("Web Programming");

                webProgramming.AddStudent(sasho);

                telerikAcademy.AddStudent(pesho);
                telerikAcademy.AddStudent(gosho);
                telerikAcademy.AddStudent(misho);

                telerikAcademy.RemoveStudent(gosho);
                Console.WriteLine(gosho.ToString() + " was removed from course.");

                Console.WriteLine("Courses:");
                Console.WriteLine(telerikAcademy);

                School freeSchool = new School("School of Computer Sciences");
                freeSchool.AddCourse(webProgramming);
                freeSchool.AddCourse(telerikAcademy);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    static void Main(string[] args)
    {
        var o = new
        {
            Id      = 1,
            Name    = "Patrick",
            Courses = new[] { new { Id = 1, Name = "C#" } }
        };

        Student student = null;
        Scholar scholar = null;

        if (o.CanBeConverted <Student>())
        {
            student = o.ConvertToType <Student>();
        }
        else if (o.CanBeConverted <Scholar>())
        {
            scholar = o.ConvertToType <Scholar>();
        }

        System.Console.WriteLine(student?.ToString());
        System.Console.WriteLine(scholar?.ToString());

        System.Console.ReadKey();
    }
示例#6
0
        static void Main(string[] args)
        {
            // test the constructor with initializerz
            Student firstStudent = new Student("Petar", "Ivanov", "Georgiev", "3210-2112-35435",
                "Sofia, Vasil Levski Str., No 201", "0888197143",
                "*****@*****.**", "Java Programming", Specialty.ComputerScience,
                Faculty.MathsAndInformatics, University.SofiaUniversity);

            // test the Clone() method
            Student cloned = (Student)firstStudent.Clone();

            // test the ToString() method
            Console.WriteLine("Information about the first student:");
            Console.WriteLine(firstStudent.ToString());

            Console.WriteLine("Information about the cloned student: ");
            Console.WriteLine(cloned.ToString());

            //test the equality operator
            Console.WriteLine("The two students are equal: {0}",
                firstStudent == cloned);

            cloned.MiddleName = "Dimitrov";
            cloned.SSN = "98978989-8984934-0435";

            //test the CompareTo() method
            Console.WriteLine("Some properties were changed. CompareTo returns: {0}",
                firstStudent.CompareTo(cloned));
        }
示例#7
0
 public void Student_ToStringTest()
 {
     string name = "Pesho";
     int id = 12345;
     Student testStudent = new Student(name, id);
     Assert.AreEqual("Student Pesho, Unique number 12345;", testStudent.ToString());
 }
示例#8
0
        static void Main(string[] args)
        {
            //Create 3 test students
            Student firstStudent = new Student("Gosho", "Ivanov", "Peshov", "11122", "Gosho Street", "02423423", "*****@*****.**", 1,
                Universities.HarvardUniversity, Faculties.FacultyOfComputerScience ,Specialties.ComputerGraphics);
            Student secondStudent = new Student("Ivan", "Georgiev", "Alexandrov", "15624", "Pesho Street", "09415743", "*****@*****.**", 2,
                Universities.MassachusettsInstituteofTechnology, Faculties.FacultyOfComputerScience, Specialties.ArtificialIntelligence);
            Student thirdStudent = new Student("Gosho", "Ivanov", "Peshov", "10021", "Ivan Street", "931234", "*****@*****.**", 1,
                Universities.SofiaUniversity, Faculties.FacultyOfComputerScience, Specialties.ComputerProgramming);

            //Clone a student from the first
            Student clonedStundent = firstStudent.Clone() as Student;

            Console.WriteLine(firstStudent.ToString());
            Console.WriteLine(secondStudent.ToString());
            Console.WriteLine(thirdStudent.ToString());
            Console.WriteLine("First student == Second Student ?:{0}", firstStudent == secondStudent);
            Console.WriteLine("First student != Third Student ?:{0}", firstStudent != thirdStudent);
            Console.WriteLine("First student Equals Cloned Student ?:{0}", firstStudent.Equals(clonedStundent));
            Console.WriteLine("First student compared to Second Student (in ints): {0}", firstStudent.CompareTo(secondStudent));
            Console.WriteLine("First student compared to Third Student (in ints): {0}", firstStudent.CompareTo(thirdStudent));
            Console.WriteLine("First student compared to Cloned Student (in ints): {0}", firstStudent.CompareTo(clonedStundent));

            //Before change
            Console.WriteLine("Is first student number equal to cloned first student number ? {0}", firstStudent.MobilePhone == clonedStundent.MobilePhone);
            //The first student changes his number
            firstStudent.MobilePhone = "088888888";

            //Compare the cloned first student to the changed one
            Console.WriteLine("Is first student number equal to cloned first student number ? {0}", firstStudent.MobilePhone == clonedStundent.MobilePhone);
        }
        public void TestStudentToString1()
        {
            Student kentBeck = new Student("Kent Beck");

            Assert.AreEqual(
                string.Format("{{ Id = {0}, Name = Kent Beck }}", kentBeck.Id),
                kentBeck.ToString(),
                "Student.ToString() is not correct.");
        }
示例#10
0
 public void ToStringTest()
 {
     string name = "Maria Petrova";
     int uniqueNumber = 12345;
     Student student = new Student(name, uniqueNumber);
     string expected = "Student Maria Petrova, ID 12345; ";
     string actual;
     actual = student.ToString();
     Assert.AreEqual(expected, actual);
 }
示例#11
0
 public void ToStringTest()
 {
     string name = "Pesho Petrov";
     int classNumber = 12345;
     Student student = new Student(name, classNumber);
     string expected = "Student Pesho Petrov, ID 12345; ";
     string actual;
     actual = student.ToString();
     Assert.AreEqual(expected, actual);
 }
示例#12
0
        static void Main(string[] args)
        {
            bool result = false;
            int testNum = 0;
            Student st1 = new Student("Pe6o","Pe6ov", "Peshistia", "8514897589");
            Student st2 = (Student)st1.Clone(); // deep copy student st1 to st2
            Student st3 = new Student("Angel", "Yavorov", "Angelov", "123450");

            st2.Ssn= (ulong.Parse(st2.Ssn) + 1).ToString(); // increase st2 ssn with 1

            testNum = 1;
            int returned = st1.CompareTo(st2);
            result = (returned == -1) ? true : false;
            PrintResult(testNum, result);

            testNum = 2;
            st2.Ssn = (ulong.Parse(st2.Ssn) - 2).ToString();
            returned = st1.CompareTo(st2);
            result = (returned == 1) ? true : false;
            PrintResult(testNum, result);

            testNum = 3;
            st2.Ssn = (ulong.Parse(st2.Ssn) + 1).ToString();
            returned = st1.CompareTo(st2);
            result = (returned == 0) ? true : false;
            PrintResult(testNum, result);

            testNum = 4;
            returned = st1.CompareTo(st3);
            result = (returned == 1) ? true : false;
            PrintResult(testNum, result);

            testNum = 5;
            st2 = (Student)st1.Clone();
            result = st1 == st2;
            PrintResult(testNum, result);

            testNum = 6;
            result = !(st1 == st3);
            PrintResult(testNum, result);

            testNum = 7;
            result = st1 != st3;
            PrintResult(testNum, result);

            testNum = 8;
            result = !(st1 != st2);
            PrintResult(testNum, result);

            testNum = 9;
            string resultStr = st1.ToString();
            string expectedStr = "Pe6o Peshistia, SSN = 8514897589";
            result = (resultStr == expectedStr) ? true : false;
            PrintResult(testNum, result);
        }
    static void Main(string[] args)
    {
        Student student1 = new Student("nameF", "nameM", "nameFam", 555, "Address", 033, "FA",
           Universities.Universities1, Specialty.Specialty2, Faculty.Faculty3);
        Student student2 = new Student("nameF", "nameM", "nameFam", 555, "Address", 0331, "FA",
           Universities.Universities1, Specialty.Specialty2, Faculty.Faculty3);
        //It is looking for same ssn
        Console.WriteLine("Are the students equal?");
        Console.WriteLine(student1.Equals(student2));
        //!=
        Console.WriteLine(student1 != student2);
        //to string
        Console.WriteLine("---------------------------------------------------------------------");
        Console.WriteLine(student1.ToString());
        Console.WriteLine("Clone----------------------------------------------------------------");
        // firstName is not private because I want to try this things
        Student clStudent= student1.Clone() as Student;
        //check for first and last name of the clone student
        Console.WriteLine(clStudent.FirstName);
        Console.WriteLine(clStudent.LastName);
        //check for string builder used in ToString
        Console.WriteLine(clStudent.ToString());
        //check what will happen if I rename fistrName of  the clone student
        clStudent.FirstName = "RenameName";
        Console.WriteLine("Rename--------------------------------------------------------------");
        Console.WriteLine("The original name is :{0}",student1.FirstName);
        Console.WriteLine("The new name is      :{0}",clStudent.FirstName);
        //you can not have two people with same SSN, but in this case You can :)
        Console.WriteLine(clStudent.Equals(clStudent));
        Console.WriteLine("Rename and ToString------------------------------------------------");
        Console.WriteLine(clStudent.ToString());
        Console.WriteLine("");
        Console.WriteLine("Ex.3---------------------------------------------------------------");

        Student student3 = new Student("A", "nameM", "nameFam", 455, "Address", 033, "FA",
           Universities.Universities1, Specialty.Specialty2, Faculty.Faculty3);
        Student student4 = new Student("A", "nameM", "nameFam", 555, "Address", 0331, "FA",
           Universities.Universities2, Specialty.Specialty2, Faculty.Faculty2);
        if (student3.CompareTo(student4)== 0)
        {
            Console.WriteLine("Student3 is equal to student4");
        }
        else if (student3.CompareTo(student4) < 0)
        {
            Console.WriteLine("It must be in lexicographic order ");
            Console.WriteLine("First student is : {0}",student3);
            Console.WriteLine("Second student is: {0}",student4);
        }
        else
        {
            Console.WriteLine("It must be in lexicographic order ");
            Console.WriteLine("First student is : {0}", student4);
            Console.WriteLine("Second student is: {0}", student3);
        }
    }
示例#14
0
        /// <summary>
        ///     Comparisons the specified a.
        /// </summary>
        /// <param name="a">a.</param>
        /// <param name="b">The b.</param>
        /// <returns></returns>
        public static int Comparison(Student a, Student b)
        {
            // The Students Do not have the same Name
            // Sort by name
            if (!a.Name.Equals(b.Name)) return a.CompareTo(b);

            // The students have the same type
            return a.ToString().Equals(b.ToString())
                ? a.Number.CompareTo(b.Number)
                : TypeValue(a.GetType()).CompareTo(TypeValue(b.GetType()));
        }
示例#15
0
    static void Main(string[] args)
    {
        Student firstStudent = new Student("Petko", "Georgiev", "Karaulanov", 7811125447, "Makedonska 55", 0888880088, "*****@*****.**",
                "3", Specialties.HTML, Faculties.Economics, Universitaties.FUB);

            Console.WriteLine(firstStudent.ToString());

            Student clonedFirst = firstStudent.Clone();

            Console.WriteLine(clonedFirst.ToString());

            Console.WriteLine("The two students are equals:{0}",firstStudent.Equals(clonedFirst));
    }
示例#16
0
        public static void Main()
        {
            #region Test Student Class
            //test Student class
            Student pesho = new Student("Pesho", "Goshev", "Kirov", 8876, "Bulgaria, Sofia, 84681 st", "986571342",
                                        "*****@*****.**", "second", Specialty.Ikonomics, University.Harvard, Faculty.Buisnes);

            Student pesho2 = new Student("Pesho", "Goshev", "Kirov", 8659, "Bulgaria, Sofia, 84681 st", "986571342",
                                        "*****@*****.**", "second", Specialty.Ikonomics, University.Harvard, Faculty.Buisnes);

            //test == operator and != operator
            Console.WriteLine(pesho == pesho2);

            //test ToString() method
            Console.WriteLine(pesho.ToString());

            //test Equals() method
            Console.WriteLine(pesho.Equals(pesho2));

            //test Clone() method
            object PeshoClone = pesho.Clone();
            Console.WriteLine(PeshoClone);

            //comparison
            if (pesho.CompareTo(pesho2) > 0)
            {
                Console.WriteLine("The two students are the same.");
            }
            #endregion

            #region Test Person Class

            //test functionality of Person
            Person human = new Person("Pesho"); //without age
            Console.WriteLine(human);

            #endregion

            #region Test BitArray64
            BitArray64 num = new BitArray64(7);

            //test Equals()
            Console.WriteLine(num.Equals(7));

            //test enumerator
            //foreach (var bit in num)
            //{
            //    Console.Write(bit);
            //}
            #endregion
        }
示例#17
0
        static void Main(string[] args)
        {
            var studentOne = new Student("Ivan", "Georgiev", "Dimitrov", "0123456789", "Sofia,Some str,15", "35988888888", "*****@*****.**", 4, Specialties.Chemistry, Universities.SofiaUniversity, Faculties.Science);
            var studentTwo = new Student("George", "Dimitrov", "Dimitrov", "9876543210", "Sofia,Some str,25", "077777777", "*****@*****.**", 7, Specialties.Engineering, Universities.TechnicalUniversity, Faculties.MechanicallEngineering);

            //Showing overwritten ToString()
            Console.WriteLine(studentOne.ToString());

            //Task 2: Test
            var studentThree = studentOne.Clone();
            Console.WriteLine(studentThree.ToString());

            //Task 3: Test will return 0 which shows that they are same
            Console.WriteLine(studentOne.CompareTo(studentThree));
        }
        static void Main()
        {
            var student1 = new Student("Damyan","Ralev","Chernev",40867,"8 Kanarche Street", "+359888000000","*****@*****.**", 4 ,University.UniversityOfForestry, Faculty.FacultyOfVeterinaryMedicine, Specialty.VeterinaryMedicine);
            Console.WriteLine(student1.ToString());

            Console.WriteLine();
            var student2 = new Student("Boris", "Sharkov", "Romanov", 40860, "4 Marko Balabanov Street", "+359888888888", "*****@*****.**", 2, University.SofiaUniversity, Faculty.FacultyOfBiology, Specialty.Biology);
            Console.WriteLine(student2.ToString());

            Console.WriteLine();
            var cloneStudent1 = student1.Clone();
            Console.WriteLine("First student's clone:\r\n{0}",cloneStudent1.ToString());

            Console.WriteLine(student1.CompareTo(student2));
        }
示例#19
0
        static void Main()
        {
            Student first = new Student("Rosen", "Valentinov", "Todorov", "dasfasffde");
            Student second = new Student("Nikolay", "Dimitrov", "Terziev", "affaffeefr", "Sonderbotg, str. Kastra Hulia", "+4890839489", "*****@*****.**",
                Course.Fourth, Faculty.Economics, Specialty.Audit, University.UNSS);

            Console.WriteLine(first.ToString());
            Console.WriteLine(second.ToString());
            Console.WriteLine(first.ssn == second.ssn);

            var clone = first.Clone() as Student;
            Console.WriteLine(clone.ToString());
            Console.WriteLine(first.GetHashCode());
            Console.WriteLine(second.GetHashCode());
            clone.FirstName = "Kiril";
            Console.WriteLine(clone.GetHashCode());
        }
示例#20
0
        static void Main(string[] args)
        {
            Osoba osoba = new Osoba();
            osoba.ToString();
            osoba.DajOib();
            osoba.GetHashCode();
            osoba.GetType();
            osoba.Equals( "545451454");

            Osoba osobaStudent = new Student();
            osobaStudent.DajOib();
            osobaStudent.Equals(5);
            osobaStudent.GetHashCode();
            osobaStudent.GetType();
            osobaStudent.ToString();

            //Student studos = new Osoba(); moramo izvesti eksplicitni cast
        }
        private void btnAddStudent_Click(object sender, RoutedEventArgs e)
        {
            Student stud1 = new Student();

            stud1.StudentID     = Convert.ToInt32(txtStudentID.Text);
            stud1.FirstName     = txtFirstName.Text;
            stud1.LastName      = txtLastName.Text;
            stud1.FavoriteColor = txtFavoriteColor.Text;

            string Sentence = stud1.ToString();

            1stStudent.Items.Add(Sentence);

            txtStudentID.Text     = "";
            txtFirstName.Text     = "";
            txtLastName.Text      = "";
            txtFavoriteColor.Text = "";
        }
示例#22
0
        public void ReadStudentByIdRepository(int studentIdIn, int studentIdOut)
        {
            Student entrada = new Student
            {
                StudenId = studentIdIn
            };

            Student salida = new Student
            {
                StudenId = studentIdOut
            };


            System.Console.WriteLine("Entrada: " + entrada.ToString());
            System.Console.WriteLine("Salida:  " + salida.ToString());

            Assert.AreEqual(entrada, salida);
        }
示例#23
0
        public static int CustomSort(Student a, Student b)
        {
            // If the students have different names, sort alphabetically
            if (a.Name.Equals(b.Name) == false) return a.CompareTo(b);

            // If the students have the same name
            if (a.Name.Equals(b.Name))
            {
                // If students have the same type
                return a.ToString().Equals(b.ToString())
                    // Sort by student number
                    ? a.Number.CompareTo(b.Number)
                    // Sort by student type
                    : GetStudentTypeValue(a.GetType()).CompareTo(GetStudentTypeValue(b.GetType()));
            }

            return -1;
        }
示例#24
0
        static void Main(string[] args)
        {
            Osoba osoba = new Osoba();
            string s = osoba.DajOib();
            bool isto = osoba.Equals(new Osoba());
            int hash = osoba.GetHashCode();
            System.Type t1 = osoba.GetType();
            string s1 = osoba.ToString();

            Osoba osobaStudent = new Student();
            string os = osobaStudent.DajOib();
            bool sisto = osobaStudent.Equals(new Osoba());
            int shash = osobaStudent.GetHashCode();
            System.Type st1 = osobaStudent.GetType();
            string s2 = osobaStudent.ToString();

            //Student stud = new Osoba(); //ne moze
        }
示例#25
0
        public async override Task ExecuteWith(TelegramBotClient client, Message message)
        {
            var chatId  = message.Chat.Id;
            var platoon = DutyBot.GetGroupByChatId(chatId)?.Platoon;

            if (platoon == null)
            {
                throw new InvalidIdException("Взаимодействие с данной группой не было инициировано.");
            }

            var queue = platoon.DutyQueue;

            if (Data.Trim().ToLower() == "all")
            {
                platoon.DutyQueue.ExcludeAll();

                await client.SendTextMessageAsync(message.Chat.Id,
                                                  "Все студенты были исключены из списка дежурных)\nТеперь список дежурных пуст!");

                LastStatus = CommandStatus.Success;
                return;
            }

            try
            {
                queue.Exclude(Student.ToString());
            }
            catch (Exception ex)
            {
                await client.SendTextMessageAsync(message.Chat.Id,
                                                  ex.Message);

                LastStatus = CommandStatus.Failure;
                return;
            }

            var exStudent = platoon.GetStudent(Data);

            await client.SendTextMessageAsync(message.Chat.Id,
                                              $"Студент {exStudent} исключён из списка дежурных.");

            LastStatus = CommandStatus.Success;
        }
示例#26
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IStudentDbService dbService)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseMiddleware <LoggingMiddleware>();
            app.UseWhen(context => context.Request.Path.ToString().Contains("eska"), app =>
            {
                app.Use(async(context, next) =>
                {
                    if (!context.Request.Headers.ContainsKey("Index"))
                    {
                        context.Response.StatusCode = StatusCodes.Status401Unauthorized;
                        await context.Response.WriteAsync("brak indeksu");
                        return;
                    }

                    Student student = dbService.GetStudent(context.Request.Headers["Index"].ToString());
                    if (student == null)
                    {
                        context.Response.StatusCode = StatusCodes.Status404NotFound;
                        await context.Response.WriteAsync("nie ma studenta otym indeksie");
                        return;
                    }
                    context.Response.StatusCode = StatusCodes.Status200OK;
                    await context.Response.WriteAsync(student.ToString());
                    await next();
                });
            });

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
示例#27
0
        static void Main(string[] args)
        {
            int x = 10;

            Student student = new Student();        // van Parent klas

            student.Id      = 2658;
            student.Name    = "Mauro";
            student.Address = "Zondernaamstraat";
            student.Phone   = "0477123456";

            student.Fees      = 250.05;         // van Student klas
            student.Marks     = 9;
            student.ClassName = "C#";

            Console.WriteLine(student.ToString());
            Console.WriteLine(x);

            Console.WriteLine();

            Teaching teaching = new Teaching();

            teaching.Id      = 007;
            teaching.Name    = "Kanon";
            teaching.Address = "Whateverstraat";
            teaching.Phone   = "0486987654312";


            Console.WriteLine(teaching.ToString());

            NonTeaching nonteaching = new NonTeaching();

            nonteaching.Id          = 456;
            nonteaching.Name        = "Donnel";
            nonteaching.Address     = "blablastraat";
            nonteaching.Phone       = "003212456";
            nonteaching.Salaray     = 2000.45;
            nonteaching.JobTitle    = "secretaris";
            nonteaching.ManagerName = "manager7";
            nonteaching.ManagerId   = 8910;

            Console.WriteLine(nonteaching.ToString());
        }
示例#28
0
文件: Startup.cs 项目: nayots/SoftUni
        private static void Main(string[] args)
        {
            try
            {
                var studentTokens = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                Student student      = new Student(studentTokens[0], studentTokens[1], studentTokens[2]);
                var     workerTokens = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                Worker  worker       = new Worker(workerTokens[0], workerTokens[1], decimal.Parse(workerTokens[2]), decimal.Parse(workerTokens[3]));

                Console.WriteLine(student.ToString());
                Console.WriteLine();
                Console.WriteLine(worker.ToString());
            }
            catch (ArgumentException ae)
            {
                Console.WriteLine(ae.Message);
            }
        }
示例#29
0
        static void Main(string[] args)
        {
            Person dude_man   = new Person(true, "dude man", 25, 50000, true);
            Person dude_lady  = new Person(false, "dude lady", 22, 0, true);
            Person haxoor_man = new Person(true, "haxoor_man", 12, 500000000, false);

            Student poor_dude = new Student(true, "poor man", 19, 0, true, 2.5, "Math");
            Student rich_mans = new Student(true, "rich_mans", 23, 300000, true, 0.5, "Slacking off");

            Employee dis_wamen = new Employee(false, "dis wamen", 35, 70000, true, 70000, "Head of Diversity");
            Employee richard   = new Employee(true, "richard", 67, 30000, true, 30000, "Sir Richard, Butler of Huthering Weights");

            poor_dude.Age             = -1;
            poor_dude.FavoriteSubject = "Biology";
            poor_dude.Name            = "1235453";
            Console.WriteLine(dude_man.ToString());
            Console.WriteLine(poor_dude.ToString());
            Console.WriteLine(richard.ToString());
        }
示例#30
0
        public void Run()
        {
            StringBuilder result = new StringBuilder();

            string[] studentInput = Console.ReadLine()
                                    .Split(' ', StringSplitOptions.RemoveEmptyEntries);
            try
            {
                string  studentFirstName = studentInput[0];
                string  studentLastName  = studentInput[1];
                string  facultyNumber    = studentInput[2];
                Student student          = new Student(studentFirstName, studentLastName, facultyNumber);
                result.AppendLine(student.ToString());
                result.AppendLine();
            }
            catch (FormatException ex)
            {
                Console.WriteLine(ex.Message);
                Environment.Exit(0);
            }

            string[] workerInput = Console.ReadLine()
                                   .Split(' ', StringSplitOptions.RemoveEmptyEntries);
            try
            {
                string  workerFirstName = workerInput[0];
                string  workerLastName  = workerInput[1];
                decimal workerSalary    = decimal.Parse(workerInput[2]);
                int     workHours       = int.Parse(workerInput[3]);
                Worker  worker          = new Worker(workerFirstName,
                                                     workerLastName,
                                                     workerSalary,
                                                     workHours);
                result.AppendLine(worker.ToString());
            }
            catch (FormatException ex)
            {
                Console.WriteLine(ex.Message);
                Environment.Exit(0);
            }

            Console.WriteLine(result.ToString());
        }
示例#31
0
        private void tsmiSummaryStudentProgress_Click(object sender, EventArgs e)
        {
            if (_student == null)
            {
                return;
            }
            var t   = Type.Missing;
            var xl1 = new Microsoft.Office.Interop.Excel.Application();

            xl1.Visible = true;
            var       book  = xl1.Workbooks.Add(t);
            var       lists = book.Worksheets;
            Worksheet list  = lists.Item[1];
            var       cell  = xl1.Selection.Cells;

            list.Range["C3", t].Value2  = _student.ToString();
            list.Range["C4", t].Value2  = _student.BirthDay.ToShortDateString();
            list.Range["H5", t].Value2  = "Минский радиотехнический колледж";
            list.Range["H6", t].Value2  = "г.Минск";
            list.Range["C7", t].Value2  = _student.EducationCertificate;
            list.Range["C8", t].Value2  = Helper.GetStudyGroupById(_student.IdStudyGroup).TrainingPeriod + " года";
            list.Range["C9", t].Value2  = Helper.SpecialityById(_student.IdSpeciality);
            list.Range["C10", t].Value2 = Helper.SpecializationById(_student.IdSpecialization);
            var row = 12;

            foreach (var semester in _root.Semesters)
            {
                var report = ReportsBuilder.GetStudentPerformance(_root, semester, _student);
                if (report.ReportRows.Count == 0)
                {
                    continue;
                }
                list.Range[$"A{row}", t].Value2 = $"Семестр {semester}";
                row++;
                for (var i = 0; i < report.ReportRows.Count; i++)
                {
                    list.Range[$"B{row}", t].Value2 = report.ReportRows[i].Items[0];
                    list.Range[$"H{row}", t].Value2 = report.ReportRows[i].Items[1];
                    row++;
                }
            }
        }
示例#32
0
        public static bool SearchStudentById(Student student, StudentRespository studentRepository)
        {
            student           = new Student();
            studentRepository = new StudentRespository();
            string number  = null;
            bool   isFound = false;

            if (!studentRepository.IsExistData())
            {
                System.Console.WriteLine("Don't exist data!!");
                return(isFound);
            }
            else
            {
                do
                {
                    System.Console.Clear();
                    System.Console.Write("Insert number id of Student : ");
                    number   = System.Console.ReadLine();
                    isNumber = int.TryParse(number, out int valor);
                } while (!isNumber);

                student.StudenId = int.Parse(number);
                studentIdStatic  = student.StudenId;
                if (studentRepository.FoundStudentById(student) != student)
                {
                    System.Console.WriteLine("Student  not found!");
                    isFound = false;
                }
                else
                {
                    HeaderData();
                    System.Console.WriteLine(student.ToString());
                    System.Console.WriteLine("Student  found it!");
                    isFound = true;
                }

                System.Console.ReadKey();

                return(isFound);
            }
        }
示例#33
0
        public void InsertStudent(Student student)
        {
            using (var conn = new SqlConnection(_connectionString))
            using (var cmd = conn.CreateCommand())
            {
                // Open a connection
                conn.Open();

                // Build SQL query
                cmd.CommandText = "INSERT INTO Student (StudentNum, Name, Type) VALUES (@studentNum, @name, @type)";

                // Insert parameters into the course table
                cmd.Parameters.AddWithValue("@studentNum", student.Number);
                cmd.Parameters.AddWithValue("@name", student.Name);
                cmd.Parameters.AddWithValue("@type", student.ToString());

                // Perform the INSERT operation
                cmd.ExecuteNonQuery();
            }
        }
        public void ToStringTest()
        {
            student.AddSubjectToStudent(new Subject("PSY3", "Psychology", "B", "A"));
            student.AddSubjectToStudent(new Subject("SOC3", "Sociology", "A", "B"));
            student.AddSubjectToStudent(new Subject("PHI3", "Philosophy", "A*", "A*"));

            string output =
                "\nID: #0186" +
                "\nForename: Jack" +
                "\nSurname: Kallis" +
                "\nYear: 7" +
                "\nClass: Scarlett" +
                "\nSubjects:" +
                "\n+++++++++" +
                "\nPsychology: B (A) <PSY3>" +
                "\nSociology: A (B) <SOC3>" +
                "\nPhilosophy: A* (A*) <PHI3>\n";

            Assert.AreEqual(output, student.ToString());
        }
示例#35
0
        private void btnShowStudent_Click(object sender, EventArgs e)
        {
            // Uses Age property defined in the Person class
            aStudent.Age = 25;

            // Calls overridden ToString() in Person class
            txtName.Text = aStudent.ToString();

            // Calls ToString() defined in pbject class
            txtAge.Text = aStudent.Age.ToString();

            // Uses StudentID property in Student class
            txtID.Text = aStudent.StudentId;

            // Calls GetSleepAmt() defined in Student class
            txtSleepAmt.Text = Convert.ToString(aStudent.GetSleepAmt());

            // Calls method defined in Student class that has calls to base.GetSleepAmt() in Person class
            txtAverageSleepAmt.Text = Convert.ToString(aStudent.CallOverriddenGetSleepAmt());
        }
示例#36
0
 public override Student Add(Student o)
 {
     try
     {
         using (StreamWriter w = File.AppendText(localPath))
         {
             w.WriteLine(o.ToString());
         }
     }
     catch (UnauthorizedAccessException e)
     {
         Log.Error(e.Message);
         throw;
     }
     catch (ArgumentNullException e)
     {
         Log.Error(e.Message);
         throw;
     }
     catch (ArgumentException e)
     {
         Log.Error(e.Message);
         throw;
     }
     catch (PathTooLongException e)
     {
         Log.Error(e.Message);
         throw;
     }
     catch (DirectoryNotFoundException e)
     {
         Log.Error(e.Message);
         throw;
     }
     catch (NotSupportedException e)
     {
         Log.Error(e.Message);
         throw;
     }
     return(GetLast());
 }
示例#37
0
    public static void Main()
    {
        try
        {
            input = Console.ReadLine().Split(' ');
            var student = new Student(input[0], input[1], input[2]);

            input = Console.ReadLine().Split(' ');
            var salary   = Convert.ToDecimal(input[2]);
            var hours    = Convert.ToDecimal(input[3]);
            var employee = new Employee(input[0], input[1], salary, hours);

            Console.WriteLine(student.ToString());
            Console.WriteLine();
            Console.WriteLine(employee.ToString());
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
    }
示例#38
0
文件: Program.cs 项目: Roboman94/UML
        static void Main(string[] args)
        {
            Person p             = new Person("Bill", "1715 Holland Dr.");
            string person2String = p.ToString();

            Student w = new Student("Regis", "1080 Park Dr.");
            string  student2String = w.ToString();

            Staff  c            = new Staff("Vali", "6070 Bull Way");
            string staff2String = c.ToString();

            Console.WriteLine();
            Console.WriteLine("Person class returned: ");
            Console.WriteLine(person2String);
            Console.WriteLine();
            Console.WriteLine("Student class returned: ");
            Console.WriteLine(student2String);
            Console.WriteLine();
            Console.WriteLine("Staff class returned: ");
            Console.WriteLine(staff2String);
        }
示例#39
0
        static void Main(string[] args)
        {
            Console.WriteLine("Fill info about first student.");
            Student firstStudent = CreateStudent();

            Console.WriteLine("Fill info about second student.");
            Student secondStudent = CreateStudent();

            Console.WriteLine("Equals test\n" + firstStudent.Equals(secondStudent));
            Console.WriteLine("GetHashCode test for first student\n" + firstStudent.GetHashCode());
            Console.WriteLine("GetHashCode test for second student\n" + secondStudent.GetHashCode());
            Console.WriteLine("ToString test for first student\n" + firstStudent.ToString());
            Console.WriteLine("ToString test for second student\n" + secondStudent.ToString());
            Console.WriteLine("== test\n{0}", (firstStudent == secondStudent));
            Console.WriteLine("!= test\n{0}", (firstStudent != secondStudent));

            Student clone = firstStudent.Clone();

            Console.WriteLine("Clone test for first user\n" + clone.ToString());
            Console.WriteLine("CompareTo test\n" + firstStudent.CompareTo(secondStudent));
        }
    public static void Main()
    {
        //Enter information and create an object of class Student
        Console.WriteLine("Enter first name");
        string firstName = Console.ReadLine();
        Console.WriteLine("Enter middle name");
        string middleName = Console.ReadLine();
        Console.WriteLine("Enter last name");
        string lastName = Console.ReadLine();
        Console.WriteLine("Enter social security number");
        string socialSecurityNumber = Console.ReadLine();
        Console.WriteLine("Enter address");
        string address = Console.ReadLine();
        Console.WriteLine("Enter phone");
        string phone = Console.ReadLine();
        Console.WriteLine("Enter email");
        string email = Console.ReadLine();
        Console.WriteLine("Enter course");
        string course = Console.ReadLine();
        Console.WriteLine("Enter index of specialty");
        int specialty = int.Parse(Console.ReadLine());
        Console.WriteLine("Enter index of faculty");
        int faculty = int.Parse(Console.ReadLine());
        Console.WriteLine("Enter index of university");
        int university = int.Parse(Console.ReadLine());
        Student student = new Student(firstName, middleName, lastName, socialSecurityNumber, address, phone, email,
            course, (Specialty)specialty, (Faculty)faculty, (University)university);

        //Test methods of class Student - Clone(), Equals(), ToString(), CompareTo()
        Console.WriteLine(student.ToString());
        Student clone = (Student)student.Clone();
        Console.WriteLine(clone.ToString());
        Console.WriteLine(clone.Equals(student));
        Console.WriteLine(clone.CompareTo(student));
        clone.LastName = student.MiddleName;
        Console.WriteLine("{0} {1}", clone.MiddleName, clone.LastName);
        Console.WriteLine("{0} {1}", student.MiddleName, student.LastName);
        Console.WriteLine(clone.CompareTo(student));
    }
示例#41
0
            private static void IzmStudent(ArrayList al)
            {
                Console.WriteLine("Введите фамилию:");
                string  findFIO = Console.ReadLine();
                bool    fd      = false;
                Student findSt  = new Student();

                foreach (var item in al)
                {
                    Student st = (Student)item;
                    if (findFIO == st.FIO)
                    {
                        findSt = st;
                        al.Remove(st);
                        fd = true;
                        break;
                    }
                }
                if (fd)
                {
                    Console.WriteLine(findSt.ToString());
                }
                else
                {
                    Console.WriteLine("Студент не найден");
                }

                string fio; int age; string grupa;

                Console.WriteLine("Введите пожалуйста фио студента для изменения");
                fio = Console.ReadLine();
                Console.WriteLine("Возраст дял изменения:");
                age = int.Parse(Console.ReadLine());
                Console.WriteLine("Группа для изменения:");
                grupa = Console.ReadLine();
                al.Add(new Student {
                    Vozrast = age, FIO = fio, Gruppa = grupa
                });
            }
示例#42
0
    public static void Main()
    {
        string[] studentTokens = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        string[] workerTokens  = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        try
        {
            Student student = new Student(studentTokens[0], studentTokens[1], studentTokens[2]);

            Worker worker = new Worker
                                (workerTokens[0]
                                , workerTokens[1]
                                , decimal.Parse(workerTokens[2])
                                , decimal.Parse(workerTokens[3]));

            Console.WriteLine(student.ToString());
            Console.WriteLine(worker.ToString());
        }
        catch (ArgumentException argEx)
        {
            Console.WriteLine(argEx.Message);
        }
    }
示例#43
0
    public static void Main()
    {
        try
        {
            string[] studentInput = Console.ReadLine().Split(new[] { ' ' },
                                                             StringSplitOptions.RemoveEmptyEntries);

            Student student = new Student(studentInput[0], studentInput[1], studentInput[2]);

            string[] workerInput = Console.ReadLine().Split(new[] { ' ' },
                                                            StringSplitOptions.RemoveEmptyEntries);

            Worker worker = new Worker(workerInput[0], workerInput[1],
                                       decimal.Parse(workerInput[2]), double.Parse(workerInput[3]));
            Console.WriteLine(student.ToString());
            Console.WriteLine(worker);
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }
    }
示例#44
0
        public void Run()
        {
            string[] studentData = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);

            string studentFirstName  = studentData[0];
            string studentSecondName = studentData[1];
            string facultyNumber     = studentData[2];

            Student currentStudent = new Student(studentFirstName, studentSecondName, facultyNumber);

            string[] workerData       = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
            string   workerFirstName  = workerData[0];
            string   workerSecondName = workerData[1];
            double   weekSalary       = double.Parse(workerData[2]);
            double   workHours        = double.Parse(workerData[3]);

            Worker currentWorker = new Worker(workerFirstName, workerSecondName, weekSalary, workHours);

            currentWorker.CalculateMoneyPerHour();
            Console.WriteLine(currentStudent.ToString());
            Console.WriteLine(currentWorker.ToString().TrimEnd());
        }
示例#45
0
        static void Main(string[] args)
        {
            Osoba osoba = new Osoba();

            osoba.ToString();
            osoba.DajOib();
            osoba.GetHashCode();
            osoba.GetType();
            osoba.Equals("545451454");



            Osoba osobaStudent = new Student();

            osobaStudent.DajOib();
            osobaStudent.Equals(5);
            osobaStudent.GetHashCode();
            osobaStudent.GetType();
            osobaStudent.ToString();

            //Student studos = new Osoba(); moramo izvesti eksplicitni cast
        }
示例#46
0
        public bool Add(Student student)
        {
            try
            {
                if (!HelperClass.IsUserExistInStudents(student))
                {
                    using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString))
                    {
                        SqlCommand cmd = new SqlCommand("AddStudent", conn);
                        cmd.Connection.Open();
                        cmd.Parameters.Add(new SqlParameter("@firstName", student.first_name));
                        cmd.Parameters.Add(new SqlParameter("@lastName", student.last_name));
                        cmd.Parameters.Add(new SqlParameter("@userName", student.user_name));
                        cmd.Parameters.Add(new SqlParameter("@password", student.password));
                        cmd.Parameters.Add(new SqlParameter("@email", student.email));
                        cmd.Parameters.Add(new SqlParameter("@age", student.age));
                        cmd.Parameters.Add(new SqlParameter("@city_code", student.city_code));
                        cmd.Parameters.Add(new SqlParameter("@phoneNumber", student.phone_number));
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.ExecuteNonQuery();
                        cmd.Connection.Close();
                    }
                    log.Info($"New student has been created: {student.ToString()}");
                    return(true);
                }
                else
                {
                    log.Error($"Existing student is trying to create more accounts!: {student.ToString()}");
                    return(false);
                }
            }

            catch (Exception e)
            {
                log.Error(e.Message.ToString());
                throw new Exception(e.Message);
            }
        }
        public async override Task ExecuteWith(TelegramBotClient client, Message message)
        {
            var chatId  = message.Chat.Id;
            var platoon = DutyBot.GetGroupByChatId(chatId)?.Platoon;

            if (platoon == null)
            {
                throw new InvalidIdException("Взаимодействие с данной группой не было инициировано.");
            }

            if (Data.Trim().ToLower() == "all")
            {
                platoon.RemoveAll();

                await client.SendTextMessageAsync(chatId, "Все студенты были удалены из списка!");

                LastStatus = CommandStatus.Success;
                return;
            }

            try
            {
                platoon.RemoveStudent(Student.ToString());
            }
            catch (Exception ex)
            {
                await client.SendTextMessageAsync(message.Chat.Id,
                                                  ex.Message);

                LastStatus = CommandStatus.Success;
                return;
            }

            await client.SendTextMessageAsync(message.Chat.Id,
                                              $"Студент {Student} был успешно исключен.");

            LastStatus = CommandStatus.Success;
        }
示例#48
0
        public async Task <Student> Create(Student student)
        {
            _log.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + ":" + student.ToString());
            Student studentAdd;

            try
            {
                var endpoint = Resources.Config.apiAdd;
                var response = await _client.PostAsJsonAsync(endpoint, student);

                response.EnsureSuccessStatusCode();
                using (var content = response.Content)
                {
                    studentAdd = await content.ReadAsAsync <Student>();

                    return(studentAdd);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        static void Main()
        {
            Student studentPesho = new Student("Pesho", "Petrov", "Ivanov", 1234,"Sofia", "098977777","*****@*****.**", 2,
                Univercity.SofiaUni, Faculty.ArtFak, Specialty.Maths);

            Student studentGosho = new Student("Gosho", "Petrov", "Ivanov", 1234, "Sofia", "098977777", "*****@*****.**", 2,
                Univercity.SofiaUni, Faculty.ArtFak, Specialty.Maths);

            Console.WriteLine(studentPesho.ToString());
            // compare by ssn
            Console.WriteLine(studentPesho.Equals(studentGosho));
            Console.WriteLine(studentGosho == studentPesho);
            Console.WriteLine(studentGosho != studentPesho);
            Console.WriteLine(studentPesho.GetHashCode());
            // clone

            var newStudent = (Student)studentGosho.Clone();// trqbva da se kastne!
            Console.WriteLine(newStudent.FirstName);
            // compare
            Console.WriteLine("compare");
            Console.WriteLine(studentGosho.CompareTo(newStudent));
            Console.WriteLine(studentGosho.CompareTo(studentPesho));
        }
        private void frmGradesStudentsSummary_Load(object sender, EventArgs e)
        {
            if (currentStudent == null)
            {
                MessageBox.Show("Non è stato passato nessun studente");
                this.Close();
            }

            // student's name label
            lblCurrentStudent.Text = currentStudent.ToString();
            TxtIdStudent.Text      = currentStudent.IdStudent.ToString();
            lblSum.Text            = "";

            // fill the combos of lookup tables
            List <GradeType> listGrades = db.GetListGradeTypes();

            cmbSummaryGradeType.DisplayMember = "Name";
            cmbSummaryGradeType.ValueMember   = "idGradeType";
            cmbSummaryGradeType.DataSource    = listGrades;
            cmbSummaryGradeType.SelectedValue = currentGradeType.IdGradeType;

            List <SchoolSubject> listSubjects = db.GetListSchoolSubjects(false);

            cmbSchoolSubjects.DisplayMember = "Name";
            cmbSchoolSubjects.ValueMember   = "idGradeType";
            cmbSchoolSubjects.DataSource    = listSubjects;
            cmbSchoolSubjects.SelectedValue = currentSchoolSubject.IdSchoolSubject;

            List <SchoolPeriod> listPeriods = db.GetSchoolPeriods(currentSchoolYear);

            cmbSchoolPeriod.DataSource = listPeriods;

            dgwNotes.DataSource = db.AnnotationsAboutThisStudent(currentStudent, currentSchoolYear,
                                                                 chkAnnotationsShowActive.Checked);

            RefreshData();
        }
示例#51
0
    static void Main(string[] args)
    {
        var studentArgs = Console.ReadLine().Split();
        var firstNameS  = studentArgs[0];
        var lastNameS   = studentArgs[1];
        var facNumberS  = studentArgs[2];

        var workerArgs    = Console.ReadLine().Split();
        var firstNameW    = workerArgs[0];
        var lastNameW     = workerArgs[1];
        var weeklySalaryW = decimal.Parse(workerArgs[2]);
        var workingHoursW = double.Parse(workerArgs[3]);

        try
        {
            var student = new Student(firstNameS, lastNameS, facNumberS);
            Console.WriteLine(student.ToString());
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
            return;
        }

        Console.WriteLine();

        try
        {
            var worker = new Worker(firstNameW, lastNameW, weeklySalaryW, workingHoursW);
            Console.WriteLine(worker.ToString());
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
            return;
        }
    }
示例#52
0
        public IActionResult GetStudents(string index)
        {
            using (var client = new SqlConnection("Data Source=db-mssql;Initial Catalog=s18693;Integrated Security=True"))
                using (var com = new SqlCommand())
                {
                    com.Connection  = client;
                    com.CommandText = $"select Student.FirstName, Student.LastName, Enrollment.Semester from Student inner join Enrollment on Student.IdEnrollment = Enrollment.IdEnrollment where Student.IndexNumber =@index";
                    com.Parameters.AddWithValue("index", index);

                    client.Open();
                    var dr = com.ExecuteReader();

                    while (dr.Read())
                    {
                        var st = new Student {
                            IndexNumber = index, FirstName = dr["FirstName"].ToString(), LastName = dr["LastName"].ToString()
                        };
                        return(Ok($"{dr.HasRows} {st.ToString()} {dr["Semester"].ToString()} "));
                    }
                    return(NotFound());
                }

            //return Ok(_dbService.GetStudents());
        }
示例#53
0
    static void Main()
    {
        List <Student> students = new List <Student>
        {
            new Student("Pesho", "Kalinov", "Dechkov", "1256567123", "Sofiq Borisova gradina", "0874267156", "*****@*****.**", University.SU, Facultity.FMI, Speciality.KN),
            new Student("Pesho", "Kalinov", "Dechkov", "156567123", "Sofiq Borisova gradina", "0874267156", "*****@*****.**", University.SU, Facultity.FMI, Speciality.KN),
            new Student("Ivan", "Pecov", "Milinov", "12878888567123", "Popovo", "087412347156", "*****@*****.**", University.SU, Facultity.FMI, Speciality.IT),
            new Student("Desi", "Dimitrova", "Jujeva", "98647123", "Burgas", "012357156", "*****@*****.**", University.SU, Facultity.FMI, Speciality.KN),
            new Student("Neli", "Bacova", "Gacova", "571i4323", "Stara Zagora Aqzmo", "0809289967156", "*****@*****.**", University.SU, Facultity.FMI, Speciality.KN),
            new Student("Pesho", "Kalinov", "Dechkov", "1256567123", "Sofiq Borisova gradina", "0874267156", "*****@*****.**", University.SU, Facultity.FMI, Speciality.KN)
        };

        foreach (Student student in students)
        {
            Console.WriteLine("HashCode:{0}", student.GetHashCode());
            Console.WriteLine(student.ToString());
        }

        Console.WriteLine(students[0] == students[1]);
        Console.WriteLine(students[0] != students[1]);
        Console.WriteLine(students[0] != students[2]);
        Console.WriteLine(students[0] == students[4]);
        Console.WriteLine();

        Student desi = students[2].Clone();

        Console.WriteLine(desi.ToString());

        students.Sort();

        foreach (Student student in students)
        {
            Console.WriteLine("HashCode:{0}", student.GetHashCode());
            Console.WriteLine(student.ToString());
        }
    }
示例#54
0
        static void Main()
        {
            Student s1 = new Student("Pesho", "Ivanov", "Ivanov", 8832738273, "Imaginary Str 44", 3849384398,
                "*****@*****.**", 3, Specialty.Law, University.SofiaUniversity, Faculty.FacultyOfLaw);

            Student s2 = new Student("Pesho", "Ivanov", "Ivanov", 7839938273, "Imaginary Str 44", 39483439,
                "*****@*****.**", 3, Specialty.ComputerSystems, University.SofiaUniversity, Faculty.FMI);

            Console.WriteLine("s1 HashCode: " + s1.GetHashCode());
            Console.WriteLine("s2 HashCode: " + s2.GetHashCode());
            Console.WriteLine("s1 equals s2: " + s1.Equals(s2));
            Console.WriteLine("s1 == s2: " + (s1 == s2));
            Console.WriteLine("s1 != s2: " + (s1 != s2));
            Console.WriteLine();
            Console.WriteLine(s2.ToString());
            Console.WriteLine();

            Student s3 = (Student)s2.Clone();

            Console.WriteLine("s2 == s3: " + (s2 == s3));
            Console.WriteLine("s2 != s3: " + (s2 != s3));
            Console.WriteLine("s2.CompareTo(s3): " + s2.CompareTo(s3));
            Console.WriteLine("s1.CompareTo(s2): " + s1.CompareTo(s2));
        }
示例#55
0
        public void ToStringTest()
        {
            // Arrange:
            Student student1          = new Student("Math", "Mads", "Randeris");
            Student student2          = new Student("English", "Mads", "Bob");
            Student student3          = new Student("Programming", "Mads", "Sam");
            Student student4          = new Student("Dansk", "Mads", "Lol");
            string  expectedToString1 = "Navn: Mads Randeris F*g: Math";
            string  expectedToString2 = "Navn: Mads Bob F*g: English";
            string  expectedToString3 = "Navn: Mads Sam F*g: Programming";
            string  expectedToString4 = "Navn: Mads Lol F*g: Dansk";

            // Act:
            string actualToString1 = student1.ToString();
            string actualToString2 = student2.ToString();
            string actualToString3 = student3.ToString();
            string actualToString4 = student4.ToString();

            // Assert:
            Assert.AreEqual(expectedToString1, actualToString1);
            Assert.AreEqual(expectedToString2, actualToString2);
            Assert.AreEqual(expectedToString3, actualToString3);
            Assert.AreEqual(expectedToString4, actualToString4);
        }
        public void TestToString()
        {
            var student = new Student
            {
                FirstName = "xqwe",
                LastName = "yrtret",
                CNP = "1234567891234",
                SID = 123,
                EnrollmentDate = DateTime.Now,
                Phones = new[] { new Phone("0123 123456"), }
            };

            Assert.IsTrue(student.ToString().Length > 0);
        }
示例#57
0
    static void Main(string[] args)
    {
        //Creating students
        Student firstStudent = new Student("Petyr", "Georgiev", "Petrov", "*****@*****.**", 234871231, 0897213521, Universities.TechnicalUniversity, Faculties.Architecture, Specialties.Physics);
        Student secondStudent = new Student("Georgi", "'Joro'", "Georgiev", "*****@*****.**", 742711495, 0897211221, Universities.Harvard, Faculties.IT, Specialties.Programming);
        Student thirdStudent = new Student("Georgi", "'Joro'", "Georgiev", "*****@*****.**", 342411495, 0883393549, Universities.Harvard, Faculties.IT, Specialties.Programming);
        Student fourthStudent = new Student("Veselin", "Petrov", "Kirilov", 213312983);
        Student fifthStudent = new Student("Veselin", "Petrov", "Kirilov", 213312983);

        //Call the overriden ToString() on the first student
        Console.WriteLine(firstStudent.ToString());
        //Call the overriden ToString() on the fourth student
        Console.WriteLine(fourthStudent.ToString());

        //Checks if the second and third students are equal and print the rezult
        string areEqual = null;
        if (!secondStudent.Equals(thirdStudent))
        {
            areEqual = " NOT";
        }
        Console.WriteLine("The second and the third students are{0} the same!", areEqual);
        
        //Checks if last two students equals
        if (fourthStudent.Equals(fifthStudent))
        {
            Console.WriteLine("Students four and five are the same student");
            Console.WriteLine();
        }

        //Get the hash code of the first student
        Console.WriteLine("The hash code of {0}: {1}", firstStudent.FirstName, firstStudent.GetHashCode());
        Console.WriteLine();

        //Check if equals with the == operator
        if (fifthStudent == fourthStudent)
        {
            Console.WriteLine("Students four and five are the same student");
        }

        //Check if not equals ( != operator)
        if (firstStudent != thirdStudent)
        {
            Console.WriteLine("Students one and three are different");
            Console.WriteLine();
        }

        //Clone the first student (deep clone)
        Student sixthStudent = firstStudent.Clone();
        Console.WriteLine(sixthStudent.ToString());

        //Compare students
        if (firstStudent.CompareTo(sixthStudent) == 0)
        {
            Console.WriteLine("Student one is equal to student six");
            Console.WriteLine();
        }

        if (secondStudent.CompareTo(fourthStudent) < 0)
        {
            Console.WriteLine(secondStudent.FirstName);
            Console.WriteLine(fourthStudent.FirstName);
            Console.WriteLine("Student four is before student two");
        }
    }
示例#58
0
    static void Main()
    {
        Console.WriteLine("This program tests the Students project. It will run a few tests to determine if the code has been written correctly!");
        Console.WriteLine();

        // Part 1
        Console.WriteLine("Part 1: Creating two identical instances of the Student class.");

        Student st1 = new Student("Leia", "Bail", "Organa", University.Cambridge, Faculty.SocialScience, Specialty.Art, "Dantooine", 100000000, "111555999666", new System.Net.Mail.MailAddress(@"*****@*****.**"));
        Student st2 = new Student("Leia", "Bail", "Organa", University.Cambridge, Faculty.SocialScience, Specialty.Art, "Dantooine", 100000000, "111555999666", new System.Net.Mail.MailAddress(@"*****@*****.**"));

        Console.WriteLine("The studetns are the following:");
        Console.WriteLine("Student 1: " + st1.ToString());
        Console.WriteLine("Student 2: " + st2.ToString());
        Console.WriteLine("Result of comparison (are they equal?): " + st1.Equals(st2));
        Console.WriteLine();

        Console.WriteLine("Creating a new instance of the Student class.");
        Student st3 = new Student("Petromil", "Kirov", "Ivanov", 458789652);
        Console.WriteLine("The new Student is the following: " + st3.ToString());
        Console.WriteLine("Comparing Petromil to Leia (are they equal?): " + st1.Equals(st3));
        Console.WriteLine();

        Console.WriteLine("Part 3: Printing hash codes: ");
        Console.WriteLine("Student 1: " + st1.GetHashCode());
        Console.WriteLine("Student 2: " + st2.GetHashCode());
        Console.WriteLine("Student 3: " + st3.GetHashCode());
        Console.WriteLine();

        Console.WriteLine("Part 4: Testing the == and != operators");
        Console.WriteLine("Student 1 != Student 2: " + (st1 != st2));
        Console.WriteLine("Student 1 != Student 3: " + (st1 != st3));
        Console.WriteLine("Student 1 == Student 2: " + (st1 == st2));
        Console.WriteLine();

        Console.WriteLine("Part 5: Cloning");
        Console.WriteLine("Cloning Student 1 into new student.");
        Student newSt = (Student)st1.Clone();
        Console.WriteLine("Is the new student identical to Student 1? "+ (newSt == st1));
        Console.WriteLine("Is the new student identical to Student 3? " + (newSt == st3));
        Console.WriteLine();

        Console.WriteLine("Part 6: Testing the implementation of the IComparable interface.");
        Console.WriteLine("Creating an array of Students:");
        Student student1 = new Student("Atanas", "Ivanov", "Kovachev", 458956898);
        Student student2 = new Student("Petar", "Ivanov", "Kovachev", 358956898);
        Student student3 = new Student("Atanas", "Ivanov", "Kovachev", 458956893);
        Student student4 = new Student("Zhivko", "Kolev", "Penev", 450056898);
        Student student5 = new Student("Petar", "Ivanov", "Kirov", 438956898);

        Student[] students =
        {
            student1, student2, student3, student4, student5
        };

        foreach (var student in students)
        {
            Console.WriteLine(student.ToString() + ", SSN: " + student.SocSecNum);
        }
        Console.WriteLine();
        Console.WriteLine("Sorting students using Array.Sort");
        Console.WriteLine("Result of sorting:");
        Array.Sort(students);
        foreach (var student in students)
        {
            Console.WriteLine(student.ToString() + ", SSN: " + student.SocSecNum);
        }
    }
 public void ToStringTest()
 {
     string name = "Gosho Goshev";
     int uniqueNumber = 12345;
     Student student = new Student(name, uniqueNumber);
     string expected = "Student Gosho Goshev, ID 12345; ";
     string actual;
     actual = student.ToString();
     Assert.AreEqual(expected, actual, "Invalid converting student to string!");
 }
示例#60
0
    protected void DisplayStudentInfo(Student student, String type)
    {
        // Output the student's name and type to the page
        lblStudentInfoName.Text = student.Name;
        lblStudentInfoType.Text = student.ToString();

        // Display the success page
        studentInfo.Visible = true;

        // Generate the table header
        var tHead = new TableHeaderRow();
        tblCourses.Rows.Add(tHead);

        var tHeadCellCode = new TableHeaderCell();
        var tHeadCellTitle = new TableHeaderCell();
        var tHeadCellHours = new TableHeaderCell();
        var tHeadCellFee = new TableHeaderCell();

        tHeadCellCode.Text = "Course Code";
        tHeadCellTitle.Text = "Course Title";
        tHeadCellHours.Text = "Weekly Hours";
        tHeadCellFee.Text = "Fee Payable";

        tHead.Cells.Add(tHeadCellCode);
        tHead.Cells.Add(tHeadCellTitle);
        tHead.Cells.Add(tHeadCellHours);
        tHead.Cells.Add(tHeadCellFee);

        // Table generation loop
        foreach (Course course in student.getEnrolledCourses())
        {
            // Start creating the table rows
            var tRow = new TableRow();
            tblCourses.Rows.Add(tRow);

            // Now the table cells
            var tCellCode = new TableCell();
            var tCellTitle = new TableCell();
            var tCellHours = new TableCell();
            var tCellFee = new TableCell();

            tCellCode.Text = course.Code;
            tCellTitle.Text = course.Title;
            tCellHours.Text = Convert.ToString(course.WeeklyHours);
            tCellFee.Text = Convert.ToString(String.Format("{0:C0}", course.Fee));

            tRow.Cells.Add(tCellCode);
            tRow.Cells.Add(tCellTitle);
            tRow.Cells.Add(tCellHours);
            tRow.Cells.Add(tCellFee);
        }

        // Generate the table footer
        var tFoot = new TableRow();
        tblCourses.Rows.Add(tFoot);

        var tFootTotalLabel = new TableCell();
        var tFootTotalRows = new TableCell();
        var tFootTotal = new TableCell();

        tFootTotalLabel.Text = "Total";
        tFootTotalLabel.HorizontalAlign = HorizontalAlign.Right;
        tFootTotalLabel.ColumnSpan = 2;
        tFootTotalRows.Text = Convert.ToString(student.totalWeeklyHours());
        tFootTotal.Text = Convert.ToString(String.Format("{0:C0}", student.feePayable()));

        tFoot.Cells.Add(tFootTotalLabel);
        tFoot.Cells.Add(tFootTotalRows);
        tFoot.Cells.Add(tFootTotal);
    }