Advertisement
Guest User

Untitled

a guest
Oct 10th, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.10 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. //interfejs // DONE
  4. interface IMaraton{
  5. public Atleticar najdobroVreme();
  6. public int atleticariOd(String s);
  7. }
  8.  
  9. class Atleticar{//DONE
  10.  
  11. //atributi
  12. private String ime;
  13. private String pol;
  14. private int vozrast;
  15. private double vremeNaIstrcuvanjeVoSekundi;
  16. private String zemjaNaPoteklo;
  17.  
  18. //default konstruktor
  19. public Atleticar(){}
  20.  
  21. //konstruktor
  22. public Atleticar(String ime, String pol, int vozrast, double vremeNaIstrcuvanjeVoSekundi, String zemjaNaPoteklo) {
  23. this.ime = ime;
  24. this.pol = pol;
  25. this.vozrast = vozrast;
  26. this.vremeNaIstrcuvanjeVoSekundi = vremeNaIstrcuvanjeVoSekundi;
  27. this.zemjaNaPoteklo = zemjaNaPoteklo;
  28. }
  29.  
  30. //set i get metodi
  31. public String getIme() {
  32. return ime;
  33. }
  34.  
  35. public void setIme(String ime) {
  36. this.ime = ime;
  37. }
  38.  
  39. public String getPol() {
  40. return pol;
  41. }
  42.  
  43. public void setPol(String pol) {
  44. this.pol = pol;
  45. }
  46.  
  47. public int getVozrast() {
  48. return vozrast;
  49. }
  50.  
  51. public void setVozrast(int vozrast) {
  52. this.vozrast = vozrast;
  53. }
  54.  
  55. public double getVremeNaIstrcuvanjeVoSekundi() {
  56. return vremeNaIstrcuvanjeVoSekundi;
  57. }
  58.  
  59. public void setVremeNaIstrcuvanjeVoSekundi(double vremeNaIstrcuvanjeVoSekundi) {
  60. this.vremeNaIstrcuvanjeVoSekundi = vremeNaIstrcuvanjeVoSekundi;
  61. }
  62.  
  63. public String getZemjaNaPoteklo() {
  64. return zemjaNaPoteklo;
  65. }
  66.  
  67. public void setZemjaNaPoteklo(String zemjaNaPoteklo) {
  68. this.zemjaNaPoteklo = zemjaNaPoteklo;
  69. }
  70.  
  71. @Override
  72. public String toString() {
  73. return getIme() + " " + getVozrast() + " " + getZemjaNaPoteklo() + " " + getVremeNaIstrcuvanjeVoSekundi();
  74. }
  75.  
  76. }
  77.  
  78. class Maraton implements IMaraton{//mora da gi implementira metodite od interfejsot
  79.  
  80. //atributi
  81. private String mestoNaOdrzuvanje;
  82. private int godina;
  83. private Atleticar[] atleticar;
  84.  
  85. //default konstruktor
  86. public Maraton(){}
  87.  
  88. //konstruktor
  89. public Maraton(String mestoNaOdrzuvanje, int godina, Atleticar[] atleticar) {
  90. this.mestoNaOdrzuvanje = mestoNaOdrzuvanje;
  91. this.godina = godina;
  92. this.atleticar = atleticar;
  93. }
  94.  
  95. //set i get metodi
  96. public String getMestoNaOdrzuvanje() {
  97. return mestoNaOdrzuvanje;
  98. }
  99.  
  100. public void setMestoNaOdrzuvanje(String mestoNaOdrzuvanje) {
  101. this.mestoNaOdrzuvanje = mestoNaOdrzuvanje;
  102. }
  103.  
  104. public int getGodina() {
  105. return godina;
  106. }
  107.  
  108. public void setGodina(int godina) {
  109. this.godina = godina;
  110. }
  111.  
  112. public Atleticar[] getAtleticar() {
  113. return atleticar;
  114. }
  115.  
  116. public void setAtleticar(Atleticar[] atleticar) {
  117. this.atleticar = atleticar;
  118. }
  119.  
  120. @Override
  121. public String toString() {
  122. return getMestoNaOdrzuvanje() + "\n" + godina + "\n"
  123. + getAtleticar();
  124. }
  125.  
  126. @Override
  127. public Atleticar najdobroVreme() {
  128. // TODO Auto-generated method stub
  129. return null;
  130. }
  131. @Override
  132. public int atleticariOd(String s) {
  133. // TODO Auto-generated method stub
  134. return 0;
  135. }
  136.  
  137.  
  138. }
  139.  
  140. public class ZadacaMaraton {
  141.  
  142. public static void main(String[] args) {
  143. Scanner input = new Scanner(System.in);
  144. int n=input.nextInt();
  145. Atleticar[] atleticari = new Atleticar[n];
  146.  
  147. String ime;
  148. String pol;
  149. int vozrast;
  150. double vreme;
  151. String zemja;
  152.  
  153. input.nextLine();
  154.  
  155. for(int i=0;i<n;i++)
  156. {
  157. ime = input.nextLine();
  158. pol = input.nextLine();
  159. vozrast = input.nextInt();
  160. vreme = input.nextDouble();
  161. input.nextLine();
  162. zemja = input.nextLine();
  163. atleticari[i]=new Atleticar(ime,pol,vozrast,vreme,zemja);
  164. }
  165.  
  166. String mesto;
  167. int godina;
  168. String zemjaP;
  169. mesto = input.nextLine();
  170. godina = input.nextInt();
  171. input.nextLine();
  172.  
  173. Maraton m1 = new Maraton(mesto, godina, atleticari);
  174. System.out.print(m1.toString());
  175.  
  176. zemjaP = input.nextLine();
  177. //System.out.println("Prvo mesto: " + m1.najdobroVreme().toString());
  178. //System.out.println("Ima vkupno " + m1.atleticariOd(zemjaP) + " atleticar/i od " + zemjaP);
  179. }
  180. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement