Write a program that moves a forester unit and a desert corps unit to a given target location and prints the number of hours it took for each unit to reach the target. First, the user will give the starting X and Y positions of the forester unit as well as its base speed (all ints). Then, the starting X and Y positions of the desert corps unit as well as its base speed (all ints). Finally, the target X and Y positions (both ints) and the terrain type (std:string). Speeds are given as distance traveled in one full day (i.e., 24 hours) and is affected by the terrain type using a multiplier over the base speed. Also, after 1 full day, each unit rests for a certain number of hours. Speed multiplier and rest amount of each type of unit depending on the terrain type are as below. Speed Multiplier Rest Duration After 1 day Terrain type Forester Desert Corps Forester Desert Corps Forest 1.3 0.6 4 12 Desert 0.4 1.2 15 Hills 0.7 0.8 6 Others 1.0 0.8 6 After getting all this information, the program will move both the units to the target by printing out the total time (in hours) it took the units to reach their target and their final positions in the format seen in the outputs. Requirements: • You should define a class for the unit, two CHILD classes of the unit class one for the forester unit, another for the desert corps unit. • Coordinate information should be kept as private inside the unit class whereas the speed information should be kept as protected inside the unit class. • Classes should take the related input in their constructor functions. • The base unit class MUST have a public function which prints out the current location of the unit. • The base unit class MUST have a protected function which moves the unit to a given location. • The base unit class MUST have a protected function which calculates the distance between itself and a target location. • Each child classes MUST have a public function which moves the unit to a target location given the terrain type, calculates the total amount of hours it took the unit to reach to the target, and print it out. • Getting all the user input, instantiating objects, calling the move functions of the child classes should be done in the main() function. • Do NOT use polymorphism in this question (i.e., do NOT overload the move function of the base class). 0 0 20 10 70 44 10 70 44 Input 0 0 25 60 4 32 60 4 32 0 100 forest 80 24 desert 80 24 hills Forester walked for Forester walked for 174.22 hours Forester walked for 104.308 hours Desert Corps walked Desert Corps walked Desert Corps walked for 232 hours 77.2688 hours Output for 17.6777 hours for 34.5165 hours Unit is at 0, 100 Unit is at 80, 24 Unit is at 80, 24 Unit is at 0, 100 Unit is at 80, 24 Unit is at 80, 24

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

c++

Write a program that moves a forester unit and a desert corps unit to a given target location and prints the number of hours it took for each unit to reach the
target.
First, the user will give the starting X and Y positions of the forester unit as well as its base speed (all ints). Then, the starting X and Y positions of the desert
corps unit as well as its base speed (all ints). Finally, the target X and Y positions (both ints) and the terrain type (std:string).
Speeds are given as distance traveled in one full day (i.e., 24 hours) and is affected by the terrain type using a multiplier over the base speed. Also, after 1 full
day, each unit rests for a certain number of hours. Speed multiplier and rest amount of each type of unit depending on the terrain type are as below.
Speed Multiplier
Rest Duration After 1 day
Terrain type
Forester
Desert Corps
Forester
Desert Corps
Forest
1.3
0.6
4
12
Desert
0.4
1.2
15
Hills
0.7
0.8
6
Others
1.0
0.8
8
6
After getting all this information, the program will move both the units to the target by printing out the total time (in hours) it took the units to reach their target
and their final positions in the format seen in the outputs.
Requirements:
• You should define a class for the unit, two CHILD classes of the unit class one for the forester unit, another for the desert corps unit.
• Coordinate information should be kept as private inside the unit class whereas the speed information should be kept as protected inside the unit
class.
Classes should take the related input in their constructor functions.
• The base unit class MUST have a public function which prints out the current location of the unit.
• The base unit class MUST have a protected function which moves the unit to a given location.
The base unit class MUST have a protected function which calculates the distance between itself and a target location.
• Each child classes MUST have a public function which moves the unit to a target location given the terrain type, calculates the total amount of hours
it took the unit to reach to the target, and print it out.
• Getting all the user input, instantiating objects, calling the move functions of the child classes should be done in the main() function.
• Do NOT use polymorphism in this question (i.e., do NOT overload the move function of the base class).
0 0 20
10 70 44
10 70 44
0 0 25
60 4 32
60 4 32
Input
0 100 forest
80 24 desert
80 24 hills
Forester walked for
104.308 hours
Forester walked for Forester walked for
174.22 hours
77.2688 hours
Desert Corps walked
for 232 hours
Desert Corps walked Desert Corps walked
for 17.6777 hours
Output
for 34,5165 hours
Unit is at 0, 100
Unit is at 80, 24
Unit is at 80, 24
Unit is at 0, 100
Unit is at 80, 24
Unit is at 80, 24
Transcribed Image Text:Write a program that moves a forester unit and a desert corps unit to a given target location and prints the number of hours it took for each unit to reach the target. First, the user will give the starting X and Y positions of the forester unit as well as its base speed (all ints). Then, the starting X and Y positions of the desert corps unit as well as its base speed (all ints). Finally, the target X and Y positions (both ints) and the terrain type (std:string). Speeds are given as distance traveled in one full day (i.e., 24 hours) and is affected by the terrain type using a multiplier over the base speed. Also, after 1 full day, each unit rests for a certain number of hours. Speed multiplier and rest amount of each type of unit depending on the terrain type are as below. Speed Multiplier Rest Duration After 1 day Terrain type Forester Desert Corps Forester Desert Corps Forest 1.3 0.6 4 12 Desert 0.4 1.2 15 Hills 0.7 0.8 6 Others 1.0 0.8 8 6 After getting all this information, the program will move both the units to the target by printing out the total time (in hours) it took the units to reach their target and their final positions in the format seen in the outputs. Requirements: • You should define a class for the unit, two CHILD classes of the unit class one for the forester unit, another for the desert corps unit. • Coordinate information should be kept as private inside the unit class whereas the speed information should be kept as protected inside the unit class. Classes should take the related input in their constructor functions. • The base unit class MUST have a public function which prints out the current location of the unit. • The base unit class MUST have a protected function which moves the unit to a given location. The base unit class MUST have a protected function which calculates the distance between itself and a target location. • Each child classes MUST have a public function which moves the unit to a target location given the terrain type, calculates the total amount of hours it took the unit to reach to the target, and print it out. • Getting all the user input, instantiating objects, calling the move functions of the child classes should be done in the main() function. • Do NOT use polymorphism in this question (i.e., do NOT overload the move function of the base class). 0 0 20 10 70 44 10 70 44 0 0 25 60 4 32 60 4 32 Input 0 100 forest 80 24 desert 80 24 hills Forester walked for 104.308 hours Forester walked for Forester walked for 174.22 hours 77.2688 hours Desert Corps walked for 232 hours Desert Corps walked Desert Corps walked for 17.6777 hours Output for 34,5165 hours Unit is at 0, 100 Unit is at 80, 24 Unit is at 80, 24 Unit is at 0, 100 Unit is at 80, 24 Unit is at 80, 24
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY