package yue;
import java.util.Scanner;
class MyException extends Exception{
public MyException(){
super();
}
public MyException (String message){
super (message);
}
}
class My{
public void play(int a,int b,int c) throws MyException{
if(a+b<c||a+c<b||b+c<a){
throw new MyException("不能構成三角形");
}
System.out.println("能構成三角形");
}
}
public class Trangle{
static double a,b,c;
private static Scanner scan;
public Trangle()
{
}
public double getCircle()
{
return a+b+c;
}
public double getArea()
{
double p=(a+b+c)/2.0;
double s=Math.sqrt(p*(p-a)*(p-b)*(p-c));
return s;
}
public static void main(String[] args) throws MyException{
try{
Trangle S=new Trangle();
for(int i=0;i<1;){
System.out.println("輸入三角形三邊長:");
scan = new Scanner(System.in);
a=scan.nextDouble();
b=scan.nextDouble();
c=scan.nextDouble();
}
}catch( MyException e) {
System. out.println("例外:"+e.toString());
System.out.println(e.getMessage());
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/268594.html
標籤:Java相關
上一篇:介面中可以有實體方法嗎
下一篇:chrome自動下載eml檔案,而不顯示郵件內容,response.setContentType("message/rfc822");
