diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..829f0a2 --- /dev/null +++ b/.DS_Store Binary files differ diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..96ee3d1 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin" +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +## Getting Started + +Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code. + +## Folder Structure + +The workspace contains two folders by default, where: + +- `src`: the folder to maintain sources +- `lib`: the folder to maintain dependencies + +Meanwhile, the compiled output files will be generated in the `bin` folder by default. + +> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there. + +## Dependency Management + +The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies). diff --git a/bin/App.class b/bin/App.class new file mode 100644 index 0000000..aa90a01 --- /dev/null +++ b/bin/App.class Binary files differ diff --git a/bin/Onigiri.class b/bin/Onigiri.class new file mode 100644 index 0000000..b4ab8ae --- /dev/null +++ b/bin/Onigiri.class Binary files differ diff --git a/bin/YakiOnigiri.class b/bin/YakiOnigiri.class new file mode 100644 index 0000000..8c3d670 --- /dev/null +++ b/bin/YakiOnigiri.class Binary files differ diff --git a/bin/pack/InPackage.class b/bin/pack/InPackage.class new file mode 100644 index 0000000..fdbd8fa --- /dev/null +++ b/bin/pack/InPackage.class Binary files differ diff --git a/src/App.java b/src/App.java new file mode 100644 index 0000000..30238ce --- /dev/null +++ b/src/App.java @@ -0,0 +1,32 @@ +//import javax.swing.JOptionPane; + +public class App { + public static void main(String[] args) throws Exception { + javax.swing.JOptionPane.showMessageDialog(null, "message", "title", javax.swing.JOptionPane.INFORMATION_MESSAGE); + System.out.println("Hello, World!"); + // 基本のおにぎりをつくる + // コンストラクタを呼び出し、インスタンスを生成 + Onigiri siomusubi = new Onigiri(); + System.out.println("siomusubi = " + siomusubi.toString()); + + Onigiri ume = new Onigiri("梅", true); + System.out.println("ume = " + ume.toString()); + + Onigiri marusake = new Onigiri("鮭", 0); + System.out.println("marusake = " + marusake.toString()); + + Onigiri mentai = new Onigiri("明太子", true, 1); + System.out.println("mentai = " + mentai.toString()); + + Onigiri okaka = new Onigiri("おかか", false, 3); + System.out.println("okaka = " + okaka.toString()); + + System.out.println(Onigiri.count + "個のおにぎりをつくりました"); + for(Onigiri x : Onigiri.all){ + System.out.println(x.toString()); + } + + System.out.println( new YakiOnigiri().toString() ); + + } +} diff --git a/src/Onigiri.java b/src/Onigiri.java new file mode 100644 index 0000000..3faedbe --- /dev/null +++ b/src/Onigiri.java @@ -0,0 +1,76 @@ +import java.util.ArrayList; + +public class Onigiri { + static int count = 0; //つくったおにぎりの数をカウントする + static void printCount(){ + System.out.println(count + "個のおにぎりをつくりました"); + } + static ArrayList all; + static { + all = new ArrayList(); + } + + public static void main(String[] args) { + Onigiri ume = new Onigiri("梅", true); + System.out.println("ume = " + ume.toString()); + System.out.println(count + "個のおにぎりをつくりました"); + + System.out.println( new YakiOnigiri().toString() ); + } + + // フィールド/メンバ=データの詳細 + String gu; /* おにぎりの具名 */ + boolean withNori; /* 海苔がついているか? true / false */ + int shape; /* 0:丸, 1:俵型, 3:三角形 */ + + // コンストラクタ=データ製造機 + public Onigiri() { + gu = "無し(塩むすび)"; + withNori = false; + shape = 3; + Onigiri.count++; + Onigiri.all.add(this); + } + + public Onigiri(String _gu) { + this(); + gu = _gu; + } + + public Onigiri(String gu, int shape) { + this(gu); + this.shape = shape; + } + + public Onigiri(String gu, boolean wnori) { + this(gu); + withNori = wnori; + } + + public Onigiri(String gu, boolean wnori, int shape) { + this(gu, wnori); + this.shape = shape; + } + + // メソッドの役割:(1) データの修正・更新をする (2) データに関する情報を出力 (3) データに関する処理 + public void setWithNori(boolean wnori) { + withNori = wnori; + } + + public String toString() { + String str = "具は " + gu + " で、"; + switch (shape) { + case 0: + str = str + "丸型で、"; + break; + case 1: + str = str + "俵型で、"; + break; + case 3: + str = str + "三角形で、"; + break; + } + str = str + (withNori ? "海苔付き" : "海苔なし"); + return str; + } +} diff --git a/src/YakiOnigiri.java b/src/YakiOnigiri.java new file mode 100644 index 0000000..6ade19a --- /dev/null +++ b/src/YakiOnigiri.java @@ -0,0 +1,13 @@ +public class YakiOnigiri extends Onigiri { + boolean koge = true; + + public YakiOnigiri() { + super();// 親クラスのコンストラクタを呼び出す + // new Onigiri() + } + + public String toString() { + String mes = super.toString(); + return mes + "こげは " + koge; + } +} diff --git a/src/pack/InPackage.java b/src/pack/InPackage.java new file mode 100644 index 0000000..89effb1 --- /dev/null +++ b/src/pack/InPackage.java @@ -0,0 +1,5 @@ +package pack; + +public class InPackage { + +}