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
class Burger | |
def initialize(name,value) | |
@name = name | |
@value = value | |
end | |
def show | |
puts("#{@name} = #{@value} yen") | |
end |
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
class Gengo | |
attr_accessor :eng, :jap | |
end | |
shiken = Array.new(50){ Gengo.new } | |
#プログラム開始 | |
i = 0 | |
print "英=>" | |
ei = gets.to_i # 英語入力 |
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 xmldomtest; | |
import javax.xml.parsers.*; | |
import org.w3c.dom.*; | |
import java.io.*; | |
import java.util.ArrayList; | |
public class JavaDomSample { | |
public static void main(String[] args) { | |
String name = null; | |
ArrayList<String> resultList = new ArrayList<String>(); |
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 bemax.test; | |
import android.content.Context; | |
import android.graphics.Bitmap; | |
import android.graphics.Canvas; | |
import android.graphics.Color; | |
import android.graphics.Paint; | |
import android.graphics.Path; | |
import android.util.Log; | |
import android.view.MotionEvent; |
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
public class KahenSample | |
{ | |
public static void main(String... args) | |
{ | |
search(5,10,2,4,5,7,9); | |
} | |
public static void search(int key, int... nums) | |
{ | |
boolean hit = false; |
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
/** | |
* カプセル化のサンプル | |
* クラスLadyのカプセル化 | |
*/ | |
class Lady | |
{ | |
private int age; //年齢 | |
Lady(int _age) |
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 animal; //animalパッケージ | |
public class Animal | |
{ | |
protected String name; //protectedなので、packageが違っていても、サブクラスなら参照可能 | |
protected String voice; //protectedなので、packageが違っていても、サブクラスなら参照可能 | |
public Animal() | |
{ | |
name = "動物"; |
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
/** | |
* static変数・メソッドのサンプル | |
* staticを付けると、クラス全体が共有する変数・メソッドになる。 | |
*/ | |
class ClassMate | |
{ | |
//static変数…クラス共有の変数 | |
static String master; //担任の名前 |
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
/** | |
* 勇者クラス | |
*/ | |
class Hero | |
{ | |
String name; | |
int hp; | |
int lv; | |
/** |
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
class MusicPlayer | |
attr_accessor :music, :volume | |
def play() | |
puts "#{@music}を再生します" | |
end | |
def stop() | |
puts "#{@music}を停止します" | |
end |
NewerOlder