Created
January 3, 2021 13:31
-
-
Save milikkan/c421576a4f1fc6d0983bd649a9eac1a6 to your computer and use it in GitHub Desktop.
Not Hesaplayıcı (Chain of Responsibility pattern)
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 dev.milikkan.cor; | |
public class AABulucu extends NotHarfiBulucu { | |
public AABulucu(NotHarfiBulucu bulucu) { | |
super(bulucu); | |
} | |
public void notHarfiBul(double not) { | |
if (not > 90) { | |
System.out.println("AA ile dersi geçtiniz."); | |
} else { | |
super.notHarfiBul(not); | |
} | |
} | |
} |
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 dev.milikkan.cor; | |
public class BABulucu extends NotHarfiBulucu { | |
public BABulucu(NotHarfiBulucu bulucu) { | |
super(bulucu); | |
} | |
public void notHarfiBul(double not) { | |
if (not > 85) { | |
System.out.println("BA ile dersi geçtiniz."); | |
} else { | |
super.notHarfiBul(not); | |
} | |
} | |
} |
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 dev.milikkan.cor; | |
public class BBBulucu extends NotHarfiBulucu { | |
public BBBulucu(NotHarfiBulucu bulucu) { | |
super(bulucu); | |
} | |
public void notHarfiBul(double not) { | |
if (not > 80) { | |
System.out.println("BB ile dersi geçtiniz."); | |
} else { | |
super.notHarfiBul(not); | |
} | |
} | |
} |
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 dev.milikkan.cor; | |
public class CBBulucu extends NotHarfiBulucu { | |
public CBBulucu(NotHarfiBulucu bulucu) { | |
super(bulucu); | |
} | |
public void notHarfiBul(double not) { | |
if (not > 75) { | |
System.out.println("CB ile dersi geçtiniz."); | |
} else { | |
super.notHarfiBul(not); | |
} | |
} | |
} |
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 dev.milikkan.cor; | |
public class GecemedinizBulucu extends NotHarfiBulucu { | |
public GecemedinizBulucu(NotHarfiBulucu bulucu) { | |
super(bulucu); | |
} | |
public void notHarfiBul(double not) { | |
System.out.println("Dersi geçemediniz."); | |
} | |
} |
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 dev.milikkan.cor; | |
public class KosulluBulucu extends NotHarfiBulucu { | |
public KosulluBulucu(NotHarfiBulucu bulucu) { | |
super(bulucu); | |
} | |
public void notHarfiBul(double not) { | |
if (not > 50) { | |
System.out.println("Koşullu geçtiniz."); | |
} else { | |
super.notHarfiBul(not); | |
} | |
} | |
} |
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 dev.milikkan.cor; | |
public abstract class NotHarfiBulucu { | |
NotHarfiBulucu sonraki; | |
public NotHarfiBulucu(NotHarfiBulucu bulucu) { | |
sonraki = bulucu; | |
} | |
public void notHarfiBul(double not) { | |
if (sonraki != null) { | |
sonraki.notHarfiBul(not); | |
} | |
} | |
} |
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 dev.milikkan.cor; | |
public class NotHesapla { | |
private NotHarfiBulucu notHarfiBulucu; | |
public NotHesapla(NotHarfiBulucu bulucu) { | |
notHarfiBulucu = bulucu; | |
} | |
public static void main(String[] args) { | |
double vizeNotu = 50.0; | |
double finalNotu = 50.0; | |
double yilSonuNotu = (vizeNotu * 0.4) + (finalNotu * 0.6); | |
System.out.printf("Yıl sonu notunuz = %.2f%n", yilSonuNotu); | |
new NotHesapla( | |
new AABulucu( | |
new BABulucu( | |
new BBBulucu( | |
new CBBulucu( | |
new KosulluBulucu( | |
new GecemedinizBulucu(null) | |
) | |
) | |
) | |
) | |
) | |
).notHarfiYazdir(yilSonuNotu); | |
} | |
public void notHarfiYazdir(double not) { | |
notHarfiBulucu.notHarfiBul(not); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment