To fazendo um exercicio… fiz tudo e na classe principal tenho que criar
Implemente a classe principal :
a. Para um objeto vendedor e um objeto administrador com dados
fornecidos pelo usuário.
b. Crie um menu principal para que o usuário escolha qual objeto deseja
criar.
comecei a fazer mas por ser abstract não consigo setar do jeito que achei que seria necessario
alguem pode me ajudar?
package Loja;
import javax.swing.JOptionPane;
/*
- To change this license header, choose License Headers in Project Properties.
- To change this template file, choose Tools | Templates
- and open the template in the editor.
*/
/**
*
-
@author familia
*/
public class usandoLoja {static int opcao; static int user;
public static void main(String[] args) {
while (true) { user = Integer.parseInt(JOptionPane.showInputDialog("[1]Fornecido pelo Usuário\n[2]Menu para escolha\n[3]Sair\n")); switch(user){ case 1: Vendedores vendedores = new Vendedores("João", 416837, 2587.97, 5000.00); System.out.println(vendedores); Administrativos administrativos = new Administrativos("Márcia", 556877899, 4232.00, 10.0); System.out.println(administrativos); break; case 2: opcao = Integer.parseInt(JOptionPane.showInputDialog("[1]Vendedores\n[2]Administrativos\n[3]Sair\n")); switch (opcao) { case 1: String nome = JOptionPane.showInputDialog("Informe o nome do vendedor: "); String rg = JOptionPane.showInputDialog("Informe o rg: "); String salarioBase = JOptionPane.showInputDialog("Informe o salario: "); String totalVendas = JOptionPane.showInputDialog("Informe o total de vendas: "); Vendedores vendedores1 = new Vendedores(); vendedores.setNome(nome); vendedores.setRg(rg); vendedores.setSalario(salarioBase); vendedores.setTotalVendas(totalVendas); break; } case 3: break; case 4: JOptionPane.showMessageDialog(null, "Programa Encerrado"); System.exit(0); break; default:JOptionPane.showMessageDialog(null, "Opção Inválida"); break; } }
}
}
/*
- To change this license header, choose License Headers in Project Properties.
- To change this template file, choose Tools | Templates
- and open the template in the editor.
*/
package Loja;
import java.text.DecimalFormat;
/**
*
-
@author familia
*/
public abstract class Funcionarios {
private String nome;
private int rg;
private double salarioBase;DecimalFormat df = new DecimalFormat("#0.00");
public Funcionarios(){
}
public Funcionarios(String nome, int rg, double salarioBase){
this.nome = nome;
this.rg = rg;
this.salarioBase = salarioBase;
}public void setNome(String nome){
this.nome = nome;
}public String getNome(){
return nome;
}public void setRg(int rg){
this.rg = rg;
}public int getRg(){
return rg;
}public void setSalario(double salarioBase){
this.salarioBase = salarioBase;
}public double getSalario(){
return salarioBase;
}@Override
public String toString(){
return "\nNome: " + getNome()
+ "\nRg: " + getRg()
+ "\nSalário Base: " + getSalario();
}
}
/*
- To change this license header, choose License Headers in Project Properties.
- To change this template file, choose Tools | Templates
- and open the template in the editor.
*/
package Loja;
/**
*
-
@author familia
*/
public class Vendedores extends Funcionarios {private double totalVendas;
public Vendedores(String nome, int rg,double salarioBase, double totalVendas){
super(nome, rg, salarioBase);
this.totalVendas = totalVendas;
}public void setTotalVendas(double totalVendas){
this.totalVendas = totalVendas;
}public double getTotalVendas(){
return totalVendas;
}public double calcularComissao(){
return getSalario() + (getTotalVendas() * 0.05);
}@Override
public String toString(){
return super.toString()
+ "\nTotal de vendas: " + totalVendas
+ "\nSalario com comissao: " + calcularComissao();
}
}
/*
- To change this license header, choose License Headers in Project Properties.
- To change this template file, choose Tools | Templates
- and open the template in the editor.
*/
package Loja;
/**
*
-
@author familia
*/
public class Administrativos extends Funcionarios{
private double horasExtras;public Administrativos(String nome, int rg, double salarioBase, double horasExtras){
super(nome, rg, salarioBase);
this.horasExtras = horasExtras;}
public void setHoras(double horasExtras){
this.horasExtras = horasExtras;
}public double horasExtras(){
return horasExtras;
}public double calcularHorasExtras(){
return (super.getSalario() + ((super.getSalario())/100) * horasExtras);
}@Override
public String toString(){
return super.toString()
+ "\nHoras extras: " + horasExtras
+ "\nTotal em horas e salario: " + calcularHorasExtras();
}
}