Answered step by step
Verified Expert Solution
Question
1 Approved Answer
/ / Urun interface'i interface Urun { double hesaplaSatisFiyati ( ) ; } / / TV s n f class TV implements Urun { private
Urun interface'i
interface Urun
double hesaplaSatisFiyati;
TV snf
class TV implements Urun
private double boyut;
private String uretici;
private double maliyet;
Constructor
public TVdouble boyut, String uretici, double maliyet
this.boyut boyut;
this.uretici uretici;
this.maliyet maliyet;
@Override
public double hesaplaSatisFiyati
return maliyet ; TV iin maliyetinin kat fazlas
Kitap snf
class Kitap implements Urun
private int basimYili;
private String yayinevi;
private double maliyet;
Constructor
public Kitapint basimYili, String yayinevi, double maliyet
this.basimYili basimYili;
this.yayinevi yayinevi;
this.maliyet maliyet;
@Override
public double hesaplaSatisFiyati
return maliyet ; Kitap iin maliyetinin kat fazlas
Main snf
public class Main
public static void mainString args
Urun tipinde boyutlu dizi oluturuluyor
Urun urunler new Urun;
adet TV nesnesi oluturuluyor
urunler new TV "Samsung", ;
urunler new TVLG;
adet Kitap nesnesi oluturuluyor
urunler new KitapKrmz Kedi Yaynevi;
Tm zellikler ekrana yazdrlyor
for Urun katman : urunler
for Urun katman : katman
for Urun urun : katman
if urun instanceof TV
TV tv TV urun;
System.out.printlnTV Boyut: tvgetBoyutretici: tvgetUretici Maliyet: tvgetMaliyet Sat Fiyat: tvhesaplaSatisFiyati;
else if urun instanceof Kitap
Kitap kitap Kitap urun;
System.out.printlnKitap Basm Yl: kitap.getBasimYili Yaynevi: kitap.getYayinevi Maliyet: kitap.getMaliyet Sat Fiyat: kitap.hesaplaSatisFiyati;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started