Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

package toBeCompleted; import java.util.*; /* * 15 methods to be completed, each worth 4 marks, * except for toString, which is worth 18 marks. *

package toBeCompleted;

import java.util.*;

/*

* 15 methods to be completed, each worth 4 marks,

* except for toString, which is worth 18 marks.

* for all methods except toString, you will get

* marks if your code passes the tests we eventually use.

* (our test data will be almost identical to the given

* test data but with just enough difference to catch

* any hard-coding)

* for toString, you will get partial marks based

* on the extent of similarity of your output to output given

* in specifications.

* toString marking guide:

* 8 marks: correct row and column heading

* 5 marks: correct indentation

* 5 marks: correct values

*/

public class Worksheet {

private ArrayList data;

private String title;

/**

* create a new worksheet with given title

* @param title

*/

public Worksheet(String title) {

data = new ArrayList();

this.title = title;

}

/**

* @return a shallow copy of the data

*/

public ArrayList getData() {

return data;

}

/**

*

* @return title of the worksheet

*/

public String getTitle() {

return title;

}

/**

*

* @param row

* @param column

* @return value of item at given row and column (if any), null otherwise

*/

public Double get(int row, int column) {

return 0;// to be completed

}

/**

* set the value of DataEntry object at given row and column to given value

*

* if a DataEntry object for given row and column already exists, overwrite the current value

* if a DataEntry object for given row and column doesn't exist, add a new DataEntry object

* with given row, column, value to the list.

* @param row

* @param column

* @param val

*/

public void set(int row, int column, double val) {

//to be completed

}

/**

*

* @param row

* @param column

* @return index of DataEntry object in list data with given row and column

* return -1 if no such DataEntry object found

*/

public int indexOf(int row, int column) {

for(int i=0; i

if(data.get(i).getRow()==row&&data.get(i).getColumn()==column)

return i;

}

return -1;//to be completed

}

/**

*

* @param row1

* @param column1

* @param row2

* @param column2

* @return number of DataEntry objects in given address range , 0 if none

* ((row1, column1) to (row2, column2))

*/

public int count(int row1, int column1, int row2, int column2) {

return 0; //to be completed

}

/**

*

* @param row1

* @param column1

* @param row2

* @param column2

* @return sum of values of all DataEntry objects in given address range

* ((row1, column1) to (row2, column2))

* return 0 if there are no items in the given range

*/

public double total(int row1, int column1, int row2, int column2) {

return 0; //to be completed

}

/**

*

* @param row1

* @param column1

* @param row2

* @param column2

* @return average of values of all DataEntry objects in given address range

* ((row1, column1) to (row2, column2))

* return 0 if there are no items in the given range

*/

public double average(int row1, int column1, int row2, int column2) {

return 0; //to be completed

}

/**

*

* @return value of the first row for which there is a DataEntry object

* in the list data

* return null if there is no data

*/

public Integer minRow() {

return null; //to be completed

}

/**

*

* @return value of the last row for which there is a DataEntry object

* in the list data

* return null if there is no data

*/

public Integer maxRow() {

return null; //to be completed

}

/**

*

* @return value of the first column for which there is a DataEntry object

* in the list data

* return null if there is no data

*/

public Integer minColumn() {

return null; //to be completed

}

/**

*

* @return value of the last column for which there is a DataEntry object

* in the list data

* return null if there is no data

*/

public Integer maxColumn() {

return null; //to be completed

}

/**

*

* @param row

* @return list of values of data items from given row

* return empty list if no items belong to the given row

*/

public ArrayList getDataByRow(int row) {

return new ArrayList(); //to be completed

}

/**

*

* @param column

* @return list of values of data items from given column

* return empty list if no items belong to the given column

*/

public ArrayList getDataByColumn(int column) {

return new ArrayList(); //to be completed

}

/**

* replace all occurrences of key item by replacement item

* @param key

* @param replacement

*/

public void replace(double key, double replacement) {

//to be completed

}

/**

*

* @param key

* @return a list of DataEntry objects that have

* key as their value attribute

*/

public ArrayList find(double key) {

return new ArrayList(); //to be completed

}

/**

* return String output of the object in format required

* in specifications

*

* NOTE there is no test for this method. output should resemble the sample output provided

* in the specifications

*/

public String toString() {

return ""; //to be completed

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

6th Edition

1943153035, 978-1943153039

More Books

Students also viewed these Databases questions

Question

3. What are potential solutions?

Answered: 1 week ago