0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

くじ引き

Last updated at Posted at 2022-12-08

中身クラス

くじ引きの中のクラスです

public class nakami {

	int n;

	nakami(int number){
		n=number;
	}

	public String toString() {

			  if(n==0) {
			return n+" : 大吉";
		}else if(n==1) {
			return n+" : 中吉";
		}else if(n==2) {
			return n+" : 小吉";
		}else if(n==3) {
			return n+" : 吉";
		}else if(n==4) {
			return n+" : 末吉";
		}else if(n==5) {
			return n+" : 凶";
		}else if(n==6) {
			return n+" : 大凶";
		}else if(n==7) {
			return n+" : 諭吉";
		}else if(n==8) {
			return n+" : ピース又吉";
		}else if(n==9) {
			return n+" : 吉田沙保里";
		}else {
			return null;
		}

	}

}

くじ引き(動作確認)クラス

くじを引くためのクラスです。


import java.util.Scanner;

public class kujibiki {

	public static void main(String[] args) {

		System.out.println("くじを引きましょう! ( 0 ~ 9 を入力)");
		Scanner num=new Scanner(System.in);
		int n=num.nextInt();

		nakami un=new nakami(n);
		System.out.println(un);

	}

}

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?