C# – A simple interface with 3 classes in C#

In the current article, I will show how to resolve with VBA an entry exam for programming in HackBulgaria. The problems could be resolved in any language and I will use VBA for this last task. The program is actually the development of a cipher, thus it takes string as input and codes it as per the cipher. This is how the task looks like:

Make an interface, called MyLogger with only 1 method – log(level, message)

The two arguments should be:

  • level – an integer, from 1 to 3.
  • 1 means that you are logging with INFO level.
  • 2 means that you are logging with WARNING level.
  • 3 means that you are logging with PLSCHECKFFS level.
  • message is a string, that you are logging.

Make 3 different classes, that implement the interface MyLogger:

ConsoleLogger

The ConsoleLogger should log the messages directly to the console.

FileLogger

The FileLogger should log the messages to a given file.

HTTPLogger

The HTTPLogger shoud log the messages via a POST request to a given HTTP url.


 What I did?

Something like this:

3 Classes, 1 interface with the method log, and one method called GenerateString in the class ConsoleLogger. Probably its place was not there, but it worked. Anyway, here comes the code:

Enjoy it! 🙂

Tagged with: , , ,