Question

In: Computer Science

c# Create a class named TelpaMotion.                The inMotion field must not be accseible outside of...

c#

Create a class named TelpaMotion.

               The inMotion field must not be accseible outside of the class. This fields can be initialized 3 different ways.

                              Default 67 mulltiplied by the value of 9.80665

                              A value being passed to it

                              A starting value and an acceleration rate can also be passed, the value should be multiplied by the acceleration rate to set the initial value.

               Create a static field called tractionValue with a default value of 0.33.

                    In the same class create a public method called OverCompensate which allows your team to increase and return a result by multiplying the inMotion value by 1.5 and adding the tractionValue to the result (i.e. (inMotion *1.5)+tractionValue)

In your main method:

Call your class:

               TelpaMotion optionA= new TelpaMotion();

               TelpaMotion optionB= new TelpaMotion(100.45);

TelpaMotion optionC= new TelpaMotion(27.9, 0.321);    

Using the object created for option c, call the OverCompensate method to assign the calculated value to a variable called emergencyStop and display the results. Option created Display to the console the results of each call to the class

              

Solutions

Expert Solution

C# Program

using System;
class TelpaMotion{ //class definition
   private double inMotion; //set inMotion as a private variable so that it cannot be accessible outside the class
   static double tractionValue=0.33; //it is declared as static and a default value is initialized
   public TelpaMotion() //default constructor
   {
       inMotion=67*9.80665;
   }
   public TelpaMotion(double val) //constructor if only one value is passed
   {
       inMotion=val;
   }
   public TelpaMotion(double startval,double accrate) //constructor if start value and acc rate is passed
   {
       inMotion=startval*accrate;
   }
   public double OverCompensate() //overcompensate method
   {
       return inMotion*1.5+tractionValue;
   }
}
  
                  
public class Program
{
   public static void Main()
   {
       double emergencyStop;
       TelpaMotion optionA= new TelpaMotion();
TelpaMotion optionB= new TelpaMotion(100.45);
       TelpaMotion optionC= new TelpaMotion(27.9, 0.321);
       emergencyStop=optionC.OverCompensate();
       Console.WriteLine("Emergency stop:"+emergencyStop);
       Console.WriteLine("optionA OverCompensate value is "+optionA.OverCompensate());
       Console.WriteLine("optionB OverCompensate value is "+optionB.OverCompensate());
   }
}

Screenshot of program

Output

If you find this useful, please rate positive , thankyou


Related Solutions

Code in C++ Must show: unit testing ------------------------------------ UsedFurnitureItem Create a class named UsedFurnitureItem to represent...
Code in C++ Must show: unit testing ------------------------------------ UsedFurnitureItem Create a class named UsedFurnitureItem to represent a used furniture item that the store sells. Private data members of a UsedFurnitureItem are: age (double) // age in years – default value for brandNewPrice (double) // the original price of the item when it was brand new description (string) // a string description of the item condition (char) // condition of the item could be A, B, or C. size (double) //...
Code in C++ Must show: unit testing ------------------------------------ UsedFurnitureItem Create a class named UsedFurnitureItem to represent...
Code in C++ Must show: unit testing ------------------------------------ UsedFurnitureItem Create a class named UsedFurnitureItem to represent a used furniture item that the store sells. Private data members of a UsedFurnitureItem are: age (double) // age in years – default value for brandNewPrice (double) // the original price of the item when it was brand new description (string) // a string description of the item condition (char) // condition of the item could be A, B, or C. size (double) //...
Create a class named Ship with a field that stores a collection of Shippable things and...
Create a class named Ship with a field that stores a collection of Shippable things and another that stores a maximum weight capacity. Include a constructor with a parameter for the max weight, and that gives the Ship an empty collection of Shippables. (Javascript)
Create a class named Ship with a field that stores a collection of Shippable things and...
Create a class named Ship with a field that stores a collection of Shippable things and another that stores a maximum weight capacity. Include a constructor with a parameter for the max weight, and that gives the Ship an empty collection of Shippables. (Javascript)
In c++ Design a class named Account that contains: a.An int data field named id for...
In c++ Design a class named Account that contains: a.An int data field named id for the account. b.A double data field named balancefor the account. c.A double data field named annualInterestRate that stores the current interestrate. d.A no-arg constructor that creates a default account with id 0, balance 0, andannualInterestRate 0. e.The set and get functions for id,balance, and annualInterestRate. f.A functionearnedAmount()that calculates and returns the amount of dollars earned after one year. g.A function named printAccountInfo() that print...
WRITE IN C++ Create a class named Coord in C++ Class has 3 private data items...
WRITE IN C++ Create a class named Coord in C++ Class has 3 private data items               int xCoord;               int yCoord;               int zCoord; write the setters and getters. They should be inline functions               void setXCoord(int)             void setYCoord(int)            void setZCoord(int)               int getXCoord()                     int getYCoord()                   int getZCoord() write a member function named void display() that displays the data items in the following format      blank line      xCoord is                          ????????      yCoord is                          ????????      zCoord...
in c#: Create a class named Square that contains fields for area and the length of...
in c#: Create a class named Square that contains fields for area and the length of a side and whose constructor requires a parameter for the length of one side of a Square. The constructor assigns its parameter to the length of the Square’s side field and calls a private method that computes the area field. Also include read-only properties to get a Square’s side and area. Create a class named DemoSquares that instantiates an array of ten Square objects...
C# Only Create a class named Customer that implements IComparable interface. Create 3 Customer class fields:...
C# Only Create a class named Customer that implements IComparable interface. Create 3 Customer class fields: Customer number, customer name, and amount due. Create automatic accessors for each field. Create an Customer class constructor that takes parameters for all of the class fields and assigns the passed values through the accessors. Create a default, no-argument Customer class constructor that will take no parameters and will cause default values of (9, "ZZZ", 0) to be sent to the 3-argument constructor. Create...
Create a file named StudentArrayList.java,within the file create a class named StudentArrayList. This class is meant...
Create a file named StudentArrayList.java,within the file create a class named StudentArrayList. This class is meant to mimic the ArrayList data structure. It will hold an ordered list of items. This list should have a variable size, meaning an arbitrary number of items may be added to the list. Most importantly this class should implement the interface SimpleArrayList provided. Feel free to add as many other functions and methods as needed to your class to accomplish this task. In other...
Java Q1: Create a class named Triangle, the class must contain: Private data fields base and...
Java Q1: Create a class named Triangle, the class must contain: Private data fields base and height with setter and getter methods. A constructor that sets the values of base and height. A method named toString() that prints the values of base and height. A method named area() that calculates and prints the area of a triangle. Draw the UML diagram for the class. Implement the class. Q2: Write a Java program that creates a two-dimensional array of type integer...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT