You are on page 1of 27

#7

,
(Facebook, Orkut, MySpace...) .

.
?

( )
. ,
: Alice, Bob, and Cathy, Don. Alice Bob Don, Cathy
Don. :


.
, .
, ,
, (
String )
.

,
. (
). .

Name ,
: Add, Delete, Lookup.
Name Add .
Mehran Sahami Add .
,
:
:
: ("Mehran Sahami")

.
: ,
.
: .
,
: No current status".
: "Friends:",
, . ,
.
:
"New profile created"
( ).


,
(Change Status, Change Picture
Friend) .
coding like a fiend Change Picture
( Enter ) :
, Mehran Sahami is coding like a fiend,
:
Status updated to coding like a fiend.


Change Picture
( MehranS.jpg) Change Picture
( Enter ).
:
MehranS.jpg
, , .


Julie Zelenski.
Julie Zelenski Add .
( ).
, (
),
, .
,
,
.
, .

Julie Zelenski Mehran. Add Friend


Mehran Sahami
Add Friend ( Enter ),
Julie Zelenski :
Mehran Sahami ,
Mehran Sahami added as a friend.


( Julie Mahran,
Mahran Julie ). Mahran ,

Mehran Sahami Lookup :
Mahram
Julie. X Y ,
Y X .


, Name (
) Julie Zelenski Delete .
.
,
Profile of Julie Zelenski deleted.

Julie
Julie,
. Mahran ,
Name Mehran Sahami Lookup ,
Mahran , Julie:
, . Name
Julie Zelenski Lookup , :

, ,

: A profile with the name Julie Zelenski does not exist. ,
( )
( sleeping
) Please select a
profile to change status, :


,
. ,
(StanfordLogo.jpg and StanfordTree.jpg)
,
.

NameSurfer FacePamphlet :
FacePamphlet - ,
.
FacePamphletConstants -
.
FacePamphletProfile -
, , .
FacePamphletDatabase -
. FacePamphletDatabase
,
( , ).
FacePamphletCanvas - GCanvas
.
ComponentListener .

. ,
.

.
.

: GUI


(. ) JLabel-, JTextField-,
JButton-.

NameSurfer
actionPerformed
, .
:
(TextField) TEXT_FIELD_SIZE
. TEXT_FIELD_SIZE
FacePamphletConstants .
Name
actionCommand. Enter
.

actionCommand-. Enter
(Button). Change Status
Enter Change Status
.
( ""),
. Name
Add ( Delete, Lookup) ,
.
.

,
( Change Status Change Picture
). Jlabel
, , EMPTY_LABEL_TEXT:

add(new JLabel(EMPTY_LABEL_TEXT), WEST);

FacePamphlet
extends Program, FacePamphlet extends ConsoleProgram,
.
actionPerformed println
.

:

1. Name Mehran Add .


2. Name Julie Delete .
3. Name Eric Lookup .
4. Change Status slipping Change Status
.
5. Change Status text eating Change Status
.
6. Change Picture StanfordLogo.jpg Change
Picture .
7. Change Picture MehranS.jpg Change Picture
.
8. Add Friend Julie Add Friend .
9. Add Friend Eric Add Friend .
( 1)

: FacePamphletProfile

FacePamphletProfile
. public ,
.
FacePamphletProfile
. :
1. . "Mehran Sahami" "Julie Zelenski"
2. . String ,
.
3. . GImage .
null,
.
4. . (String
) .
.

FacePamphletProfile toString ,
.
( 2)
: FacePamphletDatabase

FacePamphletProfile ,
FacePamphletDatabase .
FacePamphletProfile .
public , .

FacePamphletDatabase .
public :
.
.

FacePamphletDatabase ,
.
addProfile , FacePamphletProfile
.
,
.
.
,
.
,
.
getProfile ,
(FacePamphletProfile ) null
.
deleteProfile ,
. ,
.

.
containsProfile ,
true
false .
.

.
( 3)
FacePamphlet
FacePamphletDatabase Add, Delete Lookup
:
Add Name
.
"Add: new profile: "
(toString
).
,
.
Delete Name
.
,

.
Lookup Name
.
Lookup:
.
.
.
.

( 4)
: Change Status, Change Picture Add Friend

FacePamphlet , Change
Status, Change Picture Add Friend .

, .
.
Add, Delete Lookup
:
,
.

.
(
), (
).
(Lookup),
,
.
(
).

Change Status, Change Picture Add Friend
.

Change Status
Change Status
Change Status :

.
.
,
,
(
).

Change Picture
Change Picture
Change Picture :
,
.
:
GImage image = null;
try {
image = new GImage(filename);
} catch (ErrorException ex) {
// Code that is executed if the filename cannot be opened.
}
,
GImage , image null ,
image .
,
.

.
,
,
(
).

Add Friend
Add Friend Add
Friend :
,

. ,
.
,
.
,
. , ,
.
Mehran
Julie, Julie- Mehran.

, .


(
).

.
.
( 5)

: FacePamphletCanvas
FacePamphlet


.
FacePamphletCanvas .
GCanvas (extends GCanvas) public .
.
.
,
.
showMessage ,

. ()
, (baseline)
BOTTOM_MESSAGE_MARGIN
. MESSAGE_FONT.
BOTTOM_MESSAGE_MARGIN MESSAGE_FONT
FacePamphletConstants .

.
displayProfile , FacePamphletProfile
.
, ( ),
( ), ( ).

, .

.
ComponentListener ,
(resize) .

.

( 6)
FacePamphlet
Program (extends Program),
ConsoleProgram .
println
.
FacePamphlet private FacePamphletCanvas
:
private FacePamphletCanvas canvas;
FacePamphlet FacePamphletCanvas
:
canvas = new FacePamphletCanvas();
add(canvas);
,
, FacePamphletCanvas
FacePamphlet .

displayProfile

FacePamphletConstants .
( ):

( 7)

: ,
. , LEFT_MARGIN
. ,
TOP_MARGIN .
PROFILE_NAME_FONT.

:
, .
IMAGE_WIDTH IMAGE_HEIGHT .
,
,
LEFT_MARGIN
IMAGE_MARGIN .
No Image ,
PROFILE_IMAGE_FONT.
,
.
IMAGE_WIDTH IMAGE_HEIGHT .
GImage scale .

: .
(
) No current status .

, is .
, , LEFT_MARGIN
, ,
STATUS_MARGIN .
PROFILE_STATUS_FONT.

: Friends
. Friends
,
.
PROFILE_FRIEND_LABEL_FONT.
. Freiends
. GLabel getHeight()
.

PROFILE_FRIEND_FONT .

.
.

:
,
BOTTOM_MESSAGE_MARGIN
. MESSAGE_FONT.

displayProfile ,
.


FacePamphlet displayProfile showMassage .
.
.


.
: A profile
with the name <> already exists.
, :
New profile created.


,
.
,
: "Profile of <> deleted.
: A
profile with the name <> already exists.


,
. ,

"Displaying <> ". ,

:A profile with the name <> already exists.


,
.
: "Please select a
profile to change status". ,
, (
) : "Status
updated to <> ".


,
.
: "Please select a profile to change picture".
,
.
, (
) : Picture
updated.
: "Unable to open image file: < > ".
.

,
. ,
: "Please select a profile to add
friend".
.
,
,
(
) : "< > added as a friend".

: "< > already has
< > as a friend."
:
"< > does not exist."

!!! ,
.


,

.
:
(, , ,...)



(, , ,
...)

You might also like