init commit

This commit is contained in:
m-mun
2026-09-03 09:09:11 +09:00
parent 7e0caa5ac3
commit f22760db5c
180 changed files with 34706 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
/*
* PTra01_01.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra01_01 {
public static void main(String[] args) {
//TODO Hello,world と出力してください
}
}

View File

@@ -0,0 +1,19 @@
/*
* PTra01_02.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra01_02 {
public static void main(String[] args) {
// TODO 11行目のコメントを単一行コメントにしてコンパイルエラーが出ないようにしてください
ここをコメントアウトする
// TODO 14行目 ~ 16行目を複数行コメントにしてコンパイルエラーが出ないようにしてください
ここをコメントアウトする
ここをコメントアウトする
ここをコメントアウトする
}
}

View File

@@ -0,0 +1,17 @@
/*
* PTra01_03.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra01_03 {
public static void main(String[] args) {
// TODO 文字列型の変数 str を宣言してください。
// TODO str に こんにちは を代入してください
// TODO str の値を出力してください
}
}

View File

@@ -0,0 +1,15 @@
/*
* PTra01_04.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra01_04 {
public static void main(String[] args) {
// TODO 数値型の変数 number を 10 で初期化してください。
// TODO number の値を出力してください
}
}

View File

@@ -0,0 +1,15 @@
/*
* PTra01_05.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra01_05 {
public static void main(String[] args) {
// TODO char型の変数 ch を A で初期化してください。
// TODO ch の値を出力してください
}
}

View File

@@ -0,0 +1,15 @@
/*
* PTra01_06.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra01_06 {
public static void main(String[] args) {
// TODO boolean型の変数 bo を true で初期化してください。
// TODO bo の値を出力してください
}
}

View File

@@ -0,0 +1,15 @@
/*
* PTra01_07.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra01_07 {
public static void main(String[] args) {
// TODO long型の変数 lo を 1000000000000 で初期化してください。
// TODO lo の値を出力してください
}
}

View File

@@ -0,0 +1,15 @@
/*
* PTra01_08.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra01_08 {
public static void main(String[] args) {
// TODO float型の変数 fl を 3.14 で初期化してください。
// TODO fl の値を出力してください
}
}

View File

@@ -0,0 +1,17 @@
/*
* PTra01_09.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra01_09 {
public static void main(String[] args) {
// TODO 基本型8種類の変数を宣言します(変数名は自分できめてOKです)
// TODO 宣言した変数に、値を代入してください(代入する値はなんでもOKです)
// TODO それぞれの変数の中身を出力してください
}
}

View File

@@ -0,0 +1,136 @@
/Atm.class
/Calc.class
/Car.class
/Cat.class
/Dog.class
/Driver.class
/ItemA.class
/Jam.class
/JapaneseWallet.class
/Library.class
/PTra01_01.class
/PTra01_02.class
/PTra01_03.class
/PTra01_04.class
/PTra01_05.class
/PTra01_06.class
/PTra01_07.class
/PTra01_08.class
/PTra01_09.class
/PTra02_01.class
/PTra02_02.class
/PTra02_03.class
/PTra02_04.class
/PTra02_05.class
/PTra02_06.class
/PTra02_07.class
/PTra02_08.class
/PTra03_01.class
/PTra03_02.class
/PTra03_03.class
/PTra03_04.class
/PTra04_01.class
/PTra04_02.class
/PTra04_03.class
/PTra04_04.class
/PTra04_05.class
/PTra05_01.class
/PTra05_02.class
/PTra05_03.class
/PTra06_01.class
/PTra06_02.class
/PTra06_03.class
/PTra06_04.class
/PTra06_05.class
/PTra06_06.class
/PTra06_07.class
/PTra07_01.class
/PTra07_02.class
/PTra07_03.class
/PTra07_04.class
/PTra07_05.class
/PTra07_06.class
/PTra07_07.class
/PTra07_08.class
/PTra07_09.class
/PTra07_10.class
/PTra08_01.class
/PTra08_02.class
/PTra08_03.class
/PTra08_04.class
/PTra08_05.class
/PTra08_06.class
/PTra08_07.class
/PTra08_08.class
/PTra09_01.class
/PTra09_02.class
/PTra09_03.class
/PTra10_01.class
/PTra10_02.class
/PTra10_03.class
/PTra10_04.class
/PTra10_05.class
/PTra10_06.class
/PTra10_07.class
/PTra10_08.class
/PTra11_01.class
/PTra11_02.class
/PTra11_03.class
/PTra11_04.class
/PTra11_05.class
/PTra12_01.class
/PTra12_02.class
/PTra12_03.class
/PTra13_01.class
/PTra13_02.class
/PTra13_03.class
/PTra13_04.class
/PTra13_05.class
/PTra13_06.class
/PTra13_07.class
/PTra14_01.class
/PTra14_02.class
/PTra15_01.class
/PTra15_02.class
/PTra15_03.class
/PTra16_01.class
/PTra16_02.class
/PTra17_01.class
/PTra17_02.class
/PTra17_03.class
/PTra17_04.class
/PTra18_01.class
/PTra18_02.class
/PTra18_03.class
/PTra19_01.class
/PTra19_02.class
/PTra19_03.class
/PTra19_04.class
/PTra19_05.class
/PTra20_01.class
/PTra20_02.class
/PTra20_03.class
/PTra21_01.class
/PTra21_02.class
/PTra21_03.class
/PTra21_04.class
/PTra22_01.class
/PTra22_02.class
/PTra22_03.class
/PTra22_04.class
/PTra22_05.class
/PTra22_06.class
/PTra22_07.class
/PTra22_08.class
/PTra24_01.class
/Student.class
/Toast.class
/Toys.class
/USWallet.class
/User.class
/Util.class
/Wallet.class
/XmlConnection.class
/com/
/common/
/log4j2.xml

View File

@@ -0,0 +1,35 @@
/*
* PTra02_01.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra02_01 {
public static void main(String[] args) {
int sum;
int diff;
int mulch;
int div;
int rem;
// TODO 6+2を計算して結果を変数sumに代入してください
// TODO 6-2を計算して結果を変数diffに代入してください
// TODO 6×2を計算して結果を変数mulchに代入してください
// TODO 6÷2を計算して結果を変数divに代入してください
// TODO 17÷5の余りを計算して変数remに代入してください
// 各変数の表示(編集しないでください)
// ※ 8, 4, 12, 3, 2の順で表示されれば正解です
System.out.println("変数sum :" + sum);
System.out.println("変数diff :" + diff);
System.out.println("変数mulch:" + mulch);
System.out.println("変数div :" + div);
System.out.println("変数rem :" + rem);
}
}

View File

@@ -0,0 +1,18 @@
/*
* PTra02_02.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra02_02 {
public static void main(String[] args) {
String firstName = "太郎";
String lastName = "山田";
// TODO 苗字と名前をつなげて山田太郎と出力してください。
// ※ System.out.printlnを使うのは1回だけです。
}
}

View File

@@ -0,0 +1,20 @@
/*
* PTra02_03.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra02_03 {
public static void main(String[] args) {
int num = 10;
// TODO numに5を足した値をnumに代入してください
// numの値を出力します(編集しないでください)。
// ※ 15と出力されれば正解です。
System.out.println(num);
}
}

View File

@@ -0,0 +1,19 @@
/*
* PTra02_04.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra02_04 {
public static void main(String[] args) {
// TODO 以下のソースコードからコンパイルエラーを取り除いてください
// ※数値リテラル部分は編集しないでください
int sum = 10 + 3.14;
// ※以下は編集しないでください。13.14と出力されていれば正解です
System.out.println(sum);
}
}

View File

@@ -0,0 +1,25 @@
/*
* PTra02_05.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra02_05 {
public static void main(String args[]) {
// 以下のプログラムを実行すると、
/*
* 山田さんは20歳です。
* 5年後には205歳になります。
*/
// と表示されます。
// TODO 5年後には25歳になりますと表示されるように修正してください。
// ※ ただし行数を増やしてはいけません。
int age = 20;
int diff = 5;
System.out.println("山田さんは" + age + "歳です。");
System.out.println(diff + "年後には" + age + diff + "歳になります。");
}
}

View File

@@ -0,0 +1,16 @@
/*
* PTra02_06.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra02_06 {
public static void main(String[] args) {
// 以下のプログラムを実行すると割り算の結果の小数点以下が切り捨てられてしまいます。
// TODO 切り捨てられないように修正してください。
System.out.println(9/2);
}
}

View File

@@ -0,0 +1,17 @@
/*
* PTra02_07.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra02_07 {
public static void main(String[] args) {
// TODO 以下のソースコードからコンパイルエラーを取り除いてください
// ※数値リテラル部分は編集しないでください
int num = 1.0;
// ※ 以下は編集しないでください。1と出力されていれば正解です
System.out.println(num);
}
}

View File

@@ -0,0 +1,26 @@
/*
* PTra02_08.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra02_08 {
public static void main(String[] args) {
// 所持金
int money = 1000;
// 商品価格(税抜)
int price = 580;
// 消費税率
double taxRate = 0.08;
// TODO 買い物した際の残金計算をします。
// TODO 所持金から価格を引いた値を、買い物後の所持金として再代入してください。
// ※消費税を考慮してください。税込み商品価格の端数は切り捨てとします。
// 残金の表示部分です。編集しないでください
System.out.println("残金は" + money + "円です。");
}
}

View File

@@ -0,0 +1,17 @@
/*
* PTra03_01.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra03_01 {
public static void main(String[] args) {
// TODO int型の変数numを宣言し、100で初期化してください
// TODO「変数numが100である」という条件式を追加してください
if () {
System.out.println("条件に合致しました");
}
}
}

View File

@@ -0,0 +1,15 @@
/*
* PTra03_02.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra03_02 {
public static void main(String[] args) {
// TODO int型の変数numを宣言し、65で初期化してください
// TODO 変数numの値が65以上の場合は「合格です」と出力し、それ以外であれば「不合格です」を出力してください
// ※ 合格です と表示されれば正解
}
}

View File

@@ -0,0 +1,16 @@
/*
* PTra03_03.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra03_03 {
public static void main(String[] args) {
int num = 10;
// TODO numが 2で割り切れる かつ 5で割り切れるという条件式を記述してください
if () {
System.out.println(num + "は2でも5でも割り切れます。");
}
}
}

View File

@@ -0,0 +1,24 @@
/*
* PTra03_04.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra03_04 {
public static void main(String[] args) {
System.out.println("降水確率を入力してください。(数字のみ)");
// キーボードから入力した数値を変数 num に代入します
int num = new java.util.Scanner(System.in).nextInt();
// TODO 以下の条件に沿ったプログラムを記述してください
/*
* 入力された数値によって以下のように出力してください。
* 変数numの値が 75以上 の場合 -> 雨が降る確率が高いです
* 変数numの値が 30~74 の場合 -> 雨が降るかもしれないです
* 変数numの値が 30未満 の場合 -> 雨はまず降らないでしょう
*
* ※ 変数numの値が 0より小さい または 100より大きい場合は「不正な値が入力されました」と出力してください。
*/
}
}

View File

@@ -0,0 +1,26 @@
/*
* PTra04_01.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
import java.util.Random;
public class PTra04_01 {
public static void main(String[] args) {
// 乱数生成用の処理
Random random = new Random();
// 乱数を格納するための変数を初期化
int randomNumber = 0;
// 以下のwhile文は0~9のランダムな値をコンソールに出力する処理を無限に繰り返します。
// TODO while文の条件を修正して5が出力されたら繰り返しを止めるようにしてください。
while(true) {
// 0~9のランダムな値を生成
randomNumber = random.nextInt(10);
// 生成した値をコンソールに出力
System.out.println(randomNumber);
}
}
}

View File

@@ -0,0 +1,20 @@
/*
* PTra04_02.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra04_02 {
public static void main(String[] args) {
// TODO int型の変数numを宣言し、2を代入してください。
int num = 2;
/*
* TODO
* numが1000を超えるまで繰り返しを行ってください。
* 繰り返しの中でnumを2倍した数値をnumに代入してください。
* ※ 繰り返しにはwhile文を用いてください
*/
}
}

View File

@@ -0,0 +1,27 @@
/*
* PTra04_03.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
import java.util.Random;
public class PTra04_03 {
public static void main(String[] args) {
// 乱数生成処理
Random random = new Random();
// 乱数を格納するための変数を初期化
int randomNumber = 0;
// 以下のwhile文は0~9のランダムな値をコンソールに出力する処理を無限に繰り返します。
// TODO 5が出力されたら繰り返しを止めるようにしてください。
// ※ while文の条件は変更せずにbreak文を使ってください。
while(true) {
// 0~9のランダムな値を生成
randomNumber = random.nextInt(10);
// 生成した値をコンソールに出力
System.out.println(randomNumber);
}
}
}

View File

@@ -0,0 +1,47 @@
/*
* PTra04_04.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
import java.util.Random;
import java.util.Scanner;
public class PTra04_04 {
public static void main(String[] args) {
// 以下は双六のプログラムです。TODO の指示に従って完成させてください。
// 入力を読み取るための記述です。
Scanner scanner = new Scanner(System.in);
// ランダムな値を生成するための記述です。
Random random = new Random();
// TODO 双六の総コマ数としてint型の変数mapを宣言し、50を代入してください。
// TODO 現在までの進んだコマ数としてint型の変数progressを宣言し、0を代入してください。
System.out.println("===== START =====");
// TODO 変数mapとprogressを用いて、ゴールするまで繰り返すようにwhile文の条件を記述してください。
while() {
// 入力を促すメッセージを出力し、エンターキーが押されるのを待ちます。
System.out.println("Enterキーを押してください。さいころをふります。");
scanner.nextLine();
// 1~6のランダムな値を生成してさいころの目とします。
int dice = random.nextInt(6) + 1;
// TODO 変数diceを用いて、"#の目が出ました。"というメッセージを出力してください。
// ※ #には変数diceの値が入ります。
// TODO 変数progressに変数diceの値を加算してください。
// TODO まだゴールしていない場合は"残りのマスは#マスです。"というメッセージを出力してください。
// ※ #には双六の残りのマス数が入ります。
}
System.out.println("===== GOAL =====");
}
}

View File

@@ -0,0 +1,47 @@
/*
* PTra04_05.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
import java.util.Random;
import java.util.Scanner;
public class PTra04_05 {
public static void main(String[] args) {
// 以下はじゃんけんを行うプログラムです。
// TODO TODOコメントの指示に従ってプログラムを完成させてください。
// 入力を要求するためのもの
Scanner scanner = new Scanner(System.in);
// 乱数生成処理
Random random = new Random();
// 勝敗の状態を覚えておくための変数(初期値は負けとする)
boolean winFlag = false;
// プレイヤーが勝つまでじゃんけんを繰り返す。
while(!winFlag) {
int playerHand;
int npcHand;
// プレイヤーに出す手を選ばせる
// ※ 数値でない入力は考慮していません(エラーになります)
System.out.println("じゃんけんを行います。");
System.out.println("あなたの出す手を入力してください");
System.out.println("0:グー, 1:チョキ, 2:パー");
playerHand = Integer.parseInt(scanner.nextLine());
// TODO 選ばれた手を出力してください(0なら"あなたはグーを出しました"等)
// 対戦相手の手をランダムに選択する。
npcHand = random.nextInt(3);
// TODO 対戦相手の手を出力してください(0なら"相手はグーを出しました"等)
// TODO じゃんけんの結果を出力し、プレイヤーが勝った場合はプログラムが終了するようにしてください。
// 次のじゃんけんの前に改行しておく
System.out.println();
}
}
}

View File

@@ -0,0 +1,27 @@
/*
* PTra05_01.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra05_01 {
public static void main(String[] args) {
System.out.println("今日の運勢を占います。");
// ランダムな数値をnumに代入します。範囲は 0 ~ 5 です。
int num = new java.util.Random().nextInt(6);
// TODO 以下の条件に沿ったプログラムを記述してください
// ※ switch文を使用してプログラムを記述してください
/*
* 入力された数値によって以下のように出力してください。
* 変数numの値が 0 の場合 -> あなたの運勢は「大吉」です
* 変数numの値が 1 の場合 -> あなたの運勢は「吉」です
* 変数numの値が 2 の場合 -> あなたの運勢は「中吉」です
* 変数numの値が 3 の場合 -> あなたの運勢は「小吉」です
* 変数numの値が 4 の場合 -> あなたの運勢は「末吉」です
* 変数numの値が 5 の場合 -> あなたの運勢は「凶」です
*/
}
}

View File

@@ -0,0 +1,35 @@
/*
* PTra05_02.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra05_02 {
public static void main(String[] args) {
System.out.println("1つ目の数値を入力してください");
// キーボードから入力した文字列を num1 に代入します。
int num1 = new java.util.Scanner(System.in).nextInt();
System.out.println("2つ目の数値を入力してください");
// キーボードから入力した文字列を num2 に代入します。
int num2 = new java.util.Scanner(System.in).nextInt();
System.out.println("計算方法を選択してください");
// キーボードから入力した文字列を choice に代入します。
String choice = new java.util.Scanner(System.in).nextLine();
// TODO 以下の条件に沿ったプログラムを記述してください
/*
* 入力された数値によって以下のように出力してください。
* 変数choiceの値が + の場合 -> num1 と num2 を 足した数 を出力
* 変数choiceの値が - の場合 -> num1 から num2 を 引いた を出力
* 変数choiceの値が * の場合 -> num1 と num2 を 掛けた を出力
* 変数choiceの値が / の場合 -> num1 を num2 で 割った を出力
* 変数choiceの値が % の場合 -> num1 を num2 で 割った余り を出力
* 変数choiceの値が 上記以外 の場合 -> 計算に失敗しました を出力
*/
}
}

View File

@@ -0,0 +1,47 @@
/*
* PTra05_03.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra05_03 {
public static void main(String[] args) {
System.out.println("=========================================");
System.out.println(" ゲームの説明");
System.out.println("=========================================");
System.out.println("これからハイ&ローゲームを行います。");
System.out.println("ハイ&ローゲームは、あなたのカードがディーラーのカードより大きいか小さいかを予想するゲームです。");
System.out.println();
System.out.println("=========================================");
System.out.println(" ゲーム開始");
System.out.println("=========================================");
// ランダムな数値を dealerCard に代入します。(範囲は 1 ~ 13)
int dealerCard = new java.util.Random().nextInt(13) + 1;
System.out.println("ディーラーのカードは" + dealerCard + "です");
// ランダムな数値を myCard に代入します。(範囲は 1 ~ 13)
int myCard = new java.util.Random().nextInt(13) + 1;
System.out.println();
System.out.println("あなたのカードがディーラのカードより大きい場合は H 小さい場合は L を入力してください。");
System.out.println("※ カードの数値が同じ場合はあなたの勝ちです。");
// キーボードから入力した文字列を judgment に代入します。
String judgement = new java.util.Scanner(System.in).nextLine();
System.out.println("あなたのカードは" + myCard + "です");
System.out.println();
System.out.println("=========================================");
System.out.println(" 勝敗判定");
System.out.println("=========================================");
// TODO 予想が当たった場合は「あなたの勝ちです」、外れた場合は「あなたの負けです」を出力してください。
// ※ H か L 以外の文字が入力された場合は、「不正な値が入力されました」と出力してください。
}
}

View File

@@ -0,0 +1,12 @@
/*
* PTra06_01.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra06_01 {
public static void main(String[] args) {
// TODO for文を使って0から99までの整数を順にコンソールに出力してください。
}
}

View File

@@ -0,0 +1,16 @@
/*
* PTra06_02.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra06_02 {
public static void main(String[] args) {
// TODO for文を使って以下の出力結果が出るようなプログラムを作成してください。
/*
* ■■■■■
*/
}
}

View File

@@ -0,0 +1,18 @@
/*
* PTra06_03.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra06_03 {
public static void main(String[] args) {
// iが0から100になるまで繰り返しを行います
for (int i = 0; i <= 100; i++) {
// TODO iが偶数の時だけ、iの値を出力してください
}
}
}

View File

@@ -0,0 +1,21 @@
/*
* PTra06_04.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra06_04 {
public static void main(String[] args) {
// TODO 下記のfor文の中で、変数iの値を条件に以下のような挙動をするプログラムを作成してください。
/*
* ① iが3で割り切れる場合はfizzと出力する
* ② iが5で割り切れる場合はbuzzと出力する
* ③ iが3でも5でも割り切れる場合はfizzbuzzと出力する
* ④ 上記のいずれにも当てはまらない場合はiの値をそのまま出力する
*/
for(int i = 1;i < 50;i++) {
}
}
}

View File

@@ -0,0 +1,26 @@
/*
* PTra06_05.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
import java.util.Random;
public class PTra06_05 {
public static void main(String[] args) {
// 乱数生成処理
Random random = new Random();
// 乱数を格納するための変数を初期化
int randomNumber = 0;
// 以下のfor文は0~2のランダムな値を10回出力します。
// TODO 値が2の場合は出力しないようにしてください。
// ※ continueを用いてください。
for(int i = 0;i < 10;i++) {
randomNumber = random.nextInt(3);
System.out.println(randomNumber);
}
}
}

View File

@@ -0,0 +1,20 @@
/*
* PTra06_06.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra06_06 {
public static void main(String[] args) {
// TODO for文を使って以下の出力結果が出るようなプログラムを作成してください。
/*
* ■■■■■
* ■■■■■
* ■■■■■
* ■■■■■
* ■■■■■
*/
}
}

View File

@@ -0,0 +1,25 @@
/*
* PTra06_07.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra06_07 {
public static void main(String[] args) {
/*
* TODO 以下のかけ算九九の出力結果が出るようなプログラムを作成してください。
*
* 1 2 3 4 5 6 7 8 9
* 2 4 6 8 10 12 14 16 18
* 3 6 9 12 15 18 21 24 27
* 4 8 12 16 20 24 28 32 36
* 5 10 15 20 25 30 35 40 45
* 6 12 18 24 30 36 42 48 54
* 7 14 21 28 35 42 49 56 63
* 8 16 24 32 40 48 56 64 72
* 9 18 27 36 45 54 63 72 81
*/
}
}

View File

@@ -0,0 +1,17 @@
/*
* PTra07_01.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra07_01 {
public static void main(String[] args) {
// TODO 要素数5のint型の配列を宣言してください
// TODO 宣言した配列に要素として1,3,5,7,9を設定してください
// TODO 配列の2番目の値を出力してください。
// ※ 3が表示されれば正解
}
}

View File

@@ -0,0 +1,15 @@
/*
* PTra07_02.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra07_02 {
public static void main(String[] args) {
// TODO int型の配列を宣言し、整数値1,10,100を入れて初期化してください
// TODO 配列の1番目と3番目を足した値を出力してください
// ※ 101 が出力されれば正解です。
}
}

View File

@@ -0,0 +1,20 @@
/*
* PTra07_03.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra07_03 {
public static void main(String[] args) {
String[] array = new String[5];
array[0] = "森";
array[1] = "山";
array[2] = "沼";
array[3] = "島";
array[4] = "平地";
// TODO 配列arrayの全要素を順番に出力してください
// ※ 繰り返しを使用して記述すること
}
}

View File

@@ -0,0 +1,16 @@
/*
* PTra07_04.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra07_04 {
public static void main(String[] args) {
int[] array = new int[1000];
// TODO 配列arrayに1から1000までの整数を順に入れてください
// ※ for文を用いて代入を行うこと
// TODO 配列arrayの全要素を順番に出力してください
}
}

View File

@@ -0,0 +1,24 @@
/*
* PTra07_05.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
import java.util.Random;
public class PTra07_05 {
public static void main(String[] args) {
String[] array = new String[5];
array[0] = "森";
array[1] = "山";
array[2] = "沼";
array[3] = "島";
array[4] = "平地";
// 0~4のランダムな整数を作成しています
int random = new Random().nextInt(5);
// TODO 配列arrayから変数randomが示す要素を出力してください
}
}

View File

@@ -0,0 +1,20 @@
/*
* PTra07_06.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra07_06 {
public static void main(String[] args) {
String[] array = new String[5];
array[0] = "森";
array[1] = "山";
array[2] = "沼";
array[3] = "島";
array[4] = "平地";
// TODO 配列arrayの内容を末尾から先頭に向けて順に出力してください
// ※ 繰り返しを使用して記述すること
}
}

View File

@@ -0,0 +1,22 @@
/*
* PTra07_07.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra07_07 {
public static void main(String[] args) {
// 以下の変数schedule一週間の時間割を2次元配列で表したものです
String[][] schedule =
{ /*月*/ /*火*/ /*水*/ /*木*/ /*金*/
/*1時間目*/ {"国語", "社会", "国語", "理科", "社会"},
/*2時間目*/ {"英語", "数学", "英語", "数学", "国語"},
/*3時間目*/ {"理科", "国語", "理科", "国語", "理科"},
/*4時間目*/ {"社会", "社会", "数学", "社会", "数学"},
/*5時間目*/ {"数学", "英語", "英語", "理科", "英語"},
};
// TODO 変数scheduleから金曜日の2時間目の科目を取得して出力してください
}
}

View File

@@ -0,0 +1,19 @@
/*
* PTra07_08.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra07_08 {
public static void main(String[] args) {
// 2次元配列
int[][] array = {
{1,3,5,7},
{11,13,17,19,23,29}
};
// TODO 2次元配列arrayに含まれるすべての整数要素を順に出力してください
// ※ 繰り返しを使用して記述すること
}
}

View File

@@ -0,0 +1,19 @@
/*
* PTra07_09.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra07_09 {
public static void main(String[] args) {
// 2次元配列
int[][] array = {
{1,3,5,7},
{11,13,17,19,23,29}
};
// TODO 2次元配列arrayに含まれるすべての整数要素の平均値を浮動小数で出力してください
// ※ 繰り返しを使用して記述すること
}
}

View File

@@ -0,0 +1,28 @@
/*
* PTra07_10.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra07_10 {
public static void main(String[] args) {
// 配列の宣言
int[] array = new int[100];
// このプログラムを実行すると実行中に「ArrayIndexOutOfBoundsException」というエラーがコンソールに出力されてしまいます
// TODO 以下のプログラムを修正してエラーが出力されないようにしてください
// ※コンソールに1から100までの値が順番に表示されれば成功です
// 配列の中身が{1,2,3,…,98,99,100}となるように値を代入する
int i = 1;
while(i <= 100) {
array[i] = i + 1;
i++;
}
// 配列の中身を順にすべて出力する
for(int element: array) {
System.out.println(element);
}
}
}

View File

@@ -0,0 +1,17 @@
/*
* PTra08_01.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra08_01{
public static void main(String[] args) {
// TODO helloメソッドを呼び出してください
}
public static void hello() {
System.out.println("こんにちは");
}
}

View File

@@ -0,0 +1,16 @@
/*
* PTra08_02.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra08_02{
public static void main(String[] args) {
// TODO 引数に 山田 を渡してhelloメソッドを呼び出してください。
}
public static void hello(String name) {
System.out.println("こんにちは。" + name + "です");
}
}

View File

@@ -0,0 +1,19 @@
/*
* PTra08_03.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra08_03{
public static void main(String[] args) {
// TODO String型の str という変数にhelloメソッドの戻り値を代入してください
// TODO str の値を出力してください
}
public static String hello() {
return "こんにちは";
}
}

View File

@@ -0,0 +1,19 @@
/*
* PTra08_04.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra08_04{
public static void main(String[] args) {
// TODO 引数に 1 と 2 を渡してsumメソッドを呼び出し、戻り値を、変数 sum に代入してください
// TODO sum の値を出力してください
}
public static int sum(int x, int y) {
return x + y;
}
}

View File

@@ -0,0 +1,32 @@
/*
* PTra08_05.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra08_05 {
public static void main(String[] args) {
System.out.println("1つ目の数値を入力してください");
// キーボードから入力した文字列を num1 に代入します。
int num1 = new java.util.Scanner(System.in).nextInt();
System.out.println("2つ目の数値を入力してください");
// キーボードから入力した文字列を num2 に代入します。
int num2 = new java.util.Scanner(System.in).nextInt();
// TODO num1、num2メソッドを引数に渡してsumメソッドを呼び出し、戻り値を変数 sum に代入してください。
// TODO 変数 sum の値を出力してください。
}
/*
* TODO 以下の仕様でメソッドを作成してください。
*
* 戻り値 :int
* メソッド名 :sum
* 引数 :int x, int y
*
* 引数で渡された2つのint型の合計を返すメソッド
*/
}

View File

