Skip to content

Instantly share code, notes, and snippets.

View numa08's full-sized avatar
๐Ÿ

Takaya Funabiki numa08

๐Ÿ
View GitHub Profile
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) {
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;
}
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;
}
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);
@numa08
numa08 / Display1.rb
Last active December 10, 2015 10:19
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.
class Profile
def initialize(name, age)
@name = name
@age = age
end
def output
"Hell, I am #{@name} , and I'm #{@age} old."
end
end
@numa08
numa08 / Display2.rb
Last active December 10, 2015 10:19
def display(data)
puts data.output
end
today = Time.now
display(today) #Today is 2013/01/01
class Time
def output
strftime("Today is %Y/%m/%d")
end
end
class Profile(name:String, age:Int) extends Outputable{
override def output = {
"Hey I am " + name + " and , I'm " + age + " old."
}
}
trait Outputable {
def output:String
}