Subject: RE: hw4 - ChangeDirectoryDown
From: John Sung (john_j_sung@yahoo.com)
Date: Tue Feb 12 2002 - 14:29:00 EST
Hi jessie,
Conceptually, you can do 2 things right?
1. iterate through the enumeration of the current directory, find the file
with the same name, compare the string and change directory down if you have
a string match. But you also have to remember that the filename match could
be to a SimpleFile instead of a CompoundFile. So, somehow you have to deal
with it.
Some of the people used the instanceof operator available in java. This
violates the whole concept behind data hiding and is a no-no. The better
implementation is to actually have abstract method in File, then implement
the method in SimpleFile and CompoundFile. I could call this, something like
CompoundFile changeDir(), returns null for SimpleFile and returns the
CompoundFile for CompoundFiles. The advantage of this method is that you can
add other file types and it would not change the code for change directory
down.
2. use a strategy, i.e from CompoundFile to CompoundFile bypassing
CompoundFile as we talked about, then use a visitor to do the string
comparison and return the CompoundFile. You can check out how the
CommandVisitor is implemented to get the idea on how to implement a visitor
for this homework. Basically, you need to modify the .cd to add the visitor
class and add the before and after methods in one of the .beh files or
create a new .beh file. Then, call traverse method with the class graph,
strategy and visitor.
If you need more detailed instructions, let me know. Although, I'm not sure
how much more I can be detailed without giving you the answer. :)
John
-----Original Message-----
From: Wan W. Foong [mailto:wanfoong@ccs.neu.edu]
Sent: Tuesday, February 12, 2002 2:03 PM
To: John Sung
Cc: com1205@ccs.neu.edu
Subject: hw4 - ChangeDirectoryDown
Hi John,
How are you?
I am still working on the ChangeDirectoryDown, the major issue that I am
dealing with is the Syntax, actual implementation of the concept.
This is what I have, and it fetch out the object that I want, namely, cd
a, the "a" is what gets return in nam. The next step is to traverse the
PList of the cdir to locate "a", this is where I need help in.
Please advise. Thanks.
// ChangeDirectoryDown
void before (ChangeDirectoryDown host) {
Ident nam = (Ident) Main.cg.fetch(host, "from ChangeDirectoryDown
to" + Main.FIdent);
System.out.println("object = " + nam);
=====================================================================
HAVE A NICE DAY!
______________________________
\___/ / Jessie Wan Foong \ \___/
*---________-0 O- | Northeastern University | -O O-________
| ## \Y/ | College of Computer Science | \Y/ ## |\_*
|___ #_ | | Email: wanfoong@ccs.neu.edu | | _ ___# |
|/|/ |/|/ \__or natsukamu@hotmail.com _/ \|\| \|\|
W W W W || || W W W W
______________________________________________________________________
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
This archive was generated by hypermail 2b28 : Tue Feb 12 2002 - 14:28:28 EST