Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.util.Scanner;
- public class Grade
- {
- String gradeName;
- Racaz racaz = new Racaz("Racaz", "math");
- static CLASS []classArray= new CLASS[2];
- public Grade(String name, String Racaz){
- this.gradeName = name;
- for(int i=0; i<classArray.length; i++){
- classArray[i] = new CLASS(" ", i);
- }
- }
- public void setName(String name){
- this.gradeName = name;
- }
- public String getName(){
- return this.gradeName;
- }
- }
- import java.util.*;
- public class Class {
- String className;
- static int numStudents;
- static Student[]classArray= new Student[5];
- public Class(String numClass,int numStudents){
- classArray = new Student[5];
- this.className=numClass;
- this.numStudents=numStudents;
- for(int i = 0; i<classArray.length; i++){
- classArray[i] = new Student (numClass,"aviv", 100-i); //String classNumber, String name, double average
- }
- }
- /**
- *
- * @return true if you can add a student
- */
- public int getStudent(){
- return numStudents;
- }
- /**
- *
- */
- public String toString(){
- return "Class: number of students = "+ numStudents +" the class name= "+ className + ". the class has 5 students: ";
- }
- }
- import java.util.*;
- public class Student
- { //13:08 - 13:16
- String classNumber;
- String name;
- double average;
- /**
- * פעולה בונה תלמיד עם כיתה ושם
- * @param classNumber הכיתה
- * @param name שם
- */
- public Student(String classNumber, String name, double average){
- this.classNumber = classNumber;
- this.name = name;
- this.average = average;
- }
- /**
- * הפעולה מחזירה את הכיתה של התלמיד
- * לפעולה אין פרמטרים
- * @return הפעולה מחזירה ערך
- */
- public String getClassNumber(){
- return this.classNumber;
- }
- /**
- * הפעולה מחזירה את שם התלמיד
- * לפעולה אין פרמטרים
- * @return הפעולה מחזירה ערך
- */
- public String getName(){
- return this.name;
- }
- /**
- * הפעולה מחזירה את ממוצע התלמיד
- * לפעולה אין פרמטרים
- * @return הפעולה מחזירה ערך
- */
- public double getAverage(){
- return this.average;
- }
- /**
- * הפעולה מקבלת את הכיתה החדשה של התלמיד ומעדכנת בטיפוס
- * הפעולה לא מחזירה ערך
- * @param classNumbernew הכיתה החדשה של התלמיד
- */
- public void setClassNumber(String classNumbernew){
- this.classNumber = classNumbernew;
- }
- /**
- * הפעולה מקבלת את הממוצע החדש של התלמיד ומעדכנת בטיפוס
- * הפעולה לא מחזירה ערך
- * @param average הממוצע החדש של התלמיד
- */
- public void setAverage(int average){
- this.average = average;
- }
- /**
- * הפעולה מקבלת את שם התלמיד ומעדכנת בטיפוס
- * הפעולה לא מחזירה ערך
- * @param Name שם התלמיד
- */
- public void setName(String Name){
- this.name = Name;
- }
- }
- import java.util.*;
- import java.util.Scanner;
- public class twoObjectives
- {
- public static void main(String[] args){
- Class c1 = new Class("yud3", 5);
- double highestGrade = 0;
- String bestStudent = "yehu";
- System.out.println(c1);
- for(int i = 0;i<c1.classArray.length; i++){
- if (c1.classArray[i].average>highestGrade){
- highestGrade = c1.classArray[i].average;
- bestStudent = c1.classArray[i].name;
- }
- }
- System.out.println("The student with the highest grade is " + bestStudent + " with an average of " + highestGrade);
- c1.classArray[3].average = 100;
- System.out.println(c1);
- }
- }
- import java.util.*;
- public class Shirt
- {
- double price;
- String color;
- int measure;
- /**
- * builds the shirt
- * @param price the price of the shirt
- * @param color the color of the shirt
- * @param measure the measure of the shirt
- */
- public Shirt (int price, String color, int measure){
- this.color = color;
- this.price = price;
- this.measure = measure;
- }
- /**
- * getting a discount and reterning the price of the shirt after the discount
- * @param discount
- * @return shirt price after discount
- */
- public double discount(double discount){
- return this.price*((100-discount)%100);
- }
- /**
- * returns the Description of the shirt
- * @return the string with the description
- * @see java.lang.Object#toString()
- */
- public String toString(){
- String toString = "the shirt is" + color + "its price is" + price + "and the measure is" + measure ;
- return toString;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement