java 08 作业

三角形的三边之和

------------------------------------------------------------------------

class Triangthroeb{
public static void main(String[] agrs) {
Person p = new Person();
try{
p.Person(1,1,3);
}
catch(TriangchaException e){
e.printlnError();

}

catch(TriangException e){
e.printlnError();

}
finally {
System.out.println("程序执行完毕");

}

}
}

class Person{
private int a;
private int b;
private int c;

/* public Person (int a , int b , int c)throws TriangchaException,TriangException{
if (a<0||b<0||c<0 ){

throw new TriangException("参数为负数");
}
else if (a+b < c ||a+c < b ||b+c < a){
throw new TriangchaException();
}

this.int a = a;
this.int b = b;
this.int c = c;
} */


public int Person(int a,int b,int c) throws TriangchaException,TriangException{
if (a<0||b<0||c<0 ){

throw new TriangException("参数为负数");
}
else if (a+b < c ||a+c < b ||b+c < a){
throw new TriangchaException();
}

return a;

}
}


class TriangException extends Exception{
private String info;
public TriangException (String info){
this.info =info;
}
public void printlnError(){
System.out.println(info);
}
}

class TriangchaException extends TriangException{
public TriangchaException (String info){
super(info);
}
public TriangchaException(){
this("两边之和小于第三边");
}
}

------------------------------------------------------------------

判断输入的日期是否正确

(年份,月份,日)

代写  课程在09-01作业即可查看

年 ;;;;

月 1-12

日 1-31  除了2月

public int year,mounth, date

public  void  setBirthday(int year,int mounth,int date) {

}

原文地址:https://www.cnblogs.com/simly/p/10283496.html