Visual Studio 2012 C# Enter data into textboxes and compare

Raymond Highers

Raymond Highers

Oct 16 2015 9:15 PM

Here's my problem (Engine Stats):

Create a new Engine structure in an appropriate place in your code.  It should include three integer fields (cylinders, horsepower, and torque).  I made three integer textboxes (txtCylinders, txtHorsepower, and txtTorque).
Create a list to hold instances of the Engine structure in an appropriate place in your code.
When the Engine Stats button is clicked, the following should happen:
(1) Clear out any text in the Stats Results label (I made it lblStatsResults) that's right underneath the torque field.
(2) Declare a new instance of the Engine structure
(3) Use a try/catch statement to ensure that integers have been entered into all three textboxes before executing the code to pull information from the textboxes and compare it to structure instances that have already been stored in the list created earlier   Create a user friendly message for the catch statement.
(4) If integers have been entered into all three textboxes, the following should happen:
     (a) Pull the values from the textboxes and assign them to the appropriate structure fields
     (b) Call a method that will compare the new structure instance to those that already exist in the list due to previous entries on the part of the user.
           The new instance should be sent to the method for processing.
     (c) The method should compare the new Engine instance to all others in the list of Engines to determine if an identical one exists and the following
           should happen:
           (i) If a match exists, the message "The engine has already been added" should be displayed to the user.
           (ii) If a match does not exist, then the new Engine instance should be added to the list and the user should see a message "The new engine stats
                 have been added".
I hope somebody out there can help me with this!

Answers (10)