Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Constructor Detail TagElement Initializes a tag element. We can have tag element

ID: 3749604 • Letter: C

Question

Constructor Detail

TagElement

Initializes a tag element. We can have tag elements with only a start tag. Each time a new tag element is created it is assigned a unique id (starting at 1).

Parameters:

tagName -

endTag -

content -

attributes -

Method Detail

getId

Returns:

unique id

getStringId

Returns:

tagname followed by the unique id

getStartTag

Returns the start tag. It will not include the id if inclusion has been disabled.

Returns:

string representing the start tag including attributes (if any).

getEndTag

Returns:

end tag or empty string (for tags with only start tag).

setAttributes

Updates attributes field.

Parameters:

attributes -

resetIds

Allow us to start assigning ids at 1 again.

enableId

Allow us to enable or disable the generation of ids for tags.

Parameters:

choice -

genHTML

{

Description copied from interface: Element

Returns a string that represents the HTML associated with the element. The string is indented based on the parameter value.

Specified by:

genHTML in interface Element

Returns:

HTML associated with the element.

}

Explanation / Answer

There are a lot of parts in the quetion, I'm completing most of them here.

class TagName {

String id;

String tagName;

String tagName;

String endTag;

String content;

String attributes;

boolean choice;

this.tagName = tagName;

this.endTag = endTag;

this.content = content;

this.attributes = attributes;

this.id = 1;

this.choice = false;

}

public int getId() {

return this.id;

}

public String getStringId() {

return tagName+id.toString();

}

public void setAttributes(String attributes) {

this.attributes = attributes;

}

public static void enabledId(boolean choice) {

this.choice = choice;

}

public static void resetIds() {

this.id = 1;

}

public String getEndTag() {

return this.endTag == null? "" : this.endTag;

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote