Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSC3 Rocks
33,474 PointsThrowing Exceptions Exercise
Hi, I a dyslexic who is completely new to C#, and I honestly don't understand what I'm expected to do here or even how I'm supposed to do it - I would appreciate someone breaking down for me further what and how I'm supposed to do this exercise or maybe provide some kind of one-on-one Tutoring links that I could use - Thank you...
SC3 Rocks
33,474 PointsSorry, here's the link to the exercise I'm working on: https://teamtreehouse.com/library/c-objects/inheritance/throwing-exceptions-2
1 Answer
Katrin Nitsche
23,462 PointsYou have to do 2 things.
- You check if the value is between 0 and 20.
- If the value is is less than 0 or above 20 than throw an exception, because those values are not correct.
Exceptions are used to tell if something is going wrong. This can happen automatically, e.g. a file doesn't exists and you want to read it or in cases when the programmer decides something is wrong, e.g. a variable has the wrong value or an input is missing.
In the case of the exercise you need this. I usually write pseudo code
// check if the value is below 0 or above 20
if (.. C# code to check "value" variable ...) {
// then ... throw an exception with the text "The value is outside of the range. 0 to 20."
... C# code to throw a generic exception with a message text ...
}
You need to break down your task in little steps and first try to write you "code" in English. Than you can fill the gabs with C# code. I hope this helps.
SC3 Rocks
33,474 PointsI'll try it - Not sure if I fully understand, but I'll try - Thank you, Katrin...
Amil
Steven Parker
231,198 PointsSteven Parker
231,198 PointsIt would be most helpful if you supply a link to the course page you are asking about.
The only "one-on-one Tutoring" available that I am aware of is the mentoring part of the Techdegree programs.