Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- //interfejs // DONE
- interface IMaraton{
- public Atleticar najdobroVreme();
- public int atleticariOd(String s);
- }
- class Atleticar{//DONE
- //atributi
- private String ime;
- private String pol;
- private int vozrast;
- private double vremeNaIstrcuvanjeVoSekundi;
- private String zemjaNaPoteklo;
- //default konstruktor
- public Atleticar(){}
- //konstruktor
- public Atleticar(String ime, String pol, int vozrast, double vremeNaIstrcuvanjeVoSekundi, String zemjaNaPoteklo) {
- this.ime = ime;
- this.pol = pol;
- this.vozrast = vozrast;
- this.vremeNaIstrcuvanjeVoSekundi = vremeNaIstrcuvanjeVoSekundi;
- this.zemjaNaPoteklo = zemjaNaPoteklo;
- }
- //set i get metodi
- public String getIme() {
- return ime;
- }
- public void setIme(String ime) {
- this.ime = ime;
- }
- public String getPol() {
- return pol;
- }
- public void setPol(String pol) {
- this.pol = pol;
- }
- public int getVozrast() {
- return vozrast;
- }
- public void setVozrast(int vozrast) {
- this.vozrast = vozrast;
- }
- public double getVremeNaIstrcuvanjeVoSekundi() {
- return vremeNaIstrcuvanjeVoSekundi;
- }
- public void setVremeNaIstrcuvanjeVoSekundi(double vremeNaIstrcuvanjeVoSekundi) {
- this.vremeNaIstrcuvanjeVoSekundi = vremeNaIstrcuvanjeVoSekundi;
- }
- public String getZemjaNaPoteklo() {
- return zemjaNaPoteklo;
- }
- public void setZemjaNaPoteklo(String zemjaNaPoteklo) {
- this.zemjaNaPoteklo = zemjaNaPoteklo;
- }
- @Override
- public String toString() {
- return getIme() + " " + getVozrast() + " " + getZemjaNaPoteklo() + " " + getVremeNaIstrcuvanjeVoSekundi();
- }
- }
- class Maraton implements IMaraton{//mora da gi implementira metodite od interfejsot
- //atributi
- private String mestoNaOdrzuvanje;
- private int godina;
- private Atleticar[] atleticar;
- //default konstruktor
- public Maraton(){}
- //konstruktor
- public Maraton(String mestoNaOdrzuvanje, int godina, Atleticar[] atleticar) {
- this.mestoNaOdrzuvanje = mestoNaOdrzuvanje;
- this.godina = godina;
- this.atleticar = atleticar;
- }
- //set i get metodi
- public String getMestoNaOdrzuvanje() {
- return mestoNaOdrzuvanje;
- }
- public void setMestoNaOdrzuvanje(String mestoNaOdrzuvanje) {
- this.mestoNaOdrzuvanje = mestoNaOdrzuvanje;
- }
- public int getGodina() {
- return godina;
- }
- public void setGodina(int godina) {
- this.godina = godina;
- }
- public Atleticar[] getAtleticar() {
- return atleticar;
- }
- public void setAtleticar(Atleticar[] atleticar) {
- this.atleticar = atleticar;
- }
- @Override
- public String toString() {
- return getMestoNaOdrzuvanje() + "\n" + godina + "\n"
- + getAtleticar();
- }
- @Override
- public Atleticar najdobroVreme() {
- // TODO Auto-generated method stub
- return null;
- }
- @Override
- public int atleticariOd(String s) {
- // TODO Auto-generated method stub
- return 0;
- }
- }
- public class ZadacaMaraton {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int n=input.nextInt();
- Atleticar[] atleticari = new Atleticar[n];
- String ime;
- String pol;
- int vozrast;
- double vreme;
- String zemja;
- input.nextLine();
- for(int i=0;i<n;i++)
- {
- ime = input.nextLine();
- pol = input.nextLine();
- vozrast = input.nextInt();
- vreme = input.nextDouble();
- input.nextLine();
- zemja = input.nextLine();
- atleticari[i]=new Atleticar(ime,pol,vozrast,vreme,zemja);
- }
- String mesto;
- int godina;
- String zemjaP;
- mesto = input.nextLine();
- godina = input.nextInt();
- input.nextLine();
- Maraton m1 = new Maraton(mesto, godina, atleticari);
- System.out.print(m1.toString());
- zemjaP = input.nextLine();
- //System.out.println("Prvo mesto: " + m1.najdobroVreme().toString());
- //System.out.println("Ima vkupno " + m1.atleticariOd(zemjaP) + " atleticar/i od " + zemjaP);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement