This commit is contained in:
m-mun
2026-09-09 08:34:32 +09:00
parent 8e67b4ccb9
commit 1b863df929
181 changed files with 34869 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
/*
* PTra15_01.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra15_01 {
public static void main(String[] args) {
//※ この問題はcommonパッケージのクラスを使用して解いてください。
// TODO SportsCar型のインスタンスをCar型の変数に代入してください
// TODO 作成したインスタンスのrunメソッドを実行してください。
// ※ スポーツカーは時速100で走った と表示されれば正解
// TODO Truck型のインスタンスをCar型の変数に代入してください
// TODO 作成したインスタンスのrunメソッドを実行してください。
// ※ トラックは時速30で走った
}
}

View File

@@ -0,0 +1,26 @@
/*
* PTra15_02.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra15_02 {
public static void main(String[] args) {
//※ この問題はcommonパッケージのクラスを使用して解いてください。
// TODO SportsCar型のインスタンスをCar型の変数に代入してください
// TODO Truck型のインスタンスをCar型の変数に代入してください
// TODO Car型の配列を作成して、上記2つのインスタンスを追加してください
/* TODO carListの中身を順番に取り出して、runメソッドを実行してください。
*
* 以下が表示されれば正解
*
* スポーツカーは時速100で走った
* トラックは時速30で走った
*/
}
}

View File

@@ -0,0 +1,22 @@
import common.Car;
import common.SportsCar;
/*
* PTra15_03.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra15_03 {
public static void main(String[] args) {
//※ この問題はcommonパッケージのクラスを使用して解いてください。
Car car = new SportsCar();
// TODO キャストを利用してSportsCarクラスに car 変数を代入してください。
// TODO turboメソッドを実行してください。
// ※ スポーツカーは時速300で走った と表示されれば正解
}
}

View File

@@ -0,0 +1,41 @@
/*
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
package common;
public class Car {
private String name;
private int speed;
public Car(String name, int speed) {
this.name = name;
this.speed = speed;
}
/**
* 設定されたスピードで走る
*/
public void run() {
System.out.println(this.name + "は時速" + this.speed + "で走った");
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getSpeed() {
return speed;
}
public void setSpeed(int speed) {
this.speed = speed;
}
}

View File

@@ -0,0 +1,19 @@
/*
* PTra12_01.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
package common;
public class SportsCar extends Car{
public SportsCar() {
super("スポーツカー", 100);
}
/**
* 設定されたスピードの3倍の速度で走る
*/
public void turbo() {
System.out.println(super.getName() + "は時速" + (super.getSpeed() * 3 ) + "で走った");
}
}

View File

@@ -0,0 +1,13 @@
/*
* PTra12_01.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
package common;
public class Truck extends Car{
public Truck() {
super("トラック", 30);
}
}