I'm just getting started with C# and I've been stuck on this problem for two weeks. I have a main form that gets values from a class and a subclass. My problem is that when I try to create an object of the CorporateClass VB tells me that two of my variables (CarSizeInteger and DiscountInteger) are unassigned. My question is why. I implemented them earlier in the program. Help! I'm hopelessly stuck!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace EX02_CarRentals
{
public partial class RentalForm : Form
{
public RentalForm()
{
InitializeComponent();
}
private void CloseButton_Click(object sender, EventArgs e)
{
Close();
}
private void CalculateButton_Click(object sender, EventArgs e)
{
int DaysInteger, BeginningOdometerInteger, EndingOdometerInteger, CarSizeInteger, DiscountInteger;
if (LicenseTextBox.Text != "")
if (CompactRadioButton.Checked || MidSizeRadioButton.Checked || LuxuryRadioButton.Checked)
{
int.TryParse(DaysRentedTextBox.Text, out DaysInteger);
int.TryParse(BeginningOdometerTextBox.Text, out BeginningOdometerInteger);
if (BeginningOdometerInteger > 0)
{
int.TryParse(EndingOdometerTextBox.Text, out EndingOdometerInteger);
if (EndingOdometerInteger > 0)
{
if (CompactRadioButton.Checked)
CarSizeInteger = (int)CarSize.Compact;
else if (MidSizeRadioButton.Checked)
CarSizeInteger = (int)CarSize.MidSize;
else CarSizeInteger = (int)CarSize.Luxury;
}
{
if (CorporateRadioButton.Checked || InsuranceRadioButton.Checked)
{
if (CorporateRadioButton.Checked)
DiscountInteger = (int)Discount.Corporate;
else if (InsuranceRadioButton.Checked)
DiscountInteger = (int)Discount.Insurance;
//create an instance of the Corporate Class
CorporateClass aCorpRental = new CorporateClass(BeginningOdometerInteger, EndingOdometerInteger, CarSizeInteger, DaysInteger, DiscountInteger);
AmountDueTextBox.Text = (aCorpRental.getAmountDue()).ToString("C");
}
else
{
//create an instance of the Rental Class
RentalRate ARental = new RentalRate(BeginningOdometerInteger, EndingOdometerInteger, CarSizeInteger, DaysInteger);
AmountDueTextBox.Text = (ARental.getAmountDue()).ToString("C");
}
}
}
}
}
}
private void DaysRentedTextBox_TextChanged(object sender, EventArgs e)
{
}
}
}