Exemple #1
0
        public static void addStudents() // to add a new student
        {
            Console.WriteLine("Please enter a student ID: ");
            string sID = Console.ReadLine();

            Console.WriteLine("Please enter a student name: ");
            string name = Console.ReadLine();

            Console.WriteLine("Please enter the fees due: ");
            double outF = Double.Parse(Console.ReadLine());

            Console.WriteLine("Please enter enrollment date: ");
            string enrDate = Console.ReadLine();

            Console.WriteLine("Is " + name + " studying full time? (y/n) : ");

            if (Console.ReadLine().Equals("y"))                          // decides object type
            {
                FTStudent fts = new FTStudent(sID, name, outF, enrDate); // Program(not dependant on StudentList) ->
                StudentManger.Instance.addStudent(fts);                  // StudentManager(receive student object) ->
            }                                                            // StudentList (Dependancy Inversion)
            else
            {
                PTStudent pts = new PTStudent(sID, name, outF, enrDate);
                StudentManger.Instance.addStudent(pts);
            }
            StudentManger.Instance.saveStudents();
        }
Exemple #2
0
 public static Student ToStudent(string txt)
 {  //converts txt string to studentObject
     string[] lineParts = txt.Split(',');
     if (lineParts[0].Equals("0"))
     {
         PTStudent pt = new PTStudent(lineParts[1], lineParts[2], Double.Parse(lineParts[3]), lineParts[4]);
         return(pt);
     }
     else
     {
         FTStudent ft = new FTStudent(lineParts[1], lineParts[2], Double.Parse(lineParts[3]), lineParts[4]);
         return(ft);
     }
 }
Exemple #3
0
        public static string ToFileString(Student st)
        {  //converts student to delimeted string
            string line = "";

            if (st.GetType() == typeof(PTStudent))
            {
                PTStudent tempPTS = (PTStudent)st;
                line = "0," + tempPTS.StudentID + "," + tempPTS.Name + "," + tempPTS.OutstandingFees + "," + tempPTS.EnrollDate;
            }
            else
            {
                FTStudent tempFTS = (FTStudent)st;
                line = "1," + tempFTS.StudentID + "," + tempFTS.Name + "," + tempFTS.OutstandingFees + "," + tempFTS.EnrollDate;
            }
            return(line);
        }
Exemple #4
0
 public void addStudent(FTStudent ft) //override
 {
     StudentList.Instance.lsStudents.Add(ft);
     Console.WriteLine("Student successfully added");
 }