I have this exercise below to do in the question "D" I am having difficulties, if someone can explain to me how I should do:
a) Create an interface called
ModeloContato
with methodsgetNome()
,getTelefone()
andgetEndereco()
, all without parameters and returningString
,int
andString
respectively;b) Create a concrete class called
Contato
that implements the abstract interface methods created in letter a.Contato
should include methodsset
and attributesnome
,telefone
andendereço
.c) Create a
ArrayList
of typeContato
, representing a schedule. Add contacts by assigning initial values to the attributes.d) Print the data of the contacts registered in the letter C.
e) Implement the search for a contact in the directory, printing when the result is found or reporting that it was not found case.
Follow the code already done:
public static void main(String[] args) {
ArrayList<Contato> agenda = new ArrayList<Contato>();
Contato a = new Contato ();
Contato b = new Contato ();
Contato c = new Contato ();
for (int i = 0 ; i < 3; i++){
Contato contato1 = new Contato();
agenda.add(contato1);
agenda.get(i).setNome("joao");
agenda.add(contato1);
agenda.get(i).setEndereco("Rua Joao Camara");
agenda.add(contato1);
agenda.get(i).setTelefone(3589);
}
for(int i = 1; i <= 1; i++){
System.out.println(agenda.get(0).getNome());
System.out.println(agenda.get(0).getEndereco());
System.out.println(agenda.get(0).getTelefone());
}
}
If you can give me just one example of how to do it would be great, if you give me the answer I will not learn how to do it.