Last active
September 20, 2020 14:06
-
-
Save mrnirva/e1f763ce2ff8c34e641c23cb1209ba60 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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