How do I display attributes of an object stored in a vector?

-2

I'm doing a job that consists of a fictional real estate. In this program there is a class called principal where it receives Property (Class) and stores the real estate in a vector, a real estate class that has method of registering the real estate, a superclass Real estate and other 4 classes that are the types of Property (Land, House and Apartment) each of these 4 classes has an @override of Property to display its attributes. Here's how I accomplished the storage of real estate:

Imovel[] imoveis; // cria vetor de imoveis do tipo Imovel (SuperClasse)

//Pega o imovel e coloca no dito array
public void setImovelArray(Imovel imv) {
        imoveis[b] = imv;
        b++;
        System.out.println("Imóvel guardado sob ID:"+b);
    }

Logic party where the real estate class has the function register real estate and the main class the function of storing in the array. Where and how do I call a function to search the array for a specific property (eg for the owner attribute in all properties) and call its respective function ViewDetails (); existing in each instance of property?

Any additional information you may request;)

    
asked by anonymous 27.10.2018 / 02:24

1 answer

0

I do not handle much of java. But all types of real estate where you want to get the data inherit from the immovable class.

You can make a method in it by passing the attributes that you may want to fetch and if you do not have a null arrow by default.

In the implementation of this class you go through the array looking for the value that came in the parameter.

And finally in the main you call this implementation for all types of real estate that you need.

I hope I have helped in some way: D

    
27.10.2018 / 04:26