diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..ff061dd --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,14 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ], + "java.completion.filteredTypes": [ + "com.sun.*", + "sun.*", + "jdk.*", + "org.graalvm.*", + "io.micrometer.shaded.*" + ] +} 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..baa6c67 --- /dev/null +++ b/bin/App.class Binary files differ diff --git a/bin/BigB.class b/bin/BigB.class new file mode 100644 index 0000000..67519fa --- /dev/null +++ b/bin/BigB.class Binary files differ diff --git a/bin/FirstGUI.class b/bin/FirstGUI.class new file mode 100644 index 0000000..1b2a49d --- /dev/null +++ b/bin/FirstGUI.class Binary files differ diff --git a/bin/NikumakiOnigiri.class b/bin/NikumakiOnigiri.class new file mode 100644 index 0000000..d9a0bd8 --- /dev/null +++ b/bin/NikumakiOnigiri.class Binary files differ diff --git a/bin/Onigiri.class b/bin/Onigiri.class new file mode 100644 index 0000000..1829bae --- /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..7655096 --- /dev/null +++ b/bin/YakiOnigiri.class Binary files differ diff --git a/src/App.java b/src/App.java new file mode 100644 index 0000000..0a839f9 --- /dev/null +++ b/src/App.java @@ -0,0 +1,5 @@ +public class App { + public static void main(String[] args) throws Exception { + System.out.println("Hello, World!"); + } +} diff --git a/src/FirstGUI.java b/src/FirstGUI.java new file mode 100644 index 0000000..fa70abd --- /dev/null +++ b/src/FirstGUI.java @@ -0,0 +1,42 @@ +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JFrame; + +class BigB extends JButton { + BigB(String label) { + super(label); + } + + public Dimension getPreferredSize() { + Dimension oyaD = super.getPreferredSize(); + return new Dimension(oyaD.width * 2, oyaD.height * 2); + } +} + +public class FirstGUI implements ActionListener { + static JFrame parent; + + public static void main(String[] args) { + + JFrame jf = new JFrame("FirstGUI"); + jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + parent = jf; + + JButton jb = new BigB("BigSize asfdasdfasdf sdf");// JButton("Button"); + jf.getContentPane().add(jb); + jf.getContentPane().add(new JButton("2nd Button"), BorderLayout.SOUTH); + jb.addActionListener(new FirstGUI()); + jf.setSize(300, 300); + jf.setVisible(true); + } + + @Override + public void actionPerformed(ActionEvent e) { + System.out.println(e.getActionCommand()); + parent.pack(); + } +} diff --git a/src/Onigiri.java b/src/Onigiri.java new file mode 100644 index 0000000..9f0254e --- /dev/null +++ b/src/Onigiri.java @@ -0,0 +1,97 @@ +import java.util.ArrayList; + +public class Onigiri extends Object{ + static int count = 0 ; // Onigiri.count = 9 ; + static ArrayList list; + static { + list = new ArrayList(); + } + // フィールド/メンバ=データの詳細 + String gu ; /* おにぎりの具名 */ + boolean withNori; /* 海苔がついているか? true / false */ + int shape ; /* 0:丸, 1:俵型, 3:三角形 */ + + //コンストラクタ=データ製造機 + public Onigiri() { + gu = "無し(塩むすび)"; + withNori = false; + shape = 3; + count++ ; list.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; + } + + public static void main(String[] args) { + //基本のおにぎりをつくる + //コンストラクタを呼び出し,インスタンスを生成 + 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 oni : list){ + System.out.println(oni.toString()); + } + YakiOnigiri yaki = new YakiOnigiri(); + yaki.setWithNori(true); + System.out.println(yaki.getClass().getName()); + System.out.println(yaki.toString()); + } +} +class YakiOnigiri extends Onigiri { + boolean koge = false; + public String toString(){ + String mes = super.toString(); + String kogemes = (koge)? "焦げあり" : "焦げなし"; + return mes+kogemes; + } +} +class NikumakiOnigiri extends Onigiri { + String niku; +} +