//ADD NEIGHBOURHD METHOD private void addNeighbrhd() { //neighbrhd variables string newNeighbrhdName = txtNeighbourhdName.Text; int newNumProperties = Convert.ToInt32(txtNumPropertiesInNeighbrhd.Text); Property[] newProperties = new Property[0]; //create neighbourhood object Neighbourhood newNeighbrhd = new Neighbourhood(newNeighbrhdName, newNumProperties, newProperties); //temp neighbrhd array Neighbourhood[] allNeighbrhds = Data.allDistricts[selectedDistrict].getAllNeighbrhds(); //add neighbrhd to neighbrhd array int currentSize = allNeighbrhds.Length; Array.Resize(ref allNeighbrhds, currentSize + 1); allNeighbrhds[currentSize] = newNeighbrhd; //put into bigger array Data.allDistricts[selectedDistrict].setAllNeighbrhds(allNeighbrhds); //Call method to write to file // NeighbrhdToFile(); }
private void btnSaveNeighbrhd_Click(object sender, EventArgs e) { //get new value string newNeighbrhdName = txtNeighbourhdName.Text; string newNumProperties = txtNumPropertiesInNeighbrhd.Text; //which district and which neighbrhd Neighbourhood tempNeighbrhd = Data.allDistricts[selectedDistrict].getAllNeighbrhds()[selectedNeighbrhd]; //put into array tempNeighbrhd.setNeighbourhdName(newNeighbrhdName); tempNeighbrhd.setNumProperties(newNumProperties); //messagebox to finish MessageBox.Show("Neighbourhood details have been saved successfully"); //show showNeighbrhd(); }
private void showProperties() { //read properties from which array? Neighbourhood[] tempAllNeighbrhd = Data.allDistricts[selectedDistrict].getAllNeighbrhds(); Neighbourhood tempOneNbhd = tempAllNeighbrhd[selectedNeighbrhd]; Property[] thisPropertyArray = tempOneNbhd.getAllProperties(); lstProperties.Items.Clear(); foreach (Property p in thisPropertyArray) { lstProperties.Items.Add("ID: " + p.getpropertyID() + " Name: " + p.getpropertyName() + " Host ID: " + p.gethostID() + " Host Names: " + p.gethostName() + " Properties Listed for host: " + p.getNumPropertiesForHost() + " Latitude: " + p.getLatitude() + " Longitude: " + p.getLongitude() + " Room Type: " + p.getRoomType() + " Price (£): " + p.getPrice() + " Min. No. of Nights: " + p.getMinNumNights() + " No. of available days: " + p.getNumOfAvailability()); } selectedProperty = 0; //display horizontal scrollbar lstProperties.HorizontalScrollbar = true; }
//ADD DISTRICT METHOD private void addDistrict() { // district variables string newDistrictName = txtDistrictName.Text; string newNumNeighbrhds = txtNumNeighbrhdsInDistrict.Text; Neighbourhood[] newNeighbrhds = new Neighbourhood[0]; // new district District newDistrict = new District(newDistrictName, newNumNeighbrhds, newNeighbrhds); //add district to array int currentDistrict = Data.allDistricts.Length; Array.Resize(ref Data.allDistricts, currentDistrict + 1); Data.allDistricts[currentDistrict] = newDistrict; //call method write to file //districtToFile(); }
private Neighbourhood [] getaNeighbrhd(int numNeighbrhds, StreamReader input) { //make district array - now we know how many times to go around Neighbourhood[] dumplater = new Neighbourhood[0]; for (int i = 0; i < numNeighbrhds; i++) { string neighbrhdName = input.ReadLine(); int numProperties = Convert.ToInt32(input.ReadLine()); Property[] theseProperties; //get property theseProperties = getaProperty(numProperties, input); //increase array Array.Resize(ref dumplater, dumplater.Length + 1); //add new neighbrhd into neighbrhd array dumplater[dumplater.Length - 1] = new Neighbourhood(neighbrhdName, numProperties, theseProperties); } return(dumplater); }