Site hosted by Angelfire.com: Build your free website today!

import java.lang.*;

import java.io.*;

import Misclases.*;

class Empleado

{

String nom;

Empleado(String n)

{

nom=n;

}

}

class Neg extends Exception

{

Neg()

{

super ("\n\nERROR...");

}

}

class Empresa

{

Empleado arreglo[];

Empresa(int n)

{

arreglo = new Empleado [n];

}

public void insertar(int r, String nom)

{

arreglo[r]=new Empleado(nom);

}

}

 

public class pro1

{

public static void main(String args[])

{

int r,j=0;

String nom;

int i;

System.out.print("\n\t NUMERO DE ELEMENTOS: ");

i=Getdat.getInt();

try

{

if(i<=0)

{

throw new Neg();

}

}

catch(Neg e)

{

System.out.println(e.getMessage());

System.exit(0);

}

Empresa obj = new Empresa(i);

for(j=0;j<i;j++)

{

System.out.print("\n\n\tNOMBRE: ");

nom=Getdat.getCad();

obj.insertar(j,nom);

}

}

}