Question: Problem is asking for me to assign the leading zero to a zip code when it is appropriate. Code so far is above. Constructor Border

Problem is asking for me to assign the leading zero to a zip code when it is appropriate. Code so far is above.
 Problem is asking for me to assign the leading zero to
a zip code when it is appropriate. Code so far is above.
Constructor Border Cases Part 1 In our the s with r constructor,

Constructor Border Cases Part 1 In our the s with r constructor, we are passing the zip code as an integer even though zip codes always have ame number of digits. In this case, the border cases involve the zip code beginning or ending zeroes because these are the cases in which we are most likely to lose information, so we'd like to write tests for each of those possibilities. Pirst, let's address the issue of trailing zeros. Create an instance of zipCode passing 12340 to the constructor. 2. Check that the tostring) of that zip code returns the string "12340 This test is making sure that the trailing zero in the zip code is handled properly. Luckily, it will go GREEN without any work. That doesn't mean the test isn't useful, it just means it didn't require any special code. If you want to be very thorough, make your test verify zip codes 12300, 12000, and 10000 to make sure that all trailing zeros work. Now, let's deal with leading zeros. Consider the zip code 01234. If we think of that as an integer, we wouldn't normally write the leading zero. In Java, if we use o1234 as an int, the leading zero tells the compiler to treat the number as base 8 instead of base 10. There's a long explanation for this, but, for this exercise, it's enough to know that we shouldn't put leading zeroes on ints. To test for zip codes with leading zeros, build a test that does the following: Create an instance of ZipCode passing 1234 to the constructor. Check that the tostring () of that zip code returns the string "o1 1. 2. Build the test and watch it fail. (RED) Clearly, leading zeroes are going to require some special handling toString) Phase 2 Rem tmber the issue we had when we output seconds in the duration of a song. All you must do is (cp on the leading zero to the output in the appropriate case. Don't go on until the test passes. aking the leading zeros test pass is going to take a little more work, but you've done this before. (GREEN)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!