I need some help!

Asked

Viewed 66 times

-5

I started studying object orientation and I need some help. I don’t understand the question Could anyone help me.

With the Client and Person classes: a. create a client instance b. create a person instance c. create an Arraylist of Clients d. add the client instance created in (a) in Arraylist. e. add the person instance created in (b) in Arraylist.

  • Don’t you understand the statement? From what is described, it seems that you have to create a class Pessoa, a class Cliente extending Person (implicit), creating an instance of Person, an instance of Client, an instance of ArrayList which will store both the person and the client, and then add them to the list. As Client Extends Person, you can declare your Arraylist as ArrayList<Pessoa>, thus when recovering an existing object in it, you will be assured that the object will possess the attributes and methods of Person.

1 answer

1

taking into account that the Customer class is extending person..

ArrayList<Pessoa> array = new ArrayList<>();
 array.add(new Pessoa());
 array.add(new Cliente());

Browser other questions tagged

You are not signed in. Login or sign up in order to post.