Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package funcionarios_pizzaria;
- import java.io.BufferedReader;
- import java.io.FileReader;
- import java.io.FileWriter;
- import java.io.IOException;
- import javax.swing.JOptionPane;
- import java.util.ArrayList;
- public class Main {
- public static void main(String[] args) {
- ArrayList<Funcionarios> funcs = new ArrayList<Funcionarios>();
- int n = 0;
- boolean sair = false;
- try{
- BufferedReader leitor = new BufferedReader(new FileReader("dados.txt"));
- String linha = "";
- while((linha = leitor.readLine()) != null){
- String[] partes = linha.split(";");
- System.out.println("");
- Funcionarios fun = new Funcionarios(partes[0], partes[1], partes[2], partes[3], partes[4], partes[5]);
- funcs.add(fun);
- }
- }catch(IOException ex){
- ex.printStackTrace();
- }
- while (sair == false) {
- String e = JOptionPane.showInputDialog("escolha:");
- if (e.equals("add")) {
- //INSTANCIAMENTO DE ATRIBUTOS DA CLASSE FUNCIONARIOS
- String nome = JOptionPane.showInputDialog("entre com o nome do funcionario");
- int sal = Integer.parseInt(JOptionPane.showInputDialog("entre com o valor do salario"));
- String setor = JOptionPane.showInputDialog("entre com o setor");
- int tel = Integer.parseInt(JOptionPane.showInputDialog("entre com o numero"));
- int idade = Integer.parseInt(JOptionPane.showInputDialog("entre com a idade"));
- int tempo = Integer.parseInt(JOptionPane.showInputDialog("entre com o tempo na empresa"));
- funcs.add(n, new Funcionarios(sal, setor, nome, tel, idade, tempo));
- n++;
- } else if (e.equals("show")) {
- String nome = JOptionPane.showInputDialog(null, "digite o nome");
- for (Funcionarios f : funcs) {
- if(f.getNome().equals(nome));{
- JOptionPane.showMessageDialog(null, "nome: "+f.getNome());
- }
- }
- }else if (e.equals("exit")){
- sair = true;
- try{
- JOptionPane.showMessageDialog(null, "irmao ja vai grava calma");
- FileWriter arq = new FileWriter("dados.txt");
- for(Funcionarios fun : funcs){
- arq.write(fun.toString()+"\n");
- }
- arq.close();
- JOptionPane.showMessageDialog(null,"gravado");
- }catch(IOException ex){
- ex.printStackTrace();
- }
- }else{
- JOptionPane.showMessageDialog(null, "opcao invalida");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement