diff --git a/Driver.java b/Driver.java new file mode 100644 index 0000000..72a1437 --- /dev/null +++ b/Driver.java @@ -0,0 +1,47 @@ +package models; + +public class Driver extends Person implements PaymentCheck{ + private String driveLicense; + public double salary; + public int hours; + public double fines; + public double addings; + + + public Driver(String name, String familyName, String driveLicense){ + super(name, familyName); + this.driveLicense = driveLicense; + } + + public String getDriveLicense(){ + return this.driveLicense; + } + + public void setDriveLicense(String driveLicense){ + this.driveLicense = driveLicense; + } + + public void setSalary(double salary){ + this.salary = salary; + } + + public void setAditionalNightHours(int hours){ + addings = 40 * hours; + } + + public void setGottenFines (double fines){ + this.fines = fines; + } + + public double getGrossWage(){ + return (salary + addings); + } // returning the gross salary + + public String getDiscounts(){ + return "Fines: " + fines; + } // returning the discounts and descriptions + + public double calculateNetWage(){ + return (getGrossWage() - fines); + } // returning the net wage. +} \ No newline at end of file diff --git a/Main.java b/Main.java new file mode 100644 index 0000000..b890706 --- /dev/null +++ b/Main.java @@ -0,0 +1,26 @@ +import models.Driver; + +public class Main{ + public static void main (String args[]){ + + Driver pedro = new Driver("Pedro","FamilyName","DriverLicense"); + + pedro.setSalary(1000); + pedro.setAditionalNightHours(5); + pedro.setGottenFines(100); + + System.out.println("Pedro Gross Wage:"); + System.out.println(pedro.getGrossWage()); + // 1000 + 5*40 + + + System.out.println("Pedro Discounts:"); + System.out.println(pedro.getDiscounts()); + // Fines: 100 + + System.out.println("Pedro will get:"); + System.out.println(pedro.calculateNetWage()); + // (1000 + 5*40) - 100 + } + +} \ No newline at end of file diff --git a/PaymentCheck.java b/PaymentCheck.java new file mode 100644 index 0000000..efef882 --- /dev/null +++ b/PaymentCheck.java @@ -0,0 +1,7 @@ +package models; + +public interface PaymentCheck{ + double getGrossWage(); // returning the gross salary + String getDiscounts(); // returning the discounts and descriptions + double calculateNetWage(); // returning the net wage. +} \ No newline at end of file diff --git a/Person.java b/Person.java new file mode 100644 index 0000000..05f9e47 --- /dev/null +++ b/Person.java @@ -0,0 +1,36 @@ +package models; + +//Import the Date package +import java.util.Date; + +public abstract class Person{ + private String name; + private String familyName; + + public Person(String name, String familyName){ + this.name = name; + this.familyName = familyName; + } + + //Getters and Setters + public String getName(){ + return name; + } + + public void setName(String name){ + this.name = name; + } + + public String getFamilyName(){ + return familyName; + } + + public void setFamilyName(String familyName){ + this.familyName = familyName; + } + + @Override + public String toString(){ + return "name: "+name+ "\nfamilyName: "+familyName ; + } +} \ No newline at end of file