Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ackage SupermarktTest;
- public class SupermarktTest {
- public static void main(String[] args) {
- }
- }
- abstract class Einkaufsposten{
- private String bezeichnung;
- private long anzahl;
- private double nettoEinzelPreis;
- public String getBezeichnung() {
- return bezeichnung;
- }
- public void setBezeichnung(String bezeichnung) {
- this.bezeichnung = bezeichnung;
- }
- public long getAnzahl() {
- return anzahl;
- }
- public void setAnzahl(long anzahl) {
- this.anzahl = anzahl;
- }
- public double getNettoEinzelPreis() {
- return nettoEinzelPreis;
- }
- public void setNettoEinzelPreis(double nettoEinzelPreis) {
- this.nettoEinzelPreis = nettoEinzelPreis;
- }
- Einkaufsposten(String bezeichnung, long anzahl, double nettoEinzelPreis){
- this.bezeichnung = bezeichnung;
- this.anzahl = anzahl;
- this.nettoEinzelPreis = nettoEinzelPreis;
- }
- public abstract double getBruttogesamtpreis();
- public double getGesamtpreis() {
- return getBruttoEinzelpreis() * anzahl;
- }
- @Override
- public String toString() {
- return("Anzahl: "+this.anzahl+"\n"+"Bezeichnung: "+this.bezeichnung+"\n"+"Gesamtpreis: "+getGesamtpreis()+"\n");
- }
- }
- class Obst extends Einkaufsposten{
- Obst(String name ,long anzahl,double nettoEinzelPreis){
- super(name,anzahl,nettoEinzelPreis);
- }
- @Override
- public double getBruttoEinzelpreis() {
- return getNettoEinzelPreis() * 1.08;
- }
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement