Thread: exception
View Single Post
  #3 (permalink)  
Old 03-23-2008, 08:01 PM
Oktam Oktam is offline
Member
 
Join Date: Mar 2008
Posts: 3
Oktam is on a distinguished road
Tnx Capt ...but...it seems i didn't define my problem well enough...here goes.. i'll put a part of my programme here...i made a few classes... one extends the other...

Code:
public class GeometricFigure{ private String name; public GeometricFigure(String ime) { this.ime = ime; } public String getName() { return this.name; } }
Code:
public class Line extends GeometricFigure { public Line(int x0, int y0, int x1, int y1) {//coordinates super("Line"); this.x0 = x0; this.y0 = y0; this.x1 = x1; this.y1 = y1; } ... .. .. public static GeometricFigure fromStringArray(String[] params) throws IllegalArgumentException{ try{ int arg_x0 = Integer.parseInt(params[0]); int arg_y0 = Integer.parseInt(params[1]); int arg_x1 = Integer.parseInt(params[2]); int arg_y1 = Integer.parseInt(params[3]); return new Line(arg_x0, arg_y0, arg_x1, arg_y1); } catch(NumberFormatException e) { throw new IllegalArgumentException(); } } }
how can i make the bolded part print "Exception" when i call for example
GeometricFigure figure = Line.fromStringArray(subarray); from some other function from somewhere (one of the elements of subarray is a string).
... how to make it work ... help

EDIT: anyone...?

Last edited by Oktam : 03-25-2008 at 01:23 PM. Reason: deadline
Reply With Quote