Skip to content

Instantly share code, notes, and snippets.

@mrnirva
Last active September 20, 2020 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrnirva/e1f763ce2ff8c34e641c23cb1209ba60 to your computer and use it in GitHub Desktop.
Save mrnirva/e1f763ce2ff8c34e641c23cb1209ba60 to your computer and use it in GitHub Desktop.
package sinifnesne;
public class SinifNesne {
public static void main(String[] args) {
// Nesne oluşturmak
// Nesne oluşturulurken new anahtar kelimesi kullanılır
Arac araba = new Arac();
araba.kapilar = 4;
araba.hiz = 240;
araba.renk = "Mavi";
araba.calistir();
araba.dur();
araba.ozellikleriListele();
araba.renk = "Yeşil";
System.out.println("Arabanın Yeni Rengi: "+araba.renk);
}
}
class Arac{ // Sınıf tanımlama
// Özellikleri tanımlama
public int kapilar;
public int hiz;
public String renk;
// Metotları tanımlama
public void calistir(){
System.out.println("Araba Çalıştı");
}
public void dur(){
System.out.println("Araba Durdu");
}
public void ozellikleriListele(){
System.out.println("Kapı Sayısı: "+kapilar);
System.out.println("Hız: "+hiz);
System.out.println("Renk: "+renk);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment