Esempio n. 1
0
        //Function-> this function reads in the information from an input file and populates the chart with that info
        public void ReadInfoIntoChart()
        {
            //go to the file and extract the X and Y points
            string line;
            string StudentA, StudentB, StudentC, StudentD;

            using (StreamReader inFile = new StreamReader("../../GradePercentsOnAssigns.txt"))
            {
                while ((line = inFile.ReadLine()) != null)
                {
                    //each student is split by a tab, each test score per student is split by ":"
                    //split the lines by a comma (since input goes X,Y)
                    string[] Students = line.Split('\t');

                    //get each student's test scores
                    StudentA = Students[0];
                    StudentB = Students[1];
                    StudentC = Students[2];
                    StudentD = Students[3];

                    //now split each student by the colons since each test score is separated by that
                    string[] StudentAScores = StudentA.Split(':');
                    string[] StudentBScores = StudentB.Split(':');
                    string[] StudentCScores = StudentC.Split(':');
                    string[] StudentDScores = StudentD.Split(':');

                    //call function above to go through each student's test & score array
                    //and populate the correct values into the points for the chart
                    StudentAPoints = createDataPoints(StudentAScores);
                    StudentBPoints = createDataPoints(StudentBScores);
                    StudentCPoints = createDataPoints(StudentCScores);
                    StudentDPoints = createDataPoints(StudentDScores);
                }
            }
        }
        private void BtnOK_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (TxtGPA.Text != String.Empty && TxtName.Text != String.Empty)
                {
                    StudentC St = new StudentC();
                    //St.StudentId = int.Parse( TxtID.Text);
                    St.Name   = TxtName.Text;
                    St.DOB    = DateBirthPicker.DisplayDate;
                    St.GPA    = double.Parse(TxtGPA.Text);
                    St.Active = CheckActive.IsChecked.Value;

                    Data.stc     = St;
                    DialogResult = true;
                }
                else
                {
                    MessageBox.Show("Please Fill incomplete fields");
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show("An Error Occured : " + exc.Message);
            }
        }
        static void Main(string[] args)
        {
            StudentC studentC = new StudentC();
            studentC.Name = "Jane";

            ByValueTestClass(studentC); // passed by ref

            Console.WriteLine(studentC.Name); // Prints - Jane-ByValue

            ByReferenceTestClass(ref studentC); // passed by ref - ref keyword is redundant

            Console.WriteLine(studentC.Name); // Prints - Jane-ByValue-ByReference

            //--

            StudentS studentS = new StudentS();
            studentS.Name = "John";

            ByValueTestStruct(studentS); // passed by value

            Console.WriteLine(studentS.Name); // Prints - John

            ByReferenceTestStruct(ref studentS); // passed by ref

            Console.WriteLine(studentS.Name); // Prints - John-ByReference

            //-
            Console.ReadKey();
        }
        private void BtnOK_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (TxtGPA.Text != String.Empty && TxtName.Text != String.Empty)
                {
                    StudentC St = new StudentC();
                    //St.StudentId = int.Parse( TxtID.Text);
                    St.Name = TxtName.Text;
                    St.DOB = DateBirthPicker.DisplayDate;
                    St.GPA = double.Parse(TxtGPA.Text);
                    St.Active = CheckActive.IsChecked.Value;

                    Data.stc = St;
                    DialogResult = true;
                }
                else
                {
                    MessageBox.Show("Please Fill incomplete fields");
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show("An Error Occured : " + exc.Message);
            }
        }
Esempio n. 5
0
        public void FormatIdAndNameWithEmptyNameReturnsNull()
        {
            MyFake fake = new MyFake();

            fake.Database = new List <string>();

            StudentC student = new StudentC(fake, fake);

            //string formatted = student.FormatIdAndName("", 1);
            student.Add("1");
            student.Add("2");
            Assert.AreEqual(fake.Database.Count, 2);
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            Console.WriteLine("INHERITANCE");
            Student student = new Student();

            PrintInheritance(student);
            Console.WriteLine("COMPOSITION");
            StudentC studentC = new StudentC();

            PrintInheritance(student);

            Console.ReadKey();
        }
        private void SaveStudents()
        {
            StudentC[] stdc = new StudentC[tempDt.Rows.Count];
            int        i    = 0;

            try
            {
                foreach (DataRow row in tempDt.Rows)
                {
                    stdc[i]        = new StudentC();
                    stdc[i].Name   = row[1].ToString();
                    stdc[i].DOB    = DateTime.Parse(row[2].ToString());
                    stdc[i].GPA    = double.Parse(row[3].ToString());
                    stdc[i].Active = bool.Parse(row[4].ToString());
                    i++;
                }
                client.AddStudent(stdc);
                MessageBox.Show("Data Saved Successully");
            }
            catch (Exception exc)
            {
                MessageBox.Show("An Error Occured : " + exc.Message);
            }
        }
 static void ByReferenceTestClass(ref StudentC student)
 {
     student.Name += "-ByReference";
 }
 static void ByValueTestClass(StudentC student)
 {
     student.Name += "-ByValue";
 }
Esempio n. 10
0
 public static void PrintComposition(StudentC student)
 {
     Console.WriteLine(student.FormatNameAndId("Ernesto Chaves", 111));
 }
Esempio n. 11
0
 private void FillBtn_Click(object sender, EventArgs e)
 {
     myStudent = new StudentC(NameTxtB.Text, AddressTxtB.Text, PhoneTxtB.Text, EmailTxtB.Text, MajorTxtB.Text, GPATxtB.Text);
 }
Esempio n. 12
0
 public static void PrintPerson(StudentC student)
 {
     Console.Write(student.FormatIdAndName("John Smith", 1));
 }
Esempio n. 13
0
        private void SaveStudents()
        {
            StudentC[] stdc = new StudentC[tempDt.Rows.Count];
            int i = 0;

            try
            {
                foreach (DataRow row in tempDt.Rows)
                {
                    stdc[i] = new StudentC();
                    stdc[i].Name = row[1].ToString();
                    stdc[i].DOB = DateTime.Parse(row[2].ToString());
                    stdc[i].GPA = double.Parse(row[3].ToString());
                    stdc[i].Active = bool.Parse(row[4].ToString());
                    i++;
                }
                client.AddStudent(stdc);
                MessageBox.Show("Data Saved Successully");
            }
            catch (Exception exc)
            {
                MessageBox.Show("An Error Occured : " + exc.Message);
            }
        }