Advertisement
Dido09

Company-ET

Nov 1st, 2022
1,019
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.55 KB | None | 0 0
  1. package AgainstTheOdds;
  2.  
  3. public class Company_ET extends Company {
  4.     public Company_ET(String name, String date, String code, String ownerName, double startingFund, double currentFund) {
  5.         super(name, date, code);
  6.  
  7.         this.ownerName = ownerName;
  8.         this.startingFund = startingFund;
  9.         this.currentFund = currentFund;
  10.     }
  11.  
  12.     private String ownerName;
  13.     private double startingFund;
  14.     private double currentFund;
  15.  
  16.  
  17.     public String getOwnerName() {
  18.         return ownerName;
  19.     }
  20.  
  21.     public void setOwnerName(String ownerName) {
  22.         this.ownerName = ownerName;
  23.     }
  24.  
  25.     public double getStartingFund() {
  26.         return startingFund;
  27.     }
  28.  
  29.     public void setStartingFund(double startingFund) {
  30.         this.startingFund = startingFund;
  31.     }
  32.  
  33.     public double getCurrentFund() {
  34.         return currentFund;
  35.     }
  36.  
  37.     public void setCurrentFund(double currentFund) {
  38.         this.currentFund = currentFund;
  39.     }
  40.  
  41.     public double profit() {
  42.         return this.currentFund - this.startingFund;
  43.     }
  44.  
  45.  
  46.     public static void main(String[] args) {
  47.  
  48.  
  49.         Company company1 = new Company("Coca-Cola", "12.04.1999", "42141");
  50.         Company company2 = new Company("Tesla", "09.08.2009", "543643412141");
  51.         Company_ET company3 = new Company_ET("Nike", "12.07.1990", "52353", "Johnny", 4000, 10000);
  52.  
  53.         if (company2.getCode().length() > 10) {
  54.             System.out.println("The code is above 10!");
  55.         }
  56.  
  57.         System.out.println(company3.profit());
  58.  
  59.  
  60.     }
  61.  
  62.  
  63. }
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement