hello, I am currently struggling so bad in understanding Java and how to implement the codes. I have to implement two subclasses for Canadian and US postal code in Java.
For Canadian Postal code, a valid postal postal code has the rule: positions at 0,2,5 are letters. Positions at 1,4,6 are digits. Position at 3 is white space.
(eg: V9A 7N2)
For a valid USA postal code, it starts with two letter, then white space and followed by 5 digits. (eg: WA 98001)
I only need to do implementation on the Canadian and US class.
I have included the parent class and main.java for reference.

Screenshot_(286).png

Screenshot_(285).png

Screenshot_(284).png

These are what was given:

Screenshot_(283).png

You can use Regex , but depending on where you are in the learning curve it may be simpler to do it directly…

There’s a String method that converts a string to an array of chars
The Character class has methods that tell you if a given char is numeric, alpha, blank etc

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.