private void processFile() { Customer aCustomer; string[] customerFields; string aCustomerRecord = myStreamReader.ReadLine(); // Read the file record by record. while (aCustomerRecord != null) { // Break the record into fields. customerFields = aCustomerRecord.Split(DELIMETER); try { // Validate the record. for (int i = 0; i < Customer.NUMBER_OF_FIELDS; i++) { // This throws a MyInvalidFieldException. MyDataStorerForCustomers.TryValidateField(i, customerFields[i]); } // Once it passes the validation loop.... string name = customerFields[Customer.FIELD_NAME_INDEX]; string address = customerFields[Customer.FIELD_ADDRESS_INDEX]; string telephoneNumber = customerFields[Customer.FIELD_TELNUM_INDEX]; // Create an object Customer with properties from the broken down fields. aCustomer = new Customer(name, address, telephoneNumber); // Add the object Customer to the customer array. anArray[counter++] = aCustomer; } catch (IndexOutOfRangeException ioore) { Console.WriteLine("Caught in my own method processFile(), catch block ioore: " + ioore.Message); } catch (MyInvalidFieldException mife) { Console.WriteLine("Caught in my own method processFile(), catch block mife: " + mife.Message); } catch (Exception e) { Console.WriteLine("Caught in my own method processFile(), catch block e: " + e.Message); } // Read the next record. aCustomerRecord = myStreamReader.ReadLine(); } }
public void LoadCustomer(string filePath) { myDataStorerForCustomers = new MyDataStorerForCustomers(filePath); }
public MyProgramController() { myDataStorerForCustomers = null; myDataStorerForBoats = null; myDataStorerForOwnedBoats = new MyDataStorerForOwnedBoats(); }