Question
Use C# slove the project Constructor Logic 1. Constructor with only the ID as a parameter. 1.1. The constructor should assign the ID received as
Use C# slove the project
Constructor Logic 1. Constructor with only the ID as a parameter. 1.1. The constructor should assign the ID received as a parameter to the instance variable representing ID within the class. You can technically use both the instance variable and the instance property to store the variable using the variable gives you direct access to the variable while using the property takes you through the same checks and balances as anybody using the property from outside the class.
1.2. Increment the student count by 1.
1.3. Write to the console that a new student with xxx ID has been created.
1.4. Also, print the total number of students to the console.
2. Constructor with ID and name as parameters.
2.1. The constructor will assign the ID and name to the instance variables (similar to part 1).
2.2. Increment the student count by 1.
2.3. Print to the Console that a new student with xxx name and ID has been created.
2.4. Also, print the total number of students to the Console.
StudentSystem Class
Rename your existing Program.cs class to StudentSystem.cs
StudentSystem
- studentRoster: Student[]
+ Main(args: string[])
- LoadStudents(): void
3. LoadStudents Method
3.1. Allocate 10 elements to the studentRoster array.
3.2. Declare a boolean variable, continueLoop and initialize it to false.
3.3. Declare local variables for storing name and ID. Name them appropriately.
3.4. Create a do-while loop, and keep looping while continueLoop is true. Within the dowhile loop,
3.4.1. Set continueLoop to false. We are assuming that the user does not want to enter any more students. 3.4.2. Ask the user for the name and ID of a new student. Store them in the appropriate variables you created.
3.4.3. Instantiate a new Student call the constructor and pass it the necessary arguments. Store the reference to the newly created Student in a variable called tmpStudent (youll need to declare it as a local variable).
3.4.4. Store the tmpStudent reference in the studentRoster array. Use the StudentCount property minus one (i.e. StudentCount - 1) from the Student class as the index location. Check if the property is static or instance. That will determine how you access the property. The reason we put in (StudentCount -1) is to account for the Constructor increasing the Count to 1. Since the first Student should go into index 0, we subtract 1 from the Student.
3.4.5. Ask if the user would like to create another student. Read input and store it in a sring.
3.4.6. Using an if statement, test to see if the user entered a Y. Instead of manually converting to upper case and comparing using an equal sign, use the Equals method of the string class as follows. The method utilizes a constant to specify if the comparison should be case sensitive or case insensitive. If the method returns true, assign true to continueLoop. We are allowing the user to change our assumption of no more students.
3.5. Loop through all the students in the studentRoster array and print out a list of students. Remember to use the count variable from the Student class. This should be outside of the while loop. Main Method
4. Call the LoadStudents method.
Show transcribed image text
Student Class Student - studentCount: int name:string - id: string +Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started