Exercises

Exercise 13-1

Define an interface IConvertible that indicates that the class can convert a string to C# or VB2005. The interface should have two methods: ConvertToCSharp and ConvertToVB2005. Each method should take a string, and return a string.

Exercise 13-2

Implement that interface and test it by creating a class ProgramHelper that implements IConvertible. You can use simple string messages to simulate the conversion.

Exercise 13-3

Extend the interface by creating a new interface, ICodeChecker. The new interface should implement one new method, CodeCheckSyntax, which takes two strings: the string to check, and the language to use. The method should return a bool. Revise the ProgramHelper class from Exercise 13-2 to use the new interface.

Exercise 13-4

Demonstrate the use of is and as. Create a new class, ProgramConverter, that implements IConvertible. ProgramConverter should implement the ConvertToC-Sharp( ) and ConvertToVB( ) methods. Revise ProgramHelper so that it derives from ProgramConverter, and implements ICodeChecker.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset