C# Write a two class solution that includes data members for the name of the cou
ID: 3678662 • Letter: C
Question
C#
Write a two class solution that includes data members for the name of the course, current enrollment, and maximum enrollment. Include an instance method that returns the number of students that can still enroll in the course. The ToString( ) method should return the name of the course, current enrollment, and the number of open slots. Declare an array of class objects in your implementation class. Test your application with the following data:
Class name Current enrollment Maximum enrollment
cs150 180 200
cs250 21 30
cs270 9 20
cs300 4 20
cs350 20 20
it has to be a console aplication
Your program should gather information in the driver class for each specific course, including all of the data members mentioned, then create an object for the course as an element of an object array. You may ask the user how many courses they will be entering.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
}
}
}
sing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Class1
{
public Class1()
{
}
public int Property
{
get
{
}
set
{
}
}
}
}
Explanation / Answer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var w = new Class1();
var r = new Enroll();
while (!r.finish)
{
w.enabled = true;
string k = Console.ReadKey(false).KeyChar.ToString();
w.enabled = false;
string line = k + Console.ReadLine();
r.Read(line);
}
}
}
class Class1
{
public bool enabled = true;
public Class1()
{
var timer = new System.Timers.Timer(1000);
timer.Elapsed += (a, b) =>
{
if(enabled)
Console.WriteLine("Test");
};
timer.Start();
}
}
class Enroll
{
public bool finish = false;
public void Read(string line)
{
if (line == "stop")
{
finish = true;
}
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.