Hi, I am working on an assignment in c# where I have to maintain student scores...there is a few questions up here already about it but I am still having problems. I need to create a program that allows the user to enter student names and scores...
I gather I need to use a list to store these values but I am having problems understanding how to go about this.. I just want to be able add student names and scores to a list and pass them back to the main form..
I'll post the code i have and project specs below..
any guidence would really be appreciated...really struggling with c#.
thanks..
Student class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
{
public class Student
{
public string name { get; set; }
public List<int> Scores = new List<int>();
public override string ToString()
{
return name;
}
}
}
Add Student Form
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
{
public partial class AddStudent : Form
{
public AddStudent()
{
InitializeComponent();
}
private void button4_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
Main Form :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
{
public partial class Main : Form
{
List<Student> Students;
public Main()
{
InitializeComponent();
}
private void Main_Load(object sender, EventArgs e)
{
Students = new List<Student>();
Student s1 = new Student();
s1.name = "Joel Murach";
s1.Scores.Add(100);
s1.Scores.Add(100);
Students.Add(s1);
}
private void button1_Click(object sender, EventArgs e)
{
Form studentForm = new AddStudent();
studentForm.ShowDialog();
}
private void button2_Click(object sender, EventArgs e)
{
Form updateForm = new updateStudent();
updateForm.ShowDialog();
}
private void button4_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
Project specs:
The design of the Student Scores form
Operation
To display the total, count, and average for a student, the user selects the student from the list box. If the list box is empty, the total, count, and average labels should be cleared.
To add a new student, the user clicks the Add button to display the Add New Student dialog box.
To update an existing student’s scores, the user selects the student in the list box and clicks the Update button to display the Update Student Scores dialog box.
To delete a student, the user selects the student in the list box and clicks the Delete button.
The design of the Add New Student form
Operation
To add a new student, the user enters a student name and, optionally, one or more scores and clicks the OK button.
To add a score, the user enters a score and clicks the Add Score button. The score is added to the list of scores in the Scores label.
To remove all scores from the Scores label, the user clicks the Clear Scores button.
To cancel the add operation, the user clicks the Cancel button.
The design of the Update Student Scores
and Add/Update Score forms
Operation
To add a score, the user clicks the Add button and enters the score in the Add Score dialog box that’s displayed.
To update a score, the user selects the score, clicks the Update button, and changes the score in the Update Score dialog box that’s displayed.
To remove a score from the Scores list box, the user selects the score and clicks the Remove button.
To remove all scores from the Scores list box, the user clicks the Clear Scores button.
To accept all changes, the user clicks the OK button.
To cancel the update operation, the user clicks the Cancel button.
Specifications
This application should make sure that the user enters a name for a new student. However, a new student can be added without any scores.
This application should check all scores entered by the user to make sure that each score is a valid integer from 0 to 100.
When the application starts, it should load the list box with three sample students.
Hint
To get the labels that display the area and perimeter to look like the ones shown above, you’ll need to set the AutoSize property of the labels to False and the BorderStyle property to Fixed3D.S