Beispiel #1
0
        //Command Prefix
        private static string CommandPrefix(User currentUser, Cafe selectedBuilding)
        {
            string commandPrefix = (currentUser == null ? "" : currentUser.Email) + ":/GMaps";

            if (selectedBuilding != null)
            {
                commandPrefix += String.Format("/{0}/{1}/{2}/{3}/{4}", selectedBuilding.Address.Country,
                                               selectedBuilding.Address.City, selectedBuilding.Address.Street,
                                               selectedBuilding.Address.NumberOfBuilding, selectedBuilding.Name);
            }
            return(commandPrefix + "$  ");
        }
Beispiel #2
0
 //Save
 public static void Save(User currentUser, Cafe selectedBuilding)
 {
     if (selectedBuilding != null)
     {
         if (currentUser == null)
         {
             Console.WriteLine("\nPlease log in. \n");
         }
         else
         {
             currentUser.Save(selectedBuilding);
         }
     }
     else
     {
         MessageBox.Show("There is no selected building.");
     }
 }
Beispiel #3
0
 //Rate
 public static void Rate(User currentUser, Cafe selectedBuilding, string rateLine)
 {
     if (selectedBuilding != null)
     {
         if (currentUser == null)
         {
             MessageBox.Show("Please log in");
             return;
         }
         if (rateLine[0] - '0' > 5 || rateLine[0] - '0' < 1)
         {
             MessageBox.Show("Your rate must be from 1 to 5.");
             return;
         }
         UserRating rate = new UserRating(currentUser, (Rate)(rateLine[0] - '0'), rateLine.Trim());
         selectedBuilding.AddRate(rate);
         return;
     }
     MessageBox.Show("There is no selected building.");
 }
Beispiel #4
0
 //Nearby
 private static void Nearby(string line, User currentUser, Cafe selectedBuilding)
 {
     if (line.Split()[0].ToLower() == "me")
     {
         try
         {
             List <Cafe> nearbyBuildings = currentUser.Nearby(int.Parse(line.Split()[1]));
             foreach (Cafe b in nearbyBuildings)
             {
                 Console.WriteLine(b.Name + "\n" + "Address: " + b.Address + "\n");
             }
         }
         catch (FormatException)
         {
             MessageBox.Show("Incorrect distance!!!");
             return;
         }
     }
     else if (selectedBuilding != null)
     {
         try
         {
             List <Cafe> nearbyBuildings = selectedBuilding.Nearby(int.Parse(line));
             foreach (Cafe b in nearbyBuildings)
             {
                 Console.WriteLine(b.Name + "\n" + "Address: " + b.Address + "\n");
             }
         }
         catch (FormatException)
         {
             MessageBox.Show("Write correct distance.");
         }
     }
     else
     {
         Console.WriteLine();
     }
 }
        static void Main(string[] args)
        {
            //AllRates rate = new AllRates();
            //rate.AddRate(new UserRating("Ara", Rate.five, "sdfsfsfsdf"));
            //rate.AddRate(new UserRating("Ara", Rate.five, "sdfsfsfsdf"));
            //rate.AddRate(new UserRating("Ara", Rate.five, "sdfsfsfsdf"));
            //rate.AddRate(new UserRating("Ara", Rate.five, "sdfsfsfsdf"));
            ////rate.Print();
            //OpenTimes[] op = new OpenTimes[7];
            //op[0] = new OpenTimes(DayOfWeek.Friday, "10:00", "24:00");
            //op[0] = new OpenTimes(DayOfWeek.Wednesday, "10:00", "24:00");
            //op[0] = new OpenTimes(DayOfWeek.Saturday, "10:00", "24:00");
            //op[0] = new OpenTimes(DayOfWeek.Sunday, "10:00", "24:00");
            //op[0] = new OpenTimes(DayOfWeek.Monday, "10:00", "24:00");
            //op[0] = new OpenTimes(DayOfWeek.Thursday, "10:00", "24:00");
            //op[0] = new OpenTimes(DayOfWeek.Tuesday, "10:00", "24:00");
            //Cafe myCafe = new Cafe("Big Book", new Address("a", "a", "ak", "k"), new System.Device.Location.GeoCoordinate(23.12, 21.21), op, "321321321321", "bigBook.am");
            //myCafe.Print();

            OpenTimes[] op = new OpenTimes[7];
            op[0] = new OpenTimes(DayOfWeek.Monday, "12:12", "23:12");
            op[1] = new OpenTimes(DayOfWeek.Friday, "12:12", "23:12");
            op[2] = new OpenTimes(DayOfWeek.Saturday, "12:12", "23:12");
            op[3] = new OpenTimes(DayOfWeek.Thursday, "12:12", "23:12");
            op[4] = new OpenTimes(DayOfWeek.Tuesday, "12:12", "23:12");
            op[5] = new OpenTimes(DayOfWeek.Sunday, "12:12", "23:12");
            op[6] = new OpenTimes(DayOfWeek.Wednesday, "12:12", "23:12");
            Cafe building1 = new Cafe(new Address("2/9", "Northen Aveneue", "Yerevan", "Armenia"), new GeoCoordinate(43.047550, -84.698465), op, "Jazzve", "+37477553364", "annmanya.com");
            Cafe building2 = new Cafe(new Address("2/9", "Komitas", "Yerevan", "Armenia"), new GeoCoordinate(43.049300, -84.699813), op, "Jose", "+122121321", "annmanya.com");
            Cafe building3 = new Cafe(new Address("2/9", "Pushkin", "Yerevan", "Armenia"), new GeoCoordinate(43.050970, -84.694992), op, "Jazzve", "+37477553364", "annmanya.com");
            Cafe building4 = new Cafe(new Address("2/9", "Ani", "Musaler", "Armenia"), new GeoCoordinate(43.059503, -84.698707), op, "Tashir Cafe", "+37477553364", "annmanya.com");

            MyMap.AllCafes.Add(building1);
            MyMap.AllCafes.Add(building2);
            MyMap.AllCafes.Add(building3);
            MyMap.AllCafes.Add(building4);
            MyMap.MyConsole();
        }
