Question: package questions; //Do not import any additional libraries! //-20 penalty applies for each additional import public class Bookmark { private String name; private Webpage webpage;

package questions;

//Do not import any additional libraries!

//-20 penalty applies for each additional import

public class Bookmark {

private String name;

private Webpage webpage;

public String getName() {

return name;

}

public Webpage getWebpage() {

return webpage;

}

/**

* (4 marks)

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

*

* The function should ensure the following

* - If a null value is given, the 'name' should be set to "default"

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

* - The name should not exceed 15 characters, if the passed parameter exceeds 15 characters,

* only the first 15 should be used.

* - The name should not contain any special characters. If there are any special characters,

* the 'name' instance variable should be set to "default" instead.

*/

public void setName(String name) {

//TODO To be completed

}

/**

* (1 marks)

* @param webpage - The Webpage object used to set the instance variable

*

* This function should use a shallow copy to copy the passed Webpage

* object to the 'webpage' instance variable

*/

public void setWebpage(Webpage webpage) {

//TODO To be completed

}

/**

* (1 marks)

* @param name

* @param webpage

*

* 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 Bookmark(String name, Webpage webpage) {

//TODO To be completed

}

/**

* (3 marks)

* This function should return a string representing the calling object

*

* Example

* If the calling object contained the following values:

* - name = "Favourite Cat Website"

* - webpage = Webpage(

* title = "Cats!!!"

* url = "https://wikipedia.com/cats"

* fileSize = 5812

* )

*

* toString() should return the following String:

* Bookmark name = "Favourite Cat Website", Webpage data = [title = Cats!!!, url = https://wikipedia.com/cats, fileSize = 5812]

*

* Hint: You can use the toString() for the Webpage object to help you

*/

public String toString() {

//TODO To be completed

return null;

}

/**

* DO NOT MODIFY ANYTHING BELOW!!!

*/

public Bookmark() {}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!