Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

programming in go language Create an interface Transporter with the following two methods Create a simple delivery simulation for a company that is located in

programming in go language

image text in transcribed

Create an interface Transporter with the following two methodsimage text in transcribed

Create a simple delivery simulation for a company that is located in Ottawa and ships to Montreal and Toronto. 1. Create a struct Trip with the following fields: .A string for the name of the destination for the trip, A float 32 for the weight of the load to carry on the trip, .A int for the deadline in hours from for the trip. Create the structures Truck, Pickup and TrainCar with the following fields (Note that the default values are given in brackets): 2. A string for the vehicle of it (Truck, Pickup and TrainCar) A string for the name of it (Truck, Pickup and TrainCar), .A string for the name of the destination ("" A f loat 32 for the average speed (40, 60 and 30), A float 32 for the carrying capacity (10, 2 and 30) .A float 32 for the load the vehicle is assigned to carry (0), In addition, the Pickup will have a bool field isPrivate (true) and the TrainCar will have an extra string field railway (CNR). You must use embedded types in the structures minimizing duplication for full marks. Implement the corresponding global functions NewTruck, NewPickUp and NewTrainCar returning a structure of the corresponding type with the above initializations. addLoad with a Tripas argument returning an error if the transporter has insufficient capacity to carry the weight, has a different destination or cannot make the destination on time. If the current destination is empty, the destination needs to be updated to the trip's destination . print with no argument and no return, printing the transporter to console (see below for an example) 4. Implement the following global functions NewTorontoTrip with arguments weight as float32 and deadline in hours as int returning a pointer to Trip with the destination field set to "Toronto" NewMontrealTrip as above but with the destination field set to "Montreal" 5. Implement methods of the interface Transporter for a pointer to Truck, PickUp and TrainCar 6. Supply a main routine that constructs 2 Truck, 3 Pickup and 1 TrainCar. Then go into a loop where you ask a user to create a Trip where the user supplies the weight and the deadline in hours form now. You must only create trips that are on time and by transporters that can carry the weights. You are not asked to be efficient, i.e., you may assign the Trip to the first Vehicle in the list that can make the Trip. A trip as a whole must be assigned to one vehicle, but one vehicle can carry multiple trips if the destinations match and there is enough time. Print the list of trips after the loop Assume that the distance to Toronto is 400 km while it is 200 km to Montreal for the purpose of determining if a transporter will be on time. Please see an example input /output on the next page

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

Principles Of Multimedia Database Systems

Authors: V.S. Subrahmanian

1st Edition

1558604669, 978-1558604667

More Books

Students also viewed these Databases questions

Question

1. Write down two or three of your greatest strengths.

Answered: 1 week ago

Question

What roles have these individuals played in your life?

Answered: 1 week ago

Question

2. Write two or three of your greatest weaknesses.

Answered: 1 week ago