完了済
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>
|
||||
7
Question14-Interface/src/main/java/Book.java
Normal file
7
Question14-Interface/src/main/java/Book.java
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
public interface Book {
|
||||
|
||||
String getTitle();
|
||||
String[] getChapters();
|
||||
|
||||
}
|
||||
7
Question14-Interface/src/main/java/Car.java
Normal file
7
Question14-Interface/src/main/java/Car.java
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
public interface Car {
|
||||
|
||||
void Charge(int gasoline);
|
||||
void Run(int velocity);
|
||||
|
||||
}
|
||||
20
Question14-Interface/src/main/java/ProgrammingBook.java
Normal file
20
Question14-Interface/src/main/java/ProgrammingBook.java
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
public class ProgrammingBook implements Book {
|
||||
|
||||
String title;
|
||||
String[] chapters;
|
||||
|
||||
public ProgrammingBook(String title,String[] chapters) {
|
||||
this.title = title;
|
||||
this.chapters = chapters;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public String[] getChapters() {
|
||||
return this.chapters;
|
||||
}
|
||||
|
||||
}
|
||||
17
Question14-Interface/src/main/java/Question14_1.java
Normal file
17
Question14-Interface/src/main/java/Question14_1.java
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
public class Question14_1 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
|
||||
String title = "プログラミング基礎入門";
|
||||
String[] chapters = {"式と変数","制御構文","メソッド","オブジェクト指向","継承"};
|
||||
ProgrammingBook pb = new ProgrammingBook(title,chapters);
|
||||
|
||||
System.out.println(pb.getTitle());
|
||||
for (String s:pb.getChapters()) {
|
||||
System.out.print(s+" ");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
14
Question14-Interface/src/main/java/Question14_2.java
Normal file
14
Question14-Interface/src/main/java/Question14_2.java
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
public class Question14_2 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
|
||||
SportCar sc = new SportCar();
|
||||
sc.Charge(100);
|
||||
sc.Run(100);
|
||||
sc.Run(301);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
16
Question14-Interface/src/main/java/SportCar.java
Normal file
16
Question14-Interface/src/main/java/SportCar.java
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
public class SportCar implements Car {
|
||||
|
||||
public void Charge(int gasoline) {
|
||||
System.out.println("ハイオクを"+gasoline+"リットル補充した");
|
||||
}
|
||||
|
||||
public void Run(int velocity) {
|
||||
if (velocity>300) {
|
||||
System.out.println("速度オーバーです");
|
||||
} else {
|
||||
System.out.println("スポーツカーは時速"+velocity+"キロで走った");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user