What is going on?

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

What is going on?

Post by answerhappygod »

What is going on?
What Is Going On 1
What Is Going On 1 (44.26 KiB) Viewed 38 times
What Is Going On 2
What Is Going On 2 (25.78 KiB) Viewed 38 times
CHALLENGE 9.15.5: Have the Address class implement the Comparable interface. ACTIVITY 390562.2379304.qx3zqy7 Have the Address class implement the Comparable interface. First compare the street name, then the house number. For example, 123 Main Street comes after 57 Main Street but before 1 State Street. Address.java Tester.java 2232425262728293813233435 36 7 8 39 4 30 37 38 public int compareTo (Object o) { Address address (Address) o; (street.compareTo(address.street) > 0) { } if return 1; else if (street.compareTo(address.street) > 0) { return -1; } } else { if (houseNumber > address.houseNumber) { return 1; } else if (houseNumber > address.houseNumber) { return -1; } return 0;
Your output Expected output Expected: 0 true Expected: true true Expected: true true Expected: false [123 Main Street, 57 Main Street, 11235 Hollywood Ave] Expected: [11235 Hollywood Ave, 57 Main Street, 123 Main Street] 0 Expected: 0 true Expected: true true Expected: true false Expected: false [11235 Hollywood Ave, 57 Main Street, 123 Main Street] Expected: [11235 Hollywood Ave, 57 Main Street, 123 Main Street]
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply