This file contains hidden or 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
| public class Display { | |
| public static void main(String[] args) { | |
| Display display = new Display(); | |
| Outputalbe data = new Profile("numa08", 24); | |
| display.out(data); //Hey I am numa08 and , I'm 24 old. | |
| } | |
| private void out(Outputalbe data) { |
This file contains hidden or 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
| public class Profile implements Outputalbe { | |
| private final String name; | |
| private final int age; | |
| public Profile(String name, int age) { | |
| super(); | |
| this.name = name; | |
| this.age = age; | |
| } |
This file contains hidden or 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
| import java.text.SimpleDateFormat; | |
| import java.util.Calendar; | |
| public class OutputableCalendar implements Outputalbe { | |
| private final Calendar calendar; | |
| public OutputableCalendar(Calendar calendar) { | |
| super(); | |
| this.calendar = calendar; | |
| } |
This file contains hidden or 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
| import java.util.Calendar; | |
| import java.util.GregorianCalendar; | |
| public class Display { | |
| public static void main(String[] args) { | |
| Display display = new Display(); | |
| Calendar today = GregorianCalendar.getInstance(); | |
| Outputalbe data = new OutputableCalendar(today); |
This file contains hidden or 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
| require "./Profile.rb" | |
| def display(data) | |
| puts data.output | |
| end | |
| profile = Profile.new("numa08", 24) | |
| display(profile) #Hey I am numa08 and , I'm 24 old. |
This file contains hidden or 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
| class Profile | |
| def initialize(name, age) | |
| @name = name | |
| @age = age | |
| end | |
| def output | |
| "Hell, I am #{@name} , and I'm #{@age} old." | |
| end | |
| end |
This file contains hidden or 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
| def display(data) | |
| puts data.output | |
| end | |
| today = Time.now | |
| display(today) #Today is 2013/01/01 |
This file contains hidden or 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
| class Time | |
| def output | |
| strftime("Today is %Y/%m/%d") | |
| end | |
| end |
This file contains hidden or 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
| class Profile(name:String, age:Int) extends Outputable{ | |
| override def output = { | |
| "Hey I am " + name + " and , I'm " + age + " old." | |
| } | |
| } |
This file contains hidden or 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
| trait Outputable { | |
| def output:String | |
| } |