Question

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 available

The application should be able to store Motor class objects in the List collection. Create an input Form in the application that allows users to input new motor records to be added to the List. Create another form that displays all the motors in the List in a list box.

When the application ends, it should save the contents of the List collection to a sequential text file. When the application starts up, it should load the data from the file into the collection. Be sure to write the appropriate error handlers.

Need Written in C#, Thanks

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

Answer:

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.

Add a comment
Know the answer?
Add Answer to:
Create an application that tracks electric motors in a manufacturing plant. The application should have a...
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 (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...

  • 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

  • create a new Java application called "WeightedAvgWithExceptions" (without the quotation marks), according to the following guidelines...

    create a new Java application called "WeightedAvgWithExceptions" (without the quotation marks), according to the following guidelines and using try-catch-finally blocks in your methods that read from a file and write to a file, as in the examples in the lesson notes for reading and writing text files. Input File The input file - which you need to create and prompt the user for the name of - should be called 'data.txt', and it should be created according to the instructions...

  • Application should be in C# programming language Create a class called SavingsAccount.  ...

    Application should be in C# programming language Create a class called SavingsAccount.  Use a static variable called annualInterestRate to store the annual interest rate for all account holders.  Each object of the class contains a private instance variable savingsBalance, indicating the amount the saver currently has on deposit. Provide method CalculateMonthlyInterest to calculate the monthly interest by multiplying the savingsBalance by annualInterestRate divided by 12 – this interest should be added to savingsBalance.  Provide static method setAnnualInterestRate to set the...

  • create a new Java application called "WeightedAvgDataAnalyzer" (without the quotation marks), that modifies the DataAnalyzer.java in...

    create a new Java application called "WeightedAvgDataAnalyzer" (without the quotation marks), that modifies the DataAnalyzer.java in Horstmann Section 7.5, pp. 350-351 according to the specifications below. The input file should be called 'data.txt' and should be created according to the highlighted instructions below. Note that even though you know the name of the input file, you should not hard-code this name into your program. Instead, prompt the user for the name of the input file. The input file should contain...

  • Exercise 1: Create a class Resource. The class should have: a) Two private variables status and w...

    C++C++ Exercise 1: Create a class Resource. The class should have: a) Two private variables status and writeTo representing integer value either 0 or 1. b) One default constructor that initializes the status and writeTo to zero. c) One single parameterized constructor to initialize the writeTo variable. d) Two constant accessor functions per class that return the values of status e) Two mutator functions per class that set the values of status and writeTo One output (member) function that outputs...

  • Create a class fully-qualified as edu.udc.cs 1. ArrayWork. This class should have a static method that...

    Create a class fully-qualified as edu.udc.cs 1. ArrayWork. This class should have a static method that takes an integer array with at least 1 element. All elements will be more than 0. The method must return a double array of the same size filled with normalized values at the same positions. Normalized values will be a value between 0 (exclusive) and 1 inclusive. Simply, it will be every input value divided by the maximum value in the input. For instance...

  • IN C# Objectives: Create an application that uses a dictionary collection to store information ...

    IN C# Objectives: Create an application that uses a dictionary collection to store information about an object. Understanding of abstract classes and how to use them Utilize override with an abstract class Understanding of Interfaces and how to use them Implement an Interface to create a “contract” between classes. Compare and contrast inheritance and interfaces. Instructions: Interface: Create an interface called ITrainable which contains the following: Dictionary<string, string> Behaviors{ get; set; } string Perform(String signal); string Train(String signal, string behavior);...

  • Assighment. Creaung Java Classes with methods Note: If you have not yet completed this unit's Discussion,...

    Assighment. Creaung Java Classes with methods Note: If you have not yet completed this unit's Discussion, it is best to complete it before you begin this Assignment As studied in the Discussion, it is important to design a test plan prior to creating a class, as it will help reduce coding problems. In this unit's Assignment, you create, compile, and execute a class containing methods. Be sure to use best coding practices, such as creating a test plan, before you...

  • I need some help i need to do this in C# Objectives: • Create an application...

    I need some help i need to do this in C# Objectives: • Create an application that uses a dictionary collection to store information about an object. • Understanding of abstract classes and how to use them • Utilize override with an abstract class • Understanding of Interfaces and how to use them • Implement an Interface to create a “contract” between classes. • Compare and contrast inheritance and interfaces. Instructions: Interface: Create an interface called ITrainable which contains the...

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