Student Club App

In my C# class the final project is

This application allows you to manage the members of a student club. By selecting different menu options, you can add, delete, edit, and list the students in the club.

The program returns to the main menu after each operation until the user selects to Exit the application.

The main menu should look like this:

The main menu should look like this: 

Student Club Management
1. Add Student
2. Delete Student
3. Edit Student
4. List Students
5. Exit

Select an option:

List Students

Print a numbered list of all students in the club, similar to the following:

Select an option: 4
1. Stacy Read | [email protected]
2. Brittney Schultz | [email protected]
3. Matt Green | [email protected]

Add Student

To add a student, prompt the user to enter their first name, last name, and email. The student will be added to the club.

Select an option: 1
Enter first name: Davante
Enter last name: Adams
Enter email: [email protected]
Student added successfully

Delete Student

Print a menu of all students in the club (similar to List Students). Prompt the user to enter the number of the student to delete. The student will be removed from the club.

Select an option: 2
1. Stacy Read | [email protected]
2. Brittney Schultz | [email protected]
3. Matt Green | [email protected]
4. Davante Adams | [email protected]

Enter # to delete: 1
Student deleted successfully

Edit Student

Print a menu of all students in the club (similar to List Students). Prompt the user to enter the number of the student to edit. Allow the user to update the first name, last name, and email of the selected student.

Select an option: 3
1. Brittney Schultz | [email protected]
2. Matt Green | [email protected]
3. Davante Adams | [email protected]

Enter # to edit: 2
Enter new first name: Matthew
Enter new last name: Blue
Enter new email: [email protected]
Student edited successfully

Which I accomplish this Some code (not finished);

using System;
using System.IO;
using System.Collections.Generic;
using NLog;
using NLog.Web;

namespace SudentClubApp
{
class Program
{
private string fileName = "students.csv";
private List<Student> students;
private NLog.Logger logger = NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();


public Program()
{
this.students = new List<Student>();
}

public Program(List<Student> students = null)
{
this.students = students;
}

public List<Student> Students
{
get => students;
set => students = value;
}

public void DefaultPopulate()
{
this.students = new List<Student>();
this.students.Add(new Student("Andy", "Gunn", "[email protected]"));
this.students.Add(new Student("Boby", "Gunn", "[email protected]"));
this.students.Add(new Student("Bobdsdy", "Gfsdfunn", "@gmail.com"));
this.students.Add(new Student("gsadgs", "Gundsn", "gmail.com"));

try
{
StreamWriter writer = new StreamWriter(this.fileName, true);

foreach (Student s in this.students)
{
Student.QueueId++;
writer.WriteLine($"{Student.QueueId} {s.FirstName} {s.LastName}, {s.Email}");
}

writer.Close();
}
catch (Exception e)
{
Console.WriteLine(e);
this.logger.Error(e);
throw;
}
}

public void StudentsList()
{
int id = 0;

try
{
if (this.Students.Count > 0)
{
foreach (Student s in this.Students)
{
id++;
Console.WriteLine($"{id}. | " +
$"{s.Id} -- " +
$"{s.FirstName} " +
$"{s.LastName} | " +
$"{s.Email}");
}
}
}
catch (Exception e)
{
Console.WriteLine(e);
this.logger.Error(e.Message);
//throw;
}
}

public void HomeList()
{
Console.WriteLine($"Student Club Management");
Console.WriteLine($"1. Add Student");
Console.WriteLine($"2. Delete Student");
Console.WriteLine($"3. Edit Student");
Console.WriteLine($"4. List Students");
Console.WriteLine($"5. Exit");
}

static void Main(string[] args)
{
Program p = new Program();
//p.logger.Error("error");

p.DefaultPopulate();
p.StudentsList();
}
}
}
using System;

namespace SudentClubApp
{
public class Student
{
private int id;
private string firstName;
private string lastName;
private string email;
private static int queueId;

public Student(string firstName = null, string lastName = null, string email = null)
{
Student.queueId++;
this.id = Student.queueId;
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
}

public Student(int id = default, string firstName = null, string lastName = null, string email = null)
{
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
}

// public Student(string firstName = null, string lastName = null, string email = null)
// {
// Student.queueId = 0;
//
//
// }

public int Id
{
get => id;
set => id = value;
}

public static int QueueId
{
get => queueId;
set => queueId = value;
}

public string FirstName
{
get => firstName;
set => firstName = value;
}

public string LastName
{
get => lastName;
set => lastName = value;
}

public string Email
{
get => email;
set => email = value;
}

public string Print()
{
return $"{FirstName} {LastName} | {Email}";
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using NLog;
using NLog.Web;

namespace SudentClubApp
{
public class File
{
private string filePath;
private Logger logger;
private StreamReader reader;
private List<Student> students;
private StreamWriter writer;

public File(List<Student> students = null, Logger logger = null, StreamReader reader = null,
StreamWriter writer = null)
{
this.students = students;
this.logger = NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
;
this.reader = reader;
this.writer = writer;
}

public File()
{
this.filePath = "student.csv";
this.logger = NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
}

public File(string filePath = null)
{
this.filePath = filePath;
this.logger = NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
// this.Reader = new StreamReader(this.filePath);
}

public List<Student> Students
{
get => students;
set => students = value;
}

public Logger Logger
{
get => logger;
set => logger = value;
}

public StreamReader Reader
{
get => reader;
set => reader = value;
}

public StreamWriter Writer
{
get => writer;
set => writer = value;
}

public void HandleFile()
{
//students = new List<Student>();

// try
// {
// this.Reader = new StreamReader(this.filePath);
// this.Reader.ReadLine();
//
// while (!this.Reader.EndOfStream)
// {
// Student student = new Student();
// string line = this.Reader.ReadLine();
// int index = line.IndexOf('"');
// if (index == -1)
// {
// string[] movieData = line.Split(',');
// student.MovieID = Int32.Parse(movieData[0]);
// movie.Title = movieData[1];
// movie.Genres = movieData[2].Split('|').ToList();
// }
// else
// {
// movie.MovieID = Int32.Parse(line.Substring(0, index - 1));
// line = line.Substring(index + 1);
// index = line.IndexOf('"');
// movie.Title = line.Substring(0, index);
// line = line.Substring(index + 2);
// movie.Genres = line.Split('|').ToList();
// }
//
// movies.Add(movie);
// }
// }
// catch (Exception e)
// {
// Console.WriteLine(e);
// this.logger.Error(e.Message);
// throw;
// }
}
}
}

Next post →

3 Comments

  1. Hi, this is a comment.
    To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.
    Commenter avatars come from Gravatar.

  2. Hi Andrew,
    Your WordPress plugin https://wordpress.org/plugins/woo-out-of-stock-products/ has awesome feature that I’m looking for. Specifically, I’m looking to add a PNG frame to cover selected Woo products, maybe a category, or a tag, such as a “on sale” tag. Or add different frames to different categories and/or tags.
    Is that possible please ?
    Thanks.

    Best regards,
    Thomas

    • Hello Thomas,

      After a some time spent away from developing I am back finishing my degree in Computer Science. This means I am re-dedicating myself to supporting my plugins and I will be in contact because I will work with you add support of what you need, give me a week or two to get back into the swing of things.

      I created a post for this plugin located here: https://andrewgunn.org/woo-out-of-stock-products/

      Check back on this post later this week or you can email me at: [email protected]

      Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *