Erinevus lehekülje "ITI0011:harjutus 10" redaktsioonide vahel

Allikas: Kursused
Mine navigeerimisribale Mine otsikasti
11. rida: 11. rida:
 
* Kui kaks PremiumPackage tüüpi pakki omavad sama prioriteeti, siis tuleb arvestada klientide summaarset prioriteeti (receiver.priority + sender.priority). Identsete prioriteetidega pakke ei järjestata (vahet pole, kumb enne väljastatakse)
 
* Kui kaks PremiumPackage tüüpi pakki omavad sama prioriteeti, siis tuleb arvestada klientide summaarset prioriteeti (receiver.priority + sender.priority). Identsete prioriteetidega pakke ei järjestata (vahet pole, kumb enne väljastatakse)
 
* Tavaliste pakkide puhul arvestada ainult klientide summaarset prioriteeti.
 
* Tavaliste pakkide puhul arvestada ainult klientide summaarset prioriteeti.
 +
 +
== Mall ==
 +
Package.java
 +
<source lang="java">
 +
public class Package {
 +
    private String packageNumber;
 +
    private int width;
 +
    private int height;
 +
    private Customer sender;
 +
    private Customer receiver;
 +
 +
    private static int packageCount = 0;
 +
 +
    public Customer getReceiver() {
 +
        return receiver;
 +
    }
 +
 +
    public void setReceiver(Customer receiver) {
 +
        this.receiver = receiver;
 +
    }
 +
 +
    public Customer getSender() {
 +
        return sender;
 +
    }
 +
 +
    public void setSender(Customer sender) {
 +
        this.sender = sender;
 +
    }
 +
 +
 +
    private static int getNextPackageId() {
 +
        return ++packageCount;
 +
    }
 +
 +
    public Package() {
 +
    }
 +
 +
    public Package(String packageNumber) {
 +
        this(packageNumber, -1, -1);
 +
    }
 +
    public Package(int width, int height) {
 +
        this("Package " + getNextPackageId(), width, height);
 +
    }
 +
    public Package(String packageNumber, int width, int height) {
 +
        this.packageNumber = packageNumber;
 +
        this.width = width;
 +
        this.height = height;
 +
    }
 +
 +
    public String getPackageNumber() {
 +
        return packageNumber;
 +
    }
 +
 +
    public void setPackageNumber(String packageNumber) {
 +
        this.packageNumber = packageNumber;
 +
    }
 +
 +
    public int getHeight() {
 +
        return height;
 +
    }
 +
 +
    public void setHeight(int height) {
 +
        this.height = height;
 +
    }
 +
 +
    public int getWidth() {
 +
        return width;
 +
    }
 +
 +
    public void setWidth(int width) {
 +
        this.width = width;
 +
    }
 +
 +
    @Override
 +
    public String toString() {
 +
        return packageNumber;
 +
    }
 +
}
 +
 +
</source>
 +
 +
Customer.java
 +
<source lang="java">
 +
public class Customer {
 +
    private int priority;
 +
    private String name;
 +
    private String address;
 +
 +
    private static final int DEFAULT_PRIORITY = 10;
 +
 +
 +
    public Customer(String name, int priority) {
 +
        this(name, priority, null);
 +
    }
 +
 +
    public Customer(String name, int priority, String address) {
 +
        this.name = name;
 +
        this.priority = priority;
 +
        this.address = address;
 +
    }
 +
 +
    public Customer(String name) {
 +
        this(name, DEFAULT_PRIORITY);
 +
    }
 +
 +
    public String getAddress() {
 +
        return address;
 +
    }
 +
 +
 +
    public void setAddress(String address) {
 +
        this.address = address;
 +
    }
 +
 +
    public String getName() {
 +
        return name;
 +
    }
 +
 +
    public void setName(String name) {
 +
        this.name = name;
 +
    }
 +
 +
    public int getPriority() {
 +
        return priority;
 +
    }
 +
    public void setPriority(int priority) {
 +
        this.priority = priority;
 +
    }
 +
}
 +
</source>
 +
 +
PackageProvider.java
 +
<source lang="java">
 +
import java.util.List;
 +
public interface PackageProvider {
 +
 +
    public Package getNextPackage();
 +
 +
    public boolean addPackage(Package packageToAdd);
 +
 +
    public List<Package> getOrderedPackages();
 +
 +
    public List<Package> findAllPackagesBySender(Customer customer);
 +
 +
    public List<Package> findAllPackagesByReceiver(Customer customer);
 +
 +
</source>

Redaktsioon: 14. märts 2016, kell 07:50

Üldine

Ülesande kaitsmised: 16. - 18. märts
Kaust gitis: EX10

Ülesanne

Tundmatu logistikakeskus on sattunud seni nägemata probleemi otsa, nimelt tuli firma omanikelt idee luua priotiseeritud pakisüsteemi, mis saadab pakke vastavalt logistikakekuse poolt määratud järjekorrale. Idee oli määratud parendama tähtsate klientide rahololu transporditeenusega. Paraku on süsteem ööpäevaringselt töös ning ümberkirjutamine on antud fintantstingimustes võimatu. Firma peaarhitekti poolt tuli ettepanek laiendada süsteemi standardpakke ja vahetada iga logistikakeskuse väljastusautomaadi PackageProvider uue vastu nii, et oleks täidetud järgmised tingimused:

  • Väljastusautomaat eelistab alati PremiumPackage tüüpi pakke
  • PremiumPackagesitest tuleb eelistada kõrgema prioriteediga (suurema priority väärtusega pakk)
  • Kui kaks PremiumPackage tüüpi pakki omavad sama prioriteeti, siis tuleb arvestada klientide summaarset prioriteeti (receiver.priority + sender.priority). Identsete prioriteetidega pakke ei järjestata (vahet pole, kumb enne väljastatakse)
  • Tavaliste pakkide puhul arvestada ainult klientide summaarset prioriteeti.

Mall

Package.java <source lang="java"> public class Package {

   private String packageNumber;
   private int width;
   private int height;
   private Customer sender;
   private Customer receiver;
   private static int packageCount = 0;
   public Customer getReceiver() {
       return receiver;
   }
   public void setReceiver(Customer receiver) {
       this.receiver = receiver;
   }
   public Customer getSender() {
       return sender;
   }
   public void setSender(Customer sender) {
       this.sender = sender;
   }


   private static int getNextPackageId() {
       return ++packageCount;
   }
   public Package() {
   }
   public Package(String packageNumber) {
       this(packageNumber, -1, -1);
   }
   public Package(int width, int height) {
       this("Package " + getNextPackageId(), width, height);
   }
   public Package(String packageNumber, int width, int height) {
       this.packageNumber = packageNumber;
       this.width = width;
       this.height = height;
   }
   public String getPackageNumber() {
       return packageNumber;
   }
   public void setPackageNumber(String packageNumber) {
       this.packageNumber = packageNumber;
   }
   public int getHeight() {
       return height;
   }
   public void setHeight(int height) {
       this.height = height;
   }
   public int getWidth() {
       return width;
   }
   public void setWidth(int width) {
       this.width = width;
   }
   @Override
   public String toString() {
       return packageNumber;
   }

}

</source>

Customer.java <source lang="java"> public class Customer {

   private int priority;
   private String name;
   private String address;
   private static final int DEFAULT_PRIORITY = 10;


   public Customer(String name, int priority) {
       this(name, priority, null);
   }
   public Customer(String name, int priority, String address) {
       this.name = name;
       this.priority = priority;
       this.address = address;
   }
   public Customer(String name) {
       this(name, DEFAULT_PRIORITY);
   }
   public String getAddress() {
       return address;
   }


   public void setAddress(String address) {
       this.address = address;
   }
   public String getName() {
       return name;
   }
   public void setName(String name) {
       this.name = name;
   }
   public int getPriority() {
       return priority;
   }
   public void setPriority(int priority) {
       this.priority = priority;
   }

} </source>

PackageProvider.java <source lang="java"> import java.util.List; public interface PackageProvider {

   public Package getNextPackage();
   public boolean addPackage(Package packageToAdd);
   public List<Package> getOrderedPackages();
   public List<Package> findAllPackagesBySender(Customer customer);
   public List<Package> findAllPackagesByReceiver(Customer customer);

</source>