Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are to implement a basic trip planner. First draw a graphical representation (simplified map) of the cities listed below. Then let a user choose

You are to implement a basic trip planner. First draw a graphical representation (simplified map) of the cities listed below. Then let a user choose a series of destinations in the map. Assuming the user will start the journey at Acapulco, after every click (representing the next destination), you should: draw a line joining the current destination to the next destination; display the distance (in Km) between the current and next destination; and indicate graphically whether the user will be travelling east or west. You may assume: The user will not click outside of the map. The user will end the trip when a location within 20km of Mexico city is selected as the next destination. Once the user has selected Mexico City as the next and final destination, you should report at the bottom of the screen (in a location outside of the map) the total distance traveled in Kilometers. Also, since it is a well-known fact that Cuernavaca (my hometown) is the center of the universe, you should display a message indicating how many times the user passes within 50 Km of the center of the universe. Trips that start within 50 Km of Cuernavaca should not count as a pass. Once this process has been completed you should ask the user whether or not to continue and proceed accordingly. The locations of the cities that are to be represented are given below. You should declare these points as global constants. You are not allowed to use any other global variable in your program. Cuernavaca (0,0) Mexico City (0,75) Acapulco (-50,-225) Ixtapa (-300,-200) Salamanca (-225,250) Morelia (-250,125) Casitas (300,225) You may find the following formulas useful: This formula looks complicated because we're trying to compute the distance from a point to a line segment, instead of the infinite line passing through the given points. Below is my interpretation of central Mexico. The first screenshot shows what initially appears on the screen. The other two screenshots show two possible routes. The bare minimum your program should show is listed below: The 7 cities listed above with their names; Tick marks every 100 Kilometers and labels every 200 Kilometers. Some graphical representation of the direction of travel (east or west). I have chosen to draw a truck facing left or right accordingly. Whatever you choose must not be a simple shape like an arrow or a message. The representation must include at least one rectangle and at least one circle. What is this assignment about? The purpose of this assignment is that you code your program efficiently using functions. Your program should demonstrate a knowledge and proficiency with modular programming. I strongly recommend using the following functions: drawMap -- to draw the basic map of central Mexico on the screen. drawTruck -- to draw a basic representation of the direction of travel. connectCities -- to draw a line between two adjacent destinations. distanceBetweenCities -- to compute the distance between two adjacent destinations. distanceToCuernavaca (alternatively: distanceToCenterOfTheUniverse) -- to compute the closest distance from a line segment to the center of the map. The choice of return values and parameters is up to you. You may wish to create other functions as well. I suggest getting the drawMap function working first, then planning your output around the map. The next step should be to work on the drawTruck function, making sure you can move your truck around and have it face east or west. As a third step you might want to implement the connectCities function (the following example might come in handy). The functions that compute distances are simple in comparison to the other functions but you need to make sure the computations are accurate. The final step of course would be to make sure the individual pieces work together as a whole. Needless to say that this assignment takes some careful planning. Even though you will have more time, do not wait until the last minute. I have taken my version of this trip planner and compiled it to produce an executable (.exe) file. You should be able to download it and run it on one of the machines in the PIC Lab. It might give you a better idea of what is expected from your program. Click here to download it.

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

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions

Question

Simplify. .V3 logq q

Answered: 1 week ago

Question

1. Identify and control your anxieties

Answered: 1 week ago