Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- class Oceny extends Człowiek{
- public ArrayList< Integer > T = new ArrayList< Integer >(5);
- public Oceny(){
- ArrayList<Integer> x =new ArrayList <Integer>(5);
- for(int i=0;i<5;i++){
- x.add(1);
- }
- T=x;
- }
- public Oceny(ArrayList<Integer> t){
- T=t;
- }
- public Oceny(ArrayList<Integer> t,String k){
- super("K",k);
- T=t;
- }
- public Oceny(ArrayList<Integer> t , String k, String p){
- super(k,p);
- T=t;
- }
- public void wypisz(){
- for(int i:T ){
- System.out.print(i);
- System.out.print(" ");
- }
- System.out.println(this.Srednia());
- System.out.println(super.toString());
- }
- public boolean Rowna(){
- double sr=3.4;
- if(this.Srednia() == (sr)) return true;
- return false;
- }
- public boolean czyKlasa(Object innyObiekt){
- if (this == innyObiekt) return true;
- if (!( this.getClass().equals(innyObiekt.getClass()) )) return true;
- return false;
- }
- public double Srednia(){
- int ilosc=T.size();
- int suma=0;
- for(int i:T){
- suma+=i;
- }
- double wynik=(double)suma / ilosc;
- return wynik;
- }
- public static void main(String[] args) {
- ArrayList< Integer > z = new ArrayList< Integer >(5);
- z.add(3);
- z.add(4);
- z.add(5);
- z.add(2);
- z.add(4);
- Oceny o=new Oceny(z,"Pawel","M");
- o.wypisz();
- Oceny o1 = new Oceny();
- o1.wypisz();
- }
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- public class Człowiek {
- public String imie;
- public String plec;
- public Człowiek(){
- this.imie="Jan";
- this.plec="M";
- }
- public Człowiek(String a){
- this.plec=a;
- if(a.equals("M")){
- this.imie="Jan";
- }
- else{
- this.imie="Ania";
- }
- }
- public Człowiek(String a, String b){
- this.plec=a;
- this.imie=b;
- }
- public String toString(){
- return "Płeć : " + plec + " " + imie;
- }
- public static void main(String[] args) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement