Author Topic: Here we go!  (Read 3384 times)

codebirth

  • Administrator
  • *
  • Posts: 36
    • View Profile
    • c o d e b i r t h
Here we go!
« on: June 20, 2011, 12:36:28 PM »
Simple C++ example

Code: C++
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5.    std::cout << "Hello, world!\n";
  6. }

PHP example highlighting line 6

Code: PHP
  1. class Person {
  2.    public $firstName;
  3.    public $lastName;
  4.  
  5.    public function __construct($firstName, $lastName = '') { //Optional parameter
  6.        $this->firstName = $firstName;
  7.        $this->lastName = $lastName;
  8.    }
  9.  
  10.    public function greet() {
  11.        return "Hello, my name is " . $this->firstName . " " . $this->lastName . ".";
  12.    }
  13.  
  14.    static public function staticGreet($firstName, $lastName) {
  15.        return "Hello, my name is " . $firstName . " " . $lastName . ".";
  16.    }
  17. }
  18.  
  19. $he = new Person('John', 'Smith');
  20. $she = new Person('Sally', 'Davis');
  21. $other= new Person('Joe');
  22.  
  23. echo $he->greet(); // prints "Hello, my name is John Smith."
  24. echo '<br />';
  25. echo $she->greet(); // prints "Hello, my name is Sally Davis."
  26. echo '<br />';
  27. echo $other->greet(); // prints "Hello, my name is Joe  ."
  28. echo '<br />';
  29. echo Person::staticGreet('Jane', 'Doe'); // prints "Hello, my name is Jane Doe."
  30.  

Java example starting numbering lines from 9 and highlighting lines 2 and 6

Code: Java
  1. // OddEven.java
  2. import javax.swing.JOptionPane;
  3.  
  4. public class OddEven {
  5.     // "input" is the number that the user gives to the computer
  6.     private int input; // a whole number("int" means integer)
  7.  
  8.     /*
  9.      * This is the constructor method. It gets called when an object of the OddEven type
  10.      * is being created.
  11.      */
  12.     public OddEven() {
  13.     /*
  14.      * In most Java programs constructors can initialize objects with default values, or create
  15.      * other objects that this object might use to perform its functions. In some Java programs, the
  16.      * constructor may simply be an empty function if nothing needs to be initialized prior to the
  17.      * functioning of the object.  In this program's case, an empty constructor would suffice, even if
  18.      * it is empty. A constructor must exist, however if the user doesn't put one in then the compiler
  19.      * will create an empty one.
  20.      */
  21.     }
  22.  
  23.     // This is the main method. It gets called when this class is run through a Java interpreter.
  24.     public static void main(String[] args) {
  25.         /*
  26.          * This line of code creates a new instance of this class called "number" (also known as an
  27.          * Object) and initializes it by calling the constructor.  The next line of code calls
  28.          * the "showDialog()" method, which brings up a prompt to ask you for a number
  29.          */
  30.         OddEven number = new OddEven();
  31.         number.showDialog();
  32.     }
  33.  
  34.     public void showDialog() {
  35.         /*
  36.          * "try" makes sure nothing goes wrong. If something does,
  37.          * the interpreter skips to "catch" to see what it should do.
  38.          */
  39.         try {
  40.             /*
  41.              * The code below brings up a JOptionPane, which is a dialog box
  42.              * The String returned by the "showInputDialog()" method is converted into
  43.              * an integer, making the program treat it as a number instead of a word.
  44.              * After that, this method calls a second method, calculate() that will
  45.              * display either "Even" or "Odd."
  46.              */
  47.             input = Integer.parseInt(JOptionPane.showInputDialog("Please Enter A Number"));
  48.             calculate();
  49.         } catch (NumberFormatException e) {
  50.             /*
  51.              * Getting in the catch block means that there was a problem with the format of
  52.              * the number. Probably some letters were typed in instead of a number.
  53.              */
  54.             System.err.println("ERROR: Invalid input. Please type in a numerical value.");
  55.         }
  56.     }
  57.  
  58.     /*
  59.      * When this gets called, it sends a message to the interpreter.
  60.      * The interpreter usually shows it on the command prompt (For Windows users)
  61.      * or the terminal (For Linux users).(Assuming it's open)
  62.      */
  63.     private void calculate() {
  64.         if (input % 2 == 0) {
  65.             System.out.println("Even");
  66.         } else {
  67.             System.out.println("Odd");
  68.         }
  69.     }
  70. }
  71.  
« Last Edit: June 20, 2011, 12:40:31 PM by codebirth »
c o d e b i r t h

liyunyun

  • Newbie
  • *
  • Posts: 46
    • View Profile
michael kors factory outlet
« Reply #1 on: Today at 10:50:29 AM »
lacoste online shop
air force 1
hogan outlet online
air max 2016
ferragamo belt
michael jordan shoes
yeezy shoes
links of london
adidas online shop
five finger shoes
louboutin shoes uk
michael kors
kobe shoes
kobe shoes
chrome hearts
longchamp outlet
nike air force 1
yeezy
kobe sneakers
longchamp le pliage
nmd
nike roshe run
chrome hearts online store
michael kors outlet store
michael kors outlet online
yeezy boost
yeezy boost 350
nike air max 2017
nike air max
air jordan shoes
hermes belts for men
true religion outlet
michael kors factory outlet
michael kors outlet online
longchamp sale
michael jordan shoes
yeezy boost 350 v2
yeezy boost 350
michael kors outlet
air yeezy
michael kors handbags
adidas stan smith shoes
louboutin shoes
yeezy boost 350
timberland shoes
ultra boost
michael kors outlet store
michael kors outlet store
lacoste online shop
michael kors outlet
asics running shoes
kobe basketball shoes
nike air force
yeezy boost 350
yeezy boost
af1
adidas ultra boost
air jordan shoes
michael kors uk
michael kors outlet online
harden shoes
new england patriots jersey
michael kors handbags
cheap jordans
prada sunglasses
michael kors handbags
led shoes
cheap jordans
longchamp
nike zoom
michael kors purses
air jordan
nike roshe one
longchamp handbags
nike air huarache
true religion jeans
led shoes
yeezy boost 350
cheap jordans
adidas stan smith
atlanta falcons jersey
timberland boots
adidas ultra boost uncaged
links of london sale
michael kors outlet
nike polo
air jordans
longchamp outlet
Kanye West shoes
nike dunks
yeezy shoes
kobe 9
roshe run
retro jordans
adidas nmd r1
fitflops
lebron james shoes
chrome hearts
yeezy boost
asics shoes
adidas stan smith
jordans for cheap
yeezy boost 350
basketball shoes
kyrie irving shoes
cheap jordans
adidas neo
nike roshe run
nmd
adidas yeezy
http://www.kobeshoes.uk
yeezy boost 350 v2
hermes belt
adidas yeezy boost
cheap jordans
air jordan
adidas superstar
nike air force 1
michael kors outlet
yeezy boost
chrome hearts online
cheap jordans
pandora charms sale
lebron 13 shoes
kyrie 3 shoes
adidas nmd
nike mercurial
adidas nmd
kobe shoes
prada glasses
longchamp
lacoste outlet
curry 3 shoes
fitflops clearance
yeezy boost 350 v2
reebok outlet
fitflops sale clearance
longchamp bags
kobe 9
pandora jewelry
nike football boots
adidas nmd
pandora charms
light up shoes
jordan shoes
adidas ultra boost
adidas nmd
lacoste polo
true religion jeans
adidas gazelle
adidas ultra boost
authentic jordans
adidas superstar shoes
adidas superstar
tory burch shoes
lebron 14 shoes
yeezy boost 350 v2
yeezys
links of london outlet store
cheap basketball shoes
pandora bracelet
nmd
adidas tubular
air force 1
adidas neo
led shoes for kids
roshe shoes
longchamp bags
patriots jersey
pandora jewelry
lebron shoes
hogan outlet
yeezys
pandora charms
true religion outlet
adidas superstar shoes
longchamp bags
james harden shoes
nike air huarache
michael kors handbags
nike air zoom
adidas stan smith sneakers
jordan shoes
longchamp
kobe 11
brady jersey
adidas ultra
michael kors outlet online
kobe 11
yeezy shoes
yeezy shoes
nike air zoom
nike huarache
adidas nmd
kobe bryant shoes
vibram fivefingers
air max 2017
nike huarache
jordan shoes
http://www.kobebasketballshoes.us.com
michael kors outlet
kyrie shoes
stephen curry shoes
lacoste outlet
reebok shoes
nike air max
michael kors outlet
nike huarache
lebron 14
authentic jordans
pandora uk
chrome hearts online
hermes belts
lacoste outlet
adidas tubular
air max
kyrie 3
fitflops
nike air force
adidas tubular shadow
nike zoom
kobe basketball shoes
true religion
adidas tubular shadow
lebron 13
yeezy boost
nike polo shirts
pandora jewelry
hermes belt
longchamps
jordan shoes
nike zoom running shoe
yeezy boost 350
nike dunks shoes
chrome hearts online
timberland outlet
cheap jordans
timberland boots
falcons jersey
nike roshe uk
michael kors outlet
tory burch shoes
adidas nmd runner
michael kors handbags outlet
tory burch outlet
longchamp bags
michael kors factory outlet
curry shoes
curry 3
ferragamo belts
longchamp handbags
links of london
629