예제 #1
0
        public static Marchandise operator +(Marchandise client1, Marchandise client2)
        {
            Marchandise client = new Marchandise();

            client.m_nbClients = client1.m_nbClients + client2.m_nbClients;

            return(client);
        }
예제 #2
0
        private void assignerClientTransport(Client p_client) //Assigner le client à un véhicule
        {
            string type = p_client.ToString();                //Type du client

            string[] infos = p_client.obtenirInfoClient().Split(',');
            int      qte   = Convert.ToInt32(infos[3]); //Quantité du client
            int      qteMax;                            //Quantité maximale du véhicule

            for (int i = 0; i < m_vehicules.Count; i++)
            {
                if ((type == m_vehicules[i].Type()) && m_vehicules[i].disponible()) //Si c'est le bon type
                {
                    qteMax = m_vehicules[i].CapaciteRestante;

                    if (qte <= qteMax) //S'il y a de l'espace
                    {
                        m_vehicules[i].AssignerClient(p_client);
                        m_clients.Remove(p_client);
                    }
                    else
                    {
                        int surplus = qte - qteMax; //Le nombre de clients en surplus

                        if (type == "Passagers")
                        {
                            Passager newPass = p_client.separerClientPassager(surplus);
                            m_vehicules[i].AssignerClient(p_client);
                            m_clients.Remove(p_client);
                            m_clients.Add(newPass);
                        }
                        else
                        {
                            Marchandise newMarch = p_client.separerClientMarchandise(surplus);
                            m_vehicules[i].AssignerClient(p_client);
                            m_clients.Remove(p_client);
                            m_clients.Add(newMarch);
                        }
                    }
                    return;
                }
            }
        }
예제 #3
0
        private void creerClientsTransport() //Créer les clients de ce type
        {
            Usine           usine        = Usine.obtenirUsine();
            List <PosCarte> posAeroports = aeroportsPosListe(); //Liste de pos
            Aeroport        aeroport;                           //Aéroport de départ

            Passager passager1 = usine.creerPassager(rnd, posAeroports);

            aeroport = aeroportCorrespondant(passager1.PositionDepart);
            aeroport.ajouterClient(passager1);

            Passager passager2 = usine.creerPassager(rnd, posAeroports);

            aeroport = aeroportCorrespondant(passager2.PositionDepart);
            aeroport.ajouterClient(passager2);

            Passager passager3 = usine.creerPassager(rnd, posAeroports);

            aeroport = aeroportCorrespondant(passager3.PositionDepart);
            aeroport.ajouterClient(passager3);

            Marchandise marchandise1 = usine.creerMarchandise(rnd, posAeroports);

            aeroport = aeroportCorrespondant(marchandise1.PositionDepart);
            aeroport.ajouterClient(marchandise1);

            Marchandise marchandise2 = usine.creerMarchandise(rnd, posAeroports);

            aeroport = aeroportCorrespondant(marchandise2.PositionDepart);
            aeroport.ajouterClient(marchandise2);

            Marchandise marchandise3 = usine.creerMarchandise(rnd, posAeroports);

            aeroport = aeroportCorrespondant(marchandise3.PositionDepart);
            aeroport.ajouterClient(marchandise3);
        }