160 likes | 301 Views
Example Project. Previously. GUI Example Switch. Overview. Study a problem and discompose it. Overview. Write a simple Address Book Application Each entry should be able to store the following information about an address: Street name Number City Postcode Country
E N D
Previously • GUI Example • Switch
Overview Study a problem and discompose it
Overview • Write a simple Address Book Application • Each entry should be able to store the following information about an address: • Street name • Number • City • Postcode • Country • Occupants - each occupant should have a first name, last name, date of birth and title (Mr, Ms, Miss, Mrs)
Overview • The application should be able to perform at least the following functions: • Add a new address • Delete an existing address • Display an address • Add a new occupier record • Delete an existing occupier record • Display any addresses on a given city • Display any addresses on a given postcode • Display addresses for a particular occupier
Data Address Book • Write a simple Address Book Application • Each entry should be able to store the following information about an address: • Street name • Number • City • Postcode • Country • Occupants - each occupant should have a first name, last name, date of birth and title (Mr, Ms, Miss, Mrs) address occupant
Data • Address • Street name • Is the address a street name? • Has the address a street name? • Number • Is the address a number? • Has the address a number? • City • Is the address a city? • Has the address a city? No member variable Yes No member variable Yes No member variable Yes
Data • Address • Postcode • Is the address a postcode? • Has the address a postcode? • Country • Is the address a country? • Has the address a country? • Occupants • Is the address the occupants? • Has the address the occupants? No member variable Yes No member variable Yes s No member variable Yes
Data • Address public class Address { private String mstrStreetName; privateintmiNumber; private String mstrCity; private String mstrPostcode; private String mstrCountry; private Vector<Occupant> mOccupants; public Address(String strStreetName, intiNumber, String strCity, String strPostcode, String strCountry) { mOccupants = new Vector<Occupant>(); } // Constructor () ... } // end class Address
Occupant • Occupant • First name • Is the address a first name? • Has the address a first name? • Last name • Is the address a last name? • Has the address a last name? • Date of birth • Is the address a date of birth? • Has the address a date of birth? No member variable Yes No member variable Yes No member variable Yes
Occupant • Occupant • Title (Mr, Ms, Miss, Mrs) • Is the address a title? • Has the address a title? • Addresses • Is the address a last name? • Has the address a last name? No member variable Yes s No member variable Yes
Data ? • Occupier public class Occupier { private String mstrFirstName; private String mstrLastName; private Date mBirthDate; private Vector<Address> mAddresses; public Address(String strStreetName, intiNumber, String strCity, String strPostcode) { mAddresses = new Vector<Address>(); } // Constructor () ... } // end class Address Occupier(String strFirstName, String mstrLastName, Date birthDate) {
Data • Occupier public class Occupier { private String mstrFirstName; private String mstrLastName; private Date mBirthDate; private Vector<Address> mAddresses; public Occupier(String strFirstName, String mstrLastName, Date birthDate) { mAddresses = new Vector<Address>(); } // Constructor () ... } // end class Address Occupier(String strFirstName, String mstrLastName, Date birthDate) {
Data • Address Book is a class AddressBook • Data • Contains Addresses Vector of Addresses • Need functionality; methods • Add new addresses • Remove existing address • Load from file • Save to file Add Remove Load Save
Data • Occupier Book is a class ListOccupiers • Data • Contains Occupiers Vector of Occupiers • Need functionality; methods • Add new occupier • Remove existing occupier • Load occupiers from file • Save occupiers in to file Add Remove Load Save