1030自主学習
This commit is contained in:
6
Question14-Interface/.classpath
Normal file
6
Question14-Interface/.classpath
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21"/>
|
||||
<classpathentry kind="src" path="src/main/java"/>
|
||||
<classpathentry kind="output" path="build/classes"/>
|
||||
</classpath>
|
||||
1
Question14-Interface/.gitignore
vendored
Normal file
1
Question14-Interface/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build/
|
||||
23
Question14-Interface/.project
Normal file
23
Question14-Interface/.project
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Question14-Interface</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.common.project.facet.core.builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,9 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=21
|
||||
org.eclipse.jdt.core.compiler.compliance=21
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=21
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<installed facet="java" version="21"/>
|
||||
</faceted-project>
|
||||
6
Question14-Interface/src/main/java/Book.java
Normal file
6
Question14-Interface/src/main/java/Book.java
Normal file
@@ -0,0 +1,6 @@
|
||||
import java.util.List;
|
||||
|
||||
public interface Book {
|
||||
String title();
|
||||
List <String> chapter();
|
||||
}
|
||||
21
Question14-Interface/src/main/java/Book1_programming.java
Normal file
21
Question14-Interface/src/main/java/Book1_programming.java
Normal file
@@ -0,0 +1,21 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Book1_programming implements Book{
|
||||
public String title() {
|
||||
return "プログラミング基礎入門";
|
||||
}
|
||||
|
||||
|
||||
public List <String> chapter(){
|
||||
List <String> chapter = new ArrayList<String>();
|
||||
chapter.add("式と変数");
|
||||
chapter.add("制御構文");
|
||||
chapter.add("メソッド");
|
||||
chapter.add("オブジェクト指向");
|
||||
chapter.add("継承");
|
||||
return chapter;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
5
Question14-Interface/src/main/java/Car.java
Normal file
5
Question14-Interface/src/main/java/Car.java
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
public interface Car {
|
||||
void refill(int amount);
|
||||
void run(int speed);
|
||||
}
|
||||
11
Question14-Interface/src/main/java/Question14_1.java
Normal file
11
Question14-Interface/src/main/java/Question14_1.java
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
public class Question14_1 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
Book1_programming book = new Book1_programming();
|
||||
System.out.println(book.title());
|
||||
System.out.println(book.chapter());
|
||||
}
|
||||
|
||||
}
|
||||
11
Question14-Interface/src/main/java/Question14_2.java
Normal file
11
Question14-Interface/src/main/java/Question14_2.java
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
public class Question14_2 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
sportCar car = new sportCar();
|
||||
car.refill(100);
|
||||
car.run(100);
|
||||
car.run(301);
|
||||
}
|
||||
}
|
||||
14
Question14-Interface/src/main/java/sportCar.java
Normal file
14
Question14-Interface/src/main/java/sportCar.java
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
public class sportCar implements Car{
|
||||
public void refill(int num) {
|
||||
System.out.println("ハイオクを" + num + "リットル補充した");
|
||||
}
|
||||
|
||||
public void run(int speed) {
|
||||
if(speed > 300) {
|
||||
System.out.println("速度オーバーです");
|
||||
}else {
|
||||
System.out.println("スポーツカーは時速" + speed + "キロで走った");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user