[Solved]C C C Assignment Need Textbox Display Amount Total Credits Course Worth 3 Credits Choose Q37141641
C# C#
For this C# assignment I need for the TextBox to display theamount of total credits I have. Each course is worth 3 credits andI can only choose a maximum of 9 credits. what doe I need to add inorder to get it to display what I want it to display?

heres the course.cs code

Here is the MainWindow.xaml.cs code
using System.Windows;
using System.Windows.Controls;
namespace WPFRegisterStudent
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
Course choice;
private int totalCredits;//added this for the credits
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgse)
{
Course course1 = new Course(“IT 145”);
Course course2 = new Course(“IT 200”);
Course course3 = new Course(“IT 201”);
Course course4 = new Course(“IT 270”);
Course course5 = new Course(“IT 315”);
Course course6 = new Course(“IT 328”);
Course course7 = new Course(“IT 330”);
this.comboBox.Items.Add(course1);
this.comboBox.Items.Add(course2);
this.comboBox.Items.Add(course3);
this.comboBox.Items.Add(course4);
this.comboBox.Items.Add(course5);
this.comboBox.Items.Add(course6);
this.comboBox.Items.Add(course7);
ItemCollection courses = this.comboBox.Items;//set credits forcourse
foreach (Course course in courses)
{
course.SetCredits(3);
}
this.textBox.Text = “”;
}
private void button_Click(object sender, RoutedEventArgse)
{
choice = (Course)(this.comboBox.SelectedItem);
// update the total credit hours textbox if registration isconfirmed for a selected course
if (choice != null)
{
if (totalCredits == 9) // check whether it is completed the 9credit hours of the registered courses.
{
MessageBox.Show(“You can not register for more than 9 credithours.”, “Message”, MessageBoxButton.OK,MessageBoxImage.Warning);
}
else if (IsAlreadyRegisteredCourse(choice)) // check whether theselected course is already registered.
{
MessageBox.Show(“Already registerd. Please registered for anothercourse.”, “Message”, MessageBoxButton.OK,MessageBoxImage.Warning);
}
else
{
// add the registered course name to the listbox
this.listBox.Items.Add(choice.ToString());
// increase the total credits
totalCredits += choice.GetCredits();
}
}
else
{
MessageBox.Show(“Please choose a course to register.”, “Message”,MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
private bool IsAlreadyRegisteredCourse(Course choice) // checkwhether the choose cource is already registered.
{
bool registered = false;
ItemCollection registeredCourses = this.listBox.Items;
foreach (string course in registeredCourses)
{
if (course.Equals(choice.getName()))
{
registered = true;
break;
}
else
{
MessageBox.Show(“Please choose a course to register.”, “Message”,MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
return registered;
}
}
}
Piopenes qister Studcnt Piaase salect a courss for which you war to registe App.coni You are currently regsored fer Total Credt Hours nina:xhetp://schemas.icrosoft.conywinfx/2202/m ealram».http://zchetu…psttealfutTiLa.urx,’.” reup wnutisility/2พ6. Title-y: Register Studert . Tencer’s Copy” Height-295,982. utst”-525″ Loaded-udo”-Lozded’s 沁ㄧ 見:Nunc-‘1.bc11° uu. Lent..Yu..r: urre, Lly registered rur.” hur using System; using System.Collections.Generic; using System.Linq using System.Text using System.Threading. Tasks: Search Solution Explorer (Ctrli+:) Solution ‘WPFRegisterStudent’ (1 project) 4. WPFRegisterStudent Properties с# Assemblyinfo.cs 6 namespace WPFRegisterStudent Resources.resx 8 D 0 Settings.settings 19 references class Course 9 10 References App.config App.xaml D App.xaml.cs private string name”; private bool isRegisteredAlready-false; private int credits; // number of credits of the course C# Course 7 references MainWindow.xaml ש MainWindow.xami.cs public Course(string name) 15 16 17 18 19 this.name name; 0 references public void setName (string name) 20 21 this.namename: 24 1 reference public int GetCredits() 25 26 27 28 29 return this.credits; 2 references public string getName() 30 32 return name; 1 reference public void SetCredits (int credits) 35 36 37 38 39 this.credits credits; 0 references public bool IsRegisteredAlreadyO 40 41 42 43 return isRegisteredAlready; O references public void SetToRegistered() 45 Solution Explorer Team Explorer Properties Course.cs File Properties isRegisteredAlready true; 47 48 49 1 reference public override string ToString() 50 Build Action Copy to Output Directory Custom Tool Custom Tool Namespace File Name Compile Do not copy return getName); 52 53 54 Course.cs Show transcribed image text Piopenes qister Studcnt Piaase salect a courss for which you war to registe App.coni You are currently regsored fer Total Credt Hours nina:xhetp://schemas.icrosoft.conywinfx/2202/m ealram».http://zchetu…psttealfutTiLa.urx,’.” reup wnutisility/2พ6. Title-y: Register Studert . Tencer’s Copy” Height-295,982. utst”-525″ Loaded-udo”-Lozded’s 沁ㄧ 見:Nunc-‘1.bc11° uu. Lent..Yu..r: urre, Lly registered rur.” hur
using System; using System.Collections.Generic; using System.Linq using System.Text using System.Threading. Tasks: Search Solution Explorer (Ctrli+:) Solution ‘WPFRegisterStudent’ (1 project) 4. WPFRegisterStudent Properties с# Assemblyinfo.cs 6 namespace WPFRegisterStudent Resources.resx 8 D 0 Settings.settings 19 references class Course 9 10 References App.config App.xaml D App.xaml.cs private string name”; private bool isRegisteredAlready-false; private int credits; // number of credits of the course C# Course 7 references MainWindow.xaml ש MainWindow.xami.cs public Course(string name) 15 16 17 18 19 this.name name; 0 references public void setName (string name) 20 21 this.namename: 24 1 reference public int GetCredits() 25 26 27 28 29 return this.credits; 2 references public string getName() 30 32 return name; 1 reference public void SetCredits (int credits) 35 36 37 38 39 this.credits credits; 0 references public bool IsRegisteredAlreadyO 40 41 42 43 return isRegisteredAlready; O references public void SetToRegistered() 45 Solution Explorer Team Explorer Properties Course.cs File Properties isRegisteredAlready true; 47 48 49 1 reference public override string ToString() 50 Build Action Copy to Output Directory Custom Tool Custom Tool Namespace File Name Compile Do not copy return getName); 52 53 54 Course.cs
Expert Answer
Answer to C# C# For this C# assignment I need for the TextBox to display the amount of total credits I have. Each course is worth … . . .
OR