@@ -0,0 +1,25 @@
/*
* PTra08_06.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra08_06 {
public static void main(String[] args) {
// TODO 引数に 10 と 20 を渡してaddArrayメソッドを呼び出し、戻り値を変数 array に代入してください
// TODO arrayの中身を全て出力してください
}
/*
* TODO 以下の仕様でメソッドを作成してください。
*
* 戻り値 :int[]
* メソッド名 :addArray
* 引数 :int x, int y
*
* 配列を宣言して、引数で渡された2つのint型の引数を配列の0番目と1番目に代入して返す
*/
}

View File

@@ -0,0 +1,32 @@
/*
* PTra08_07.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra08_07 {
public static void main(String[] args) {
printValue("こんにちは");
printValue(100);
printValue(10.1);
printValue('A');
}
/*
* TODO 以下の仕様でメソッドを作成してください
*
* 戻り値 :void
* メソッド名 :printValue
* 引数 :String value
*
* 引数はxxxですと表示するメソッド(xxxには渡された引数を当てはめる)
*/
// TODO printValueを引数intでオーバーロードしてください。処理は同じ
// TODO printValueを引数doubleでオーバーロードしてください。処理は同じ
// TODO printValueを引数charでオーバーロードしてください。処理は同じ
}

View File

@@ -0,0 +1,28 @@
/*
* PTra08_08.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra08_08 {
public static void main(String[] args) {
System.out.println(sum(1, 2));
System.out.println(sum(1, 2 ,3));
System.out.println(sum(1, 2, 3, 4));
}
/*
* TODO 以下の仕様でメソッドを作成してください
*
* 戻り値 :int
* メソッド名 :sum
* 引数 :int num1, int num2
*
* 引数で渡された値合計した値を戻り値として返す
*/
//TODO sumを引数3つでオーバーロードしてください。処理は同じ
//TODO sumを引数4つでオーバーロードしてください。処理は同じ
}

View File

@@ -0,0 +1,15 @@
/*
* PTra09_01.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra09_01 {
public static void main(String[] args) {
// TODO 同一パッケージのUtilクラスのhelloメソッドを呼び出してください
}
}

View File

@@ -0,0 +1,27 @@
/*
* PTra09_02.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra09_02 {
public static void main(String[] args) {
/*
* TODO このプロジェクトに以下を作成してください。
* 新しくcommonパッケージを作成してください。
* 作成したcommonパッケージの中にUtilクラスを作成してください。
*
* 作成したUtilクラスに以下の要件を満たすshowSumメソッドを作成してください
*
* メソッド名 :showSum
* 戻り値 :void
* 引数 :int num1, int num2
* 動作 :num1とnum2の合計値をコンソールに出力する
*/
// TODO 作成したshowSumメソッドを完全限定名で呼び出してください
// ※ 引数には任意の整数を与えてください。
}
}

View File

@@ -0,0 +1,14 @@
/*
* PTra09_03.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra09_03 {
public static void main(String[] args) {
// TODO PTra09_02で作成したUtilクラスのshowSumメソッドを呼び出してください
// ※ importを使って呼び出すこと
}
}

View File

@@ -0,0 +1,14 @@
/*
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class Util {
/**
* こんにちはと出力する
*/
public static void hello() {
System.out.println("こんにちは");
}
}

View File

@@ -0,0 +1,23 @@
/*
* PTra10_01.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra10_01 {
public static void main(String[] args) {
// ※ この問題はUserクラスを使用して解いてください。
// TODO User型変数 user を宣言してください。
// TODO 変数 user に userインスタンスを代入してください。
// TODO 変数 userのidフィールドに 1000 を代入してください。
// TODO 変数 userのnameフィールドに 山田太郎 を代入してください。
// TODO 変数 userの idフィールド を出力してください。
// TODO 変数 userの nameフィールド を出力してください。
}
}

View File

@@ -0,0 +1,21 @@
/*
* PTra10_02.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra10_02 {
public static void main(String[] args) {
// ※ この問題はUserクラスを使用して解いてください。
// TODO User型変数 user を宣言してください。
// TODO 変数 user に userインスタンスを代入してください。
// TODO 変数 userのidフィールドに 2000 を代入してください。
// TODO 変数 userのnameフィールドに 佐藤二郎 を代入してください。
// TODO 変数 userの printProfileメソッド を呼び出してください。
}
}

View File

@@ -0,0 +1,39 @@
/*
* PTra10_03.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
/*
* TODO 以下の仕様のクラスを作成してください
* (このファイルとは別に、新しくJavaファイルを作成してください)
*
* クラス名
* Student
* フィールド
* studentId : int型
* name : String型
* mail : String型
* password : String型
* メソッド
* なし
*/
public class PTra10_03 {
public static void main(String[] args) {
// ※この問題はStudentクラスを作成してから解いてください。
// TODO Student型変数 student をStudent型のインスタンスで初期化してください。
// TODO 変数 studentの studentIdフィールドに 10 を代入してください。
// TODO 変数 studentの nameフィールドに 田中二郎 を代入してください。
// TODO 変数 studentの mailフィールドに test@mail.com を代入してください。
// TODO 変数 studentの passwordフィールドに pass を代入してください。
// TODO studentの全てのフィールド(studentId, name, mail, password)それぞれを出力してください
}
}

View File

@@ -0,0 +1,35 @@
/*
* PTra10_04.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
/*
* TODO 以下の仕様のクラスを作成してください
* (このファイルとは別に、新しくJavaファイルを作成してください)
*
* クラス名
* Calculation
* フィールド
* baseNum : int型
* メソッド
* 戻り値(なし)、メソッド名(add)、引数(int num)
* フィールドbaseNum に引数num を加える
*/
public class PTra10_04 {
public static void main(String[] args) {
// ※この問題はCalculationクラスを作成してから解いてください。
// TODO Calculation型変数 cal をCalculation型のインスタンスで初期化してください。
// TODO 変数 calの baseNumフィールドに 100 を代入してください。
// TODO 変数 calの addメソッドを引数に100を渡して呼び出してください。
// TODO 変数 calの baseNumフィールドを出力してください。
// ※ 200 と出力されれば正解
}
}

View File

@@ -0,0 +1,40 @@
/*
* PTra10_05.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
/*
* TODO 以下の仕様のクラスを作成してください(新しくJavaファイルを作成してください)
*
* クラス名
* Car
* フィールド
* color : String型
* gasoline : int型
* メソッド
* 戻り値(int)、メソッド名(run)、引数(なし)
* ・gasolineフィールドの値を1減らす。
* ・1~15の数の中からランダムな値(車が進む距離)を戻り値として返す。
* ・もしgasolineフィールドが負の数になった場合(車がもう進めない)は-1を戻り値として返す。
*/
public class PTra10_05 {
public static void main(String[] args) {
// ※この問題はCarクラスを作成してから解いてください。
// TODO Car型変数 car を型のインスタンスで初期化してください。
// TODO 変数 carの colorフィールドに 赤 を代入してください。
// TODO 変数 carの gasolineフィールドに 50 を代入してください。
// TODO 変数 carに格納されているインスタンスメソッドrunを実行してください。
// TODO 「x色の車はy進みました」と出力してください。
// ※ xには車の色、yには車の進んだ距離を入れること
// TODO 変数 carのgasolineフィールドを出力してください。(49が出力されること)
}
}

View File

@@ -0,0 +1,27 @@
/*
* PTra10_06.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra10_06 {
public static void main(String[] args) {
//※この問題はPTra10_05で作成したCarクラスを使用して解いてください。
// TODO Car型変数 car を型のインスタンスで初期化してください。
// TODO 変数 carの colorフィールドに 赤 を代入してください。
// TODO 変数 carの gasolineフィールドに 50 を代入してください。
// 目的地までの距離
final int DISTANCE = 300;
/*
* TODO 変数carに格納されているインスタンスメソッドrunを繰り返し使って、目的地まで進んでください
* 先にガソリンがなくなった場合は、「x色の車は目的地に到達できませんでした」を出力してください
* 目的地についた時点で「x色の車は目的地にまでy時間かかりました。残りのガソリンは、zリットルです」を出力してください
* xは車の色、yはrunメソッドを実行した回数, zは残りのガソリンの数です
*/
}
}

View File

@@ -0,0 +1,29 @@
/*
* PTra10_07.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra10_07 {
/**
* @param args
*/
public static void main(String[] args) {
// ※ この問題はUserクラスを使用して解いてください。
// TODO User型の変数が3つ入る配列userListを宣言・確保してください
// TODO User型変数のインスタンスをuser1, user2, user3という名前で3つ作成してください。
/*
* TODO 作成した3つのインスタンスのフィールドにそれぞれ以下を代入してください。
* user1 : idフィールドに 1、nameフィールドに 一郎
* user2 : idフィールドに 2、nameフィールドに 二郎
* user3 : idフィールドに 3、nameフィールドに 三郎
*/
// TODO userListに作成したuser1, user2, user3を追加してください。
// TODO 繰り返しを使ってuserListの中身を順番に取り出してprintProfileメソッドを実行してください。
}
}

View File

@@ -0,0 +1,27 @@
/*
* PTra10_08.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra10_08 {
public static void main(String[] args) {
//※この問題は PTra10_05で作成したCarクラスを使用して解いてください。
// 目的地までの距離
final int DISTANCE = 300;
/*
* TODO Car型のインスタンスを3件作成し、それぞれの色、ガソリンを以下のように設定してください。
* 1台目:colorフィールドに"赤"、gasolineフィールドに50
* 2台目:colorフィールドに"青"、gasolineフィールドに60
* 3台目:colorフィールドに"黄"、gasolineフィールドに70
*
* 各carインスタンスメソッドrunを繰り返し使って、それぞれ目的地まで進んでください
* 先にガソリンがなくなった場合は、「x色の車は、目的地に到達できませんでした」を出力してください
* 目的地についた時点で「x色の車は、目的地にまでy時間かかりました。残りのガソリンは、zリットルです」を出力してください
* ※ xは車の色、yはrunメソッドを実行した回数, zは残りのガソリンの数です
* ※ クラス型配列を利用して処理を行なってください。
*/
}
}

View File

@@ -0,0 +1,19 @@
/*
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class User {
int id;
String name;
/**
* IDと名前を出力する挨拶メソッド
*/
void printProfile() {
System.out.println("ID" + this.id + ":" +this.name);
}
}

View File

@@ -0,0 +1,29 @@
public class Atm {
// 預金残高
int credit = 100000;
/**
* 預金を引き出す処理を行う。
* 指定した金額を預金残高から減らして、財布の中にお金を追加する
* @param wallet 財布
* @param money 引き出す金額
*/
void withdraw(Wallet wallet, int money) {
// 引き出す金額が預金残高より大きい場合
if (credit < money) {
System.out.println("預金残高不足です。現金の引き出しに失敗しました。");
// 引き出す金額が預金残高より小さい場合
} else {
// 預金残高から指定金額を引く
credit -= money;
// 財布の中のお金に指定金額を追加
wallet.money += money;
System.out.println("ATMの残り残高は" + this.credit + "です");
}
}
}

View File

@@ -0,0 +1,18 @@
public class Cat {
String name;
/*
* TODO 以下のコンストラクタを作成してください。
* 引数 なし
* nameフィールドに タマ を代入する
*/
/*
* TODO 以下のコンストラクタを作成してください。
* 引数 String name
* nameフィールドに 引数に渡された name を代入する
*/
}

View File

@@ -0,0 +1,12 @@
public class Jam {
// TODO String型のmaterialフィールドを作成してください。
/*
* TODO String型の引数を1つ持つコンストラクタを作成してください。
* 処理:与えられた引数をmaterialフィールドに代入する
*/
}

View File

@@ -0,0 +1,29 @@
/*
* PTra11_01.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra11_01 {
public static void main(String[] args) {
// ※ この問題はUserクラス、Walletクラスを使用して解いてください。
// TODO Wallet型変数 wallet をWallet型のインスタンスで初期化してください。
// TODO walletのmoneyフィールドに10000を代入してください。
// TODO User型変数 user をUser型のインスタンスで初期化してください
// TODO userのnameフィールドに太郎を代入してください。
// TODO userのwalletフィールドに作成したwalletを代入してください。
// TODO userのconfirmWalletメソッドを実行してください。
// ※ 太郎の財布の中の残額は10000円です と表示されます。
// TODO userのuseMoneyメソッドを 引数1000 で実行してください。
// TODO userのconfirmWalletメソッドを再度実行してください。
// ※ 太郎の財布の中の残額は9000円です と表示されます。
}
}

View File

@@ -0,0 +1,35 @@
/*
* PTra11_02.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra11_02 {
public static void main(String[] args) {
// ※ この問題はWalletクラス、Atmクラスを使用して解いてください。
// TODO Wallet型変数 wallet をWallet型のインスタンスで初期化してください。
// TODO walletのmoneyフィールドに10000を代入してください。
// TODO Atm型変数 atm をAtm型のインスタンスで初期化してください
/*
* TODO atmの withdrawメソッドに以下の引数を渡して呼びだしてください
* 第一引数 wallet、第二引数 100000
*/
// TODO walletのmoneyフィールドを出力してください
// ※ 値が110000になっていれば正解
/*
* TODO atmの withdrawメソッドに以下の引数を渡して呼びだしてください
* 第一引数 wallet、第二引数 100000
* ※ 預金残高不足です。現金の引き出しに失敗しましたと出れば正解
*/
// TODO walletのmoneyフィールドを出力してください
// ※ 値が110000のまま変わっていなければ正解
}
}

View File

@@ -0,0 +1,23 @@
/*
* PTra11_03.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra11_03 {
public static void main(String[] args) {
// ※ この問題はCatクラスにコンストラクタを作成してから解いてください。
// TODO Cat型変数 cat1 を 引数なしでインスタンス化してください。
// TODO cat1のnameフィールドを出力してください
// ※ タマと出力されれば正解
// TODO Cat型変数 cat2 を 引数にミケを渡してインスタンス化してください。
// TODO cat2のnameフィールドを出力してください
// ※ ミケと出力されれば正解
}
}

View File

@@ -0,0 +1,23 @@
/*
* PTra11_04.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra11_04 {
public static void main(String[] args) {
// ※この問題はStudentクラスを使用して解いてください。
// TODO 生徒の名前に 太郎 を設定してください。
// TODO 教室の名前に A を設定してください。
// TODO 先生の名前に 山田 を設定してください。
// TODO studentProfileメソッドを実行してください。
// ※ 太郎はA教室の生徒です と表示されれば正解
// TODO groupProfileメソッドを実行してください
// ※ A教室の担任は山田先生です。 と表示されれば正解
}
}

View File

@@ -0,0 +1,17 @@
/*
* PTra11_05.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra11_05 {
public static void main(String[] args) {
// ※ この問題はJamクラス、Toastクラスを完成させてから解いてください。
// TODO Jam型のインスタンスを引数 ブルーベリー で作成してください
// TODO Toast型のインスタンスを作成してください。
// TODO 作成したToast型インスタンスからtasteメソッドを呼び出してください
}
}

View File

@@ -0,0 +1,23 @@
public class Student {
String name; // 生徒の名前
static String group; // 教室の名前
static String teacher; // 先生の名前
/**
* 生徒のプロフィールを出力する
*/
void studentProfile() {
System.out.println(this.name + "は" + group + "教室の生徒です");
}
/**
* 教室のプロフィールを出力する。
*/
static void groupProfile() {
System.out.println(group + "教室の担任は" + teacher + "先生です。");
}
}

