Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ngpaketic;
- import java.util.Objects;
- public class NovogodisnjiPaketic implements Pakovanje{
- private String opis;
- private String namenjen;
- private boolean spakovan;
- private int min_uzr;
- private boolean zasluzen;
- private boolean spreman_isporuka;
- public NovogodisnjiPaketic(String opis, String namenjen, boolean spakovan, int min_uzr, boolean zasluzen,
- boolean spreman_isporuka) {
- super();
- this.opis = opis;
- this.namenjen = namenjen;
- this.spakovan = spakovan;
- this.min_uzr = min_uzr;
- this.zasluzen = zasluzen;
- this.spreman_isporuka = spreman_isporuka;
- }
- // seter za opis
- public void setOpis(String opis) {
- this.opis = opis;
- }
- //geter za namenjen
- public String getNamenjen() {
- return namenjen;
- }
- //geter za spakovan
- public boolean isSpakovan() {
- return spakovan;
- }
- //geter za spreman
- public boolean isSpreman_isporuka() {
- return spreman_isporuka;
- }
- //seter za spreman za isporuku
- public void setSpreman_isporuka(boolean spreman_isporuka) {
- this.spreman_isporuka = spreman_isporuka;
- }
- public boolean spakuj() {
- if(this.spakovan==true || this.zasluzen==false) {
- return false;
- }else if((this.namenjen=="Decak" || this.namenjen=="Devojcica") && this.min_uzr>2) {
- this.spakovan=true; // postaje spakovan
- System.out.println("Novogodisnji paketic je uspesno spakovan");
- return true;
- }
- return false;
- }
- @Override
- public int hashCode() {
- return Objects.hash(min_uzr, namenjen, opis, spakovan, spreman_isporuka, zasluzen);
- }
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- NovogodisnjiPaketic other = (NovogodisnjiPaketic) obj;
- return min_uzr == other.min_uzr && Objects.equals(namenjen, other.namenjen) && Objects.equals(opis, other.opis)
- && spakovan == other.spakovan && spreman_isporuka == other.spreman_isporuka && zasluzen == other.zasluzen;
- }
- @Override
- public String toString() {
- String temp="Opis paketica:"+""+this.opis+"\n";
- temp+="Namenjen:"+""+this.namenjen+"\n";
- if(this.spakovan) {
- temp+="PAKETIC JE SPAKOVAN"+"\n";
- }else temp+="PAKETIC NIJE SPAKOVAN"+"\n";
- temp+="Minimalan uzrast:"+""+this.min_uzr+"\n";
- if(this.zasluzen) {
- temp+="PAKETIC JE ZASLUZEN"+"\n";
- }else temp+="PAKETIC NIJE ZASLUZEN"+"\n";
- if(this.spreman_isporuka) {
- temp+="PAKETIC JE SPREMAN ZA ISPORUKU"+"\n";
- }else temp+="PAKETIC NIJE SPREMAN ZA ISPORUKU"+"\n";
- return temp;
- }
- }
Add Comment
Please, Sign In to add comment