Final Exam for Beginner Course

Task 3

Please define a public class named Question. This class should be abstract as it will be inherited by other classes. The Question class should have an automatic public property called Label which should be a string. The Label property must have both a getter and a setter.

The Question class should define a protected method named CreateAnswer that has a single string parameter. This method should be abstract so should not have an implementation within this class. The method must return an instance of Answer. The input parameter must be named input and represents the user's response from the question.

The Question class should define a protected method named PrintQuestion that by default will write Label property value to the Console using WriteLine. It must be possible to override this method in any inherited classes.

The Question class should also define a public method named Ask which will first print the question. It will then collect the next line from Console using ReadLine and create an answer by returning the value of the CreateAnswer method, using the collected input.

The answer must then be returned as the return value of the Ask method.

Page 5 of 10