Friday, 17 January 2014

Java Method Overriding

Refer this link and make some changes in the existing file Encapsulation and Subclasses In Java (Employee Project)

/*Program for Overriding 
* Change the codes from EmployeeTest.java file and Make other package say "com.example.business" in the same folder.
* In the package com.example.business add the Class "EmployeeStockPlan"
*/
/*EmployeeTest.java Code*/
package com.example;
/*@author Aqib */
import com.example.business.EmployeeStockPlan;//importing the package in this file
import com.example.domain.Admin;
import com.example.domain.Director;
import com.example.domain.Employee;
import com.example.domain.Engineers;
import com.example.domain.Manager;
public class EmployeeTest {
    private int eid;
    private String ename;
    private String essn;
    private double esalary;

    public void setEid(int eid) {
        this.eid = eid;
    } 

    public void setEname(String ename) {
        this.ename = ename;
    }   

    public void setEssn(String essn) {
        this.essn = essn;
    }   

    public void setEsalary(double esalary) {
        this.esalary = esalary;
    }
    
    public static void printEmployee(Employee eobj){
        System.out.println("--Employee constructor is called--");
        System.out.println(eobj);
    }
    
    public static void printEmployee(Employee eobj, EmployeeStockPlan esp){
        printEmployee(eobj);/*Replaced codes*/
        System.out.println("Employee Stock: " + esp.grantStock(eobj));
    }
    
    public static void printEmployee(Manager mobj){
        System.out.println("--Manager constructor is called--");
        System.out.println("Employee Id is " + mobj.getEid());
        System.out.println("Employee Name is " + mobj.getEname());
        System.out.println("Emploee SSN number is " + mobj.getEssn());
        System.out.println("Employee Salary is " + mobj.getEsalary());
        System.out.println("Employee Department Name is " + mobj.getDeptName());
    }
    
     public static void printEmployee(Admin aobj){
        System.out.println("--Admin constructor is called--");
         System.out.println("Employee Type : " + aobj.getClass().getSimpleName());//to get the name of the class
        System.out.println("Employee Id is " + aobj.getEid());
        System.out.println("Employee Name is " + aobj.getEname());
        System.out.println("Emploee SSN number is " + aobj.getEssn());
        System.out.println("Employee Salary is " + aobj.getEsalary());
    }
     
      public static void printEmployee(Director dobj){
        System.out.println("--Director constructor is called--");
        System.out.println("Employee Id is " + dobj.getEid());
        System.out.println("Employee Name is " + dobj.getEname());
        System.out.println("Emploee SSN number is " + dobj.getEssn());
        System.out.println("Employee Salary is " + dobj.getEsalary());
    }
    public static void main(String[] args) {
        // TODO code application logic here
        Engineers eobj = new Engineers(101,"Aqib Ferhan","012-98-9898",120_345.98);
        Manager mobj = new Manager(120,"John","239-97-09090",130_89.65,"US Manager");
        Admin aobj = new Admin(139,"Sam Coles","439-09-8776",450_454.90);
        Director dobj = new Director(120,"John","239-97-09090",130_89.65,"US Manager");
        EmployeeStockPlan esp = new EmployeeStockPlan();
        printEmployee(eobj);
        printEmployee(mobj);
        printEmployee(aobj);
        printEmployee(dobj);
        printEmployee(eobj, esp);
    }
}

/*EmployeeStockPlan.java code in the package com.example.business*/
package com.example.business;

import com.example.domain.Director;
import com.example.domain.Employee;
import com.example.domain.Manager;

public class EmployeeStockPlan {
    private final int empshare=10;
    private final int mgrshare=100;
    private final int dirshare=1000;
    
    public int grantStock(Employee eobj){
        if(eobj instanceof Director){
            return dirshare;
        }else{
            if(eobj instanceof Manager){
                return mgrshare;
            }else{
                return empshare;
            }
        }
    }
}
/*Employee.java File */

package com.example.domain;
public class Employee {
private int eid;
private String ename,essn;
private double esalary;
    public int getEid() {
        return eid;
    }

    public String getEname() {
        return ename;
    }

    public void setEname(String ename) {
        this.ename = ename;
    }

    public String getEssn() {
        return essn;
    }
    public double getEsalary() {
        return esalary;
    }
//method is added here which is overriden in Manager.java Class
    public String toString(){
        return "Employee Id" + getEid() + "\n" + "Employee name:" + getEname() + "\n" + "Employee SSN" + getEssn() + "\n" 

+ "Employee salary" + getEsalary();
    }

