Using a text editor write an HTML page that has a table in it. Use a browser to check that it is working. Then add the HTML for the table to the body of a homepage generated with the class WebPageWriter.
What will be an ideal response?
``` I am i n t e r e s t e d i n t h e f o l l o w i n g ” +
/? ?
? Method t o r e t u r n t h e s t r i n g f o r an HTML t a b l e
? from t h e p a s s e d l i s t w i t h t h e p a s s e d maximum columns
? @param t a b l e L i s t t h e l i s t t o make t h e t a b l e from
? @param maxCols t h e maximum number o f columns
? @return a s t r i n g w i t h t h e HTML t a g s f o r t h e t a b l e
?/
private S t r i n g makeTableFromList ( L i s t t a b l e L i s t , i nt maxCols )
{
S t r i n g r e s u l t = ”
Iterator iterator = tableList . iterator ();
// g e t t h e number o f rows i n t h e t a b l e
i n t numRows = ( i n t ) Math . c e i l ( t a b l e L i s t . s i z e ( ) /
( double ) maxCols ) ;
// l o o p t h r o u g h t h e rows
f o r ( i n t row = 0 ; row < numRows ; row++)
{
r e s u l t = r e s u l t + ”
// l o o p t h r o u g h t h e columns
f o r ( in t c o l = 0 ;
c o l < maxCols &&
( row ? maxCols + c o l ) < t a b l e L i s t . s i z e ( ) ;
c o l ++)
{
r e s u l t = r e s u l t + ”” + i t e r a t o r . n ext ( ) + ” ” ;
}
r e s u l t = r e s u l t + ”
}
r e s u l t = r e s u l t + ” t a b l e >” ;
return r e s u l t ;
}
/? ?
? Method f o r w r i t i n g a homepage
? @param name t h e p e r s o n ’ s name
? @param i n t e r e s t s a l i s t o f t h e p e r s o n ’ s i n t e r e s t s
?/
public void writeHomepageV7 ( S t r i n g name ,
List interests )
{
// t r y t h e f o l l o w i n g
try {
// open a f i l e f o r w r i t i n g
S t r i n g path = F i l e C h o o s e r . getMediaPath ( name + ” . html ” ) ;
BufferedWriter writer =
new B u f f e r e d W r i t e r (new F i l e W r i t e r ( path ) ) ;
// w r i t e t h e s t a r t
writeStart ( writer );
// w r i t e t h e h e a d e r
writeHead ( w r i t e r , name + ” ’ s Homepage” ) ;
// make a t a b l e o f t h e i n t e r e s t s l i s t
S t r i n g i n t e r e s t T a b l e = makeTableFromList ( i n t e r e s t s , 3 ) ;
// w r i t e t h e body
writeBody ( w r i t e r , ”Welcome t o ” + name +
” +
” ’ s Homepage
”
interestTable );
// end t h e page
writeEnd ( w r i t e r ) ;
// c l o s e t h e w r i t e r
writer . close ( ) ;
} catch ( E x c e p t i o n ex ) {
ex . p r i n t S t a c k T r a c e ( ) ;
}
}
```
You might also like to view...
PowerPoint does not provide layouts containing chart placeholders, only picture ones.
Answer the following statement true (T) or false (F)
Apache OpenOffice is the most popular office suite today
Indicate whether the statement is true or false
A digital camera’s resolution is measured in ____, or millions of dots per inch.
a. pixels b. megapixels c. bits d. none of the above
Captions are numbered sequentially
Indicate whether the statement is true or false