View File

@@ -0,0 +1,20 @@
public class Toast {
// TODO Jam型のフィールドjamを作成してください
/*
* TODO 以下のコンストラクタを作成してください
* 引数 :Jam型 jam
* 処理 :引数のjamをjamフィールドに代入する
*/
/*
* TODO tasteメソッドを作成してください
* 引数 :なし
* 戻り値 :なし
* 処理 :xx 味のトーストです。 出力する
* ※ xxにはjamフィールドのmaterialの値が入る
*/
}

View File

@@ -0,0 +1,22 @@
public class User {
String name;
Wallet wallet;
/**
* 引数で渡された金額を、walletフィールドのmoneyから引く
* @param money
*/
void useMoney(int money) {
this.wallet.money -= money;
System.out.println(this.name +"は財布の中のお金を" + money + "円使用しました");
}
/**
* 財布の中の金額を出力する
*/
void confirmWallet() {
System.out.println(this.name +"の財布の中の残額は" + this.wallet.money + "円です");
}
}

View File

@@ -0,0 +1,5 @@
public class Wallet {
int money;
}

View File

@@ -0,0 +1,9 @@
/*
* ItemA.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class ItemA {
private String name = "アイテムA";
}

View File

@@ -0,0 +1,26 @@
/*
* PTra12_01.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
import common.User;
public class PTra12_01 {
public static void main(String[] args) {
// ※ この問題はcommonパッケージのUserクラスを完成させてから解いてください。
/*
* TODO インスタンスフィールドへのアクセスをアクセサ経由に変更してください
*/
User user = new User();
user.userId = 1000;
user.userName = "リゾーム太郎";
user.mailAddress ="rhizome@hogehoge.com";
user.password = "12345";
System.out.println("ID :" + user.userId);
System.out.println("名前 :" + user.userName);
System.out.println("メールアドレス  :" + user.mailAddress);
System.out.println("パスワード  :" + user.password);
}
}

View File

@@ -0,0 +1,16 @@
/*
* PTra12_02.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
// TODO 同一パッケージのItemAクラスを変更してエラーが出ないようにしてください。
// ※ このクラスの内容は変更しないこと
public class PTra12_02 {
public static void main(String[] args) {
ItemA item = new ItemA();
System.out.println(item.name);
}
}

View File

@@ -0,0 +1,18 @@
import common.ItemB;
/*
* PTra12_03.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
//TODO commonパッケージのItemBクラスを変更してエラーが出ないようにしてください。
//※ このクラスの内容は変更しないこと
public class PTra12_03 {
public static void main(String[] args) {
ItemB item2 = new ItemB();
System.out.println(item2.name);
}
}

View File

@@ -0,0 +1,11 @@
package common;
/*
* ItemB.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class ItemB {
String name = "アイテムB";
}

View File

@@ -0,0 +1,18 @@
package common;
/*
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class User {
// TODO 各フィールドにprivateアクセス修飾子を指定してください
int userId;
String userName;
String mailAddress;
String password;
// TODO 各フィールドのアクセサを作成してください
}

View File

@@ -0,0 +1,21 @@
/*
* PTra13_01.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra13_01 {
public static void main(String[] args) {
//※ この問題はcommonパッケージのCatクラスを完成させてから解いてください。
// TODO commonパッケージのCatクラスをインスタンス化してください
// TODO Cat型インスタンスのnameフィールドに タマ を代入してください
// TODO Cat型インスタンスのrunメソッドを実行してください
// ※ タマは走りました。が表示されれば正解
// TODO Cat型インスタンスのeatメソッドを実行してください
// ※ タマは食事をしました。が表示されれば正解
}
}

View File

@@ -0,0 +1,21 @@
/*
* PTra13_02.java
* 作成 Rhizome
*------------------------------------------------------------
*/
public class PTra13_02 {
public static void main(String[] args) {
//※ この問題はcommonパッケージのDogクラスを完成させてから解いてください。
// TODO commonパッケージのDogクラスをインスタンス化してください
// TODO Dog型インスタンスのnameフィールドに ポチ を代入してください
// TODO Dog型インスタンスのrunメソッドを実行してください
// ※ ポチは走りました。が表示されれば正解
// TODO Dog型インスタンスのeatメソッドを実行してください
// ※ ポチはドッグフードを食べました。が表示されれば正解
}
}

View File

@@ -0,0 +1,24 @@
/*
* PTra13_03.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra13_03 {
/*
* TODO commonパッケージ内に、Characterクラスを継承した、Heroクラスを作成してから解いてください。
* ●HP, POWER, ENDURANCEはそれぞれ、(25, 10, 7)
*/
//※Heroクラスに継承したCharacterクラスをよく読んでから解いてください。
public static void main(String[] args) {
// TODO Heroクラスをインスタンス化してください
// TODO Heroインスタンスのnameフィールドに 勇者 を設定して下さい
// TODO Heroインスタンスのキャラクター情報を表示してください
}
}

View File

@@ -0,0 +1,22 @@
/*
* PTra13_04.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra13_04 {
/* TODO commonパッケージにCharacterクラスを継承した、Slimeクラスを作成してから解いてください。
* ●HP, POWER, ENDURANCEはそれぞれ、(10, 5, 2)
*/
//※Slimeクラスに継承したCharacterクラスをよく読んでから解いてください。
public static void main(String[] args) {
// TODO Slimeクラスをインスタンス化してください
// TODO Slimeインスタンスのnameフィールドに スライム を設定して下さい
// TODO Slimeインスタンスのキャラクター情報を表示してください
}
}

View File

@@ -0,0 +1,23 @@
/*
* PTra13_05.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra13_05 {
public static void main(String[] args) {
//※この問題はPTra13_03、PTra13_04で作成したHero、Slimeクラスを使用して解いてください。
// TODO HeroインスタンスとSlimeインスタンスを作成し、それぞれの名前に"勇者", "スライム"を設定してください
/*
* TODO HeroとSlimeを、どちらかが体力0になるまで戦わせます
*
* ●Heroの攻撃 -> ダメージ判定 -> Slimeの攻撃 -> ダメージ判定
* 上記を繰り返し行います
*
* 戦いが終了したら、勝利した方の出力を行ってください。「○○は■■との戦闘に勝利した」
*/
}
}

View File

