Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###################################################
- package predmet;
- public class predmet {
- protected String nazev;
- protected int body;
- protected boolean zapocet = false;
- protected static final int MIN_BOD = 15;
- public int getBody()
- {
- return this.body;
- }
- public void setBody(int body)
- {
- this.body = body;
- }
- public String getNazev()
- {
- return this.nazev;
- }
- public boolean getZapocet()
- {
- if (getBody() >= MIN_BOD)
- this.zapocet = true;
- return this.zapocet;
- }
- }
- ##############################################
- package predmet;
- public class Bpc1 extends predmet{
- private String nazev = "BPC-1";
- private int cvik = 0;
- private int exam = 0;
- public int getCvik()
- {
- return cvik;
- }
- public void setCvik(int body)
- {
- this.cvik+= body;
- if (this.cvik > 20)
- this.cvik = 20;
- }
- public void setExam(int body)
- {
- this.exam+= body;
- if (this.exam > 80)
- this.exam = 80;
- }
- public int getBody()
- {
- this.body = this.cvik + this.exam;
- return body;
- }
- }
- ##############################################
- package predmet;
- public class Bpc2 extends predmet {
- String nazev = "BPC-2";
- int projekt = 0;
- int halfExam = 0;
- int exam = 0;
- public void setExam(int body)
- {
- this.exam+= body;
- if (this.exam > 50)
- this.exam = 50;
- }
- public void setHalfExam(int body)
- {
- this.halfExam+= body;
- if (this.halfExam > 30)
- this.halfExam = 30;
- }
- public void setProjekt(int body)
- {
- this.projekt+= body;
- if (this.projekt > 20)
- this.projekt = 20;
- }
- public int getBody()
- {
- this.body = this.projekt + this.exam + this.halfExam;
- return body;
- }
- }
- #######################################################
- package predmet;
- public class Bpis extends predmet {
- public void setZapocet()
- {
- this.zapocet = true;
- }
- }
- ######################################################
- package predmet;
- import java.util.Scanner;
- public class Test {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- Bpc1 bpc1 = new Bpc1();
- Bpc2 bpc2 = new Bpc2();
- Bpis bpis = new Bpis();
- System.out.println("Zadejte body za cviceni BPC-1: ");
- while(true)
- {
- if(sc.hasNext())
- {
- bpc1.setCvik(sc.nextInt());
- break;
- }
- else
- System.out.println("Spatny format, zkuste znovu");
- }
- System.out.println("Zadejte body za zkousku BPC-1: ");
- while(true)
- {
- if(sc.hasNext())
- {
- bpc1.setExam(sc.nextInt());
- break;
- }
- else
- System.out.println("Spatny format, zkuste znovu");
- }
- System.out.println("Zadejte body za projekt BPC-2: ");
- while(true)
- {
- if(sc.hasNext())
- {
- bpc2.setProjekt(sc.nextInt());
- break;
- }
- else
- System.out.println("Spatny format, zkuste znovu");
- }
- System.out.println("Zadejte body za pulsemestralni zlousku BPC-2: ");
- while(true)
- {
- if(sc.hasNext())
- {
- bpc2.setHalfExam(sc.nextInt());
- break;
- }
- else
- System.out.println("Spatny format, zkuste znovu");
- }
- System.out.println("Zadejte body za zkousku BPC-2: ");
- while(true)
- {
- if(sc.hasNext())
- {
- bpc2.setExam(sc.nextInt());
- break;
- }
- else
- System.out.println("Spatny format, zkuste znovu");
- }
- System.out.println("Zapocet z BPIS (true/false): ");
- while(true)
- {
- if(sc.hasNextBoolean() && sc.nextBoolean() == true )
- {
- bpis.setZapocet();
- break;
- }
- else if(sc.hasNextBoolean() && sc.nextBoolean() == false)
- {
- break;
- }
- else
- System.out.println("Spatny format, zkuste znovu");
- }
- if(bpc1.getZapocet() == true)
- System.out.println("BPC-1 zapocet udelan");
- else
- System.out.println("BPC-1 zapocet neudelan");
- if(bpc2.getZapocet() == true)
- System.out.println("BPC-2 zapocet udelan");
- else
- System.out.println("BPC-1 zapocet neudelan");
- if(bpc1.getZapocet() == true)
- System.out.println("BPIS zapocet udelan");
- else
- System.out.println("BPC-1 zapocet neudelan");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement