Skip to content

practice8 #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions Driver.java
Original file line number Diff line number Diff line change
@@ -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.
}
26 changes: 26 additions & 0 deletions Main.java
Original file line number Diff line number Diff line change
@@ -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
}

}
7 changes: 7 additions & 0 deletions PaymentCheck.java
Original file line number Diff line number Diff line change
@@ -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.
}
36 changes: 36 additions & 0 deletions Person.java
Original file line number Diff line number Diff line change
@@ -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 ;
}
}