Skip to content

Instantly share code, notes, and snippets.

@mingan
Forked from goldfish01/gist:1276446
Created October 10, 2011 20:42
Show Gist options
  • Save mingan/1276466 to your computer and use it in GitHub Desktop.
Save mingan/1276466 to your computer and use it in GitHub Desktop.
Martiny úkol
public class Vysledek
{
//== Datové atributy (statické i instancí)======================================
private Tym domaci;
private Tym hoste;
private int kolo;
private String datum;
private int domaciGolu;
private int hosteGolu;
private boolean prodlouzeni;
private boolean remiza;
//== Konstruktory a tovární metody =============================================
/***************************************************************************
* Konstruktor ....
*/
public Vysledek(Tym domaci, Tym hoste,int kolo, String datum,
int domaciGolu, int hosteGolu)
{
this.domaci = domaci;
this.hoste = hoste;
this.nastavKolo(kolo);
this.datum = datum;
this.nastavDomaciGolu(domaciGolu);
this.nastavHosteGolu(hosteGolu);
prodlouzeni = false;
remiza = false;
}
//== Nesoukromé metody (instancí i třídy) ======================================
public void remiza ()
{
if (domaciGolu == hosteGolu)
{
remiza = true;
} else {
this.remiza = false;
}
}
public void prodlouzeni ()
{
if (remiza = true & kolo == 3) {
prodlouzeni = true;
}
else {
this.remiza = false;
}
}
public Tym getDomaci()
{
return domaci;
}
public Tym getHoste()
{
return hoste;
}
public String getDatum()
{
return datum;
}
public int getKolo()
{
return kolo;
}
public int getDomaciGolu()
{
return domaciGolu;
}
public int getHosteGolu()
{
return hosteGolu;
}
public void setKolo(int kolo) {
nastavKolo(kolo);
}
public void setDomaciGolu(int DomaciGolu) {
nastavDomaciGolu(domaciGolu);
}
public void setHosteGolu(int HosteGolu) {
nastavHosteGolu(hosteGolu);
}
@Override
public String toString() {
return domaci + " " + hoste;
}
//== Soukromé metody (instancí i třídy) ========================================
private void nastavKolo(int kolo) {
if (kolo >= 0 && kolo <= 3) {
this.kolo = kolo;
} else {
this.kolo = -1;
}
}
private void nastavDomaciGolu(int domaciGolu) {
if (domaciGolu >= 0 ) {
this.domaciGolu = domaciGolu;
} else {
this.domaciGolu = -1;
}
}
private void nastavHosteGolu(int hosteGolu) {
if (hosteGolu >= 0 ) {
this.hosteGolu = hosteGolu;
} else {
this.hosteGolu = -1;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment