Last active
December 1, 2016 08:07
-
-
Save kdmgs110/a0e504ebef941b9bef97ecda01f82b23 to your computer and use it in GitHub Desktop.
童貞判定プログラム
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package pass01; | |
import lib.Input; | |
public class Pass01_01 { | |
/*複数のメソッドを持つクラス | |
* 過去の経験人数を入力すると、からヤリチン、かろうじて非童貞、童貞にランク付けしてくれるシステム | |
*/ | |
public static void main(String[] args) { | |
dispTitle(); //titleメソッド | |
String name = Input.getString("おぬしの名前を教えてくれ");// 名前を入力する | |
int number = Input.getInt("経験人数を教えてくれ"); | |
String grade = toGrade(number);//経験人数で各付けしてくれるメソッド | |
dispResult(name,number,grade); | |
} | |
public static void dispTitle(){ | |
System.out.println("*****童貞診断を始めるのじゃ*****");//disTitleメソッドの中身 | |
} | |
public static String toGrade(int number){ // toGradeメソッド名。引数は経験人数 | |
String grade; //メソッド内はローカル変数なので、同じ変数(grade)を使用してよい。 | |
if (number >=2){ //経験人数が2人以上 | |
grade = "ヤリチン"; | |
} else if (number == 1){ | |
grade ="かろうじて非童貞"; | |
}else{ | |
grade = "童貞"; | |
} | |
return grade; | |
} | |
public static void dispResult(String name, int number,String grade){ | |
System.out.println("おぬしの名前は"+name+"じゃ。"); | |
System.out.println("おぬしの経験人数は"+number+"人じゃ。"); | |
System.out.println("よって"+grade+"じゃ。"); | |
} | |
} | |
/* コンソール | |
*****童貞診断を始めるのじゃ***** | |
[おぬしの名前を教えてくれ]>dai | |
[経験人数を教えてくれ]>0 | |
おぬしの名前はdaiじゃ。 | |
おぬしの経験人数は0人じゃ。 | |
よって童貞じゃ。 | |
*/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment