SlideShare a Scribd company logo
1 of 4
Download to read offline
Create an advance data type to represent web page history. Name this class 'WebHistory'. The
following should be the private members of this class: 1- int totalPagesVisited; 2- WebPagell
pages; As you can see, you also need to class "WebPage" which should have the following
private members: 1- Date visitedOn; 2- String url; 3- String content; Implement all the
necessary. constructors and all the getters/setters for these classes. Now, inside main(), write a
test code to test the working of your class. The test code should be something like this: public
static void main(String[] args) {//this is just a sample, you must test every function you wrote.
WebHistory myhist = new WebHistory(2);//totalPagesVisited should be 2 Date today = new
Date(10, 10, 2016); Date yesterday = new Date(9, 10, 2016); WebPage pi = new
WebPage(today, "www.google.com", "This is Google's webpage"); WebPage p2 = new
WebPage(yesterday, "www.yahoo.com", "This is Yahoo's webpage"); myhis.t.Add(pl);
myhist. Add(p2); System.out.printIn(myhist);
Solution
import java.util.Date;
public class WebPage {
Date visitedOn;
String url;
String content;
/**
* @param visitedOn
* @param url
* @param content
*/
public WebPage(Date visitedOn, String url, String content) {
this.visitedOn = visitedOn;
this.url = url;
this.content = content;
}
/**
* @return the visitedOn
*/
public Date getVisitedOn() {
return visitedOn;
}
/**
* @param visitedOn
* the visitedOn to set
*/
public void setVisitedOn(Date visitedOn) {
this.visitedOn = visitedOn;
}
/**
* @return the url
*/
public String getUrl() {
return url;
}
/**
* @param url
* the url to set
*/
public void setUrl(String url) {
this.url = url;
}
/**
* @return the content
*/
public String getContent() {
return content;
}
/**
* @param content
* the content to set
*/
public void setContent(String content) {
this.content = content;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "WebPage [visitedOn=" + visitedOn + ", url=" + url
+ ", content=" + content + "]";
}
}
import java.util.Arrays;
public class WebHistory {
int totalPagesVisited;
WebPage[] pages;
/**
* @param totalPagesVisited
* @param pages
*/
public WebHistory(int totalPages) {
this.totalPagesVisited = 0;
this.pages = new WebPage[totalPages];
}
public boolean Add(WebPage p) {
if (totalPagesVisited < pages.length) {
pages[totalPagesVisited] = p;
totalPagesVisited++;
return true;
} else
return false;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "WebHistory [totalPagesVisited=" + totalPagesVisited
+ ", pages=" + Arrays.toString(pages) + "]";
}
}
import java.util.Date;
public class TestWebHistory {
public static void main(String[] args) {
WebHistory myhist = new WebHistory(2);
Date today = new Date(10, 10, 2016);
Date yesterday = new Date(9, 10, 2016);
WebPage p1 = new WebPage(today, "www.google.com",
"This is Google's webpage");
WebPage p2 = new WebPage(yesterday, "www.yahoo.com",
"This is Yahoo's webpage");
myhist.Add(p1);
myhist.Add(p2);
System.out.println(myhist);
}
}
OUTPUT:
WebHistory [totalPagesVisited=2, pages=[WebPage [visitedOn=Mon May 08 00:00:00 IST
1916, url=www.google.com, content=This is Google's webpage], WebPage [visitedOn=Sun
May 09 00:00:00 IST 1915, url=www.yahoo.com, content=This is Yahoo's webpage]]]

More Related Content

Similar to Create an advance data type to represent web page history. Name this .pdf

First java-server-faces-tutorial-en
First java-server-faces-tutorial-enFirst java-server-faces-tutorial-en
First java-server-faces-tutorial-en
techbed
 
! Modernizr v2.0.6 httpwww.modernizr.com Copyri.docx
!  Modernizr v2.0.6  httpwww.modernizr.com   Copyri.docx!  Modernizr v2.0.6  httpwww.modernizr.com   Copyri.docx
! Modernizr v2.0.6 httpwww.modernizr.com Copyri.docx
MARRY7
 
1. Design a Java interface called Priority that includes two methods.pdf
1. Design a Java interface called Priority that includes two methods.pdf1. Design a Java interface called Priority that includes two methods.pdf
1. Design a Java interface called Priority that includes two methods.pdf
feelinggift
 
WuKong - Framework for Integrated Test
WuKong - Framework for Integrated TestWuKong - Framework for Integrated Test
WuKong - Framework for Integrated Test
Summer Lu
 
For this project your task is to update the RSS Reader program you w.pdf
For this project your task is to update the RSS Reader program you w.pdfFor this project your task is to update the RSS Reader program you w.pdf
For this project your task is to update the RSS Reader program you w.pdf
fathimahardwareelect
 

Similar to Create an advance data type to represent web page history. Name this .pdf (20)

Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...
Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...
Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...
 
Xml & Java
Xml & JavaXml & Java
Xml & Java
 
First java-server-faces-tutorial-en
First java-server-faces-tutorial-enFirst java-server-faces-tutorial-en
First java-server-faces-tutorial-en
 
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and Simple
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and SimpleDrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and Simple
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and Simple
 
Java Script Best Practices
Java Script Best PracticesJava Script Best Practices
Java Script Best Practices
 
Webdriver with Thucydides - TdT@Cluj #18
Webdriver with Thucydides - TdT@Cluj #18Webdriver with Thucydides - TdT@Cluj #18
Webdriver with Thucydides - TdT@Cluj #18
 
[@IndeedEng] Building Indeed Resume Search
[@IndeedEng] Building Indeed Resume Search[@IndeedEng] Building Indeed Resume Search
[@IndeedEng] Building Indeed Resume Search
 
Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6
 
Codemotion appengine
Codemotion appengineCodemotion appengine
Codemotion appengine
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
 
Multilingualism makes better programmers
Multilingualism makes better programmersMultilingualism makes better programmers
Multilingualism makes better programmers
 
! Modernizr v2.0.6 httpwww.modernizr.com Copyri.docx
!  Modernizr v2.0.6  httpwww.modernizr.com   Copyri.docx!  Modernizr v2.0.6  httpwww.modernizr.com   Copyri.docx
! Modernizr v2.0.6 httpwww.modernizr.com Copyri.docx
 
Introduction to Spring Boot.pdf
Introduction to Spring Boot.pdfIntroduction to Spring Boot.pdf
Introduction to Spring Boot.pdf
 
FluentLeniumで困った話
FluentLeniumで困った話FluentLeniumで困った話
FluentLeniumで困った話
 
1. Design a Java interface called Priority that includes two methods.pdf
1. Design a Java interface called Priority that includes two methods.pdf1. Design a Java interface called Priority that includes two methods.pdf
1. Design a Java interface called Priority that includes two methods.pdf
 
Architecure components by Paulina Szklarska
Architecure components by Paulina SzklarskaArchitecure components by Paulina Szklarska
Architecure components by Paulina Szklarska
 
The Groovy Way of Testing with Spock
The Groovy Way of Testing with SpockThe Groovy Way of Testing with Spock
The Groovy Way of Testing with Spock
 
How I make a podcast website using serverless technology in 2023
How I make a podcast website using serverless technology in 2023How I make a podcast website using serverless technology in 2023
How I make a podcast website using serverless technology in 2023
 
WuKong - Framework for Integrated Test
WuKong - Framework for Integrated TestWuKong - Framework for Integrated Test
WuKong - Framework for Integrated Test
 
For this project your task is to update the RSS Reader program you w.pdf
For this project your task is to update the RSS Reader program you w.pdfFor this project your task is to update the RSS Reader program you w.pdf
For this project your task is to update the RSS Reader program you w.pdf
 

More from sanuoptical

Complete the implementation of the binary search tree started in cla.pdf
Complete the implementation of the binary search tree started in cla.pdfComplete the implementation of the binary search tree started in cla.pdf
Complete the implementation of the binary search tree started in cla.pdf
sanuoptical
 
True, False, Uncertain with Explanation(a) Including an interacti.pdf
True, False, Uncertain with Explanation(a) Including an interacti.pdfTrue, False, Uncertain with Explanation(a) Including an interacti.pdf
True, False, Uncertain with Explanation(a) Including an interacti.pdf
sanuoptical
 

More from sanuoptical (20)

Briefly explain four functions of stems. SolutionFunction of S.pdf
Briefly explain four functions of stems.  SolutionFunction of S.pdfBriefly explain four functions of stems.  SolutionFunction of S.pdf
Briefly explain four functions of stems. SolutionFunction of S.pdf
 
AVR was one of the first microcontroller families to use A. on-chip .pdf
AVR was one of the first microcontroller families to use  A. on-chip .pdfAVR was one of the first microcontroller families to use  A. on-chip .pdf
AVR was one of the first microcontroller families to use A. on-chip .pdf
 
Complete the implementation of the binary search tree started in cla.pdf
Complete the implementation of the binary search tree started in cla.pdfComplete the implementation of the binary search tree started in cla.pdf
Complete the implementation of the binary search tree started in cla.pdf
 
A researcher was interested in studying Americans email habits. She .pdf
A researcher was interested in studying Americans email habits. She .pdfA researcher was interested in studying Americans email habits. She .pdf
A researcher was interested in studying Americans email habits. She .pdf
 
A 50 mL stock sample of cells is diluted 110 six times. If 0.1 mL o.pdf
A 50 mL stock sample of cells is diluted 110 six times. If 0.1 mL o.pdfA 50 mL stock sample of cells is diluted 110 six times. If 0.1 mL o.pdf
A 50 mL stock sample of cells is diluted 110 six times. If 0.1 mL o.pdf
 
Why are clocks (or timers) discussed in the context of IO systems.pdf
Why are clocks (or timers) discussed in the context of IO systems.pdfWhy are clocks (or timers) discussed in the context of IO systems.pdf
Why are clocks (or timers) discussed in the context of IO systems.pdf
 
why the SSB receiver re-injects the missing carrier Why add the c.pdf
why the SSB receiver re-injects the missing carrier Why add the c.pdfwhy the SSB receiver re-injects the missing carrier Why add the c.pdf
why the SSB receiver re-injects the missing carrier Why add the c.pdf
 
80 µl of 10^-5 dilution of E. coli culture was plated on LB agar and.pdf
80 µl of 10^-5 dilution of E. coli culture was plated on LB agar and.pdf80 µl of 10^-5 dilution of E. coli culture was plated on LB agar and.pdf
80 µl of 10^-5 dilution of E. coli culture was plated on LB agar and.pdf
 
Which of the following statements about pyruvate is most accurate P.pdf
Which of the following statements about pyruvate is most accurate  P.pdfWhich of the following statements about pyruvate is most accurate  P.pdf
Which of the following statements about pyruvate is most accurate P.pdf
 
Which CLI modes let you use the show running-config commandA. Use.pdf
Which CLI modes let you use the show running-config commandA. Use.pdfWhich CLI modes let you use the show running-config commandA. Use.pdf
Which CLI modes let you use the show running-config commandA. Use.pdf
 
What is meant by star activity with respect to a restriction enz.pdf
What is meant by star activity with respect to a restriction enz.pdfWhat is meant by star activity with respect to a restriction enz.pdf
What is meant by star activity with respect to a restriction enz.pdf
 
Type III hypersensitivities are also referred to as immune complex me.pdf
Type III hypersensitivities are also referred to as immune complex me.pdfType III hypersensitivities are also referred to as immune complex me.pdf
Type III hypersensitivities are also referred to as immune complex me.pdf
 
True, False, Uncertain with Explanation(a) Including an interacti.pdf
True, False, Uncertain with Explanation(a) Including an interacti.pdfTrue, False, Uncertain with Explanation(a) Including an interacti.pdf
True, False, Uncertain with Explanation(a) Including an interacti.pdf
 
Traits that are detrimental to the long-term survival of an individu.pdf
Traits that are detrimental to the long-term survival of an individu.pdfTraits that are detrimental to the long-term survival of an individu.pdf
Traits that are detrimental to the long-term survival of an individu.pdf
 
The sampling distribution of the sample mean is the probability dist.pdf
The sampling distribution of the sample mean is the probability dist.pdfThe sampling distribution of the sample mean is the probability dist.pdf
The sampling distribution of the sample mean is the probability dist.pdf
 
The lantana has which inflorescence morphology type campanulte tub.pdf
The lantana has which inflorescence morphology type  campanulte  tub.pdfThe lantana has which inflorescence morphology type  campanulte  tub.pdf
The lantana has which inflorescence morphology type campanulte tub.pdf
 
The intensity of the sound of traffic at a busy intersection was mea.pdf
The intensity of the sound of traffic at a busy intersection was mea.pdfThe intensity of the sound of traffic at a busy intersection was mea.pdf
The intensity of the sound of traffic at a busy intersection was mea.pdf
 
The garden pea is described as self-fertilizing. What does this .pdf
The garden pea is described as self-fertilizing. What does this .pdfThe garden pea is described as self-fertilizing. What does this .pdf
The garden pea is described as self-fertilizing. What does this .pdf
 
The equation for the time of one swing of a pendulum is given by T = .pdf
The equation for the time of one swing of a pendulum is given by T = .pdfThe equation for the time of one swing of a pendulum is given by T = .pdf
The equation for the time of one swing of a pendulum is given by T = .pdf
 
The assumption that arrivals follow a Poisson probability distributi.pdf
The assumption that arrivals follow a Poisson probability distributi.pdfThe assumption that arrivals follow a Poisson probability distributi.pdf
The assumption that arrivals follow a Poisson probability distributi.pdf
 

Recently uploaded

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 

Recently uploaded (20)

Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 

Create an advance data type to represent web page history. Name this .pdf

  • 1. Create an advance data type to represent web page history. Name this class 'WebHistory'. The following should be the private members of this class: 1- int totalPagesVisited; 2- WebPagell pages; As you can see, you also need to class "WebPage" which should have the following private members: 1- Date visitedOn; 2- String url; 3- String content; Implement all the necessary. constructors and all the getters/setters for these classes. Now, inside main(), write a test code to test the working of your class. The test code should be something like this: public static void main(String[] args) {//this is just a sample, you must test every function you wrote. WebHistory myhist = new WebHistory(2);//totalPagesVisited should be 2 Date today = new Date(10, 10, 2016); Date yesterday = new Date(9, 10, 2016); WebPage pi = new WebPage(today, "www.google.com", "This is Google's webpage"); WebPage p2 = new WebPage(yesterday, "www.yahoo.com", "This is Yahoo's webpage"); myhis.t.Add(pl); myhist. Add(p2); System.out.printIn(myhist); Solution import java.util.Date; public class WebPage { Date visitedOn; String url; String content; /** * @param visitedOn * @param url * @param content */ public WebPage(Date visitedOn, String url, String content) { this.visitedOn = visitedOn; this.url = url; this.content = content; } /** * @return the visitedOn */ public Date getVisitedOn() { return visitedOn; }
  • 2. /** * @param visitedOn * the visitedOn to set */ public void setVisitedOn(Date visitedOn) { this.visitedOn = visitedOn; } /** * @return the url */ public String getUrl() { return url; } /** * @param url * the url to set */ public void setUrl(String url) { this.url = url; } /** * @return the content */ public String getContent() { return content; } /** * @param content * the content to set */ public void setContent(String content) { this.content = content; } /* * (non-Javadoc) *
  • 3. * @see java.lang.Object#toString() */ @Override public String toString() { return "WebPage [visitedOn=" + visitedOn + ", url=" + url + ", content=" + content + "]"; } } import java.util.Arrays; public class WebHistory { int totalPagesVisited; WebPage[] pages; /** * @param totalPagesVisited * @param pages */ public WebHistory(int totalPages) { this.totalPagesVisited = 0; this.pages = new WebPage[totalPages]; } public boolean Add(WebPage p) { if (totalPagesVisited < pages.length) { pages[totalPagesVisited] = p; totalPagesVisited++; return true; } else return false; } /* * (non-Javadoc) * * @see java.lang.Object#toString() */ @Override public String toString() { return "WebHistory [totalPagesVisited=" + totalPagesVisited
  • 4. + ", pages=" + Arrays.toString(pages) + "]"; } } import java.util.Date; public class TestWebHistory { public static void main(String[] args) { WebHistory myhist = new WebHistory(2); Date today = new Date(10, 10, 2016); Date yesterday = new Date(9, 10, 2016); WebPage p1 = new WebPage(today, "www.google.com", "This is Google's webpage"); WebPage p2 = new WebPage(yesterday, "www.yahoo.com", "This is Yahoo's webpage"); myhist.Add(p1); myhist.Add(p2); System.out.println(myhist); } } OUTPUT: WebHistory [totalPagesVisited=2, pages=[WebPage [visitedOn=Mon May 08 00:00:00 IST 1916, url=www.google.com, content=This is Google's webpage], WebPage [visitedOn=Sun May 09 00:00:00 IST 1915, url=www.yahoo.com, content=This is Yahoo's webpage]]]