    public Employee(int eid, String ename,String essn,double esalary) {
        this.eid=eid;
        this.ename=ename;
        this.essn=essn;
        this.esalary=esalary;
    }
    public void raiseSalary(double increase){
        esalary+=increase;
    }
}

/*Manager.java file*/
package com.example.domain;

public class Manager extends Employee {
    private String deptName;
    
    public Manager(int eid, String ename,String essn,double esalary,String deptName){
        super(eid,ename,essn,esalary);
        this.deptName=deptName;
    }
    @Override
    public String toString(){
        return super.toString() + "Department Name" + getDeptName();
    }

    public String getDeptName() {
        return deptName;
    }
}
Output is changed at red underlines

Java Working with Method Overloading and User Input

/*Program of Method Overloading with User Input */
package newproject;

import java.util.Scanner;
/*@author Aqib */
public class MethodOverload {
    private int num1,num2;
    private float num3;
    private float result;
    Scanner ipobj = new Scanner(System.in);
    
    public void Area(int num1){
        System.out.println("Enter the Side of Square");
        num1=ipobj.nextInt();
        result=num1*num1;
        System.out.println("Area of Square is (Side * Side) " + (int)result);
    }
    public void Area(int num1,int num2){
        System.out.println("Enter Length of Rectangle");
        num1=ipobj.nextInt();
        System.out.println("Enter the Breadth of Rectangle");
        num2=ipobj.nextInt();
        result=(num1*num2);
        System.out.println("Area of rectangle is (Length * Breadth ) " + (int)result);
    }
    public void Area(int num1,float num3){
        float HALF;
        HALF = 0.5f;
        System.out.println("Enter Base of Triangle");
        num1=ipobj.nextInt();
        System.out.println("Enter the Heigth of Triangle");
        num3=ipobj.nextFloat();
        result=HALF*(num1*num3);
        System.out.println("Area of Triangle is (1/2(base * Height))" + result);
    }
    
    
   
    public static void main(String[] args) {
        MethodOverload obj = new MethodOverload();
        obj.Area(12, 13);
        obj.Area(12);
        obj.Area(3, 3.5f);
    }
}

Thursday, 16 January 2014

Java Working with Subclass and Encapsulation

/*Program of Encapsulation and Subclass 
* EmployeeTest.java (Main Class)
* package used com.example and com.example.domain
*/

package com.example;
/*@author Aqib*/
import com.example.domain.Admin;
import com.example.domain.Director;
import com.example.domain.Employee;
import com.example.domain.Engineers;
import com.example.domain.Manager;
public class EmployeeTest {
    private int eid;
    private String ename;
    private String essn;
    private double esalary;

    /**
     * @param args the command line arguments
     */
    public void setEid(int eid) {
        this.eid = eid;
    } 

    public void setEname(String ename) {
        this.ename = ename;
    }   

    public void setEssn(String essn) {
        this.essn = essn;
    }   

    public void setEsalary(double esalary) {
        this.esalary = esalary;
    }
    
    public static void printEmployee(Employee eobj){
        System.out.println("--Employee constructor is called--");
        System.out.println("Employee Id is " + eobj.getEid());
        System.out.println("Employee Name is " + eobj.getEname());
        System.out.println("Emploee SSN number is " + eobj.getEssn());
        System.out.println("Employee Salary is " + eobj.getEsalary());
    }
    
    public static void printEmployee(Manager mobj){
        System.out.println("--Manager constructor is called--");
        System.out.println("Employee Id is " + mobj.getEid());
        System.out.println("Employee Name is " + mobj.getEname());
        System.out.println("Emploee SSN number is " + mobj.getEssn());
        System.out.println("Employee Salary is " + mobj.getEsalary());
        System.out.println("Employee Department Name is " + mobj.getDeptName());
    }
    
     public static void printEmployee(Admin aobj){
        System.out.println("--Admin constructor is called--");
        System.out.println("Employee Id is " + aobj.getEid());
        System.out.println("Employee Name is " + aobj.getEname());
        System.out.println("Emploee SSN number is " + aobj.getEssn());
        System.out.println("Employee Salary is " + aobj.getEsalary());
    }
     
      public static void printEmployee(Director dobj){
        System.out.println("--Director constructor is called--");
        System.out.println("Employee Id is " + dobj.getEid());
        System.out.println("Employee Name is " + dobj.getEname());
        System.out.println("Emploee SSN number is " + dobj.getEssn());
        System.out.println("Employee Salary is " + dobj.getEsalary());
    }
    public static void main(String[] args) {
        // TODO code application logic here
        Engineers eobj = new Engineers(101,"Aqib Ferhan","012-98-9898",120_345.98);
        Manager mobj = new Manager(120,"John","239-97-09090",130_89.65,"US Manager");
        Admin aobj = new Admin(139,"Sam Coles","439-09-8776",450_454.90);
        Director dobj = new Director(120,"John","239-97-09090",130_89.65,"US Manager");
        printEmployee(eobj);
        printEmployee(mobj);
        printEmployee(aobj);
        printEmployee(dobj);
    }
}

/*Employee.java File*/

package com.example.domain;

public class Employee {
private int eid;
private String ename,essn;
private double esalary;
    public int getEid() {
        return eid;
    }

    public String getEname() {
        return ename;
    }

    public void setEname(String ename) {
        this.ename = ename;
    }

    public String getEssn() {
        return essn;
    }
    public double getEsalary() {
        return esalary;
    }

    public Employee(int eid, String ename,String essn,double esalary) {
        this.eid=eid;
        this.ename=ename;
        this.essn=essn;
        this.esalary=esalary;
    }
    public void raiseSalary(double increase){
        esalary+=increase;
    }
}

/*Manager.java inherited from Employee*/
package com.example.domain;

public class Manager extends Employee {
    private String deptName;
    
    public Manager(int eid, String ename,String essn,double esalary,String deptName){
        super(eid,ename,essn,esalary);
        this.deptName=deptName;
    }

    public String getDeptName() {
        return deptName;
    }
}

/*Engineers.java inherited from Employee Class*/
package com.example.domain;

public class Engineers extends Employee {
    public Engineers(int eid, String ename,String essn,double esalary){
        super(eid,ename,essn,esalary);
    }
}

/*Admin.java inherited from Employee*/
package com.example.domain;

public class Admin extends Employee {
    public Admin(int eid, String ename,String essn,double esalary){
        super(eid,ename,essn,esalary);
    }
}

/*Director.java inherited from Manager*/
package com.example.domain;

public class Director extends Manager {
    private double budget;
    
    public Director(int eid, String ename,String essn,double esalary,String deptName){
        super(eid,ename,essn,esalary,deptName);
        this.budget=120_09.89;
    }

    public double getBudget() {
        return budget;
    }
}



Java Creating Classes and Package

/*Creating Java Class and Using getter/setter method..
Save the file with EmployeeTest.java in the package "com.example" and also make another package with name 

"com.example.domain See below to have the Employee.java file"
 */
package com.example;
/**
 *
 * @author Aqib
 */
import com.example.domain.Employee;
public class EmployeeTest {
    private int eid;
    private String ename;
    private String essn;
    private double esalary;

    
    public void setEid(int eid) {
        this.eid = eid;
    } 

    public void setEname(String ename) {
        this.ename = ename;
    }   

    public void setEssn(String essn) {
        this.essn = essn;
    }   

    public void setEsalary(double esalary) {
        this.esalary = esalary;
    }
    public static void main(String[] args) {
        // TODO code application logic here
        Employee eobj = new Employee();
        eobj.setEid(101);
        eobj.setEname("Aqib");
        eobj.setEssn("120-099-877");
        eobj.setEsalary(120_345.87);
        System.out.println("Employee Id is " + eobj.getEid());
        System.out.println("Employee Name is " + eobj.getEname());
        System.out.println("Emploee SSN number is " + eobj.getEssn());
        System.out.println("Employee Salary is " + eobj.getEsalary());
    }
}


/*Employee.java file*/

package com.example.domain;

public class Employee {
public int eid;
public String ename,essn;
public double esalary;
    public int getEid() {
        return eid;
    }

    public void setEid(int eid) {
        this.eid = eid;
    }

    public String getEname() {
        return ename;
    }

    public void setEname(String ename) {
        this.ename = ename;
    }

    public String getEssn() {
        return essn;
    }

    public void setEssn(String essn) {
        this.essn = essn;
    }

    public double getEsalary() {
        return esalary;
    }

    public void setEsalary(double esalary) {
        this.esalary = esalary;
    }

    public Employee() {
    }

    public static void main(String[] args) {
    
}
}

Thursday, 19 December 2013

Play Hangman Game In C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace hangman
{
    public class Hangman
    {
        string randomString, userString;
        int dataLength;
        string Category;
        string[] bookData = new string[5];
        string[] movieData = new string[5];
        int bookCount = 0, movieCount = 0;
        public Hangman()
        {
            FillNameValues();
        }
        private void FillNameValues()
        {
            string firstLine;
            StreamReader sRead =new StreamReader("d:\\aqib\\Texttest.txt");
            sRead.BaseStream.Seek (0,SeekOrigin.Begin);
            firstLine = sRead.ReadLine();
            while(firstLine != null)
            {
                if (firstLine.Substring (0,1) =="B")
                {
                    int stringStratPos=firstLine.IndexOf(':');
                    bookData[bookCount] = firstLine.Substring(stringStratPos+ 1);
                    bookCount++;
                }
                else
                {
                    int stringStartPos=firstLine.IndexOf(':');
                    movieData[movieCount]=firstLine.Substring(stringStartPos+1);
                    movieCount++;
                }
                firstLine=sRead.ReadLine();

           


    }
}
 public int AcceptCategory()
 {
     Console.WriteLine("enter the category to play-book/movie");
     Category = Console.ReadLine();
     Category=Category.ToUpper();
     if (Category!="BOOK" && Category!="MOVIE")
     {
         Console.WriteLine("Invalid category.......\n");
         return 0;
     }
     else
     {
         ExtractName();
         return 1;
     }
 }
        public void ExtractName()
        {
             Random RandGen=new Random();
            if (Category=="BOOK")
            {
             
                int Rnd=RandGen.Next(0,bookCount-1);
                randomString=bookData[Rnd];
            }
        }
        public void StartGame()
        {
            dataLength=randomString.Length;
            char locatechar;
            int correctCnt=0,inCorrectCnt=0;
        int i,k;
        char [] s=new char[randomString.Length];
        InitializeUserString();
        showUserInputString();
        if (Category=="BOOK")
    {
        Console.WriteLine("the total number of characters in the Book:{0}",randomString.Length);
        Console.WriteLine("the total number of characters you can enter to guess the name of Book: {0}",randomString.Length+2);
    }
    else
{
    Console.WriteLine("the total number of characters in the Movie:{0}",randomString.Length);
     Console.WriteLine("the total number of characters you can enter to guess the name of Movie:{0}",randomString.Length+2);

}
    for (i =1,k=0;i<=dataLength+2||k==dataLength;i++)
{
 if (correctCnt == dataLength || inCorrectCnt ==dataLength)
    break;
    Console.WriteLine("Enter the char ");
    locatechar = Convert.ToChar(Console.ReadLine().ToLower());
    int foundPos=0;
    int foundChar=0;
        foreach (char c in randomString)
        {
    if (c== locatechar)
{
    UpdateString (foundPos,locatechar.ToString());
    k++;
    foundChar=1;
}
    foundPos++;
}
    if (foundChar == 0)
{
    inCorrectCnt++;}
    else
{
    correctCnt++;
}
    showUserInputString();
    Console.WriteLine("Total Correct Attempts:{0}\t",correctCnt);
    Console.WriteLine("Total InCorrect Attempts:{0}\n", inCorrectCnt);
    if (k == dataLength)
    break;
}
if (randomString == userString)
{
Console.WriteLine("You have Won \n");
}
else{
Console.WriteLine("The Correct name is {0}",randomString);
Console.WriteLine("You have lost\n");
}
}
private void UpdateString (int fPos, string updateStr)
{
string beforeString, afterString;
if(fPos!=0&&fPos!=dataLength-1)
{
if (fPos==1)
beforeString=userString.Substring(0,1);
else
beforeString=userString.Substring(0,fPos);
afterString=userString.Substring(fPos+1,dataLength-(fPos));
userString=updateStr+afterString;
}
if (fPos==dataLength-1)
{
beforeString=userString.Substring(0,fPos);
userString=beforeString+updateStr;
}    
}
public void InitializeUserString()
{
userString="           ";
for (int i=0;i<dataLength;i++)
{
userString=userString.Insert(i,"*");
}
}
public void showUserInputString()
{
Console.WriteLine("input value:{0}\n\n\n",userString);
}
    }
    class Game
{
static void Main (string[]args)
{
Console.Clear();
Hangman obj=new Hangman();
int returnVal=obj.AcceptCategory();
if (returnVal==1)
{
obj.StartGame();


Console.ReadLine();}
}
}
}

Thursday, 12 December 2013

Bouncing Ball


Bouncing Ball Codes

<!DOCTYPE HTML>
<HTML>
<HEAD>
<TITLE>Rotating Ball</TITLE>
</HEAD>
<BODY>
<DIV>
<CANVAS ID="canvas" width="400" height="300"> </CANVAS>
</DIV>
<SCRIPT type="text/javascript">
var canvas;
var ctx;
var x = 400;
var y = 300;
var dx = 2;
var dy = 4;
var WIDTH = 400;
var HEIGHT = 300;
function circle()
{
ctx.beginPath();
ctx.fillStyle="red";
ctx.arc(x, y, 10, 0, Math.PI*2, true);
ctx.fill();
ctx.closePath();
}
function clear()
{
ctx.clearRect(0, 0, WIDTH, HEIGHT);
}
function init()
{
canvas = document.getElementById("canvas");
ctx = canvas.getContext("2d");
return setInterval(draw, 10);
}
function draw()
{
clear();
circle();
if (x > WIDTH || x < 0)
dx = -dx;
if (y > HEIGHT || y < 0)
dy = -dy;
x += dx;
y += dy;
}
init();
</SCRIPT>
</BODY>
</HTML>

HTML: Forms, Validation, Image Gallery

Code for the homepage
<html>
<head>
<title>Home</title>
<link rel="stylesheet" type="text/css" href="style.css" media="all"/>

<script src="scripts/jquery-1.9.1.min.js"></script>
<script>
 $(document).ready(function(){
  $("#reg_show").click(function(){
    $("#sign_up").slideToggle("slow");
  });
});

function open_fp()
{
window.open("forgotpass.html","_blank","toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=550, height=180");
}
</script>

</head>
<body>
<div id="container">
<h1>Safari Tour</h1>
<hr/>
<ul>
    <li><a href="index.html">Home</a></li>
    <li><a href="gallery.html">Gallery</a></li>
    <li><a href="">About Us</a></li>
    <li><a href="contactus.html">Contact Us</a></li>
<li><a href="register.html" title="For New User">Register</a></li>
</ul>
<hr/>
<form name="SignIn" id="signin" action="login.html" method="get">
<h2>Sign In  </h2>
<img src="images/user.png" width="100" height="100" id="user_logo"/>
<table>
<tr>
<td><label for="Email">Email ID</label></td>
<td><input type="email" name="Email_SignIn" placeholder="someone@example.com" size="30" required/></td>
</tr>
<tr>
<td><label for="PassWord">Password</label></td>
<td><input type="password" name="Password_SignIn" placeholder="Password" size="30" required/></td>
<tr>
<td></td>
<td><a href="" onclick="open_fp()">Forgot Password?</a></td>
</tr>
</tr>
<tr>
<td><input type="reset" value="Reset"/></td>
<td><input type="submit" value="Sign In"/></td>
</tr>
<tr><td colspan="2"><label for="NewUser">New User!!<label><a href="register.html"> Register Here!!</a></td></tr>
</table>
</form>
</div>
</body>
</html>


2. Log In page Code 
<html>
<head>
<title>Welcome New Guy</title>
<link rel="stylesheet" type="text/css" href="style.css" media="all"/>

<script src="scripts/jquery-1.9.1.min.js"></script>
<script>
$(document).ready(function(){
  $("#flip").click(function(){
   $("#offers").slideToggle("slow");
  });
});

function showd(){
var fname = document.getElementById("car1").value;
alert("You have selected "+ fname + "for your Ride \n GOOD LUCK!!");
}
</script>

</head>
<body>
<div id="container">
<h1>Safari Tour</h1>
<hr/>
<ul>
    <li><a href="index.html">Home</a></li>
    <li><a href="gallery.html">Gallery</a></li>
    <li><a href="">About Us</a></li>
    <li><a href="contactus.html">Contact Us</a></li>
