Showing posts with label design patterns. Show all posts
Showing posts with label design patterns. Show all posts
Tuesday, 15 November 2011
Saturday, 12 November 2011
Wednesday, 9 November 2011
Template Method Design Pattern
abstract class Fruit {
// Is the implementation of a template method which will be used in all the subclasses.
// This pattern is implemented by a Implementation Inheritance.
public final void eat(){
System.out.println("I am eating :" + this.getClass().getName());
}
abstract void cut();
}
class Apple extends Fruit{
@Override
void cut() {
System.out.println("This is how we cut : " + this.getClass().getName());
}
}
class Banana extends Fruit{
@Override
void cut() {
System.out.println("This is how we cut : " + this.getClass().getName());
}
}
public class TemplateMethodPattern {
public static void main(String args[]){
Fruit apple = new Apple();
apple.eat();
apple.cut();
Fruit banana = new Banana();
banana.eat();
banana.cut();
}
}
// Is the implementation of a template method which will be used in all the subclasses.
// This pattern is implemented by a Implementation Inheritance.
public final void eat(){
System.out.println("I am eating :" + this.getClass().getName());
}
abstract void cut();
}
class Apple extends Fruit{
@Override
void cut() {
System.out.println("This is how we cut : " + this.getClass().getName());
}
}
class Banana extends Fruit{
@Override
void cut() {
System.out.println("This is how we cut : " + this.getClass().getName());
}
}
public class TemplateMethodPattern {
public static void main(String args[]){
Fruit apple = new Apple();
apple.eat();
apple.cut();
Fruit banana = new Banana();
banana.eat();
banana.cut();
}
}
Thursday, 3 November 2011
Subscribe to:
Posts (Atom)
Executive Summary: Anthropic's Claude Mythos Model
What Happened Anthropic announced Claude Mythos Preview , a new AI model it describes as its most capable ever — and so powerful in cyber...
-
Setting up a MPI cluster on Ubuntu involves the following steps: 1. Install OpenMPI on all machines. $sudo apt-get install libopenmpi-de...
-
What Happened Anthropic announced Claude Mythos Preview , a new AI model it describes as its most capable ever — and so powerful in cyber...
-
What Is Claude Mythos Preview? Anthropic's most capable frontier AI model to date, showing a significant leap in capabilities across...
