II Java :30 12:00 I. I IV II. III. IV. ( a d) V. : this==null, T == N A ActionListener C class D actionperformed G getsource I implements K

Similar documents
I HTML HashMap (i) (ii) :.java import java.net.*; import java.io.*; import java.util.hashmap; public class SimpleStopWatch { public static voi

I. (i) Java? (A). 2Apples (B). Vitamin-C (C). Peach21 (D). Pine_Apple (ii) Java? (A). Java (B). Java (C). Java (D). JavaScript Java JavaScript Java (i

:30 12:00 I. I VII II. III. IV. ( a d) V. VI : this==null, T == N A ActionListener A addactionlistener C class D actionperforme

:30 12:00 I. I VII II. III. IV. ( a d) V. VI : this==null, T == N A ActionListener A addactionlistener C class D actionperformed

:30 12:00 I. I VII II. III. IV. ( a d) V. VI : this==null, T == N A ActionListener A addactionlistener C class D actionperformed

:30 12:00 I. I VII II. III. IV. ( a d) V. VI : this==null, T == N A ActionListener A addactionlistener C class D actionperforme

I. (i) Java? (A). Foo_Bar (B). G day (C). 999 (D). Golgo13 (ii)? (A). Java public (B). Java (C). Java JavaScript (D). Java C Java C (iii)? (A). Java (

6 p.1 6 Java GUI GUI paintcomponent GUI mouseclicked, keypressed, actionperformed mouseclicked paintcomponent thread, 1 GUI 6.0.2, mutlithread C

55 7 Java C Java TCP/IP TCP/IP TCP TCP_RO.java import java.net.*; import java.io.*; public class TCP_RO { public static void main(string[] a

I. java.awt.rectangle java.lang.math random Java TM API java.awt Rectangle Rectangle (x,y)... public int x Rectangle X public int y Rectangle Y public

I. (i) Foo public (A). javac Foo.java java Foo.class (C). javac Foo java Foo (ii)? (B). javac Foo.java java Foo (D). javac Foo java Foo.class (A). Jav

:30 12:00 I. I V II. III. IV. ( a d) V. VI : A ActionListener aa addactionlistener AE ActionEvent K KeyListener ak addkeyliste

I 4 p.2 4 GUI java.awt.event.* import /* 1 */ import mouseclicked MouseListener implement /* 2 */ init addmouselistener(this) this /* 3 */ this mousec

5 p Point int Java p Point Point p; p = new Point(); Point instance, p Point int 2 Point Point p = new Point(); p.x = 1; p.y = 2;

3 p.1 3 Java Java Java try catch C Java if for while C 3.1 boolean Java if C if ( ) 1 if ( ) 1 else , 2 { } boolean true false 2 boolean Gr

Thread

r1.dvi

Microsoft PowerPoint prog1_doc2x.pptx

KeyListener init addkeylistener addactionlistener addkeylistener addkeylistener( this ); this.addkeylistener( this ); KeyListener public void keytyped

Microsoft PowerPoint prog1_doc2.pptx

アプレットの作成

Chapter JDK KeyListener keypressed(keyevent e ) keyreleased(keyevent e ) keytyped(keyevent e ) MouseListener mouseclicked(mouseeven

K227 Java 2

r14.dvi

r3.dvi

r8.dvi

2 p.2 2 Java Hello0.class JVM Hello0 java > java Hello0.class Hello World! javac Java JVM java JVM : Java > javac 2> Q Foo.java Java : Q B

Chapter 20. [ ] ; [ ] = new [ ] ; Color colors [ ] = new Color[ 20 ]; // 20 Button operations [ ] = new Button[ 10 ]; // 10 colors[ 3 ] = new Color( 1

try catch Exception Java try catch try { } catch ( Exception e ) { } e 16-1 try catch 0 try { int x = 0; int y = 10 / x; } catch ( Exception e ) { Sys

vol.30.}...`.X...b.h

r2.dvi

Java (9) 1 Lesson Java System.out.println() 1 Java API 1 Java Java 1

Java 3 p.2 3 Java : boolean Graphics draw3drect fill3drect C int C OK while (1) int boolean switch case C Calendar java.util.calendar A

ただし 無作為にスレッドを複数実行すると 結果不正やデッドロックが起きる可能性がある 複数のスレッド ( マルチスレッド ) を安全に実行する ( スレッドセーフにする ) ためには 同期処理を用いるこ とが必要になる 同期処理は 予約語 synchronized で行うことができる ここでは sy

2

新・明解Java入門

text_13.dvi

< F2D834F838C A815B A CC>

< F2D B838A835882CC8CF68EAE2E6A7464>

Programming-C-9.key

問題1 以下に示すプログラムは、次の処理をするプログラムである

I 3 p.2 3 Java AddTime.java public class AddTime extends JApplet { int hour1, minute1, hour2, minute2; public void init() { hour1 = Integer.pars

Java演習(4) -- 変数と型 --

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV

Java演習(2) -- 簡単なプログラム --

IE6 2 BMI chapter1 Java 6 chapter2 Java 7 chapter3 for if 8 chapter4 : BMI 9 chapter5 Java GUI 10 chapter6 11 chapter7 BMI 12 chap


untitled

Java 2 p.2 2 Java Hello0.class JVM Hello0 java > java Hello0.class Hello World! javac Java JVM java JVM : Java > javac 2> Q Foo.java Java : Q 2.

やさしいJavaプログラミング -Great Ideas for Java Programming サンプルPDF

2 p.2 2 Java Hello0.class JVM Hello0 java > java Hello0.class Hello World! javac Java JVM java JVM : Java > javac 2> Q Foo.java Java : Q B

< F2D82518CC282CC D2E6A7464>

次の演習課題(1),(2)のプログラムを完成させよ

4 p.2 4 GUI return; public void mousepressed(mouseevent e) { /* 5 */ public void mousereleased(mouseevent e) { /* 5 */ public void mouseentered(mousee

< F2D F B834E2E6A7464>

Java プログラミング Ⅰ 3 回目変 数 今日の講義講義で学ぶ内容 変数とは 変数の使い方 キーボード入力の仕方 変 数 変 数 一時的に値を記憶させておく機能 変数は 型 ( データ型 ) と識別子をもちます 2 型 ( データ型 ) 変数に記憶する値の種類変数の型は 記憶できる値の種類と範囲

JavaプログラミングⅠ

Local variable x y i paint public class Sample extends Applet { public void paint( Graphics gc ) { int x, y;... int i=10 ; while ( i < 100 ) {... i +=

< F2D825282CC947B909482CC A815B83682E6A>

I java A

< F2D82B682E182F182AF82F12E6A7464>

PowerPoint Presentation

2 p.2 2 Java Hello0.class JVM Hello0 java > java Hello0.class Hello World! javac Java JVM java JVM : Java > javac 2> Q Foo.java Java : Q B

< F2D8EA CE909482CC92EA82852E6A7464>

** 平成 16 年度 FE 午後問題 Java** 示現塾プロジェクトマネージャ テクニカルエンジニア ( ネットワーク ) など各種セミナーを開催中!! 開催日 受講料 カリキュラム等 詳しくは 今すぐアクセス!! 平成 16

< F2D BCA82CC978E89BA82CC8EC08CB12E6A7464>

r3.dvi

< F2D92DE82E8914B82CC977088D32E6A7464>

r2.dvi

問1

Microsoft PowerPoint - prog10.ppt

Assignment_.java /////////////////////////////////////////////////////////////////////// // 課題 星の画像がマウスカーソルを追従するコードを作成しなさい 次 ///////////////////

r4.dvi

Safari AppletViewer Web HTML Netscape Web Web 15-1 Applet Web Applet init Web paint Web start Web HTML stop destroy update init Web paint start Web up

Animals サンプル Step3 張り付けた動物の上をクリックすると それぞれの鳴き声で鳴く その鳴く間 一定時間 ( ここでは 1 秒間 ) 画像が別のものに変わる <アニメーションの基礎 : タイマーについて> アニメーションは アプリケーションが指定する間 一定間隔でどんどん画像をおきかえ

GUIプログラムⅤ

JavaプログラミングⅠ

text_10.dvi


シミュレーションの簡単な例 GUI 無しのシミュレーションを作る GUI を作る パラメタを設定するデモンストレーションをする 2 オブジェクト指向プログラミング特論

オブジェクト指向プログラミング・同演習 5月21日演習課題

JAVA入門

2

Microsoft PowerPoint - prog10.ppt


はしがき・目次・事例目次・凡例.indd

Java学習教材

ii

< F2D89BA8EE882C E6A7464>

Java プログラミング Ⅰ 3 回目変数 変数 変 数 一時的に値を記憶させておく機能型 ( データ型 ) と識別子をもつ 2 型 ( データ型 ) 変数の種類型に応じて記憶できる値の種類や範囲が決まる 型 値の種類 値の範囲 boolean 真偽値 true / false char 2バイト文

II

/ ( ) 8/7/ :21 p.2/64

2008 e-learning T050050

2


1 Java Java GUI , 2 2 jlabel1 jlabel2 jlabel3 jtextfield1 jtextfield2 jtextfield3 jbutton1 jtextfield1 jtextfield2 jtextfield3

Color.cyan, Color.yellow, Color.pink, Color.orange, Color.white, Color.black, Color.gray, Color.darkGray, Color.lightGray ; Button barray [ ] = new Bu

活用ガイド (ハードウェア編)

アプレットⅤ

< F2D82518E9F8AD CC834F CC8CFC82AB82C68D4C>

Transcription:

II Java 09 2 13 10:30 12:00 I. I IV II. III. IV. ( a d) V. : this==null, T == N A ActionListener C class D actionperformed G getsource I implements K KeyListener J JApplet L addmouselistener M MouseListener N null P public Q equals R Runnable S System.out.println T this V private W new X extends Tree.java, MouseTest.java ( I), BubbleSort1.java, BubbleSort2.java, Point.java, ColorPoint.java 1

I. 8017 (quote of the day) (i) (ii) : Qotd.java import java.net.*; import java.io.*; public class Qotd { static final String[] quotes = { "Gravitation is not responsible for people falling in love." + " -- Albert Einstein", "The best way to predict the future is to invent it. -- Alan Key", "In mathematics, you don t understand things." + " You just get used to them. -- John von Neumann", " -- " ; public static void main(string args[]) { try { (i) servsock = new ServerSocket( (ii) ); while(true){ Socket sock = servsock.accept(); PrintStream out = new PrintStream(sock.getOutputStream()); long now = System.currentTimeMillis(); // int len = quotes.length; out.println(quotes[(int)(now%len)]); // sock.close() ; catch (Exception e){ System.exit(1) ; ( ) : TCP RO.java ( ) A A.1.1 import java.net.*; import java.io.*; public class TCP_RO { public static void main(string[] argv) { try { Socket readsocket = new Socket(argv[0], Integer.parseInt(argv[1])); InputStream instrm = readsocket.getinputstream(); while(true) { int c = instrm.read(); if (c==-1) break; System.out.write(c); catch (Exception e) { e.printstacktrace(); System.exit(1); 2

IP 192.168.0.1 java Qotd java TCP_RO 192.168.0.1 8017 ( ) The best way to predict the future is to invent it. -- Alan Key 3

II. Java ( ) 12 3 23 Windows Ctrl-C ************ *** *********************** ArrayList (i) 2 : CharGraph.java import java.io.*; import java.util.arraylist; public class CharGraph { public static void main(string[] args) { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); (i) ns = new (i) (); String line; try { while ((line=reader.readline())!=null) { try { int n = Integer.parseInt(line); ns.add(n); catch(numberformatexception e) { catch (IOException e) { for (int n : ns) { int i; for (i=0; i<n; i++) { System.out.print("*"); System.out.println(); Java int char double boolean Integer Character Double Boolean 4

III. NumD : NumD.java public class NumD { public int num; public void print() { // 10 System.out.printf("%d", num); public void increment() { num++; public void incrementafterprint() { print(); System.out.printf(" "); increment(); 3 NumR, NumX, NumY : NumR.java public class NumR { private static String[] roman = { "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII" ; public void print() { // if (num<=12) { System.out.print(roman[num-1]); else { System.out.print("??"); : NumX.java public class NumX { public boolean flag; public NumX(boolean b) { super(); flag = b; public void print() { // 16 if (flag) { // A F System.out.printf("%X", num); else { // a f System.out.printf("%x", num); // 01 // 02 // 03 // 04 // 05 // 06 // 07 // 08 // 09 // 10 // 11 // 12 // 13 // 14 // 15 // 16 // 17 5

: NumY.java public class NumY { private static String[] kazu = { " ", " ", " ", " ", " ", " ", " ", " ", " ", " " ; public void print() { // if (num<=10) { System.out.print(kazu[num-1]); else { System.out.print(" "); NumTest main : NumTest.java public class NumTest { public static void main(string[] args) { NumD[] ns = new NumD[3]; ns[0] = new NumR(); NumX x = new NumX(true); x.flag = false; ns[1] = x; ns[2] = new NumY(); // 9 ns[0].num = 9; ns[1].num = 9; ns[2].num = 9; int i, j; for (i=0; i<4; i++) { for (j=0; j<ns.length; j++) { ns[j].incrementafterprint(); System.out.println(" "); // // 01 // 02 // 03 // 04 // 05 // 06 // 07 // 08 // 09 // 10 // 11 // 12 // 13 // 14 // 15 // 16 // 17 // 18 // 19 // 20 (i) 3 (ii) NumX flag NumTest 6 NumX (iii) NumTest 6 main 6

IV. Java : BallAnimation.java import java.awt.*; import java.awt.event.*; import javax.swing.*; public class BallAnimation (i) { Thread ballthread = null; int x = 100, dx = 10, y = 100, dy = 16; public void init() { (ii) public void start() { if (ballthread==null) { (iii) ballthread.start(); public void stop() { ballthread = null; public void paint(graphics g) { super.paint(g); g.drawstring(" ", x, y); public void run() { Thread thisthread = Thread.currentThread(); while (ballthread==thisthread) { x += dx; y += dy; x %= 200; y %= 200; repaint(); try { Thread.sleep(300); catch (InterruptedException e){ 7

public void mouseclicked(mouseevent e) { x = e.getx(); y = e.gety(); public void mouseentered(mouseevent e) { public void mouseexited(mouseevent e) { public void mousepressed(mouseevent e) { public void mousereleased(mouseevent e) { (i) (iii) 8

Tree.java, MouseTest.java ( I), BubbleSort1.java, BubbleSort2.java, Point.java, ColorPoint.java Tree.java import java.awt.*; import javax.swing.*; import java.util.arraylist; import static java.lang.math.*; public class Tree extends JApplet { ArrayList<int[]> data = new ArrayList<int[]>(); public void drawtree(int d, double x, double y, double r, double t) { if (d==0) return; data.add(new int[] {(int)x, (int)y, (int)(x+r*cos(t)), (int)(y+r*sin(t))); drawtree(d-1, x+r*cos(t), y+r*sin(t), 0.5*r, t+0.2); drawtree(d-1, x+(0.55*r)*cos(t), y+(0.55*r)*sin(t), 0.5*r, t+1.25); drawtree(d-1, x+(0.45*r)*cos(t), y+(0.45*r)*sin(t), 0.5*r, t-1.3); public void init() { drawtree(6, 128, 255, 128, -PI/2); public void paint(graphics g) { for(int[] pts : data) { g.drawline(pts[0], pts[1], pts[2], pts[3]); MouseTest.java import javax.swing.*; import java.awt.*; import java.awt.event.*; public class MouseTest extends JApplet implements MouseListener { int x=50, y=20; public void init() { addmouselistener(this); public void mouseclicked(mouseevent e) { x = e.getx(); y = e.gety(); repaint(); return; public void mousepressed(mouseevent e) { public void mousereleased(mouseevent e) { public void mouseentered(mouseevent e) { public void mouseexited(mouseevent e) { public void paint(graphics g) { super.paint(g); // g.drawstring("hello WORLD!", x, y); 9

BubbleSort1.java import javax.swing.*; import java.awt.*; public class BubbleSort1 extends JApplet implements Runnable { int[] args = {10, 3, 46, 7, 23, 34, 8, 12, 4, 45, 44, 52; Color[] cs ={Color.RED, Color.ORANGE, Color.GREEN, Color.BLUE; Thread thread=null; public void start() { if (thread == null) { thread = new Thread(this); thread.start(); public void stop() { thread = null; public void paint(graphics g) { int i; super.paint(g); for(i=0; i<args.length; i++) { g.setcolor(cs[args[i]%cs.length]); g.fillrect(0, i*10, args[i]*5, 10); public void run() { int i, j; Thread thisthread = Thread.currentThread(); for (i=0; i<args.length-1; i++) { for (j=args.length-1; thread == thisthread && j>i; j--) { if (args[j-1]>args[j]) { // int tmp=args[j-1]; args[j-1]=args[j]; args[j]=tmp; repaint(); try { // repaint Thread.sleep(500); catch (InterruptedException e) { 10

BubbleSort2.java import javax.swing.*; import java.awt.*; import java.awt.event.*; public class BubbleSort2 extends JApplet implements Runnable, ActionListener { int[] args = { 10, 3, 46, 7, 23, 34, 8, 12, 4, 45, 44, 52; Color[] cs ={Color.RED, Color.ORANGE, Color.GREEN, Color.BLUE; Thread thread=null; private boolean threadsuspended=true; public void init() { JButton step = new JButton("Step"); step.addactionlistener(this); setlayout(new FlowLayout()); add(step); // start, stop, paint BubbleSort1.java public synchronized void actionperformed(actionevent e) { threadsuspended=false; notify(); public void run() { int i, j; for (i=0; i<args.length-1; i++) { for (j=args.length-1; j>i; j--) { if (args[j-1]>args[j]) { // int tmp=args[j-1]; args[j-1]=args[j]; args[j]=tmp; repaint(); try { // repaint synchronized(this) { while (threadsuspended) { wait(); threadsuspended=true; catch (InterruptedException e) { 11

Point.java public class Point { public int x, y; public void move(int dx, int dy) { x += dx; y += dy; public void print() { System.out.printf("(%d, %d)", x, y); public void moveandprint(int dx, int dy) { print(); move(dx, dy); print(); public Point(int x0, int y0) { x = x0; y = y0; ColorPoint.java public class ColorPoint extends Point { private String[] cs = {"black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"; private int color; // 0-1- 2-3- 4-5- 6-7- public void print() { System.out.printf("<font color= %s >", getcolor()); super.print(); System.out.print("</font>"); public void setcolor(string c) { int i; for (i=0; i<cs.length; i++) { if (c.equals(cs[i])) { color = i; return; // public ColorPoint(int x, int y, String c) { super(x, y); setcolor(c); public String getcolor() { return cs[color]; // // 12

II Java ( 09 2 13 ) I. 4 2 (i). (ii). II. III. (i). (i). 4 5 3 (ii). IV. (iii). 5, 4, 4 (i). (ii). (iii). 1

2