Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. import java.util.ArrayList;
  2.  
  3.  
  4. class Oceny extends Człowiek{
  5.  
  6.  
  7.  
  8. public ArrayList< Integer > T = new ArrayList< Integer >(5);
  9.  
  10. public Oceny(){
  11.  
  12. ArrayList<Integer> x =new ArrayList <Integer>(5);
  13. for(int i=0;i<5;i++){
  14. x.add(1);
  15. }
  16. T=x;
  17. }
  18.  
  19.  
  20. public Oceny(ArrayList<Integer> t){
  21.  
  22. T=t;
  23.  
  24. }
  25. public Oceny(ArrayList<Integer> t,String k){
  26. super("K",k);
  27. T=t;
  28. }
  29.  
  30. public Oceny(ArrayList<Integer> t , String k, String p){
  31. super(k,p);
  32. T=t;
  33. }
  34.  
  35. public void wypisz(){
  36.  
  37. for(int i:T ){
  38. System.out.print(i);
  39. System.out.print(" ");
  40. }
  41.  
  42. System.out.println(this.Srednia());
  43. System.out.println(super.toString());
  44. }
  45. public boolean Rowna(){
  46. double sr=3.4;
  47. if(this.Srednia() == (sr)) return true;
  48. return false;
  49. }
  50. public boolean czyKlasa(Object innyObiekt){
  51. if (this == innyObiekt) return true;
  52. if (!( this.getClass().equals(innyObiekt.getClass()) )) return true;
  53. return false;
  54.  
  55. }
  56. public double Srednia(){
  57. int ilosc=T.size();
  58. int suma=0;
  59. for(int i:T){
  60. suma+=i;
  61. }
  62. double wynik=(double)suma / ilosc;
  63. return wynik;
  64.  
  65. }
  66.  
  67. public static void main(String[] args) {
  68.  
  69. ArrayList< Integer > z = new ArrayList< Integer >(5);
  70. z.add(3);
  71. z.add(4);
  72. z.add(5);
  73. z.add(2);
  74. z.add(4);
  75.  
  76.  
  77. Oceny o=new Oceny(z,"Pawel","M");
  78. o.wypisz();
  79. Oceny o1 = new Oceny();
  80. o1.wypisz();
  81.  
  82. }
  83.  
  84. }
  85. /////////////////////////////////////////////////////////////////////////////////////////////////
  86.  
  87.  
  88.  
  89. public class Człowiek {
  90.  
  91. public String imie;
  92. public String plec;
  93.  
  94. public Człowiek(){
  95. this.imie="Jan";
  96. this.plec="M";
  97. }
  98. public Człowiek(String a){
  99. this.plec=a;
  100. if(a.equals("M")){
  101. this.imie="Jan";
  102. }
  103. else{
  104. this.imie="Ania";
  105. }
  106. }
  107. public Człowiek(String a, String b){
  108. this.plec=a;
  109. this.imie=b;
  110. }
  111.  
  112. public String toString(){
  113. return "Płeć : " + plec + " " + imie;
  114. }
  115.  
  116. public static void main(String[] args) {
  117.  
  118.  
  119. }
  120.  
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement