Ejemplo n.º 1
0
        // adds and event to the calendar
        // @ parameters
        //      month of event
        //      day of event
        //      start time of event
        //      end time of event
        //      name of event

        public void addEvent(int month, int day, double start, double end, string name, Year curr)
        {
            //Year curr = new Year();

            // event time is available, can input event
            if (curr.getMonth(month - 1).getDay(day - 1).checkAvailability(start, end))
            {
                curr.getMonth(month - 1).getDay(day - 1).setAvailability(start, end);   // set availability array
                curr.getMonth(month - 1).getDay(day - 1).setEvent(name, start, end);    // set event
            }
            else
            {
                Console.Write("Cannot add event, time overlap.../n");
                //Console.Write("No event found.../n");
            }
        }
Ejemplo n.º 2
0
        // load in the names of months
        public int loadCalender(Year curr, User user)
        {
            string line;
            int    monthCount = 1;
            //Year curr = new Year();
            //curr.setYear(2018);

            string year     = curr.getYear().ToString();
            string userName = user.getUserName();


            string path = "Files/" + year + "_" + userName + ".txt";

            if (!File.Exists(path))
            {
                path = "Files/" + year + ".txt";
            }

            System.IO.StreamReader file = new System.IO.StreamReader(path);
            while ((line = file.ReadLine()) != null)
            {
                //line = ReadLine()System.Console.WriteLine(line);     // read line

                curr.addMonth(monthCount, line);    // add mnth to year list

                //System.Console.WriteLine(line);     // read next line
                //System.Console.WriteLine(line);     // read next line
                line = file.ReadLine();
                int numberOfDays = Int32.Parse(line);   // turn string to int

                //System.Console.WriteLine(line);     // rad next line
                line = file.ReadLine();
                int startDay = Int32.Parse(line);       // turn string to int

                string dayName = "";

                for (int i = 1; i <= numberOfDays; i++)      // loop all days of month
                {
                    switch (startDay % 7)
                    {
                    case 1:
                        dayName = "Monday";
                        break;

                    case 2:
                        dayName = "Tuesday";
                        break;

                    case 3:
                        dayName = "Wednesday";
                        break;

                    case 4:
                        dayName = "Thursday";
                        break;

                    case 5:
                        dayName = "Friday";
                        break;

                    case 6:
                        dayName = "Saturday";
                        break;

                    case 0:
                        dayName = "Sunday";
                        break;

                    default:
                        Console.Write("ERROR.../n");
                        break;
                    }
                    // add a day to a month
                    curr.getMonth(monthCount - 1).addDay(i, dayName);
                    startDay++;
                }
                monthCount++;
            }
            file.Close();
            return(0);
        }