Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Student extends Człowiek {
- public int rok;
- public String kierunek;
- public Student(){
- this.rok=1;
- this.kierunek="Ceramika";
- }
- public Student(int a,String kierunek){
- this.rok=a;
- this.kierunek=kierunek;
- }
- public Student(int a, String kierunek,int wiek){
- super(wiek);
- this.rok=a;
- this.kierunek=kierunek;
- }
- public Student(int a,String kierunek, int wiek,String imie){
- super(imie,wiek);
- this.rok=a;
- this.kierunek=kierunek;
- }
- public int getRok(){
- return rok;
- }
- public String getKierunek(){
- return kierunek;
- }
- public String toString(){
- return "Rok :" + this.rok + " kierunek : "+ this.kierunek +" "+super.toString();
- }
- public static void main(String[] args) {
- Człowiek[] c = new Człowiek[5];
- c[0]= new Człowiek("Paweł",27);
- c[1]=new Student(2,"Informatyka",23,"Jan");
- c[2] =new Student(1,"Elektronika");
- c[3]=new Człowiek();
- c[4]=new Student(5,"Automatyka",25);
- for(Człowiek x:c){
- System.out.println(x.toString());
- }
- }
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- public class Człowiek {
- public String imie;
- public int wiek;
- public Człowiek(){
- this.imie="Jacek";
- this.wiek=20;
- }
- public Człowiek(String a){
- this.imie=a;
- this.wiek=20;
- }
- public Człowiek(int a){
- this.imie="Jacek";
- this.wiek=a;
- }
- public Człowiek(String a, int x){
- this.imie=a;
- this.wiek=x;
- }
- public String getImie(){
- return imie;
- }
- public int getWiek(){
- return wiek;
- }
- public String toString(){
- return "To człowiek o imieniu : " + this.getImie() + " wiek: " + this.getWiek();
- }
- public static void main(String[] args) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement