The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
using index to complete project
When you run the program, the console code will ask that you enter a student ID number.
The values that will return a valid student are 1234, 2468, 3690 and 4444. Any other number will return
a “no such” student. Look over all the existing code until you understand it.
The missing step is to implement the get functionality for this indexer.
The code asks the user to enter an SID, and then it uses the get part of the indexer to return a Student
object which has an SID property that matches. It then uses the returned object to write out the
student’s first and last name.
the get code for the indexer is not there, you need to implement it so that the code works.
write that code back in the Course class; you need to implement a get { } that uses the passed in SID
from the user, find the matching student object in the List, and then return that Student object. IN my
version, if I don’t count lines that are a { or a }, it takes about 4 lines of real code to do this.
However, there is one more thing the indexer get should do. If it gets an SID index that does not match
any Student object’s SID property, then create a new Student object, set the first name to “no”, and the
last name to “such” and the SID to 0, and return that student. Please look at the picture below of a
sample run.
Attachments: