Answered step by step
Verified Expert Solution
Link Copied!
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 TV(double boyut, String uretici, double maliyet){
this.boyut = boyut;
this.uretici = uretici;
this.maliyet = maliyet;
}
@Override
public double hesaplaSatisFiyati(){
return maliyet *1.8; // TV iin maliyetinin 0.8 kat fazlas
}
}
// Kitap snf
class Kitap implements Urun {
private int basimYili;
private String yayinevi;
private double maliyet;
// Constructor
public Kitap(int basimYili, String yayinevi, double maliyet){
this.basimYili = basimYili;
this.yayinevi = yayinevi;
this.maliyet = maliyet;
}
@Override
public double hesaplaSatisFiyati(){
return maliyet *1.5; // Kitap iin maliyetinin 0.5 kat fazlas
}
}
// Main snf
public class Main {
public static void main(String[] args){
// Urun tipinde 3 boyutlu dizi oluturuluyor
Urun[][][] urunler = new Urun[1][2][1];
//2 adet TV nesnesi oluturuluyor
urunler[0][0][0]= new TV(55.0, "Samsung", 2000.0);
urunler[0][1][0]= new TV(65.0,"LG",2500.0);
//1 adet Kitap nesnesi oluturuluyor
urunler[0][0][1]= new Kitap(2022,"Krmz Kedi Yaynevi",30.0);
// Tm zellikler ekrana yazdrlyor
for (Urun[][] katman1 : urunler){
for (Urun[] katman2 : katman1){
for (Urun urun : katman2){
if (urun instanceof TV){
TV tv =(TV) urun;
System.out.println("TV - Boyut: "+ tv.getBoyut()+",retici: "+ tv.getUretici()+", Maliyet: "+ tv.getMaliyet()+", Sat Fiyat: "+ tv.hesaplaSatisFiyati());
} else if (urun instanceof Kitap){
Kitap kitap =(Kitap) urun;
System.out.println("Kitap - Basm Yl: "+ kitap.getBasimYili()+", Yaynevi: "+ kitap.getYayinevi()+", Maliyet: "+ kitap.getMaliyet()+", Sat Fiyat: "+ kitap.hesaplaSatisFiyati());
}
}
}
}
}
}
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students explore these related Databases questions