- package A01;
- import java.util.Scanner;
- public class A02
- {
- static Scanner s=new Scanner(System.in);
- //方法中發生例外但沒處理,以throws語法拋給呼叫者處理
- public static void main(String[] args) throws MyException
- {
- pokemon fire=new pokemon();
- fire.name="小火龍";
- fire.AD=15;
- fire.AP=5;
-
- pokemon water=new pokemon();
- water.name="傑尼龜";
- water.AD=10;
- water.AP=10;
-
- pokemon grass=new pokemon();
- grass.name="妙蛙種子";
- grass.AD=5;
- grass.AP=15;
-
- System.out.println(fire.name+"有"+fire.AD+"AD,"+"有"+fire.AP+"AP,");
- System.out.println(water.name+"有"+fire.AD+"AD,"+"有"+water.AP+"AP,");
- System.out.println(grass.name+"有"+grass.AD+"AD,"+"有"+grass.AP+"AP,");
- }
- }
- class pokemon
- {
- String name;
- int AD;
- int AP;
-
-
- }
複製代碼 回復 1# 陳弘修 |