Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is a 2 part question Please finish the code and all parts labeled with TODO comments on the code help me learn the most

This is a 2 part question

Please finish the code and all parts labeled with TODO

comments on the code help me learn the most so comment please

Thank you

This is part 1:

package week_7.q1_travel_wish_list; /** * Represents one place in a wish list of places to travel to. */ public class Place /* TODO make Place objects Comparable, so they can be sorted */ { /* * * TODO finish this class. * * A place object will need three private fields, with these names: * name: A String for the place name (for example, Hawaii) * reason: A String reason (a reason for visiting, for example, to go surfing) * created: A Date created (when the Place object was created. * * Date objects: https://github.com/claraj/Java2545Examples/blob/master/src/main/java/week7_first_classes/DateObjects.java * * Create get and set methods for all three fields. These will have names like * getName, setName, getReason, setReason, getCreated, setCreated. * Remember that IntelliJ can generate these methods for you. * * In this class, you'll need a *public* constructor that takes two arguments, * the name, and the reason. * The constructor can create and set the Date created. * * Place objects need to be sorted by name. * You'll need to make Place implement Comparable, so one Place can * be compared to another Place. This will allow a List of Place objects * to be sorted. * * Add the compareTo() method that Comparable requires. * * * Place objects need to be printed. Create a toString method * that returns a String with all of the information about this place. * For the example data above, the String should be this EXACT form: * * "Place to visit: Hawaii. Reason: to go surfing. Date created: Thu Oct 03 10:37:02 CDT 2019" * * If the place name is "Rome" and the reason is "to visit the Colosseum" then * the String should be in this EXACT form: * * "Place to visit: Rome. Reason: to visit the Colosseum. Date created: Thu Oct 03 10:42:19 CDT 2019" * * The Date information will be whatever date's toString method returns. You don't need to do any * date formatting. * * */ // TODO create the private fields // TODO create a public constructor with required arguments // so public Place( ...arguments here... ) { ... code here ... } // TODO create get and set methods for the private fields // TODO create toString method that returns a human-readable String with all the information about a Place // TODO create compareTo method so that Place objects can be sorted. }

This is part 2:

package week_7.q1_travel_wish_list; import java.util.ArrayList; import java.util.List; import static input.InputUtils.stringInput; import static input.InputUtils.yesNoInput; /** Program to create and display a list of places a user wishes to travel to. */ public class WishList { public static void main(String[] args) { // TODO modify this line so the wishList List stores Place objects List wishList = new ArrayList<>(); do { String name = stringInput("Enter the name of the place"); String reason = stringInput("Why do you want to visit " + name + "?"); // TODO use the newPlace method to // create a new Place object with the name, and reason // The Place object's constructor should calculate the date created and store that. // TODO add the new Place object, returned by newPlace, to the wishList } while (yesNoInput("More places to add to your wish list?")); // TODO Call the displayPlacesInNameOrder method to print // a list of the places, sorted by name } public static Place newPlace(String placeName, String reason) { // TODO create a new Place object with the given placeName and reason return null; // TODO change this to return the new Place } public static void displayPlacesInNameOrder(List places) { // TODO // Sort the List of Place objects, places should be sorted in name order. // the sort should be case insensitive. 'hawaii' should be before 'Rome'. // Print each place, one per line // Don't print anything else // Make sure you've made Place Comparable, and it has a toString method } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

CL I P COL Astro- L(1-cas0) Lsing *A=2 L sin(0/2)

Answered: 1 week ago

Question

Solve each equation or inequality. |6x8-4 = 0

Answered: 1 week ago