Write the definition for a class Car which has the manufacturer, model, year, and number of doors. An example car has a manufacturer of Toyota, a model of Camry, a year of 2000 and a number of doors of 4. Be sure to code all accessor and modifier methods. See the Car class in the bookClassesFinal directory.

What will be an ideal response?


```
/**
* Clas s t h a t r e p r e s e n t s a c r e d i t card
* @author Barb Er icson er icson@cc . gat e ch . edu
*/
public clas s CreditCard
{
// ////////////// f i e l d s /////////////////////////
/** the number on the card */
private St r ing number ;
/** the e x p i r a t i o n dat e on the card */
private St r ing expDate ;
/** the name on the card */
private St r ing name ;
// ////////////// c o n s t r u c t o r s //////////////////
/**
* Cons t ruc tor t h a t t ak e i n f o on the card
* @param theNumber the number on the card
* @param theExpDate the e x p i r a t i o n dat e
* @param theName the name on the card
*/
public CreditCard ( St r ing theNumber ,
St r ing theExpDate ,
St r ing theName )
{
this . number = theNumber ;
this . expDate = theExpDate ;
this . name = theName ;
}
// /////////////// methods //////////////////////
/**
* Method to g e t the number
* @return the c r e d i t card number
*/
public St r ing getNumber ( )
{
return this . number ;
}
/**
* Method to g e t the e x p i r a t i o n dat e
* @return the e x p i r a t i o n dat e
*/
public St r ing getExpDate ( )
{
return this . expDate ;
}
/**
* Method to g e t the name on the c r e d i t card
* @return the name
*/
public St r ing getName ( )
{
return this . name ;
}
/**
* Method to s e t the number
* @param theName the name to use
*/
public void setNumber ( St r ing theNumber )
{
this . number = theNumber ;
}
/**
* Method to s e t the e x p i r a t i o n dat e
* @param theDate the dat e the card e x p i r e s
*/
public void setExpDate ( St r ing
{
this . expDate = theDate ;
}
/**
* Method to s e t the name
* @param theName the name on the card
*/
public void setName ( St r ing theName )
{
this . name = theName ;
}
/**
* Method to r e turn i n f o about the card
*/
public St r ing t oSt r ing ( )
{
return this . number + " " +
this . expDate + " " + this . name ;
}
/**
* Method to t e s t the c r e d i t card
*/
public s tat ic void main ( St r ing [ ] args )
{
CreditCard card =
new CreditCard ( " 0000 1111 2222 3333 " , " 06/06 " , "Mark Guzdial " ) ;
System . out . p r i n t l n ( card ) ;
}
}
```

Computer Science & Information Technology

You might also like to view...

Case-Based Critical Thinking QuestionsCase 1The Reports team at TPG International has just hired Maeve as a report writer. She will be responsible for interviewing an internal customer to determine his or her reporting needs, and then design a report that best fits these needs. Maeveā€™s first assignment comes from a colleague who is looking for a report that will list customer name, address, and annual purchases as column headings, with the data listed for each customer below the headings. Which type of report will Maeve select for this assignment?

A. Detailed tabular B. Grouped C. Multiple columns D. Detailed columnar

Computer Science & Information Technology

A server creates a port which it uses to receive requests from clients. Discuss the design issues concerning the relationship between the name of this port and the names used by clients.

What will be an ideal response?

Computer Science & Information Technology

Currently, the capacity of the hard disk is usually measured in gigabytes or even ________

Fill in the blank(s) with correct word

Computer Science & Information Technology

A(n) ________ is made for very specific tasks that are usually predefined and require little or no input from the user

A) embedded computer B) supercomputer C) server D) mainframe computer

Computer Science & Information Technology