10A
You are given a class Gallery which models a collection of Pictures.
You are to add these methods complete with javadoc:
public int getArea(int index)
Get the area of the picture at the given indexpublic int sum()
Get the sum of the areas of all the picturespublic void minFirst()
Put the Picture with the smallest area first.Download these images and save them in the project folder
For the draft, just implement getArea method
10B
Complete the Array2DManager class. Array2DManager has a constructor that creates a two dimensional array of random ints less that 100 with the given number of rows and columns and assigns it to the instance variable. The Random object is created for you with a seed. Do not change it.
Add these methods
public int sum()
Gets the sum of all the integers in the array for this Array2DManagerpublic String toString()
returns a string representation of a m x n array with m rows each of which contains the n numbers in the columns of that row, separated by commas. Your method should not use System.out.printlnpublic static int sum(int[][] array)
Gets the sum of the given 2d array. Notice that you have 2 methods named sum
: an instance method that works on the instance variable of the class and a static method that works on the parameter passed to it.For the draft, provide instance variable and constructor. Code the instance method sum
to return the sum of the 0th row.
10C
Complete the class StudentManager. StudentManager contains an Arraylist of Student objects. The ArrayList is called students. Do not change the variable name. A student has a name and a final average. You are given the Student class.
Add constructor and methods:
public StudentManager()
takes no parameters but must initialize the ArrayList instance variable students.public void add(Student s)
adds a student to this StudentManagerpublic Student findStudent(String name)
Gets the first instance of a student with the given name or null if a student of that name does not exist.public double classAverage()
Gets the average of all Student grades for the class. If there are not Students, return 0,public String toString()
returns a string representation of this StudentManager. Done for youFor the draft, implement the constructor and the add method