Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You will be creating your own type: Conveyor. You do that by implementing the class Conveyor based on the UML class diagram provided. You'll also

You will be creating your own type: Conveyor. You do that by implementing the class Conveyor based on the UML class diagram provided. You'll also write a corresponding test client that accesses and tests the constructor and methods of class Conveyor.

As always make sure to follow best practices like proper indentation, following Java naming conventions, providing prompts before reading in information from the user, adding appropriate comments, using single empty lines to structure your code, etc.

image text in transcribed

Instructions:

-Create a project called Conveyor It includes two java files: Conveyor.java and ConveyorApp.java , ConveyorApp is the test client and includes the main method.

Conveyor.java:

-Create a public class called Conveyor based on UML class diagram above. Include the following three comments to help you structure the code. // fields // constructors // methods In this step attention to details is very important. Make sure to match the names, types, parameter lists, access modifiers, etc. exactly as specified. No class members should be added or removed. -The speed is measured in m/s (meters per second) For clarity please include an inline comment next to the field declaration -The getters should have the typical default implementation. -The constructor and setter require some input validation. Negative speed should not be allowed. Whenever the user provides a negative speed value it should be ignored and the speed should remain unchanged. In case of the constructor the field would remain default initialized ( speed: 0 ) Hint: avoid code duplication. -The method timeToTransport requires some calculation. Based on the current speed t should return the time it takes to transport an item for the specified distance. The distance is provided in meters and the time should be returned in seconds.

ConveyorApp.java:

Class ConveyorApp is a test client and includes the main method. It calls the constructor and methods of class Conveyor in order to test that it works as expected. In main do the following:

-Create two conveyors: a flat belt conveyor and a roller conveyor. Both are instances of Conveyor. For the first conveyor the type is flat belt and its speed is 0.9 m/s. For the second conveyor the type is roller and its speed is -0.5 m/s. Notice that we used an invalid negative speed. We do this in order to test the input validation. -For both conveyors print the following conveyor information: the type of the conveyor the current speed how long it takes to transport an item 50 m -If the input validation works as expected the negative speed never got assigned to the field and the speed of the second conveyor defaulted to 0. Without any movement of the conveyor it takes forever to transport an item. Important: obtain the required values from the Conveyor instances ( by calling methods from class Conveyor ) -At this point we tested the constructors, the getters, and the method timeToTransport. However, we haven't tested the setter yet. In order to test the setter do the following: Change the speed of the first conveyor to -3 The input validation should notice that the value is not valid and thus leave the speed unchanged (still 0.9) Change the speed of the second conveyor to 0.4 0.4 is a valid speed and the field should be updated accordingly. -Again print the conveyor information we printed before but this time it reflects the latest updates. -Make the output look like the expected output shown below. Notice that it includes labels, units, etc. Notice also that the time displays only one digit after the decimal point.

What is the code in java for Conveyor.java and ConveyorApp.java?

Expected Output:

Conveyor1: flat belt conveyor with a speed of 0.9 m/s Time to transport an item 50 m: 55.6 s

Conveyor2: roller conveyor with a speed of 0.0 m/s Time to transport an item 50 m: Infinity s

.. updating speed

Conveyor1: flat belt conveyor with a speed of 0.9 m/s Time to transport an item 50 m: 55.6 s

Conveyor2: roller conveyor with a speed of 0.4 m/s Time to transport an item 50 m: 125.0 s

Conveyor type : String - speed : double Conveyor (type String, speed: double) +getType 0 : String +getSpeed () double + setSpeed ( speed : double ) +time ToTransport (distance double): double

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

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

More Books

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago