Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

package questions; //Do not import any additional libraries! //-20 penalty applies for each additional import public class Folder { private String folderName; private Bookmark[] bookmarks;

package questions;

//Do not import any additional libraries!

//-20 penalty applies for each additional import

public class Folder {

private String folderName;

private Bookmark[] bookmarks;

public String getFolderName() {

return folderName;

}

public Bookmark[] getBookmarks() {

return bookmarks;

}

/**

* (4 marks)

* @param folderName - The value used to set the object folderName

*

* The function should ensure the following

* - If a null value is given, the 'title' should be set to "New Folder"

* - If an empty string is given, the title should be set to "New Folder"

* - The folderName must start with a capital letter.

* + If the passed folderName starts with a lower case letter, it should be made uppercase

* + If the passed folderName does not start with a letter, the letter "X" should be prepended

*/

public void setFolderName(String folderName) {

//TODO To be completed

}

/**

* (4 marks)

* @param bookmarks - the Bookmark array used to set the instance variable

*

* This function should create a deepcopy of the bookmarks parameter value to the 'bookmarks'

* instance variable. The Bookmark objects held by the array should also be deep copied.

*

* To perform a deep copy you must create a new Array and new Bookmark objects.

*/

public void setBookmarks(Bookmark[] bookmarks) {

//TODO To be completed

}

/**

* (1 marks)

* @param folderName

* @param bookmarks

*

* This constructor must:

* - Use the passed values to set the instance variables

* - Use the setters created above

*

* No marks will be given unless all the setters above are used.

* Full marks will be awarded if the constructor is defined correctly.

*/

public Folder(String folderName, Bookmark[] bookmarks) {

//TODO To be completed

}

/**

* DO NOT MODIFY ANYTHING BELOW!!!

*/

public Folder() {}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions