Total Pageviews

Tuesday, March 27, 2012

(java) SKILL BUILDER : FROG RACING

/**
 * This class implements different behaviors of frog racers.
 *
 * @author Your Shadow
 * @version  1.0.0
 */
public class FrogBehaviors {

    /**
     * Models a frog that allways jumps forward one cell.
     *
     * @param frogRacer  the frog that performs this behavior.
     */
    static public void forwardRacer(Frog frogRacer) {
   

frogRacer.jumpForward(1);
    }

    /**
     * Models a frog that:
     * 50 percent of the time jumps forward two cells and
     * 50 percent of the time stays in the same cell.
     *
     * @param frogRacer  the frog that performs this behavior.
     */
    static public void stayOrJumpRacerOne(Frog frogRacer) {
   
        int value = Frog.randomValue(0, 1);

        if (value == 0) {
            frogRacer.jumpForward(2);
        } else {
            // do nothing
        }
    }

    /**
     * Models a frog that:
     * 33 percent of the time jumps forward two cells,
     * 33 percent of the time jumps forward one cell, and
     * 33 percent of the time stays in the same cell.
     *
     * @param frogRacer  the frog that performs this behavior.
     */
    static public void stayOrJumpRacerTwo(Frog frogRacer) {
   
        int value = Frog.randomValue(0,2);

        if(value == 0)
            {
            frogRacer.jumpForward(2);
            }
        else if(value == 1)
            {
                    frogRacer.jumpForward(1);
            }
             else if(value==2)
            {
                    frogRacer.jumpForward(0);
            }
           
       
    }

    /**
     * Models a frog that:
     * 50 percent of the time jumps forward three cells, and
     * 50 percent of the time jumps backward two cells.
     *
     * @param frogRacer  the frog that performs this behavior.
     */
    static public void backwardOrForwardRacerOne(Frog frogRacer) {
        int value = Frog.randomValue(0, 1);

        if (value == 0) {
            frogRacer.jumpForward(3);
        } else if(value ==1) {
            frogRacer.jumpBackward(2);
        }
       
    }

    /**
     * Models a frog that:
     * 25 percent of the time jumps forward four cells,
     * 25 percent of the time jumps forward one cells
     * 25 percent of the time jumps backward one cells, and
     * 25 percent of the time jumps backward two cells.
     *
     * @param frogRacer  the frog that performs this behavior.
     */
    static public void backwardOrForwardRacerTwo(Frog frogRacer) {
   
        int value = Frog.randomValue(0,4);

        if(value == 0)
            {
            frogRacer.jumpForward(4);
            }
        else if(value == 1)
            {
                    frogRacer.jumpForward(1);
            }
             else if(value==2)
            {
                    frogRacer.jumpBackward(1);
            }
        else if(value==3)
            {
                    frogRacer.jumpBackward(2);
            }
       
    }
}

Tuesday, March 20, 2012

SKILL BUILDER DEFINING METHODS

/**
 * Extends the functions of the original <code>Turtle</code> class.
 *
 * @author Your name
 * @version  1.0.0
 */
public class ExtendedTurtle extends Turtle {

    /**
     * Paints its current location and moves to the front location.
     *
     * @param colorName  a string that specifies the color name.
     */
    public void paintAndMove(String  colorName) {
   
        paint(colorName);
        move();
    }

    /**
     * Turns the turtle to the opposite direction.
     */
    public void turn180()
{

turnLeft();
turnLeft();
   
       
    }

    /**
     * Paints and moves four locations.
     *
     * @param colorName  a string that specifies the color name.
     */
    public void paintAndMove4(String  colorName) {

paintAndMove(colorName);
paintAndMove(colorName);
paintAndMove(colorName);
paintAndMove(colorName);
       
    }

