资 源 简 介
(1) 设计一个程序,用于根据用户输入的命令行参数数量来计算长方形、正方形、三角形的面积。如果输入的参数为一个、二个、三个则它们应分别对应正方形、长方形、三角形,如果没有参数,则通过异常处理方法现实错误消息。(用于计算面积的方法是一个重载的方法。提示:定义一个抽象的父类,并提供一个抽象的方法area(). 再派生出三个子类,重写area()方法,然后在main方法中用多态来实现具体的面积函数的调用)。-(1) design a program based on user input for the command line parameters to calculate the number of rectangular, square, triangle area. If the input parameter is one, two, three then they should correspond to a square, rectangle, triangle, without parameters, exception handling through the real error message. (Used to calculate the area is an overloaded method. Note: the definition of an abstract parent class, and provides an abstract method area (). To send birth to three sub-classes override area () method, and then in main method using multi-state to achieve a specific area of a function call).