Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package e9ludziki;
- public class E9Ludziki {
- public static void main(String[] args) {
- Facet gostek1 = new Facet();
- System.out.println(gostek1.getImie());
- gostek1.setImie("Henrjiu");
- System.out.println(gostek1.getImie());
- System.out.println(gostek1);
- Facet gostek2 = new Facet("Tonik",35,176);
- System.out.println(gostek2);
- System.out.println(gostek2.getImie()+ " waży "+ gostek2.waga()+"kg.");
- Baba kobita1 = new Baba("Zuzia",20,164);
- System.out.println(kobita1.toString());
- System.out.println(kobita1.getImie() + " waży "+kobita1.waga());
- }
- }
- class Baba extends Facet {
- public Baba (String imie, int wiek, int wzrost) {
- this.imie = imie; this.wiek = wiek; this.wzrost = wzrost;}
- public double waga(){
- return this.getWzrost() - 140+0.2*this.getWiek();
- }
- }
- class Facet {
- public double waga(){
- return wzrost - 110+0.2*wiek;
- }
- public String toString(){
- return "Nazywam się " +imie+ ", mam " + wiek + " lat oraz " + wzrost + "cm wzrostu :)";
- }
- public Facet (String imie, int wiek, int wzrost) {
- this.imie = imie; this.wiek = wiek; this.wzrost = wzrost;
- }
- public Facet() {
- imie = "Szczepan";
- wiek = 20;
- wzrost = 182;
- }
- protected String imie;
- protected int wiek;
- protected int wzrost;
- /**
- * @return the imie
- */
- public String getImie() {
- return imie;
- }
- /**
- * @param imie the imie to set
- */
- public void setImie(String imie) {
- this.imie = imie;
- }
- /**
- * @return the wiek
- */
- public int getWiek() {
- return wiek;
- }
- /**
- * @param wiek the wiek to set
- */
- public void setWiek(int wiek) {
- this.wiek = wiek;
- }
- /**
- * @return the wzrost
- */
- public int getWzrost() {
- return wzrost;
- }
- /**
- * @param wzrost the wzrost to set
- */
- public void setWzrost(int wzrost) {
- this.wzrost = wzrost;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement