Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.14 KB | None | 0 0
  1. import java.util.*;
  2. import java.util.Scanner;
  3. public class Grade
  4. {
  5. String gradeName;
  6. Racaz racaz = new Racaz("Racaz", "math");
  7. static CLASS []classArray= new CLASS[2];
  8.  
  9. public Grade(String name, String Racaz){
  10. this.gradeName = name;
  11. for(int i=0; i<classArray.length; i++){
  12. classArray[i] = new CLASS(" ", i);
  13. }
  14. }
  15.  
  16. public void setName(String name){
  17. this.gradeName = name;
  18. }
  19. public String getName(){
  20. return this.gradeName;
  21. }
  22. }
  23.  
  24.  
  25. import java.util.*;
  26. public class Class {
  27. String className;
  28. static int numStudents;
  29. static Student[]classArray= new Student[5];
  30.  
  31. public Class(String numClass,int numStudents){
  32. classArray = new Student[5];
  33. this.className=numClass;
  34. this.numStudents=numStudents;
  35. for(int i = 0; i<classArray.length; i++){
  36. classArray[i] = new Student (numClass,"aviv", 100-i); //String classNumber, String name, double average
  37.  
  38. }
  39. }
  40. /**
  41. *
  42. * @return true if you can add a student
  43. */
  44. public int getStudent(){
  45. return numStudents;
  46. }
  47. /**
  48. *
  49. */
  50. public String toString(){
  51. return "Class: number of students = "+ numStudents +" the class name= "+ className + ". the class has 5 students: ";
  52.  
  53. }
  54. }
  55.  
  56. import java.util.*;
  57. public class Student
  58. { //13:08 - 13:16
  59. String classNumber;
  60. String name;
  61. double average;
  62. /**
  63. * פעולה בונה תלמיד עם כיתה ושם
  64. * @param classNumber הכיתה
  65. * @param name שם
  66. */
  67. public Student(String classNumber, String name, double average){
  68. this.classNumber = classNumber;
  69. this.name = name;
  70. this.average = average;
  71. }
  72. /**
  73. * הפעולה מחזירה את הכיתה של התלמיד
  74. * לפעולה אין פרמטרים
  75. * @return הפעולה מחזירה ערך
  76. */
  77. public String getClassNumber(){
  78. return this.classNumber;
  79. }
  80. /**
  81. * הפעולה מחזירה את שם התלמיד
  82. * לפעולה אין פרמטרים
  83. * @return הפעולה מחזירה ערך
  84. */
  85. public String getName(){
  86. return this.name;
  87. }
  88. /**
  89. * הפעולה מחזירה את ממוצע התלמיד
  90. * לפעולה אין פרמטרים
  91. * @return הפעולה מחזירה ערך
  92. */
  93. public double getAverage(){
  94. return this.average;
  95. }
  96. /**
  97. * הפעולה מקבלת את הכיתה החדשה של התלמיד ומעדכנת בטיפוס
  98. * הפעולה לא מחזירה ערך
  99. * @param classNumbernew הכיתה החדשה של התלמיד
  100. */
  101. public void setClassNumber(String classNumbernew){
  102. this.classNumber = classNumbernew;
  103. }
  104. /**
  105. * הפעולה מקבלת את הממוצע החדש של התלמיד ומעדכנת בטיפוס
  106. * הפעולה לא מחזירה ערך
  107. * @param average הממוצע החדש של התלמיד
  108. */
  109. public void setAverage(int average){
  110. this.average = average;
  111. }
  112. /**
  113. * הפעולה מקבלת את שם התלמיד ומעדכנת בטיפוס
  114. * הפעולה לא מחזירה ערך
  115. * @param Name שם התלמיד
  116. */
  117. public void setName(String Name){
  118. this.name = Name;
  119. }
  120. }
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127. import java.util.*;
  128. import java.util.Scanner;
  129. public class twoObjectives
  130. {
  131. public static void main(String[] args){
  132. Class c1 = new Class("yud3", 5);
  133. double highestGrade = 0;
  134. String bestStudent = "yehu";
  135. System.out.println(c1);
  136. for(int i = 0;i<c1.classArray.length; i++){
  137. if (c1.classArray[i].average>highestGrade){
  138. highestGrade = c1.classArray[i].average;
  139. bestStudent = c1.classArray[i].name;
  140. }
  141. }
  142. System.out.println("The student with the highest grade is " + bestStudent + " with an average of " + highestGrade);
  143. c1.classArray[3].average = 100;
  144. System.out.println(c1);
  145. }
  146. }
  147.  
  148.  
  149. import java.util.*;
  150. public class Shirt
  151. {
  152. double price;
  153. String color;
  154. int measure;
  155. /**
  156. * builds the shirt
  157. * @param price the price of the shirt
  158. * @param color the color of the shirt
  159. * @param measure the measure of the shirt
  160. */
  161. public Shirt (int price, String color, int measure){
  162. this.color = color;
  163. this.price = price;
  164. this.measure = measure;
  165. }
  166. /**
  167. * getting a discount and reterning the price of the shirt after the discount
  168. * @param discount
  169. * @return shirt price after discount
  170. */
  171. public double discount(double discount){
  172. return this.price*((100-discount)%100);
  173. }
  174. /**
  175. * returns the Description of the shirt
  176. * @return the string with the description
  177. * @see java.lang.Object#toString()
  178. */
  179. public String toString(){
  180. String toString = "the shirt is" + color + "its price is" + price + "and the measure is" + measure ;
  181. return toString;
  182. }
  183. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement