Question

Create an application that tracks electric motors in a manufacturing plant (Python and C++). The application...

Create an application that tracks electric motors in a manufacturing plant (Python and C++).

The application should have a Motor class with the following properties:

MotorId: Five digit string, such as "02340"

Description: String

RPM: Double, values in the range 10 to 10000

Voltage: Double, values in the range 1 to 500

Status: String, three characters

The Status values are:

ON: Motor is online and running

OFF: Motor is online but not running

MNT: Motor is undergoing maintenance and cleaning

NA: Motor isn't available

The application should be able to store at least 3 Motor class objects in an Array or List.

Create an application that allows users to input new motor records to be added to the Array/List. Create a function/method that displays all the motors objects from the Array/List.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Create an application that tracks electric motors in a manufacturing plant (Python and C++).

The application should have a Motor class with the following properties:

MotorId: Five digit string, such as "02340"

Description: String

RPM: Double, values in the range 10 to 10000

Voltage: Double, values in the range 1 to 500

Status: String, three characters

The Status values are:

ON: Motor is online and running

OFF: Motor is online but not running

MNT: Motor is undergoing maintenance and cleaning

NA: Motor isn't available

The application should be able to store at least 3 Motor class objects in an Array or List.

Create an application that allows users to input new motor records to be added to the Array/List. Create a function/method that displays all the motors objects from the Array/List.

PROGRAM:

Motor Class Application

Step 1: Create a new Windows Forms Application project named Motor class.

Step 2: Set up the application’s form as shown in figures.

Step 3: Perform the following steps to add a new class to the project:

1. Click Project on the menu bar, and then click Add Class.

2. In the Add New Item dialog box, make sure Class is selected in the Templates pane. In the Name text box, type Motor.vb
3. Click the Add button.

Step 4: A new class file is created and opened in the Code window. The contents of the class appear as follows:

Public class address

End class

Step 5: Complete the class by entering the following code shown in bold.

Public Class motor

Member variables for Id, Description, RPM, Voltage, Status.

Private id As String

Private Description As String

Private RPM As Double

Private Voltage As Double

Private Status As String

'Constructor to initialize member variables.

Public Sub New()

id = 101

Description = "weel"

RPM = 100

Voltage = 200

Status = "ON"

End Sub

'MotorId Property.

Public Property MotorId() As String

Get

Return id

End Get

Set(ByVal value As String)

id = value

End Set

End Property

'Description Property.

Public Property Desc() As String

Get

Return Description

End Get

Set(ByVal value As String)

id = Description

End Set

End Property

'RPM Property

Public Property MotorRPM() As String

Get

Return RPM

End Get

Set(ByVal value As String)

id = RPM

End Set

End Property

'Voltage Property

Public Property MotorVoltage() As String

Get

Return Voltage

End Get

Set(ByVal value As String)

id = Voltage

End Set

End Property

'Status Property

Public Property MotorStatus() As String

Get

Return Status

End Get

Set(ByVal value As String)

id = Status

End Set

End Property

'Overrides ToString Method

Public Overrides Function ToString() As String

Dim str As String

str = "MitorId:" & id & "," & "Description:" & Description & "," & "RPM:" & RPM & "," & "Voltage:" & Voltage & "," & "Status:" & Status

Return str

End Function
End Class


Step 6: Add a module named MotorModule.vb to the project. Complete the module by entering the following code, shown in bold.

Module MotorModule

'Collection for motor list

Public motorCollection As New Collection

'The addMotor procedure adds a motor object to the collection and uses the Id property as the key

Public Sub addMotor(ByVal objmotor As motor)

Try

motorCollection.Add(objmotor, objmotor.MotorId)

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

End Sub

End Module


Step 7: Now write the procedures and event handlers for the MainForm form, shown in below. To create the code template, simply open MainForm in the Designer window and double-click and write following Code

Public Class Form1

'The Get Data procedure assigns values from the form to a motor object's properties

Private Sub getData(ByVal objMotor As motor)

Try

'Get all information

objMotor.MotorId = txtId.Text

objMotor.Desc = txtDesc.Text

objMotor.MotorRPM = txtRpm.Text

objMotor.MotorVoltage = txtVoltage.Text

objMotor.MotorStatus = txtStatus.Text

Catch ex As Exception

'Error Message

MessageBox.Show("Enter proper values for all entries")

End Try

End Sub

'The ClearForm procedure claers the form

Private Sub clearForm()

txtDesc.Clear()

txtId.Clear()

txtRpm.Clear()

txtStatus.Clear()

txtVoltage.Clear()

'Set the focus

txtId.Focus()

End Sub

Private Sub btnExit_Click(ByVal sender As System. Object, ByVal e As System.EventArgs) Handles btnExit.Click

'Close the form

Me. Close()

End Sub

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click

'Create an instance of the motor class.

Dim objmotor As New motor

'Get data from the form.

getData(objmotor)

'Add the motor object to the collection

addMotor(objmotor)

'Display a confirmation message.

MessageBox.Show("Motor record added successfully")

End Sub

Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click

'Create an instance of the display form

Dim frmDisplay As New disp