<li><a href="register.html" title="For New User">Register</a></li>
</ul>
<hr/>
<div id="container">
<p>Visit Our Exciting offer for new Customers.<div id="flip"><a href="#" id=>OFFERS</a>
<div id="offers">
Get a free ride on booking of 3person for a week.<a href="">Grab It!!</a><br/><br/><br/>
Get a 50% ride on booking of 2person for a week.<a href="">Grab It!!</a>
</div>
</p></div>
<form name="carform" onsubmit="showd();">
Book your Ride
<select id="car1">
<option value="New">Select Car</option>
<optgroup label="Audi">
<option value="A4">A4</option>
<option value="A8">A8</option>
<option value="R8">R8</option>
</optgroup>
<optgroup label="Maruti">
<option value="Maruti 800">800</option>
<option value="VAN">VAN</option>
<option value="SX4">SX4</option>
</optgroup>
</select>
<input type="submit" value="Book"/>
</form>
</div>
</body>

</html>


3. Register Page Code
<html>
<head>
<title>Register</title>
<link rel="stylesheet" type="text/css" href="style.css" media="all"/>

<script src="scripts/jquery-1.9.1.min.js"></script>
<script>
function validate()
{
if(document.SignUp.tnc.checked==false)
{
alert("Please Agree the Terms and Conditions");
return false
}
else
return true
}
</script>

</head>
<body>
<div id="container">
<h1>Safari Tour</h1>
<hr/>
<ul>
    <li><a href="index.html">Home</a></li>
    <li><a href="gallery.html">Gallery</a></li>
    <li><a href="">About Us</a></li>
    <li><a href="contactus.html">Contact Us</a></li>
<li><a href="register.html" title="For New User">Register</a></li>
</ul>
<hr/>
<div id="sign_up">
<h2>New User!! Register Here...</h2>
<form name="SignUp" action="new_welcome.html" method="get" id="signup" onsubmit="return validate();">
<table>
<tr>
<td><label for="Name">Enter your Name</label></td>
<td><input type="text" name="FullName" placeholder="Eg: Alan Blen" size="30" required/></td>
</tr>
<tr>
<td><label for="Email">Enter your Email</label></td>
<td><input type="email" name="Email" placeholder="Eg: someone@example.com" size="30" required/></td>
</tr>
<tr>
<td><label for="PassWord">Enter Password</label></td>
<td><input type="password" name="Password" placeholder="Password" size="30" required/></td>
</tr>
<tr>
<td><label for="ConfirmPassWord">Confirm Password</label></td>
<td><input type="password" name="ConfirmPassword" placeholder="Confirm Password" size="30" required/></td>
</tr>
<tr>
<td><label for="Gender">Select Gender</label></td>
<td><input type="radio" name="gender" value="Male"/><label for="optmale">Male</label>
<input type="radio" name="gender" value="Female"/><label for="optfemale">Female</label>
</td>
</tr>
<tr>
<td><label for="DOB">Date of Birth</label></td>
<td>
<select name="Year">
<option value="0">Month</option>
<option value="Jan">January</option>
<option value="Feb">February</option>
<option value="Mar">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="Aug">August</option>
<option value="Sep">September</option>
<option value="Oct">October</option>
<option value="Nov">November</option>
<option value="Dec">December</option>
</select>
<input type="text" name="day" id="day" size="3" placeholder="Days">
<input type="text" name="Year" size="5" placeholder="Year"/>
</td>
</tr>
<tr>
<td colspan="2"><input type="checkbox" value="validation" name="tnc" id="tnc"/><label for="chk_tnc">I accept the Terms and Conditions</label></td>
</tr>
<tr>
<td><input type="submit" value="Sign Up"/></td>
<td><input type="reset" value="Reset"/></td>
</tr>
</table>
</form>
</div>
</body>

</html>


4. Gallery Page (showing slideshow)
<html>
<head>
<title>Gallery</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
<link rel="stylesheet" href="colorbox.css" media="screen"/>
<script src="scripts/jquery-1.9.1.min.js"></script>
<script src="scripts/jquery.colorbox.js"></script>
<script>
 $(document).ready(function(){
     $(".col").colorbox({rel:'col', slideshow:true, current:false, width:"800px", height:"500px", transition:"fade"});
});
</script>

</head>
<body>
<div id="container">
<h1>Safari Tour</h1>
<hr/>
<ul>
    <li><a href="index.html">Home</a></li>
    <li><a href="gallery.html">Gallery</a></li>
    <li><a href="">About Us</a></li>
    <li><a href="contactus.html">Contact Us</a></li>