@@ -0,0 +1,33 @@
/*
* PTra13_06.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra13_06 {
/*
* TODO commonパッケージにHeroクラスを継承した、SuperHeroクラスを作成してから解いてください。
* ●HP, POWER, ENDURANCEはHeroと同じでそれぞれ、(25, 10, 7)
*
* フィールド
* Item item
* メソッド
* attackメソッドをオーバーライドし、
* powerフィールドの値に加えて、itemフィールドのadditionalDamage分を加算した値を返す
*
* itemフィールドのアクセサ
*/
public static void main(String[] args) {
// TODO SuperHeroインスタンスとSlimeインスタンスを作成し、それぞれの名前に"勇者(装備あり)", "スライム"を設定してください
// TODO Itemクラスのインスタンスを作成し、("こんぼう", 5)をコンストラクタの引数にしてください
// TODO SuperHeroインスタンスのitemフィールドに作成したitemインスタンスを設定してください
// TODO SuperHeroインスタンスのattackメソッドを呼び出して、戻り値を出力してください
// ※ 15と出力されれば正解
}
}

View File

@@ -0,0 +1,27 @@
/*
* PTra13_07.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra13_07 {
public static void main(String[] args) {
//※この問題はPTra13_03、PTra13_04で作成したHero、Slimeクラスを使用して解いてください。
// TODO SuperHeroインスタンスとSlimeインスタンスを作成し、それぞれの名前に"勇者(装備あり)", "スライム"を設定してください
// TODO Itemクラスのインスタンスを作成し、("ロングソード", 20)をコンストラクタの引数にしてください
// TODO SuperHeroインスタンスのitemフィールドに作成したitemインスタンスを設定してください
/*
* TODO SuperHeroとSlimeを、どちらかが体力0になるまで戦わせます
*
* ●SuperHeroの攻撃 -> ダメージ判定 -> Slimeの攻撃 -> ダメージ判定
* 上記を繰り返し行います
*
* 戦闘が終了したら、勝利した方の出力を行ってください。「○○は■■との戦闘に勝利した」
*/
}
}

View File

@@ -0,0 +1,46 @@
/*
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
package common;
/**
* 動物の情報や行動を持ったクラスです
*
*/
public class Animal {
/** 名前 */
private String name;
/**
* 行動:走る
*/
public void run() {
System.out.println(this.name + "は走りました。");
}
/**
* 行動:食べる
*/
public void eat() {
System.out.println(this.name + "は食事をしました。");
}
/**
* Setter
* @param name
*/
public void setName(String name) {
this.name = name;
}
/**
* Getter
* @return
*/
public String getName() {
return this.name;
}
}

View File

@@ -0,0 +1,12 @@
package common;
/*
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
// TODO 同一パッケージのAnimalクラスを継承してください
public class Cat {
}

View File

@@ -0,0 +1,119 @@
/*
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
package common;
/**
* 登場するキャラクターの情報とデフォルトの行動を設定したクラスです
* @author rhizome
*
*/
public class Character {
/** 名前 */
private String name = "キャラクター";
/** 体力 */
private int hp;
/** 力 */
private int power;
/** 防御力 */
private int endurance;
/**
* 体力、攻撃力、防御力の初期値を設定しつつ、Characterインスタンスを生成します
* @param hp
* @param attack
* @param defence
*/
public Character(int hp, int power, int endurance) {
this.hp = hp;
this.power = power;
this.endurance = endurance;
}
/**
* 名前を設定します
* @param name 設定したい名前
*/
public void setName(String name) {
this.name = name;
}
/**
* 名前を取得します
* @return 名前
*/
public String getName() {
return this.name;
}
/**
* 攻撃を行います
* @return 相手に与えるダメージを返します
*/
public int attack() {
return this.power;
}
/**
* ダメージ判定を行います
* @param attack 攻撃値
* @return 体力が0になったらtrue、まだ体力が残っていたらfalse
*/
public boolean damage(int attack) {
boolean deadFlg = false;
// ダメージ計算
int damage = attack - this.endurance;
if (damage <= 0) {
// 必ず1ダメージは入るようにする
damage = 1;
}
// ダメージ分体力を減らす
this.hp -= damage;
// 体力がなくなったかどうかの判定
if (this.hp <= 0) {
// 体力が負の値になったら0に設定する
this.hp = 0;
deadFlg = true;
System.out.println(this.name + "は" + damage + "のダメージを受けた。");
System.out.println(this.name + "の残り体力は" + this.hp + "。");
System.out.println(this.name + "は" + "ちからつきた。");
} else {
System.out.println(this.name + "は" + damage + "のダメージを受けた。");
System.out.println(this.name + "の残り体力は" + this.hp + "。");
}
System.out.println("↓");
return deadFlg;
}
/**
* キャラクター情報を表示します
* @return
*/
public String showParameter() {
StringBuilder str = new StringBuilder();
str.append("名 前:" + this.name);
str.append("\n");
str.append("体 力:" + this.hp);
str.append("\n");
str.append(" 力 :" + this.power);
str.append("\n");
str.append("耐 久:" + this.endurance);
return str.toString();
}
}

View File

@@ -0,0 +1,16 @@
/*
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
package common;
// TODO 同一パッケージのAnimalクラスを継承してください
public class Dog {
/*
* TODO eatメソッドをオーバーライドして以下の内容が出力されるようにしてください。
* name はドッグフードを食べました
* ※ name には name フィールドの値が入る
*/
}

View File

@@ -0,0 +1,62 @@
/*
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
package common;
/**
* 装備品オブジェクト
* @author rhizome
*
*/
public class Item {
/** アイテム名 */
private String name;
/** 追加ダメージ量 */
private int additionalDamage;
/**
* 装備品の初期値を設定するコンストラクタ
* @param name 装備品名
* @param additionalDamage 追加ダメージ
*/
public Item(String name, int additionalDamage) {
this.name = name;
this.additionalDamage = additionalDamage;
}
/**
* アイテム名を取得します
* @return アイテム名
*/
public String getName() {
return name;
}
/**
* アイテム名を設定します
* @param name 設定したいアイテム名
*/
public void setName(String name) {
this.name = name;
}
/**
* 追加ダメージを取得します
* @return 追加ダメージ
*/
public int getAdditionalDamage() {
return additionalDamage;
}
/**
* 追加ダメージを設定します
* @param additionalDamage 設定したい追加ダメージ
*/
public void setAdditionalDamage(int additionalDamage) {
this.additionalDamage = additionalDamage;
}
}

View File

@@ -0,0 +1,17 @@
/*
* PTra14_01.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra14_01 {
public static void main(String[] args) {
//※ この問題はcommonパッケージのJavaBasicBookクラスを完成させてから解いてください。
// TODO commonパッケージのJavaBasicBookクラスをインスタンス化してください
// TODO インスタンスから本のタイトルを取得して出力してください
// TODO インスタンスから章立てのリストを取得して出力してください
}
}

View File

@@ -0,0 +1,22 @@
/*
* PTra14_02.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra14_02 {
public static void main(String[] args) {
//※ この問題はcommonパッケージのSportsCarクラスを作成してから解いてください。
// TODO commonパッケージのSportsCarクラスをインスタンス化してください
// TODO スポーツカーにハイオクを100リットル補充してください
// ※ ハイオクを100リットル補充した と表示されれば正解
// TODO スポーツカー時速100キロで走ってください。
// ※ スポーツカーは時速100キロで走った と表示されれば正解
// TODO スポーツカー時速301キロで走ってください。
// ※ 速度オーバーです と表示されれば正解
}
}

Some files were not shown because too many files have changed in this diff Show More