10 Questions
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?
String name, String city, State state, String postCode
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?
Returns the postcode of the suburb.
What is the name of the enum class used to represent the states in Australia?
State
What is the maximum length of a suburb's name in the Suburb class?
26 characters
What is the format required for the city name in the Suburb class?
Title case
How many digits must the postcode be in the Suburb class?
Exactly 4 digits
What happens if an invalid state is provided when constructing a Suburb object?
The state is set to 'ERROR'
What is the purpose of the State enum in the Suburb class?
To represent the valid Australian States
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")
-
Test your knowledge of Australian states, suburbs, and addresses. Learn about the different states and territories in Australia and how to format addresses correctly.
Make Your Own Quizzes and Flashcards
Convert your notes into interactive study material.
Get started for free