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 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

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

Online Market Research Cost Effective Searching Of The Internet And Online Databases

Authors: John F. Lescher

1st Edition

0201489295, 978-0201489293

More Books

Students also viewed these Databases questions

Question

Explain the causes of indiscipline.

Answered: 1 week ago