'Display the form

frmDisplay.showDialog()

End Sub

End Class

Step 8: write the procedures and event handlers for the addMotor form, shown in below. To create the code template, simply open addMotor Form in the Designer window and double-click and write the following code.

Public Class disp

Private Sub disp_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

‘Declare an object variable that can reference a motor object

Dim objmotor As motor

'Get each object in the collection and add its data to the list box

For Each objmotor In motorCollection

lstOut.Items.Add(objmotor.ToString())

Next
End Sub Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click

'Close the form

Me. Close()

End Sub

End Class


Step 9: Save the project and run application. On the main form, add data for motor list, and then click add button.Repeate this for at least 10 motor lists. Click the display button to see a list of motors you have added. The output figure shown below:

OUTPUT:

Step 3: Perform the following steps to add a new class to the project:

1. Click Project on the menu bar, and then click Add Class.

2. In the Add New Item dialog box, make sure Class is selected in the Templates pane. In the Name text box, type Motor.vb
3. Click the Add button.

Step 4: A new class file is created and opened in the Code window. The contents of the class appear as follows:

Public class address

End class

Step 5: Complete the class by entering the following code shown in bold.

Public Class motor

Member variables for Id, Description, RPM, Voltage, Status.

Private id As String

Private Description As String

Private RPM As Double

Private Voltage As Double

Private Status As String

'Constructor to initialize member variables.

Public Sub New()

id = 101

Description = "weel"

RPM = 100

Voltage = 200

Status = "ON"

End Sub

'MotorId Property.

Public Property MotorId() As String

Get

Return id

End Get

Set(ByVal value As String)

id = value

End Set

End Property

'Description Property.

Public Property Desc() As String

Get

Return Description

End Get

Set(ByVal value As String)

id = Description

End Set

End Property

'RPM Property

Public Property MotorRPM() As String

Get

Return RPM

End Get

Set(ByVal value As String)

id = RPM

End Set

End Property

'Voltage Property

Public Property MotorVoltage() As String

Get

Return Voltage

End Get

Set(ByVal value As String)

id = Voltage

End Set

End Property

'Status Property

Public Property MotorStatus() As String

Get

Return Status

End Get

Set(ByVal value As String)

id = Status

End Set

End Property

'Overrides ToString Method

Public Overrides Function ToString() As String

Dim str As String

str = "MitorId:" & id & "," & "Description:" & Description & "," & "RPM:" & RPM & "," & "Voltage:" & Voltage & "," & "Status:" & Status

Return str

End Function
End Class


Step 6: Add a module named MotorModule.vb to the project. Complete the module by entering the following code, shown in bold.

Module MotorModule

'Collection for motor list

Public motorCollection As New Collection

'The addMotor procedure adds a motor object to the collection and uses the Id property as the key

Public Sub addMotor(ByVal objmotor As motor)

Try

motorCollection.Add(objmotor, objmotor.MotorId)

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

End Sub

End Module


Step 7: Now write the procedures and event handlers for the MainForm form, shown in below. To create the code template, simply open MainForm in the Designer window and double-click and write following Code

Public Class Form1

'The Get Data procedure assigns values from the form to a motor object's properties

Private Sub getData(ByVal objMotor As motor)

Try

'Get all information

objMotor.MotorId = txtId.Text

objMotor.Desc = txtDesc.Text

objMotor.MotorRPM = txtRpm.Text

objMotor.MotorVoltage = txtVoltage.Text

objMotor.MotorStatus = txtStatus.Text

Catch ex As Exception

'Error Message

MessageBox.Show("Enter proper values for all entries")

End Try

End Sub

'The ClearForm procedure claers the form

Private Sub clearForm()

txtDesc.Clear()

txtId.Clear()

txtRpm.Clear()

txtStatus.Clear()

txtVoltage.Clear()

'Set the focus

txtId.Focus()

End Sub

Private Sub btnExit_Click(ByVal sender As System. Object, ByVal e As System.EventArgs) Handles btnExit.Click

'Close the form

Me. Close()

End Sub

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click

'Create an instance of the motor class.

Dim objmotor As New motor

'Get data from the form.

getData(objmotor)

'Add the motor object to the collection

addMotor(objmotor)

'Display a confirmation message.

MessageBox.Show("Motor record added successfully")

End Sub

Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click

'Create an instance of the display form

Dim frmDisplay As New disp

'Display the form

frmDisplay.showDialog()

End Sub

End Class

Step 8: write the procedures and event handlers for the addMotor form, shown in below. To create the code template, simply open addMotor Form in the Designer window and double-click and write the following code.

Public Class disp

Private Sub disp_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

‘Declare an object variable that can reference a motor object

Dim objmotor As motor

'Get each object in the collection and add its data to the list box

For Each objmotor In motorCollection

lstOut.Items.Add(objmotor.ToString())

Next
End Sub Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click

'Close the form

Me. Close()

End Sub

End Class


Step 9: Save the project and run application. On the main form, add data for motor list, and then click add button.Repeate this for at least 10 motor lists. Click the display button to see a list of motors you have added. The output figure shown below:

OUTPUT:

