C# File Processing - Applications

 

Formula 1 Speed Calculator - Analysis

This is the Formula 1 Average Speed Calculator. It’s really two applications. When the program comes up you see a “Race Results” screen. This is meant for viewing data you have stored out on disk.

If you click the Data Entry screen below the program totally switches to a data entry application where you can key in all the race data for a given race.

Looks kind of complicated. Well, it appears that way but all applications, complicated or not, are just a collection of simpler things. And we, as problems solvers, can analyze what needs to be done and prepare our application for assembly.

It’s mentioned in the video that this is a two-part application. Sort of. We analyze and then we make it happen. Making it happen, however, is broken down into a series of videos so we can grasp the details.

Formula 1 Speed Calculator - Data Entry Screen

Well, you saw the analysis. This project has a bunch of pieces. To do this right we will break it down into smaller pieces. So, before we do any coding let’s design this form. Or is it just a form.

This project is really two applications. One is entering all the data for the races. The other is displaying the race data on command. We want these two pieces not to interfere with one another. To do that we are going to use group boxes and panels. This will help with the logic of our program when we begin to code.

Let’s get right to it and design the data entry screen.

Formula 1 Speed Calculator - Panel Setup

We’ve set up the data entry screen. We still have the race results screen to set up. But before we do that we need to figure out where to put it. Data Entry is pretty much taking up all the real estate at this time. Well, we need to think like an architect in downtown Manhattan and build up. Build layers.

We do that by using panels. One on top of the other. But we only make one panel active at a time. It’s like going from the first floor to the second floor. And it is pretty easy to do.

Formula 1 Speed Calculator - Coding Track Info

Time to enter track information. This is pretty straightforward, but it does require us to make sure that the data we are receiving is good data. We validate the information. Once we’ve entered the track information and have all that data safely stored in a series of variables, we can program our save button.

Formula 1 Speed Calculator – Coding Driver Info

Driver information time. This is different than the track info because for each track we have a number of drivers in each race. So, we need to collect the information for each driver. Best way to do that at this time is to use the list box. That way we can calculate the MPH and the KPH for each driver and save that info with the name to the list box. When we are done entering all driver info we will then be in a position to save all the info to disk.

Formula 1 Speed Calculator - Saving the Data

This is what we have been waiting for --- writing the data to disk. There’s a little bit of cleanup first. We need to program the “Delete Selected Item” button first. After that we can write the routine to save the data. This means that we will save the track information followed by the driver information. And since there are multiple drivers, we’ll need to employ a loop to save that data.

Formula 1 Speed Calculator – Testing

The Data Entry screen is complete. Time to code the Display Screen. Well, almost. We need to make sure the Data Entry screen is working smoothly. That nothing’s been missed. It is important to check this portion of the application because we want to code the Display Screen portion knowing that everything we are going to display is good data.

Formula 1 Speed Calculator – Display Screen

Now we can design the Display Screen. This is fairly short. We just need to place some labels and list boxes on the form. Add two buttons. Pretty it up and we’ll be ready to code.

Formula 1 Speed Calculator – Coding Race Results

Race Results is pretty easy. You are just reading the data in the same order that you wrote the data earlier. You read in the track information and then use a loop to read in all the drivers and their average speeds.

Formula 1 Speed Calculator – Worst Case Testing

Worst Case Testing. That’s where you put extreme values in your program to see if it will fail. We can do that with our numeric entries, and this video will show you how. For string values like the track name and Driver name it’s not quite so easy - at this time. We haven’t learned enough.