Exemple #1
0
        private void BTNsubName_Click(object sender, EventArgs e)
        {
            string districtAssign = TXTDisName.Text;

            for (int i = 0; i < DistrictDATA.libDistrict.Length; i++)
            {
                if (districtAssign.ToString().ToLower() == DistrictDATA.libDistrict[i].GetDistName().ToLower())
                {
                    string newNeighbName  = TXTnewNeighbName.Text;
                    int    newNeighbProps = 0;

                    int distNumUp = DistrictDATA.libDistrict[i].GetnumNaighbsInDistrict() + 1;
                    DistrictDATA.libDistrict[i].SetnumNaighbsInDistrict(distNumUp.ToString());

                    Neighbour neighbour = new Neighbour(newNeighbName, newNeighbProps);

                    //get length of array
                    int lengthOf = DistrictDATA.libDistrict[i].libAllNeighbs.Length;
                    //makes array one bigger
                    Array.Resize(ref DistrictDATA.libDistrict[i].libAllNeighbs, lengthOf + 1);
                    //adds new neighbourhood to District array
                    DistrictDATA.libDistrict[i].libAllNeighbs[lengthOf] = neighbour;
                }
            }
            this.Hide();
        }
Exemple #2
0
        private void collectData()
        {
            //cals streamreader and creates space for mini dat
            using (StreamReader read = new StreamReader("maxiDat.txt"))
            {
                //steps up array number in while loop
                DistrictDATA.libDistrict = new District[0];


                //while loop goes through whole text file //end of stream
                while (!read.EndOfStream)
                {
                    //reads line by line
                    string districtName = read.ReadLine();
                    int    numNaighbourhoodsInDistrict = Convert.ToInt32(read.ReadLine());
                    //adds district to array
                    District district = new District(districtName, numNaighbourhoodsInDistrict.ToString());



                    //for loop to collect neighbourhoods
                    for (int neighbNum = 0; neighbNum < numNaighbourhoodsInDistrict; neighbNum++)
                    {
                        string neighbourhoodName            = read.ReadLine();
                        int    numPropertiesInNeighbourhood = Convert.ToInt32(read.ReadLine());
                        //adds data to neighb array
                        Neighbour neighbour = new Neighbour(neighbourhoodName, numPropertiesInNeighbourhood);

                        //get length of array
                        int lengthD = district.libAllNeighbs.Length;
                        //makes array one bigger
                        Array.Resize(ref district.libAllNeighbs, lengthD + 1);
                        //adds properties to neighb array
                        district.libAllNeighbs[lengthD] = neighbour;

                        // for loop to collect properties
                        for (int propNum = 0; propNum < numPropertiesInNeighbourhood; propNum++)
                        {
                            int    propertyID      = Convert.ToInt32(read.ReadLine());
                            string propertyName    = read.ReadLine();
                            int    hostID          = Convert.ToInt32(read.ReadLine());
                            string hostName        = read.ReadLine();
                            int    propertyForHost = Convert.ToInt32(read.ReadLine());
                            double latitude        = Convert.ToDouble(read.ReadLine());
                            double longitude       = Convert.ToDouble(read.ReadLine());
                            string roomType        = read.ReadLine();
                            double price           = Convert.ToDouble(read.ReadLine());
                            int    minimumNights   = Convert.ToInt32(read.ReadLine());
                            int    availability    = Convert.ToInt32(read.ReadLine());

                            //adds to property array
                            Property property = new Property(propertyID, hostID, propertyForHost, minimumNights, availability,
                                                             propertyName, hostName, roomType, latitude, longitude, price);

                            //get length of array
                            int lengthN = neighbour.libAllProperties.Length;
                            //makes array one bigger
                            Array.Resize(ref neighbour.libAllProperties, lengthN + 1);
                            //adds properties to neighb array
                            neighbour.libAllProperties[lengthN] = property;
                        }
                    }
                    //must be below so it can add the other arrays first
                    //get length of array
                    int length = DistrictDATA.libDistrict.Length;
                    //makes array one bigger
                    Array.Resize(ref DistrictDATA.libDistrict, length + 1);
                    //adds properties to neighb array
                    DistrictDATA.libDistrict[length] = district;
                }
                //calls methods htat displays district, neighbourhood, and property
                showDist();
                //passes through 0 so that the first element is auto selected
                showNeighbs(0);
                showProp(0, 0);
                //closes streamreader
                read.Close();
            }
        }