Plugin code for the lesson.

<?php
/*
Plugin Name: Widget Demo
Plugin URI: http://agilesolutionspk.com/training
Description: It shows use of Widget
Version: 1.0
Author URI:
*/

class My_Widget_Test extends WP_Widget {

	/**
	 * Sets up the widgets name etc
	 */
	public function __construct() {
		// widget actual processes
		parent::__construct(
			'my-widget-test', // Base ID
			__( 'Test Widget', 'text_domain' ), // Name
			array( 'description' => __( 'A test widget', 'text_domain' ), ) // Args
		);
	}

	/**
	 * Outputs the content of the widget
	 *
	 * @param array $args
	 * @param array $instance
	 */
	public function widget( $args, $instance ) {
		// outputs the content of the widget
		echo "Hello World, This is my First Widget";
	}

	/**
	 * Outputs the options form on admin
	 *
	 * @param array $instance The widget options
	 */
	public function form( $instance ) {
		// outputs the options form on admin
	}

	/**
	 * Processing widget options on save
	 *
	 * @param array $new_instance The new options
	 * @param array $old_instance The previous options
	 */
	public function update( $new_instance, $old_instance ) {
		// processes widget options to be saved
	}
}

add_action( 'widgets_init', function(){
     register_widget( 'My_Widget_Test' );
});