    /**
     * Paints a 2 x 2 square and returns to its original position.
     *
     * @param colorName  a string that specifies the color name.
     */
    public void paintSmallSquare(String  colorName) {

    paintAndMove(colorName);
turnRight();
paintAndMove(colorName);
turnRight();
paintAndMove(colorName);
turnRight();
paintAndMove(colorName);
turnRight();
   
       
       
    }

    /**
     * Paints a 4 x 4 square and returns to its original position.
     *
     * @param colorName  a string that specifies the color name.
     */
    public void paintLargeSquare(String  colorName) {


      paintAndMove(colorName);
          paintAndMove(colorName);
          paintAndMove(colorName);
          turnRight();

          paintAndMove(colorName);
          paintAndMove(colorName);
          paintAndMove(colorName);
          turnRight();
         
          paintAndMove(colorName);
          paintAndMove(colorName);
          paintAndMove(colorName);
          turnRight();

          paintAndMove(colorName);
          paintAndMove(colorName);
          paintAndMove(colorName);
          turnRight();
move();
turnRight();
paintAndMove(colorName);
          paintAndMove(colorName);
          paintAndMove(colorName);

  turnLeft();
   turnLeft();
move();
   paintAndMove(colorName);
          paintAndMove(colorName);
 
     turnRight();
move();
turnRight();
paintAndMove(colorName);
paintAndMove(colorName);
paintAndMove(colorName);
    }
}

Thursday, March 15, 2012

JAVA PROGRAM TO PRINT TABLE

class Table
{
public static void main(String args[])
 {
int a=2,b=1,c;

for(b=1;b<=10;b++)
{
c=2*b;
System.out.println("2 *"+b+"="+c);
}
}
}

JAVA PROGRAM TO FIND GREATER OF 2 NUMBERS

class Greater
{
public static void main(String args[])
 {
int a=20,b=30;
if(a>b)

System.out.println("A is greater than B");

else
System.out.println("B is greater than A");
}
}

Tuesday, March 13, 2012

java program class

class Student
{
public int a,b,c,d;
public Student(int w,int x,int y,int z)
{
a=w;
b=x;
c=y;
d=z;
}
public void calAverage()
{
System.out.println((a+b+c+d)/4);
}
}




========================================================


class Test
{
public static void main(String args[])
{
Student xyz = new Student (40,40,40,40);
xyz.calAverage();
}
}

Wednesday, February 29, 2012

JAVA: PROGRAM TO FIND AREA OF TRIANGLE

class Area
{
public static void main(String args[])
 {
int a=20,b=30,c;
c=(a*b)/2;
System.out.println("Area of Triangle is = "+c);
 }
}

Wednesday, February 1, 2012

quizpr1

 quizpr1

http://www.killersites.com/

strengths: provides good tutorials for web designing , video tutorials as well!

weaknesses: NOT A FREEWARE IT COSTS TOO MUCH.

http://coolhomepages.com/

strengths:  Provides nice  tips and tricks for the webdesigning.
                  You can show your own artwork and designs on their site.
                  Premium designs and templates are available.
    A blog for discussion is available

weaknesses: Not much on tutorials side.

www.w3schools.com/

strengths: Perfect for beginners
    very well explained basics.
    Provides their own live editor that doesn't require any download.
    Good for advanced HTML USERS.Covers JAVA,CSS,VBSCRIPT,JSON,PHP,HTML5 ETC.
    Provide their own curriculum and course certificates for a small fee.
weaknesses: Doesn't provide Templates and Layouts.

http://dynamicdrive.com/

strengths: Provides online tools and support
              has a nice css library
             can talk to other users for help with Active Forums
            free css library

weaknesses: nothing on HTML BASICS.











 http://jquery.com/

strengths:

jQuery is a new kind of JavaScript Library.

jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript.




weaknesses:  no html basics available



OVERALL OVERVIEW :

I WOULD PREFER TO USER W3SCHOOLS FOR WEB DESIGNING   AS IT PROVIDES A COMPLETE TUTORIAL ON ALL WEB DESIGNING LANGUAGES.