Beispiel #6
0
        //General function
        public static void MyConsole()
        {
            const string deviderTildes = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";

            //Users and Cafes JSON deserialization
            allUsers = JsonConvert.DeserializeObject <List <User> >(File.ReadAllText(userPath));
            allCafes = JsonConvert.DeserializeObject <List <Cafe> >(File.ReadAllText(buildingPath));

            Console.WriteLine(deviderTildes);
            Console.WriteLine("Every line can contain only one command");
            PrintAllCommandes();
            Command command          = Command.nothing;
            Cafe    selectedBuilding = null;
            User    currentUser      = null;

            while (command != Command.exit)
            {
                Console.Write(CommandPrefix(currentUser, selectedBuilding));
                String line = Console.ReadLine();
                command = DetectCommand(line);
                line    = line.Replace(command.ToString(), "").Trim();
                if (command == Command.nothing)
                {
                    MessageBox.Show("Command is incorrect!!!");
                    continue;
                }
                switch (command)
                {
                case Command.allCommands:
                    PrintAllCommandes();
                    break;

                case Command.search:
                    selectedBuilding = Search(line);
                    break;

                case Command.signUp:
                    currentUser = SignUp();
                    break;

                case Command.signIn:
                    if (currentUser != null)
                    {
                        Console.WriteLine("You are already logged in.");
                        break;
                    }
                    currentUser = SignIn(currentUser);
                    break;

                case Command.addCafe:
                    if (currentUser != null)
                    {
                        Console.Write("Password: "******"Password is incorrect!!!");
                        break;
                    }
                    MessageBox.Show("You aren't signed in!!!");
                    break;

                case Command.signOut:
                    currentUser = null;
                    break;

                case Command.save:
                    Save(currentUser, selectedBuilding);
                    break;

                case Command.rate:
                    Rate(currentUser, selectedBuilding, line);
                    break;

                case Command.nearby:
                    Nearby(line, currentUser, selectedBuilding);
                    break;

                case Command.changeMyCoordinates:
                    if (currentUser != null)
                    {
                        try
                        {
                            currentUser.Coordinates =
                                new GeoCoordinate(double.Parse(line.Split()[0]), double.Parse(line.Split()[1]));
                        }
                        catch
                        {
                            MessageBox.Show("Coordinates is Incorrect!!!");
                        }
                    }
                    else
                    {
                        Console.WriteLine("You must log in at first.");
                    }
                    break;

                case Command.mySavedCafes:
                    foreach (Cafe b in currentUser.Saved)
                    {
                        Console.WriteLine(b);
                    }
                    break;

                case Command.unselect:
                    selectedBuilding = null;
                    break;
                }
                //Users and Cafes JSON serialization
                File.WriteAllText(buildingPath, JsonConvert.SerializeObject(allCafes));
                File.WriteAllText(userPath, JsonConvert.SerializeObject(allUsers));
            }
            Console.WriteLine(deviderTildes + "\n Authors: AnahitMartirosyan, ManeHarutyunyan, SonaTigranyan, HosPogh ;)");
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            Cafe cafe = new Cafe(20, 100);

            cafe.Start();
        }
Beispiel #8
0
        //public void AddPopularity(){Popularity++;}

        public double Directions(Cafe building)
        {
            return(this.Coordinates.GetDistanceTo(building.Coordinates));
        }