<li><a href="register.html" title="For New User">Register</a></li>
</ul>
<hr/>
<p>Start your Virtual Tour</p>
<a class="col" href="images/1.jpg" rel="collection"><img src="images/1.jpg" height="100px" width="100px"/></a>
<a class="col" href="images/2.jpg" rel="collection"><img src="images/2.jpg" height="100px" width="100px"/></a>
<a class="col" href="images/3.jpg" rel="collection"><img src="images/3.jpg" height="100px" width="100px"/></a>
<a class="col" href="images/4.jpg" rel="collection"><img src="images/4.jpg" height="100px" width="100px"/></a>
<a class="col" href="images/5.jpg" rel="collection"><img src="images/5.jpg" height="100px" width="100px"/></a>
<a class="col" href="images/6.jpg" rel="collection"><img src="images/6.jpg" height="100px" width="100px"/></a>
<a class="col" href="images/7.jpg" rel="collection"><img src="images/7.jpg" height="100px" width="100px"/></a>
<a class="col" href="images/8.jpg" rel="collection"><img src="images/8.jpg" height="100px" width="100px"/></a>
<a class="col" href="images/9.jpg" rel="collection"><img src="images/9.jpg" height="100px" width="100px"/></a>
<a class="col" href="images/10.jpg" rel="collection"><img src="images/10.jpg" height="100px" width="100px"/></a>
<a class="col" href="images/safari.jpg" rel="collection"><img src="images/safari.jpg" height="100px" width="100px"/></a>
<a class="col" href="images/safari2.jpg" rel="collection"><img src="images/safari2.jpg" height="100px" width="100px"/></a>
<a class="col" href="images/safari1.jpg" rel="collection"><img src="images/safari1.jpg" height="100px" width="100px"/></a>
</div>
</body>

</html>


5. Logged In Page
<html>
<head>
<title>Logged In</title>
<link rel="stylesheet" type="text/css" href="style.css" media="all"/>

<script src="scripts/jquery-1.9.1.min.js"></script>
<script>
function showd(){
var fname = document.getElementById("car1").value;
alert("You have selected "+ fname + "for your Ride \n GOOD LUCK!!");
}

</script>

</head>
<body>
<div id="container">
<h1>Safari Tour</h1>
<hr/>
<ul>
    <li><a href="index.html">Home</a></li>
    <li><a href="gallery.html">Gallery</a></li>
    <li><a href="">About Us</a></li>
    <li><a href="contactus.html">Contact Us</a></li>
<li><a href="register.html" title="For New User">Register</a></li>
</ul>
<hr/>
<h1>Welcome </h1>
<form name="carform" onsubmit="showd();">
Book your Ride
<select id="car1">
<option value="New">Select Car</option>
<optgroup label="Audi">
<option value="A4">A4</option>
<option value="A8">A8</option>
<option value="R8">R8</option>
</optgroup>
<optgroup label="Maruti">
<option value="Maruti 800">800</option>
<option value="VAN">VAN</option>
<option value="SX4">SX4</option>
</optgroup>
</select>
<input type="submit" value="Book"/>
</form>
</div>
</body>

</html>


6. Contact Us Page Code
<html>
<head>
<title>Contact Us</title>
<link rel="stylesheet" type="text/css" href="style.css" media="all"/>

<script src="scripts/jquery-1.9.1.min.js"></script>
<script>
function show()
{
var fname = document.getElementById("fname").value; 
var email = document.getElementById("emailid").value; 
var message = document.getElementById("msg").value; 
confirm("You have entered:" + "\n Name : " + fname + "\n Email : " + email + "\n Message : "+ message + "\n\n Do you want the Feedback to send?");
}

function changeColor(val)
{ 
 if((val.value=="")||(val.value==null))
{
val.style.background="pink";
}
else
{
val.style.background="#FFFFFF";
}
}
</script>

</head>
<body>
<div id="container">
<h1>Safari Tour</h1>
<hr/>
<ul>
    <li><a href="index.html">Home</a></li>
    <li><a href="gallery.html">Gallery</a></li>
    <li><a href="">About Us</a></li>
    <li><a href="contactus.html">Contact Us</a></li>
<li><a href="register.html" title="For New User">Register</a></li>
</ul>
<hr/>
<h1></h1>
<form name="Feedback" id="feedback" onsubmit="show();">
<table>
<tr>
<td><label for="Name">Enter your Name</label></td>
<td><input id="fname" type="text" name="FullName" placeholder="Eg: Alan Blen" size="30" required onblur="changeColor(this)"/></td>
</tr>
<tr>
<td><label for="Email">Enter your Email</label></td>
<td><input id="emailid" type="email" name="Email" placeholder="Eg: someone@example.com" size="30" required onblur="changeColor(this)"/></td>
</tr>
<tr>
<td><label for="Message">Enter Message</label></td>
<td><textarea id="msg" rows="5" cols="30" onblur="changeColor(this)"></textarea></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="SEND"/></td>
</tr>
</table>
</form>
</body>

</html>


7. Forgot Password Page 
7.1
<html>
<head>
<title>Forgot Password!!</title>
<link rel="stylesheet" type="text/css" href="style.css" media="all"/>

<script src="scripts/jquery-1.9.1.min.js"></script>
</head>
<body>
Forgot your Password...Enter your registered Email ID Password will be sent
<form action="sent.html" method="get" id="forgot">
<table>
<tr>
<td><label for="Email">Enter your Email</label></td>
<td><input type="email" name="Email" placeholder="Eg: someone@example.com" size="30" required/></td>
</tr>
<tr>
<td><input type="submit" value="Send"/></td>
</tr>
</table>
</form>
</body>

</html>


7.2
<html>
<head>
<title>Forgot Password!!</title>
<link rel="stylesheet" type="text/css" href="style.css" media="all"/>
<script>
function closed(){
window.close();
}
</script>
<script src="scripts/jquery-1.9.1.min.js"></script>
</head>
<body>
Password is sent to your Email ID. <br/>
<input type="button" value="CLOSE WINDOW" onclick="closed()"/>
</body>

</html>




Style Sheet File
#container{width:80%;margin: 0 auto;padding-left: 10px;padding-right: 10px;overflow: hidden;}
#signin input,#signin select,#signin textarea,#signin label,#forgot {font-family:Verdana;font-weight:normal; font-size:15px;color:#848484;}
#signup input,#signup select,#signup label{font-family:Verdana;font-weight:normal; font-size:15px;color:#848484;}

textarea:hover,select:hover,input[type=text]:hover,input[type=password]:hover,input[type=email]:hover
{
border: 1px solid #b9b9b9;
border-top: 1px solid #FA58AC;
-webkit-box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);  
-moz-box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);  
box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}

p{font-family: Verdana, Helvetica, sans-serif;font-size:15px;color:#848484}

input[type=text],input[type=password],input[type=email],input[type=submit], input[type=reset],select
{
display: inline-block;  
height: 29px;
margin: 0;
padding: 0 8px; 
background: #E0ECF8;  
border: 1px solid #d9d9d9;  
border-top: 1px solid #c0c0c0;  
-webkit-box-sizing: border-box;  
-moz-box-sizing: border-box;  
box-sizing: border-box;   
-webkit-border-radius: 1px;  
-moz-border-radius: 1px;  
border-radius:1px;
}


#offers{
border: 1px solid #c0c0c0;
-webkit-box-sizing: border-box;  
-moz-box-sizing: border-box;  
box-sizing: border-box;   
-webkit-border-radius: 1px;  
-moz-border-radius: 1px;  
border-radius:1px;
background: #E0ECF8;
width:300px;
height:200px;
display:none;
font-family:Verdana;font-weight:normal; font-size:15px;color:#848484;
}

input[type=text]:focus, textarea:focus,select:focus, input[type=password]:focus,input[type=email]:focus,input[type=submit]:focus
{
outline: none;
border: 1px solid #04B45F;
-webkit-box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
-moz-box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
}

input[type=submit]:hover, input[type=reset]:hover
{
cursor:pointer;
}

ul{list-style-type: none;overflow: hidden; margin: 0;padding: 0;}
            li{float:left;}
#container li a:link,#container li a:visited{display:inline-block;width:120px;color:#333333;text-align:center;padding:4px;text-decoration:none;text-transform:uppercase;font-family: Verdana, Helvetica, sans-serif;}
#container li a:hover,#container li a:active{text-decoration:underline;color: #333333;}

h1,h2
{
color:#848484;
text-shadow: 5px 5px 5px silver;
font-family: calibri;
}

#container a:link,#container a:visited{color:#333333;text-decoration:none;font-family: Verdana, Helvetica, sans-serif; font-size:12px;}
#container a:hover,#container a:active{text-decoration:underline;color: #333333;}

#sign_up{}


#user_logo{position:absolute;top:200px;left:540px;}



Note: Download colorbox JQuery Library from this link
JQuery Color Box Library-Download