Ok I'm taking a C# class and this is the first programming course I have ever taken so my questions will probably be dumb but well I can't figure some of things out sometimes so I have to ask.
The current issue is I have to take some information entered by a user and display it in a message box using two classes named Bonus and DVDObject. I'll post the code and if you could hopefully tell me where I'm screwing up I would greatly appreciate it. I've removed the IDE created code.
The DVDBurner namespace ( Not sure what its called. Its the
starting class )
Code:
private DVDObject m_objDVD;
private Bonus[] m_objBonusMat = new Bonus [ 3 ];
private int m_intCount;
// display information about DVD
private void btnInformation_Click(
object sender, System.EventArgs e )
{
// output string
string strInformation = m_objDVD.Title + "\r\n" +
m_objDVD.Minutes + "\r\n" + m_objDVD.BonusMaterial;
lblDisplay.Text = strInformation; // clear Label
// display output in a MessageBox
MessageBox.Show( strInformation, "DVD Description",
MessageBoxButtons.OK, MessageBoxIcon.Information );
}// end method btnInformation_Click
private void btnCreate_Click(object sender, System.EventArgs e)
{
string strMovieTitle = Convert.ToString ( txtTitle.Text );
int intMovieMinutes = Int32.Parse ( txtMovieMinute.Text );
string strDescription1 = Convert.ToString
txtDescription1.Text );
int intMinutes1 = Int32.Parse ( txtMinutes1.Text );
string strDescription2 = Convert.ToString (
txtDescription2.Text );
int intMinutes2 = Int32.Parse ( txtMinutes2.Text );
string strDescription3 = Convert.ToString (
txtDescription3.Text );
int intMinutes3 = Int32.Parse ( txtMinutes3.Text );
string[] strDescription = { strDescription1,
strDescription2, strDescription3 };
int[] intBonusMinutes = { intMinutes1, intMinutes2,
intMinutes3 };
for ( int intCount = 0; intCount <=
m_objBonusMat.GetUpperBound(0); intCount++ )
{
m_objBonusMat[ intCount ] = new Bonus(
strDescription[ intCount ],
intBonusMinutes[ intCount ] );
}
for ( int intCount = 0; intCount <=
m_objBonusMat.GetUpperBound(0); intCount++ )
{
m_objDVD = new DVDObject( strMovieTitle, intMovieMinutes,
m_objBonusMat[ m_intCount ]);
}
btnInformation.Enabled = true;
}
The Bonus class
Code:
public class Bonus
{
//instance variables
private string m_strDescription;
private int m_intMinutes;
public Bonus( string descriptionValue, int minuteValue )
{
Description = descriptionValue;
Minutes = minuteValue;
}
public string Description //property Description
{
get
{
return m_strDescription;
}
set
{
m_strDescription = value;
}
} //end property Description
public int Minutes //property Minutes
{
get
{
return m_intMinutes;
}
set
{
m_intMinutes = value;
}
}//end property Minutes
The DVDObject class
Code:
public class DVDObject
{
private string m_strTitle;
private int m_intMinutes;
private Bonus[] m_objBonusMaterial = new Bonus [ 3 ];
private int m_intCount;
public DVDObject( string titleValue, int minuteValue,
Bonus bonusValue )
{
Title = titleValue;
Minutes = minuteValue;
BonusMaterial = bonusValue;
}
public string Title //property Title
{
get
{
return m_strTitle;
}
set
{
m_strTitle = value;
}
}//end property Title
public int Minutes //property Minutes
{
get
{
return m_intMinutes;
}
set
{
m_intMinutes = value;
}
}//end property Minutes
public Bonus BonusMaterial //property Bonus
{
get
{
return m_objBonusMaterial[ m_intCount ];
}
set
{
for ( m_intCount = 0;
m_intCount <= m_objBonusMaterial.GetUpperBound(0);
m_intCount++ )
{
m_objBonusMaterial[ m_intCount ] = value;
}
}
}//end property BonusMaterial
I think I am mostly screwed up in the DVDObject class. I can't figure out what to do there. Any help would be greatly appreciated.
Tony