-1
I am building a project (I am a student) in which I need to create an event company.
The system shall provide:
- the amount spent with the responsible;
- the total cost of lectures;
- the total amount spent per lecture;
- the speaker’s data with the highest and lowest value spent on his lecture.
In the code below I created the classes Palestra
, Palestrantes
and Responsavel
. I’m caught trying to create some way to return the total amount spent on those responsible for the events. I created a for
to walk the arraylist
, It just didn’t work out. The way I did it just displays on screen the values of the time of the responsible ones, but I could not calculate the value of the hour by the number of hours of the events.
Somebody give me a hand?
package eventoHSM;
import java.util.ArrayList;
import java.util.List;
public class Eventos {
public static void main(String[] args) {
Palestra p1 = new Palestra();
p1.setTitulo("Java Guanabara");
p1.setCargaHoraria(8);
p1.setDescricao("Aprenda Java com Orientação objetos nessa série de 30 aulas");
p1.setHorarioInicio("18h");
p1.setNomePalestrante("Gustavo Guanabara");
p1.setNomeResponsavel("Pablo");
Palestra p2 = new Palestra();
p2.setTitulo("Python Guanabara");
p2.setCargaHoraria(16);
p2.setDescricao("Aprenda Python com Orientação objetos nessa série de 30 aulas");
p2.setHorarioInicio("20h");
p2.setNomePalestrante("Gustavo Guanabara");
p2.setNomeResponsavel("Pablo");
Palestra p3 = new Palestra();
p3.setTitulo("Aprendendo Libras");
p3.setCargaHoraria(40);
p3.setDescricao("Aprenda Libras com quem fala libras");
p3.setHorarioInicio("20h");
p3.setNomePalestrante("Ana Claudia");
p3.setNomeResponsavel("Ana");
Palestra p4 = new Palestra();
p4.setTitulo("Daniel e Apocalipse");
p4.setCargaHoraria(16);
p4.setDescricao("Aprenda Daniel e Apocalipse com Felipe Silva");
p4.setHorarioInicio("20h");
p4.setNomePalestrante("Felipe Silva");
p4.setNomeResponsavel("Ana");
Responsavel re1 = new Responsavel();
re1.setNomeResponsavel("Pablo");
re1.setNumTelefone("71992092623");
re1.setValorHora(26);
Responsavel re2 = new Responsavel();
re2.setNomeResponsavel("Ana");
re2.setNumTelefone("988599600");
re2.setValorHora(32);
List<Responsavel> responsaveis = new ArrayList<Responsavel>();
responsaveis.add(re1);
responsaveis.add(re2);
List<Palestra> palestras = new ArrayList<Palestra>();
palestras.add(p1);
palestras.add(p2);
palestras.add(p3);
palestras.add(p4);
for(int a = 0; a < palestras.size(); a++) {
//System.out.println(palestras.get(a).getCargaHoraria() + " - " + palestras.get(a).getNomeResponsavel());
for(int i = 0; i< responsaveis.size(); i++) {
if(palestras.get(a).getNomeResponsavel() == responsaveis.get(i).getNomeResponsavel() ) {
float valorPorResponsavel = 0;
valorPorResponsavel = valorPorResponsavel + responsaveis.get(i).getValorHora();
System.out.println(valorPorResponsavel);
}
}
}
}
}
I can give an idea, I do not want to make the solution because the way is this same, you need to try and find out, but you could have a class of Costs and in this class would have a method of attribution making the proper sums, could add the data inputados and return.
– André Martins