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!
Ray

Sujeet SumanPosted Oct 21, 2015, 1:16 PM
Raymond HighersPosted Oct 21, 2015, 9:16 AM
I can't use ErrorProvider because we haven't went over that in class (it's in an Appendix B of the book), and can't use # regions.
When I did add it, it didn't work, but then I didn't have the Component ErrorProvider in the bottom of my design form page.
Sujeet SumanPosted Oct 21, 2015, 12:25 AM
Raymond HighersPosted Oct 20, 2015, 4:11 PM
This is the design that the professor gave us.
Ray
Sujeet SumanPosted Oct 20, 2015, 1:44 PM
Vaibhav DeshmukhPosted Oct 20, 2015, 10:55 AM
Raymond HighersPosted Oct 19, 2015, 5:53 PM
I can't get the textboxes to clear when I click the btnEnterStats. I can't get anything to print out to the lblEnginesStats.
Can someone help me with this?
Raymond HighersPosted Oct 19, 2015, 11:09 AM
Raymond HighersPosted Oct 17, 2015, 7:11 PM
// The GetData method gets the data entered by the user and assigns it to the parameter object's fields.
private void GetCarData(ref Automobile auto)
{
try
{
// Get the data from the textboxes.
auto.cylinders = int.Parse(txtCylinders.Text);
auto.horsepower = int.Parse(txtHorsepower.Text);
auto.torque = int.Parse(txtTorque.Text);
}
catch
{
lblStatsResults.Text = "Please enter integers in all three textboxes.";
}
txtCylinders.Text = auto.cylinders.ToString();
txtHorsepower.Text = auto.horsepower.ToString();
txtTorque.Text = auto.torque.ToString();
CompareNewStructureInstance();
}
private void CompareNewStructureInstance()
{
}
private void btnEnterEngineStats_Click(object sender, EventArgs e)
{
// Create an instance of the Automobile structure.
Automobile car = new Automobile();
// Get the data entered by the user.
GetCarData(ref car);
// Add the car object to the List.
carList.Add(car);
// Clear the textboxes.
txtCylinders.Clear();
txtHorsepower.Clear();
txtTorque.Clear();
// Reset the focus.
txtCylinders.Focus();
}
Sujeet SumanPosted Oct 17, 2015, 2:37 AM