Question: Java code: Design an implementation for CityCode classes ( abstract parent class, the isValid method is abstract), MexicoCode and USCode which are the subclasses Concrete
Java code:
Design an implementation for CityCode classes (abstract parent class, the
isValid method is abstract), MexicoCode and USCode which are the subclasses
Concrete of CityCode. Make sure to include the instance variables as well as
the builders. The appendix below presents a summary of the class methods
String and Character.
Create a Test class to test your classes:
Declare a table, named codes, which can contain 100 postal codes;
Create n = 10 postal codes some of which are american codes while others
will be mexican codes. Likewise, some codes are valid and others are not.
Finally, save these codes in the first n cells on the left of the table;
Knowing that exactly n postal codes are in the left part of the table,
write a for loop to count the number of valid codes and display it.
/ Example output * /
2 codes are valid
Appendix
The String class contains the following methods.
char charAt (int cod): returns the character located at the position specified by the index
cod;
int length (): returns the length of this string.
The Character class contains the following methods:
static boolean isDigit (char char): determines if the character passed in parameter is a
number;
static boolean isLetter (char char): determines if the character passed in parameter is a
letter;
static boolean isWhitespace (char char): determines if the character passed in parameter is a
white space.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
