Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > java programming blueJ help

Reply
Thread Tools

java programming blueJ help

 
 
karatev123@yahoo.com
Guest
Posts: n/a
 
      10-11-2011
* You will be creating a cell phone application with two class
files, the CellPhone class which dials cell phone numbers entered by a
user or numbers entered into memory; and the Memory class which
assigns and returns nine (9) phone numbers stored in memory.

* The outline for the Memory class is displayed below:

// Enter your own comments including your name and the due date
here

public class Memory
{
// Instance variables for up to nine (9) phone numbers in
memory

private String memory1;
private String memory2;
private String memory3;
private String memory4;
private String memory5;
private String memory6;
private String memory7;
private String memory8;
private String memory9;

public Memory()
{
// No statements required as all Strings for the object
are initialized to an empty string
// When instantiated there are no phone numbers stored in
memory
}

// Add the other two (2) methods here ...

}

* Add a new void mutator method storeMemory() to the 'Memory'
class that stores a phone number into one of the memory fields; this
method takes two parameters: (1) memoryDigit, an int, which is the
location in which the phone number is to be stored (valid values are 1
through 9); and (2) memoryNumber, a String, the phone number to be
stored; use "if" testing for memoryDigit and store the phone number as
follows: if memoryDigit = 1, assign memoryNumber into the memory1
field; if memoryDigit = 2, assign memoryNumber into the memory2 field;
etc.; if memoryDigit is not a value between 1 and 9, do not store the
phoneNumber but display an error message to the terminal window

* Add a new accessor method getMemory() of type String to the
'Memory' class that retrieves a phone number from one of the memory
fields; this method takes a single parameter memoryDigit, an int,
which is the location from which the phone number is to be retrieved
(valid values are 1 through 9); if memoryDigit = 1 return the value
stored in the memory1 field, if memoryDigit = 2 return the value
stored in the memory2 field, etc.; if memoryDigit is not a value
between 1 and 9, return an empty string and display an error message
to the terminal window

* The outline for the CellPhone class is displayed below:

// Enter your own comments including your name and the due date
here

public class CellPhone
{

// Instance variables

private String phoneNumber; // The phone number to be dialed
private Memory mem; // Object instantiated from class
Memory to store memory phone numbers

public CellPhone()
{
// Write the code to instantiate a new object 'mem' from
the Memory class
// Initialize the phoneNumber field to an empty string
}

// Add the other five (5) methods here ...

}

* Add a new void mutator method setPhoneNumber() to the
'CellPhone' class that stores a string to the phoneNumber field; this
method takes a single parameter phoneNumber, a String, which is
assigned to the phoneNumber field.

* Add a new void mutator method setToMemory() to the 'CellPhone'
class that stores a string to one of the memory fields stored in the
mem object instantiated from the 'Memory' class; this method takes two
parameters: (1) memoryDigit, an int, which is the location in which
the phone number is to be stored; and (2) memoryNumber, a String, the
phone number to be stored; both of these parameter variables are
passed in a call to the storeMemory method of the 'Memory' class.

* Add a new void mutator method getFromMemory() to the 'CellPhone'
class that stores a string to the phoneNumber field; this method takes
a single parameter memoryDigit, an int, which is the location in the
mem object of the class 'Memory' from which the phone number is to be
retrieved; the method calls the getMemory method of the 'Memory'
class; if the return value is not an empty string assign it to the
field phoneNumber.

* Add a new accessor method getPhoneNumber() of type String to the
'CellPhone' class that returns the phoneNumber field.

* Add a new accessor method connect() of type String to the
'CellPhone' class; if the current value of the field phoneNumber =
empty string, return a string message asking the user to dial a number
first (to call either setPhoneNumber or getFromMemory method); if the
current value of the field phoneNumber != empty string, return the
phoneNumber field by calling its accessor method.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with creating a game in blueJ lauraa Software 0 04-18-2010 02:44 PM
Game programming API compatible with BlueJ sgeos Java 1 11-01-2006 02:54 PM
[Bluej-announce] NetBeans IDE 5.0 BlueJ Edition Released IchBin Java 0 07-29-2006 04:13 AM
trouble installing BlueJ - no Java system installed Tim923 Java 13 02-03-2005 07:43 PM
Re: bluej help Steve Horsley Java 1 10-21-2003 10:18 PM



Advertisments