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 Webpage { private String title; private String url;

package questions;

//Do not import any additional libraries!

//-20 penalty applies for each additional import

public class Webpage {

private String title;

private String url;

private String data;

private long fileSize;

public String getTitle() {

return title;

}

public String getUrl() {

return url;

}

public String getData() {

return data;

}

public long getFileSize() {

return fileSize;

}

/**

* (3 marks)

* @param t - The value used to set the object title

*

* The function should ensure the following

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

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

* - The title should not exceed 20 characters, if 't' exceeds 20 characters,

* only the first 20 should be used.

*/

public void setTitle(String t) {

//TODO To be completed

}

/**

* (4 marks)

* @param u - The value used to set the object url

*

* The function should ensure the following

* - If a null value is given, the 'url' should be set to "https://example.com"

* - If an empty string is given, the url should be set to "https://example.com"

* - The url must start with "http://" or "https://", if 'u' does not start with

* this then "http://" should be prepended.

* - The url must not contain any spaces. Any space characters should be removed

* - The url must contain a dot followed by a Top Level Domain (TLD). For example in

* "http://google.com", "com" is the Top Level Domain. If a url does not have a dot followed

* by a TLD, then ".fake" should be added to the end.

*/

public void setUrl(String u) {

//TODO To be completed

}

/**

* (2 marks)

* @param d - The value used to set the object data

*

* The function should ensure the following

* - If a null value is given, the 'data' should be set to "" (the empty string)

*/

public void setData(String d) {

//TODO To be completed

}

/**

* (2 marks)

* @param f - The value used to set the object fileSize

*

* The function should ensure the following

* - If a negative value is passed, 0 should be used set the fileSize

*/

public void setFileSize(long f) {

//TODO To be completed

}

/**

* (2 marks)

* @param t

* @param u

* @param d

* @param f

*

* 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 Webpage(String t, String u, String d, long f) {

//TODO To be completed

}

/**

* (2 marks)

* @param other - the other object to compare against

*

* @return true if the calling object and the passed object contain the

* same values (title, url, data, fileSize)

*

* If other is null, then false should be returned

*/

public boolean equals(Object other) {

//TODO To be completed

return false;

}

/**

* (2 marks)

* This function should return a string representing the calling object

*

* Example

* If the calling object contained the following values:

* - title = "Cats!!!"

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

* - fileSize = 5812

*

* toString() should return the following String:

* title = Cats!!!, url = https://wikipedia.com/cats, fileSize = 5812

*/

public String toString() {

//TODO To be completed

return null;

}

/**

* (6 marks)

* This function should return a string representing the calling object

*

* Example

* If the calling object contained the following values:

* - title = "Cats!!!"

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

* - fileSize = 5812

* - data =

* """

*

*

*

* Cats

*

*

*

Cats

*

Cats are one of the most popular pets in the world. They are known for their independent personalities and their love of napping. Cats come in a variety of breeds and colors, and they can even be trained to do tricks!

*

Health and Nutrition

*

Cats need a balanced diet to stay healthy and active. They should be fed a mix of wet and dry food, and plenty of fresh water. Regular vet visits are necessary to stay up-to-date on vaccinations and health screenings.

*

Exercise and Play

*

Cats need plenty of exercise to stay healthy and happy. Playtime with interactive toys, as well as scratching posts and cat trees, can help them stay active and have fun. Regular grooming is also important to keep their fur healthy and free of tangles.

*

*

* """

*

* toString() should return the following String:

* """

* title = Cats!!!

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

* fileSize = 5812

* data =

* 1.

* 2.

* 3.

* 4. Cats

* 5.

* 6.

* 7.

Cats

* 8.

Cats are one of the most popular pets in the world. They are known for their independent personalities and their love of napping. Cats come in a variety of breeds and colors, and they can even be trained to do tricks!

* 9.

Health and Nutrition

* 10.

Cats need a balanced diet to stay healthy and active. They should be fed a mix of wet and dry food, and plenty of fresh water. Regular vet visits are necessary to stay up-to-date on vaccinations and health screenings.

* 11.

Exercise and Play

* 12.

Cats need plenty of exercise to stay healthy and happy. Playtime with interactive toys, as well as scratching posts and cat trees, can help them stay active and have fun. Regular grooming is also important to keep their fur healthy and free of tangles.

* 13.

* 14.

* """

*

*

* Notes

* - You can make a new line in a string using " "

* - "".split(String) converts a String into a String[] based on the String passed

* - After a single digit line number e.g. "1." there is two space characters inserted

* - After a two digit line number e.g. "10." there is one space character inserted

*/

public String toStringAdvanced() {

//TODO To be completed

return null;

}

/**

* DO NOT MODIFY ANYTHING BELOW!!!

*/

public Webpage() {}

}

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

What is A free product or gift?

Answered: 1 week ago