Jump to content
pijoe

Belajar Java (oop)

Recommended Posts

QUOTE (Firestarter @ Sep 19 2008, 08:13 AM) <{POST_SNAPBACK}>
@sh4m

Java ni senang dari c++ pasal kebanyakan method dah ada jadi ko buleh guna import je. Ni di panggil sebagai pre define method. Java ni bahasa yang 'straight'. Ko buleh tulis direct dalam BI dan tak banyak simbol yang digunakan. Aku tengah mendalami asas j2ee. Tak abis lagi.



Salam,
klu awak boleh ajar saye JAVA mmg saye hargai , awak send la code2 asas ker.....bnyak da saye da lupe :-D ... harp awak dpt tlg :-)

QUOTE (Si tenang @ Aug 16 2007, 10:13 AM) <{POST_SNAPBACK}>
1st ko kena ader matlamat la..
contoh nyer untuk aper ko belajar java
1.untuk jawab exam jer ker..
2. keperluan Industri ker
3.Untuk mengajar ker..
4.hobi suka2 nak buat program
5.or ko budak it yang minat certificate ker
5...aper2 yng relevan ler..

pastu baru ko boleh terre java style mane ko nak
software development ker
atau web development..

pastu ko pilih ler coding2 yang releven
konsep OOP-polymorphism, Inheritance, encapsulation ker semua tue same jer dgn
bahas programming lain..
okies

1st ko kena ader matlamat la..
contoh nyer untuk aper ko belajar java
1.untuk jawab exam jer ker..
2. keperluan Industri ker
3.Untuk mengajar ker..
4.hobi suka2 nak buat program
5.or ko budak it yang minat certificate ker
5...aper2 yng relevan ler..

pastu baru ko boleh terre java style mane ko nak
software development ker
atau web development..

pastu ko pilih ler coding2 yang releven
konsep OOP-polymorphism, Inheritance, encapsulation ker semua tue same jer dgn
bahas programming lain..
okies


Salam, saye ingin belajar utk keperluan industri....saye nk tahu camne keje dlm industri ni?cmane&contoh2 bende yg kite kene buat? study kt kolej yg simple jer.... so klu awak2 ader ilmu utk di kongsi ..saye hargai sgt2 ... awak email kn kt saye [email protected] ,

Share this post


Link to post
Share on other sites
wah...firestarter dpt penghormatan utk ajor java..sile2..share2 la coding kat cni..sy pun nak blajo gak dgn abg firestarter....leh ek...

Share this post


Link to post
Share on other sites
Ni aku bagi contoh koding. Ko paham sendiri la. Malas aku nak terang.
CODE
package com.conygre;

public class Person {

    private String name;
    private String password;

    public String getName(){
        return name;
    }

    public void setName(String s){
        name = s;
    }

    public String getPassword(){
            return password;
    }

    public void setPassword(String s){
            password = s;
    }


}


CODE
package com.conygre;
public interface Item {
  String getTitle();
  double getPrice();
  String getId();
}


CODE
package com.conygre;

public class Stock{

  private Book[] books;
  private CompactDisc[] cds;
  private DVD[] dvds;

  public Stock() {
    Initialiser init = new Initialiser();
    books = init.books();
    cds = init.cds();
    dvds = init.dvds();
  }

  public Book[] getBooks(){
    return books;
  }

  public CompactDisc[] getCds(){
    return cds;
  }

  public DVD[] getDvds(){
    return dvds;
  }
  // inner class to initialise the products for the stock
  class Initialiser {
    public Book[] books(){
      Book[] bookArray = {
      new Book("The Voyage of the Dawn Treader",4.99,"C.S. Lewis","1"),
      new Book("Linux Desk Reference",29.99,"Scott Hawkins","2"),
      new Book("Let the Nations Be Glad",5.99,"John Piper","3"),
      new Book("Treasure Island",3.99,"Robert Louis Stephenson","4"),
      new Book("How to Be a Great Guitarist",17.99,"Paul Hunnisett","5"),
      new Book("Heart of a Hooligan",4.99,"Muthena Paul Alkazraji","6"),
      new Book("Shogun",12.99,"James Clavell","7"),
      new Book("The Art of War",4.99,"Sun Tzu","8")
      };
      return bookArray;
    }

    public CompactDisc[] cds(){
      CompactDisc[] discArray = {
      new CompactDisc("Is This It",13.99,"The Strokes",11,"9"),
      new CompactDisc("Just Enough Education to Perform",10.99,"Stereophonics",11,"0"),
      new CompactDisc("Parachutes",11.99,"Coldplay",10,"a"),
      new CompactDisc("White Ladder",9.99,"David Gray",10,"b"),
      new CompactDisc("Greatest Hits",14.99,"Penelope",14,"c"),
      new CompactDisc("Echo Park",13.99,"Feeder",12,"d"),
      new CompactDisc("Mezzanine",12.99,"Massive Attack",11,"e")
      };
      return discArray;
    }

    public DVD[] dvds(){
      DVD[] filmArray = {
        new DVD("It's a Wonderful Life",7.99,"Frank Capra","f"),
          new DVD("Crouching Tiger Hidden Dragon",15.99,"Ang Lee","g"),
          new DVD("Breakfast at Tiffany's",14.99,"Blake Edwards","h"),
          new DVD("Romeo Must Die",10.99,"Andrzej Bartkowiak","i"),
          new DVD("Scent of a Woman",17.99,"Martin Brest","j"),
          new DVD("Snatch",18.99,"Guy Ritchie","k"),
        new DVD("Scarface",16.99,"Brian De Palma","l")
      };
      return filmArray;
    }
  }
}


CODE
package com.conygre;

public class DVD implements Item{

    //Instance variables
    private String title;
    private double price;
    private String director;
    private String id;

        //Methods
    public String getId(){
        return id;
    }
    public String getTitle(){
        return title;
    }

    public double getPrice(){
        return price;
    }

    public String getDirector(){
        return director;
    }

    //public String[] getFeatures(){
    //    return features;
    //}

    //public void setFeatures(String[] s){
    //    features = s;
    //}

    //constructors
    public DVD(){}

    public DVD(String t, double p,String d, String i){
        title=t;
        price=p;
        director=d;
        id = i;

    }

}

Share this post


Link to post
Share on other sites
simple javabean

CODE
public class SimpleBean {

  private String message = "No message specified";

  public String getMessage() {
    return message;
  }
  public void setMessage(String message) {
    this.message = message;
  }
}


write koding di bawah dlm jsp page utk gunekan javabean kat atas

CODE
<html>
<head>
<titile>Demo resuing java beans in jsp</title>
</head>
<center>
<table border = 5>
<tr><th>
Re using javaBeans in JSP </table>
</center>
<p>
<jsp:useBean id ="test" class="beans.SimpleBean"/>
<jsp:setProperty name="test" property="message" value="Hello Mat"/>
<h1>Message: <i>
<jsp:getProperty name = "test" property="message"/>
</i></h1>
</body>
</html>

Share this post


Link to post
Share on other sites
QUOTE(Firestarter @ Sep 19 2008, 10:13 AM) <{POST_SNAPBACK}>
@sh4m

Java ni senang dari c++ pasal kebanyakan method dah ada jadi ko buleh guna import je. Ni di panggil sebagai pre define method. Java ni bahasa yang 'straight'. Ko buleh tulis direct dalam BI dan tak banyak simbol yang digunakan. Aku tengah mendalami asas j2ee. Tak abis lagi.





wa bro ko pro lah ...aku baru blajr asa in the java j2se baruu... blh tlong ajr tak

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...