Podcast
Questions and Answers
What is the order of the states in the enum class named State?
What is the order of the states in the enum class named State?
NEW_SOUTH_WALES, AUSTRALIAN_CAPITAL_TERRITORY, VICTORIA, QUEENSLAND, SOUTH_AUSTRALIA, WESTERN_AUSTRALIA, TASMANIA, NORTHERN_TERRITORY
What parameters does the constructor of the Suburb class take?
What parameters does the constructor of the Suburb class take?
String name, String city, State state, String postCode
What is the format of the string returned by the toString method of the Suburb class?
What is the format of the string returned by the toString method of the Suburb class?
name + : + city + : + state + : + postCode;
What is the purpose of the getPostCode method of the Suburb class?
What is the purpose of the getPostCode method of the Suburb class?
Signup and view all the answers
What is the name of the enum class used to represent the states in Australia?
What is the name of the enum class used to represent the states in Australia?
Signup and view all the answers
What is the maximum length of a suburb's name in the Suburb class?
What is the maximum length of a suburb's name in the Suburb class?
Signup and view all the answers
What is the format required for the city name in the Suburb class?
What is the format required for the city name in the Suburb class?
Signup and view all the answers
How many digits must the postcode be in the Suburb class?
How many digits must the postcode be in the Suburb class?
Signup and view all the answers
What happens if an invalid state is provided when constructing a Suburb object?
What happens if an invalid state is provided when constructing a Suburb object?
Signup and view all the answers
What is the purpose of the State enum in the Suburb class?
What is the purpose of the State enum in the Suburb class?
Signup and view all the answers
Study Notes
Suburb Class
- The Suburb class has a constructor that initializes an object with a name, city, state, and postcode.
- The state is represented by an enum called State, which has eight valid values:
- NEW_SOUTH_WALES
- AUSTRALIAN_CAPITAL_TERRITORY
- VICTORIA
- QUEENSLAND
- SOUTH_AUSTRALIA
- WESTERN_AUSTRALIA
- TASMANIA
- NORTHERN_TERRITORY
Domain Rules for Suburb Properties
- Name:
- Minimum of 1 character in length
- Maximum of 26 characters in length
- Must be in title case (e.g. Carlton North)
- City:
- Minimum of 1 character in length
- Must be in title case (e.g. Sunshine Coast)
- Postcode:
- Exactly 4 digits in length
- Must contain only numeric characters
- State:
- Must be a valid Australian state (or territory)
- Invalid values will be set to "ERROR"
Methods in Suburb Class
- Public methods:
-
public String getName()
: Returns the name of the suburb -
public String getCity()
: Returns the name of the city -
public String getPostCode()
: Returns the postcode -
public String toString()
: Returns a string representation of the suburb (e.g. "Carlton North:Melbourne:Victoria:3054")
-
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
Test your knowledge of Australian states, suburbs, and addresses. Learn about the different states and territories in Australia and how to format addresses correctly.