Motor Class Motor ID Description RPM Voltage Status Add Display Exit

a Motor List Close

Motor List MotorlD:101 Description home RPM:4000 Voltage:200 Status ON MotorlD:101 Description field RPM:4500 Voltage:100 Status OFF MotoriD:101 Description Cumericial RPM:6700 Voltage:500 Status:MNT MotoriD:101 Descriptionhome RPM:7900 Voltage:400 Status:NA Close

Add a comment
Know the answer?
Add Answer to:
Create an application that tracks electric motors in a manufacturing plant (Python and C++). The application...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create an application that tracks electric motors in a manufacturing plant. The application should have a...

    Create an application that tracks electric motors in a manufacturing plant. The application should have a Motor class with the following properties: MotorId: Five digit string, such as "02340" Description: String RPM: Double, values in the range 10 to 10000 Voltage: Double, values in the range 1 to 500 Status: String, three characters The Status values are: ON: Motor is online and running OFF: Motor is online but not running MNT: Motor is undergoing maintenance and cleaning NA: Motor isn't...

  • 4. Motor Class Create an application that tracks electric motors in a manufacturing plant. The ap-...

    4. Motor Class Create an application that tracks electric motors in a manufacturing plant. The ap- plication should have a Motor class with the following properties: . Motorld: . Description: String e RPM: Five-digit string, such as 02340" Voltage: - Status: Double, values in the range 10 to 10000 Double, values in the range 1 to 500 String, three characters

  • C++ Create an application named CarDemo that declares at least two Car objects and demonstrates how...

    C++ Create an application named CarDemo that declares at least two Car objects and demonstrates how they can be incremented using an overloaded ++ operator. Create a Car class that contains the following properties: Model - The car model (as a string) Mpg The car's miles per gallon (as a double) Include two overloaded constructors. One accepts parameters for the model and miles per gallon; the other accepts a model and sets the miles per gallon to 20. Overload a...

  • JAVA. Create an application that uses a "PriorityQueue" to perform the following Uses the constructor that rece...

    JAVA. Create an application that uses a "PriorityQueue" to perform the following Uses the constructor that receives a "Comparator" object as an argument Stores 5 "Time1" objects using the "Time1" class shown in Fig. 8.1 on page 331. The class must be modified to implement the "Comparator" interface Displays the "Universal Time" in priority order Note: To determine the ordering when implementing the "Comparator" interface, convert the time into seconds (i.e., hours * 3600 + minutes * 60 + seconds),...

  • Please Write the following program in c# You are to write an application which will create...

    Please Write the following program in c# You are to write an application which will create a company, add agents (their name, ID, and weekly sales) to that company, and printout the details of all agents in the company. The application will contain three classes: Agent.cs, Company.cs, and CompanyTest.cs (this class is already provided). Flow of the application: The CompanyTest class creates an object of the Company class and reserves space for five agents. At this point if you call...

  • You are to write a basic fitness application, in C++, that allows the user of the...

    You are to write a basic fitness application, in C++, that allows the user of the application to manually edit “diet” and “exercise” plans. For this application you will need to create three classes: DietPlan, ExercisePlan, and FitnessAppWrapper. Diet Plan Attributes: The class DietPlan is used to represent a daily diet plan. Your class must include three data members to represent your goal calories (an integer), plan name (a std::string), and date for which the plan is intended (a std::string)....

  • COSC 1437 C++2 Project Assignment 3 Description: Computer Science Department is evaluating its professors to see...

    COSC 1437 C++2 Project Assignment 3 Description: Computer Science Department is evaluating its professors to see which professor has the highest rating according to student input. You will create a ProfessorRating class consisting of professor Name and three ratings. The three ratings are used to evaluate easiness, helpfulness, and clarity. The value for each rating is in the range of 1 to 5, with 1 being the lowest and 5 being the highest. Your program should contain the following functionalities:...

  • 02. Second Assignment – The FacebookUser Class We’re going to make a small change to the...

    02. Second Assignment – The FacebookUser Class We’re going to make a small change to the UserAccount class from the last assignment by adding a new method: public abstract void getPasswordHelp(); This method is abstract because different types of user accounts may provide different types of help, such as providing a password hint that was entered by the user when the account was created or initiating a process to reset the password. Next we will create a subclass of UserAccount...

  • This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation...

    This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation inside a class. Task One common limitation of programming languages is that the built-in types are limited to smaller finite ranges of storage. For instance, the built-in int type in C++ is 4 bytes in most systems today, allowing for about 4 billion different numbers. The regular int splits this range between positive and negative numbers, but even an unsigned int (assuming 4 bytes)...

  • Additional code needed: PartA: BurgerOrder class (1 point) Objective: Create a new class that represents an...

    Additional code needed: PartA: BurgerOrder class (1 point) Objective: Create a new class that represents an order at a fast-food burger joint. This class will be used in Part B, when we work with a list of orders. As vou work through this part and Part B, draw a UML diagram of each class in using the UML drawing tool 1) Create a new Lab5TestProject project in Netbeans, right-click on the lab5testproject package and select New>Java Class 2) Call your...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT