Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java code help please:- package toBeCompleted.stage3; import java.util.*; import toBeCompleted.stage1.Assessment; import toBeCompleted.stage2.GradebookEntry; public class Gradebook { private ArrayList assessments; private ArrayList records; /** * DO

Java code help please:-

package toBeCompleted.stage3;

import java.util.*;

import toBeCompleted.stage1.Assessment;

import toBeCompleted.stage2.GradebookEntry;

public class Gradebook {

private ArrayList assessments;

private ArrayList records;

/**

* DO NOT MODIFY

* @return number of records

*/

public int numberOfRecords() {

return records.size();

}

/**

* DO NOT MODIFY

* @return number of assessments

*/

public int numberOfAssessments() {

return assessments.size();

}

/**

* DO NOT MODIFY

*/

public String toString() {

String header1 = "Asssessment title: \t";

String header2 = "Asssessment worth: \t";

double totalWorth = 0;

for(Assessment a: assessments) {

header1 = header1 + a.getTitle() + "\t";

header2 = header2 + "(" + a.getWorth() + ")\t";

totalWorth += a.getWorth();

}

header2 = header2 + "(Total "+totalWorth+")";

String data = records.toString();

data = data.replace("[", "");

data = data.replace("]", "");

data = data.replaceAll(", ", "");

return header1+" "+header2+" "+data;

}

/**

* make a deep copy of the parameters into the instance variables

* @param c

* @param r

*/

public Gradebook(ArrayList c, ArrayList r) {

//to be completed

}

/**

*

* @param recordNumber

* @return true if the given record number is valid.

* For example, if there are 9 records, valid record numbers

* are from 0 to 8 (including 0 and 8)

*/

public boolean isValidRecordNumber(int recordNumber) {

return false; //to be completed

}

/**

*

* @param assessmentNumber

* @return true if assessmentNumber is valid, false otherwise

*/

public boolean isValidAssessmentNumber(int assessmentNumber) {

return false; //to be completed

}

/**

*

* @param assessmentTitle

* @return how much is the assessment worth. return null if assessment not found

*/

public Double getWorth(String assessmentTitle) {

return null; //to be completed

}

/**

* sort the records in descending order of totals.

* hint: you can use the method compareTo from class GradebookEntry

*/

public void sortRecords() {

//to be completed

}

/**

*

* @param title

* @return index of assessment with given title. return -1 if no such title exists

*/

public int getAssessmentIndex(String title) {

return 0; //to be completed

}

/**

* scale marks of a particular assessment, whose title is provided

* by the given factor (1.2 means increase by 20%, 0.75 means decrease by 25%).

* note that marks should have an upper bound of what that particular assessment is worth,

* and a lower bound of 0. Thus, a mark of 4 out of 5, with a factor of 0.5, should become 5 (and not 6).

* Similarly, a mark of 2 out of 5, with a factor = -1.5, should become 0 (and not -1).

* do nothing if there is no assessment with the given title

* @param title

* @param factor

*/

public void scale(String title, double factor) {

//to be completed

}

/**

* D/HD

* sort the assessments in ascending order of how much they are worth.

* Note that each record should be updated as well.

*/

public void sortAssessments() {

//to be completed

}

/**

* D/HD

* set the marks of student with the given name in the assessment with the

* title of assessmentTitle to given marks

* @param name: name of student

* @param assessmentTitle: title of assessment

* @param marks: marks to be set for the given student and assignment

*/

public void setMarks(String name, String assessmentTitle, double marks) {

//to be completed

}

/**

*

* @param idx

* @return GradebookEntry at given index if index is valid, return null otherwise

*/

public GradebookEntry getRecord(int idx) {

return null; //to be completed

}

/**

*

* @param idx

* @return Assessment at given index if index is valid, return null otherwise

*/

public Assessment getAssessment(int idx) {

return null; //to be completed

}

/**

*

* @param name

* @param title

* @return mark of student with given name in an assessment with given title.

* return null if no such record exists.

*/

public Double getMark(String name, String title) {

return null; //to be completed

}

/**

*

* @param name

* @return record for student with given name. return null if no such record exists

*/

public GradebookEntry getRecord(String name) {

return null; //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_2

Step: 3

blur-text-image_3

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

Practical Neo4j

Authors: Gregory Jordan

1st Edition

1484200225, 9781484200223

More Books

Students also viewed these Databases questions

Question

Define succession planning. Why is it important?

Answered: 1 week ago

Question

Explain walter's model of dividend policy.

Answered: 1 week ago