Little help with keyframes and Armorbot

armor bot ranks software gives you an actionscript that sends
the score you want directly online, I have successfully finished it
but in the game if i enter a number like 200 and a name like "yair"
it works out just fine but when i put a variable like tt that is
connected to a number it doesnt work. Here is the Code do you think
you can help. Im guessing tt is time because i made this game with
a partner
The First keyframe has the code from my game in it then the
next keyframe has the armorbot code:
stop ();
sintro.stop();
t = Math.round(_global.totaltime * 10) / 10 + " units";
tt.text = t;
ct.text = _global.totalclickcount;
_global.puNUM = 1;
par = 1;
clickcount = 0;
N = 30;
hs = 3;
ci._visible = 0;
flr = floor._y;
kuid = false;
xv = 0;
yv = 20;
g = 1.010000E+000;
xd = 0;
go = true;
boost = 1;
_global.score = 0;
ballx = ball._x;
bally = ball._y;
d = 9.700000E-001;
bbu = 5;
bu = 20;
bhu = 23;
hb2l = 10;
hb2r = 10;
vb2t = 3;
vb2b = 10;
var B = new flash.filters.BlurFilter(0, 0, 2);
var bupA = new Array();
Heres the code on the button to the next keyframe:
on (press) {
nextFrame();
And Here is the ArmorbotCode take note of the t's:
//Send Highscore AS2.0 // Armor Bot Rankz
import ab3.rankz.*;
function __rankz_send__(par1,par2,par3,par4){
par227 = new LoadVars();
par228 = new LoadVars();
par227.flashkey = par2;
par227.SU0249 = par1;
par227.bmFtZTE = Armor_Bot_30_En_AS1.Encode(par3);
par227.c2NvcmUx =
Armor_Bot_30_En_AS1.Encode(par4+"j%e%a%n%s");
par227.flashkey = par227.flashkey.split("=").join("");
par227.SU0249 = par227.SU0249.split("=").join("");
par228.onLoad = function(success){
if(success){
trace(par228.msg);
}else{
trace(par228.loaded);
par227.sendAndLoad("
http://rankz.armorbot.com/submit/",par228,"POST");
bXlnYW1lX25hbWVfdmFyaWFibGU = "Yair";//replace
my_name1_variable with your name variable (1)
bXlnYW1lX3Njb3JlX3ZhcmlhYmxl =
tt;//replace my_score1_variable with your score1 variable
__rankz_send__("MzEyOGolZSVhJW4lcw==", "SnBrUk9ibEo=",
bXlnYW1lX25hbWVfdmFyaWFibGU, bXlnYW1lX3Njb3JlX3ZhcmlhYmxl);
//Send Highscore AS2.0 END

didittoday wrote:
No errors are thrown, but...
words is a String array containing 58,112 words,
my computer hits 100% usage, bogs down and I have to press crtl+alt+del to bring up my task manager (which in itself takes like 10 mins) and my javaw.exe shows CPU 100. I guessing it is the startsWith() call, not sure.
If I am correct in my thinking then I will just tear each word apart and check the contents myself.You basically are checking the contents yourself. It's not clear what you're thinking. I can pretty much guarantee that if you rewrite startsWith(), then you will not improve the performance of your program at all and will probably just make it worse.
But this is where my question comes in, am I correct in my thinking or am I using the vector wrong? The answers are probably no, you're not correct in your thinking, and yes, you're using the vector wrong. But you haven't exactly said what you're thinking.
The vector isn't particularly relevant, at least in terms of the search. The real problem is that you have an ordered (reportedly) array of string and for some reason you're searching through it sequentially. You should use a binary search to find the matching strings. See java.util.Arrays.binarySearch.
Now, this is probably wrong:
     // get data from vector into a string array
     int size = searchResults.capacity();
     String[] returnArray = new String[size];
     searchResults.toArray(returnArray);Vector.capacity returns how much the vector can hold, not how much it's actually holding. So you're passing toArray an array much larger than it actually needs, most likely. I have no idea what the behavior of toArray is in those circumstances but it's probably not good. You probably meant to do something more like:
return searchResults.toArray(new String[searchResults.size()]);Another problem is that you're using a Vector, and not a LinkedList.

Similar Messages

  • I need a little help with xmonad and stuff

    Hi all. I recently changed from fluxbox to xmonad, and I find it fantastic. I have some minor? problems.
    In fluxbox I was using xterm as a terminal emulator, but I couldnt use irssi with it, the Alt + w/e keys weren't working. They worked however in aterm and urxvt but those two support only 16 colors, and I wish to use 256 colors, mainly because of my vim color scheme. Is there a solution to be able to run both irssi and vim from the same terminal, or should I run different terminals for them?
    Also where can I read up on setting my .Xdefaults and xmonad.hs file? I ripped someones from this forum, and it works nice, but I want to make my onw, but cant find any decent documentation. Thanks.
    edit:
    I found the solution to using the Alt key in xterm. I had to add theese two lines in my .Xdefaults
    XTerm*eightBitInput: false
    XTerm*metaSendsEscape: true
    Last edited by tch (2007-12-28 11:00:33)

    Also where can I read up on setting my .Xdefaults and xmonad.hs file? I ripped someones from this forum, and it works nice, but I want to make my onw, but cant find any decent documentation. Thanks.
    At the moment, the best source for configs are those posted in the screenshots thread (for both Xdefaults and xmonad.hs), the xmonad config archive (and the available docs from the root page on that site), and our own thread.  Unfortunately you'll have to sort of scrounge for good docs on the xmonad.hs at the moment, since most of the information was written for the 0.4 version of xmonad.  The configuration has since been made MUCH simpler.
    Hope that helps some.

  • Hi there... I need a little help with buttons and their actions using flex builder 4.5

    I run a repo company and have zero experience in the developing applications and I could use some help from anybody that is willing to give it.... Here is a basic idea of what I need...  let's say there are 3 states... state 1 has a question that says "car you read this?" and a "yes" and a "no" button... when you select either answer, you go to slide 2.  Slide 2 with have a question like "Is the sky brown?" and a "yes" and a "no" button and when either button is selected, you are taken to Slide 3.  Slide 3 needs to be some sort of a text form that is created by the user selecting the buttons and the screen would say something like "yes, i can read this.  no, the sky is not brown", or "no, I can't read this.   yes, the sky is brown" .  I know how to get the buttons to take the user to the correct new slide, but I do not know how to get the buttons to insert specific text somewhere else when any button is selected.... Can anybody help me?  Youtube is only getting me so far, and my kids are driving me nuts while I'm trying to figure this monster out...  I've gotten several slides created and some screens have several buttons, I just need to see what I need to put in the code to get it to do this type of function 

    Also where can I read up on setting my .Xdefaults and xmonad.hs file? I ripped someones from this forum, and it works nice, but I want to make my onw, but cant find any decent documentation. Thanks.
    At the moment, the best source for configs are those posted in the screenshots thread (for both Xdefaults and xmonad.hs), the xmonad config archive (and the available docs from the root page on that site), and our own thread.  Unfortunately you'll have to sort of scrounge for good docs on the xmonad.hs at the moment, since most of the information was written for the 0.4 version of xmonad.  The configuration has since been made MUCH simpler.
    Hope that helps some.

  • [solved] Need a little help with sed and regular expressions

    Hello!
    I am shure this is something easy for most of you
    I want to make a script, which converts filenames of my ripped MP3s (replaces '_' with spaces, removes leading track numbers...)
    But I have some problems:
    j=$(echo $j | sed 's/_\+/ /g')
    j=$(echo $j | sed 's/^[0-9]{0,3}//g')
    j=$(echo $j | sed 's/[^ ]-[^ ]/ - /g')
    j=$(echo $j | sed 's/_\+/ /g') << this is working fine (converts all "_" to spaces)
    j=$(echo $j | sed 's/^[0-9]{0,3}//g') << is NOT working, why??
    For Example in "01-somebody_feat_someone-somemusic.mp3" the leading "01" number is NOT being removed..
    j=$(echo $j | sed 's/[^ ]-[^ ]/ - /g') << how can I insert spaces before and after the "-"?
    So that "someone-somemusic" becomes "someone - somemusic" (but only where "-" is surrounded by letters)
    Last edited by cyberius (2011-07-27 18:50:54)

    For sed, you must escape { and } to use them as you want (just slap a \ before them).
    For the last expression, capture the letter before/after the dash -- use \( and \) -- and then substitute it for something like "\1 -" and then "- \1". You'll want to split this into two pieces, one for the front and one for the back so you can get "somemusic -someband" the way you want without a bunch of cases.
    Edit: Or, you could just do a replace for "-" to be " - " and then have another expression to reduce spaces. I see you've used \+ before, so I'm guessing you can figure that out
    Also, sed has the -e switch so you can do multiple different expressions with one invocation.
    Also (also), have you looked into something like Picard with automatic track renaming? You can even customize how they are renamed.
    Edit (2): Also^3, check out prename. There are different versions, ones which use PCRE and ones that use other standards, but it is for renaming files based on regular expressions, which is what you're doing. In any case, you might want to put you script into the User made scripts thread when you feel more comfortable and get some more critiquing, if you're interested.
    Last edited by jac (2011-07-26 23:13:27)

  • Hoping for a little help with registering and hosting questions.

    i was hoping i could get some information from some of you
    that have personal experience with registering your site and
    picking a hosting provider.
    im wondering what the difference is between say....Dot5
    hosting at 5.00 a month and .. network solutions at 29.99 a month?
    my local provider here in sacramento wants 30 a month as
    well......299.oo a yr.
    should I go with a local provider? or go with ... say GoDaddy
    or some other company?
    also, registering. Im about to register my site name.
    however, some companies include it in the "packages" they offer.
    should I register it myself or let the hosting company I choose do
    it?
    sorry for the newb questions....but I cant find any good info
    on this and I was hoping maybe some of you that have already done
    this to chime in.
    thanks in advance.

    If you want almost all of the below features for about $9.00
    a month go to
    Gate.com and pick your package. I use them for several web
    sites and have
    never been dissatisfied with their services or features.
    They will register your domain and I've done it both ways,
    but have never
    had problems with them but it does make a lot of sense to
    register it
    yourself and keep full ownership....
    "Sonjay" <[email protected]> wrote in message
    news:C19368C5.A15FD%[email protected]...
    > There's probably not a dime's worth of difference
    between the Dot5 hosting
    > and the NetSol hosting, but I wouldn't recommend either
    of those companies
    > for hosting.
    >
    > $30/month seems high unless you have very specific needs
    -- there's plenty
    > of good hosting around for $8 or $10 a month. The thing
    you need to do is
    > decide what your requirements are: php? asp? MySQL?
    Access? dot.net?
    > E-mail?
    > Telnet or SSH access? Do you need/want a control panel
    that makes it easy
    > for you set up your own e-mail accounts, password
    protect directories, and
    > that sort of thing, or will basic FTP access be all you
    need? Do you want
    > a
    > statistics package included with your hosting? Do you
    need to run more
    > than
    > one domain under the same account? If all of the above
    makes you shake
    > your
    > head and say "I don't need any of that," then you can
    probably manage just
    > fine with any of the $5-$10 month basic packages, with a
    reputable host.
    >
    > Whatever you do, register your domain separately from
    your hosting, and
    > only
    > use an ICANN-accredited registrar, none of those
    resellers that tend to
    > disappear and/or register people's domains in their own
    name. I have
    > nothing
    > good to say about NetSol as a registrar, going back to
    the years when they
    > were the only game in town, and I will never use them
    again, but any other
    > ICANN-accredited registrar should do you just fine.
    >
    > --
    > Sonjay
    >
    > On 11/29/06 3:51 PM, "Progressive_Learning" wrote:
    >
    >>
    >>
    >> i was hoping i could get some information from some
    of you that have
    >> personal
    >> experience with registering your site and picking a
    hosting provider.
    >>
    >> im wondering what the difference is between
    say....Dot5 hosting at 5.00 a
    >> month and .. network solutions at 29.99 a month?
    >>
    >> my local provider here in sacramento wants 30 a
    month as well......299.oo
    >> a
    >> yr.
    >>
    >> should I go with a local provider? or go with ...
    say GoDaddy or some
    >> other
    >> company?
    >>
    >> also, registering. Im about to register my site
    name. however, some
    >> companies include it in the "packages" they offer.
    should I register it
    >> myself
    >> or let the hosting company I choose do it?
    >>
    >> sorry for the newb questions....but I cant find any
    good info on this and
    >> I
    >> was hoping maybe some of you that have already done
    this to chime in.
    >>
    >> thanks in advance.
    >>
    >
    >

  • Need a little Help with my new xfi titanium

    +Need a little Help with my new xfi titanium< A few questions here.
    st question? Im using opt out port on the xfi ti. card and using digital li've on a windows 7 64 bit system,? I would like to know why when i use 5. or 7. and i check to make sure each speakear is working the rear speakers wont sound off but the sr and sl will in replace of the rear speakers. I did a test tone on my sony amp and the speaker are wired correctly becasue the rear speakers and the surrond? left and right sound off when they suppose too. Also when i try to click on? the sl and sr in the sound blaster control panel they dont work but if i click on the rear speakers in the control panel the sl and sr sound off. Do anyone know how i can fix this? So i would like to know why my sl and sr act like rears when they are not?
    2nd question? How do i control the volume from my keyboard or from windows period when using opt out i was able to do so with my on board? sound max audio using spidf? Now i can only control the audio using the sony receiver.
    Thank you for any help..

    /Re: Need a little Help with my new xfi titanium? ?
    ZDragon wrote:
    I'm unsure about the first question. Do you even have a 7. system and receiver? If you just have 5., you should be able to remap the audio in the THX console.
    I do have a sony 7. reciever str de-995 its an older one but its only for my cpu. At first i didnt even have THX installed because it didnt come with the driver package for some reason until i downloaded the daniel_k support drivers and installed it. But it doesnt help in anyway.
    I have checked every where regarding the first question and alot of people are having problems getting sound out of there rear channels and the sound being re-mapped to the surround right and the surround left as if there rear left and rear right.
    I read somewhere that the daniel_k support drivers would fix this but it didnt for me and many others.
    For the second question i assumed it would be becasue of the spidf pass through and that my onboard sound card was inferior to the xfi titaniums. But i wasnt sure and i was hopeing that someone would have a solution for that problem because i miss controlling the volume with my keyboard.

  • Need a little help with syncing my iPod.

    I got a new macbook pro for cristmas and a few cds. After i tried to sync my ipod to itunes i put a symbol next to each song that i got from other cds saying that they were downloading but they werent. Also the cds i downloaded to my ipod for the first time didnt appear at all. Need help.

    /Re: Need a little Help with my new xfi titanium? ?
    ZDragon wrote:
    I'm unsure about the first question. Do you even have a 7. system and receiver? If you just have 5., you should be able to remap the audio in the THX console.
    I do have a sony 7. reciever str de-995 its an older one but its only for my cpu. At first i didnt even have THX installed because it didnt come with the driver package for some reason until i downloaded the daniel_k support drivers and installed it. But it doesnt help in anyway.
    I have checked every where regarding the first question and alot of people are having problems getting sound out of there rear channels and the sound being re-mapped to the surround right and the surround left as if there rear left and rear right.
    I read somewhere that the daniel_k support drivers would fix this but it didnt for me and many others.
    For the second question i assumed it would be becasue of the spidf pass through and that my onboard sound card was inferior to the xfi titaniums. But i wasnt sure and i was hopeing that someone would have a solution for that problem because i miss controlling the volume with my keyboard.

  • Help with count and sum query

    Hi I am using oracle 10g. Trying to aggregate duplicate count records. I have so far:
    SELECT 'ST' LEDGER,
    CASE
    WHEN c.Category = 'E' THEN 'Headcount Exempt'
    ELSE 'Headcount Non-Exempt'
    END
    ACCOUNTS,
    CASE WHEN a.COMPANY = 'ZEE' THEN 'OH' ELSE 'NA' END MARKET,
    'MARCH_12' AS PERIOD,
    COUNT (a.empl_id) head_count
    FROM essbase.employee_pubinfo a
    LEFT OUTER JOIN MMS_DIST_COPY b
    ON a.cost_ctr = TRIM (b.bu)
    INNER JOIN MMS_GL_PAY_GROUPS c
    ON a.pay_group = c.group_code
    WHERE a.employee_status IN ('A', 'L', 'P', 'S')
    AND FISCAL_YEAR = '2012'
    AND FISCAL_MONTH = 'MARCH'
    GROUP BY a.company,
    b.district,
    a.cost_ctr,
    c.category,
    a.fiscal_month,
    a.fiscal_year;
    which gives me same rows with different head_counts. I am trying to combine the same rows as a total (one record). Do I use a subquery?

    Hi,
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved.
    Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
    user610131 wrote:
    ... which gives me same rows with different head_counts.If they have different head_counts, then the rows are not the same.
    I am trying to combine the same rows as a total (one record). Do I use a subquery?Maybe. It's more likely that you need a different GROUP BY clause, since the GROUP BY clause determines how many rows of output there will be. I'll be able to say more after you post the sample data, results, and explanation.
    You may want both a sub-query and a different GROUP BY clause. For example:
    WITH    got_group_by_columns     AS
         SELECT  a.empl_id
         ,     CASE
                        WHEN  c.category = 'E'
                  THEN  'Headcount Exempt'
                        ELSE  'Headcount Non-Exempt'
                END          AS accounts
         ,       CASE
                        WHEN a.company = 'ZEE'
                        THEN 'OH'
                        ELSE 'NA'
                END          AS market
         FROM              essbase.employee_pubinfo a
         LEFT OUTER JOIN  mms_dist_copy             b  ON   a.cost_ctr     = TRIM (b.bu)
         INNER JOIN       mms_gl_pay_groups        c  ON   a.pay_group      = c.group_code
         WHERE     a.employee_status     IN ('A', 'L', 'P', 'S')
         AND        fiscal_year           = '2012'
         AND        fiscal_month          = 'MARCH'
    SELECT    'ST'               AS ledger
    ,       accounts
    ,       market
    ,       'MARCH_12'          AS period
    ,       COUNT (empl_id)       AS head_count
    FROM       got_group_by_columns
    GROUP BY  accounts
    ,            market
    ;But that's just a wild guess.
    You said you wanted "Help with count and sum". I see the COUNT, but what do you want with SUM? No doubt this will be clearer after you post the sample data and results.
    Edited by: Frank Kulash on Apr 4, 2012 5:31 PM

  • Help with writing and retrieving data from a table field with type "LCHR"

    Hi Experts,
    I need help with writing and reading data from a database table field which has a type of "LCHR". I have given an example of the original code but don't know what to change it to in order to fix it and still read in the original data that's stored in the LCHR field.
    Basically we have two Function modules, one that saves list data to a database table and one that reads in this data. Both Function modules have an identicle table which has an array of fields from type INT4, CHAR, and type P. The INT4 field is the first one.
    Incidentally this worked in the 4.7 non-unicode system but is now dumping in the new ECC6 Unicode system.
    Thanks in advance,
    C
    SAVING THE LIST DATA TO DB
    DATA: L_WA(800).
    LOOP AT T_TAB into L_WA.
    ZDBTAB-DATALEN = STRLEN( L_WA ).
    MOVE: L_WA to ZDBTAB-RAWDATA.
    ZDBTAB-LINENUM = SY-TABIX.
    INSERT ZDBTAB.
    READING THE DATA FROM DB
    DATA: BEGIN OF T_DATA,
                 SEQNR type ZDBTAB-LINENUM,
                 DATA type ZDBTAB-RAWDATA,
               END OF T_TAB.
    Select the data.
    SELECT linenum rawdata from ZDBTAB into table T_DATA
         WHERE repid = w_repname
         AND rundate = w_rundate
         ORDER BY linenum.
    Populate calling Internal Table.
    LOOP AT T-DATA.
    APPEND T_DATA to T_TAB.
    ENDLOOP.

    Hi Anuj,
    The unicode flag is active.
    When I run our report and then to try and save the list data a dump is happening at the following point
    LOOP AT T_TAB into L_WA.
    As I say, T_TAB consists of different fields and field types whereas L_WA is CHAR 800. The dump mentions UC_OBJECTS_NOT_CONVERTIBLE
    When I try to load a saved list the dump is happening at the following point
    APPEND T_DATA-RAWDATA to T_TAB.
    T_DATA-RAWDATA is type LCHR and T_TAB consists of different fields and field types.
    In both examples the dumps mention UC_OBJECTS_NOT_CONVERTIBLE
    Regards
    C

  • MOVED: [Athlon64] Need Help with X64 and Promise 20378

    This topic has been moved to Operating Systems.
    [Athlon64] Need Help with X64 and Promise 20378

    I'm moving this the the Administration Forum.  It seems more apporpiate there.

  • Little help with complex XML data as data provider for chart and adg

    Hi all,
    I've been trying to think through a problem and Im hoping for
    a little help. Here's the scenario:
    I have complex nested XML data that is wrapped by subsequent
    groupings for efficiency, but I need to determine if each inner
    item belongs in the data collection for view in a data grid and
    charts.
    I've posted an example at the bottom.
    So the goal here is to first be able to select a single
    inspector and then chart out their reports. I can get the data to
    filter from the XMLListCollection using a filter on the first layer
    (ie the name of the inspector) but then can't get a filter to go
    deeper into the structure in order to determine if the individual
    item should be contained inside the collection. In other words, I
    want to filter by inspector, then time and then tag name in order
    to be able to use this data as the basis for individual series
    inside my advanced data grid and column chart.
    I've made it work with creating a new collection and then
    looping through each time there is a change to the original
    collection and updating the new collection, but that just feels so
    bloated and inefficient. The user is going to have some buttons to
    allow them to change their view. I'm wondering if there is a
    cleaner way to approach this? I even tried chaining filter
    functions together, but that didn't work cause the collection is
    reset whenever the .refresh() is called.
    If anyone has experience in efficiently dealing with complex
    XML for charting purposes and tabular display purposes, I would
    greatly appreciate your assistance. I know I can get this to work
    with a bunch of overhead, but I'm seeking something elegant.
    Thank you.

    Hi,
    Please use the code similar to below:
    SELECT * FROM DO_NOT_LOAD INTO TABLE IT_DO_NOT_LOAD.
    SORT IT_DO_NOT_LOAD by WBS_Key.
        IF SOURCE_PACKAGE IS NOT INITIAL.
          IT_SOURCE_PACKAGE[] = SOURCE_PACKAGE[].
    LOOP AT IT_SOURCE_PACKAGE INTO WA_SOURCE_PACKAGE.
            V_SYTABIX = SY-TABIX.
            READ TABLE IT_DO_NOT_LOAD into WA_DO_NOT_LOAD
            WITH KEY WBS_Key = WA_SOURCE_PACKAGE-WBS_Key
            BINARY SEARCH.
            IF SY-SUBRC = 0.
              IF ( WA_DO_NOT_LOAD-WBS_EXT = 'A' or WA_DO_NOT_LOAD-WBS_EXT = 'B' )     
              DELETE IT_SOURCE_PACKAGE INDEX V_SYTABIX.
            ENDIF.
    ENDIF.
          ENDLOOP.
          SOURCE_PACKAGE[] = IT_SOURCE_PACKAGE[].
        ENDIF.
    -Vikram

  • Need a little help with Slimbox (Lightbox clone) and Spry data sets

    Hello guys!
    First of all let me say that I'm not a programmer in any way,
    shape or form, and somehow I managed to build me a dynamic
    thumbnail gallery that reads data from an XML file and displays it
    on my webpage using a Spry data set and a slider widget (yay!)
    This is of course only thanks to the many great examples
    provided by the Adobe Spry team, and me being stubborn enough to
    keep at it, even though I don't really understand what I'm doing :D
    But I got to this point where I have basically everything
    working, except that I can't get the Slimbox (Lightbox clone)
    script to work with the Spry-generated thumbnail gallery.
    From what I could understand from other threads on this
    forum, is that I need to add an observer somewhere, only that I'm
    not sure where and how (those threads are pretty old and the
    examples aren't available anymore).
    I'm sure you guys know what I'm talking about, anyway, here's
    what I got so far:
    http://www.riotdesign.com.ar/misc/gallery/test1.html
    I have the thumbnail gallery populated from the external XML
    file, a basic page navigation using the Sliding Panels widget, and
    the Slimbox script which works only on the static test image.
    Okay I guess that's it for now, sorry for the long post and
    of course any help with this will be GREATLY appreciated :)
    Thanks & bye!

    Kev,
    Where exactly does the .evalScripts = true; text need to go?
    Does it go in the href call?
    <a href="ManageNotes.asp" title="Manage Notes" onClick="this.blur();
    Modalbox.show(this.href, {title: 'Manage Notes', width: 575}); return false;">View your notes.</a>
    Thanks for any assistance.
    J Bishop

  • Help with encapsulation and a specific case of design

    Hello all. I have been playing with Java (my first real language and first OOP language) for a couple months now. Right now I am trying to write my first real application, but I want to design it right and I am smashing my head against the wall with my data structure, specifically with encapsulation.
    I go into detail about my app below, but it gets long so for those who don't want to read that far, let me just put these two questions up front:
    1) How do principles of encapsulation change when members are complex objects rather than primitives? If the member objects themselves have only primitive members and show good encapsulation, does it make sense to pass a reference to them? Or does good encapsulation demand that I deep-clone all the way to the bottom of my data structure and pass only cloned objects through my top level accessors? Does the analysis change when the structure gets three or four levels deep? Don't DOM structures built of walkable nodes violate basic principles of encapsulation?
    2) "Encapsulation" is sometimes used to mean no public members, othertimes to mean no public members AND no setter methods. The reasons for the first are obvious, but why go to the extreme of the latter? More importantly HOW do you go to the extreme of the latter? Would an "updatePrices" method that updates encapsulated member prices based on calculations, taking a single argument of say the time of year be considered a "setter" method that violates the stricter vision of encapsulation?
    Even help with just those two questions would be great. For the masochistic, on to my app... The present code is at
    http://www.immortalcoil.org/drake/Code.zip
    The most basic form of the application is statistics driven flash card software for Japanese Kanji (Chinese characters). For those who do not know, these are ideographic characters that represent concepts rather than sounds. There are a few thousand. In abstract terms, my data structure needs to represent the following.
    -  There are a bunch of kanji.
       Each kanji is defined by:
       -  a single character (the kanji itself); and
       -  multiple readings which fall into two categories of "on" and "kun".
          Each reading is defined by:
          -  A string of hiragana or katakana (Japanese phoenetic characters); and
          -  Statistics that I keep to represent knowledge of that reading/kanji pair.Ideally the structure should be extensible. Later I might want to add statistics associated with the character itself rather than individual readings, for example. Right now I am thinking of building a data structure like so:
    -  A Vector that holds:
       -  custom KanjiEntry objects that each hold
          -  a kanji in a primitive char value; and
          -  two (on, kun) arrays or Vectors of custom Reading objects that hold
             -  the reading in a String; and
             -  statistics of some sort, probably in primitive valuesFirst of all, is this approach sensible in the rough outlines?
    Now, I need to be able to do the obvious things... save to and load from file, generate tables and views, and edit values. The quesiton of editting values raises the questions I identified above as (1) and (2). Say I want to pull up a reading, quiz the user on it, and update its statistics based on whether the user got it right or wrong. I could do all this through the KanjiEntry object with a setter method that takes a zillion arguments like:
    theKanjiEntry.setStatistic(
    "on",   // which set of readings
    2,      // which element in that array or Vector
    "score", // which statistic
    98);      // the valueOr I could pass a clone of the Reading object out, work with that, then tell the KanjiEntry to replace the original with my modified clone.
    My instincts balk at the first approach, and a little at the second. Doesn't it make more sense to work with a reference to the Reading object? Or is that bad encapsulation?
    A second point. When running flash cards, I do not care about the subtlties of the structure, like whether a reading is an on or a kun (although this is important when browsing a table representing the entire structure). All I really care about is kanij/reading pairings. And I should be able to quickly poll the Reading objects to see which ones need quizzing the most, based on their statistics. I was thinking of making a nice neat Hashtable with the keys being the kanji characters in Strings (not the KanjiEntry objects) and the values being the Reading objects. The result would be two indeces to the Reading objects... the basic structure and my ad hoc hashtable for runninq quizzes. Then I would just make sure that they stay in sync in terms of the higher level structure (like if a whole new KanjiEntry got added). Is this bad form, or even downright dangerous?
    Apart from good form, the other consideration bouncing around in my head is that if I get all crazy with deep cloning and filling the bottom level guys with instance methods then this puppy is going to get bloated or lag when there are several thousand kanji in memory at once.
    Any help would be appreciated.
    Drake

    Usually by better design. Move methods that use the
    getters inside the class that actually has the data....
    As a basic rule of thumb:
    The one who has the data is the one using it. If
    another class needs that data, wonder what for and
    consider moving that operation away from that class.
    Or move from pull to push: instead of A getting
    something from B, have B give it to A as a method
    call argument.Thanks for the response. I think I see what you are saying.. in my case it is something like this.
    Solution 1 (disfavored):
    public class kanjiDrill{ // a chunk of Swing GUI or something
         public void runDrill(Vector kanjiEntries){
              KanjiEntry currentKanjiEntry = kanjiEntries.elementAt(0); // except really I will pick one randomly
              char theKanji = currentKanjiEntry.getKanji();
              String theReading = currentKanjiEntry.getReading();
              // build and show a flashcard based on theKanji and theReading
              // use a setter to change currentKanji's data based on whether the user answers correctly;
    }Solution 2 (favored):
    public class kanjiDrill{ // a chunk of Swing GUI or something
         public void runDrill(Vector kanjiEntries){
              KanjiEntry currentKanjiEntry = kanjiEntries.elementAt(0); // except really I will pick one randomly
              currentKanji.buildAndShowFlashcard(); // method includes updating stats
    }I can definitely see the advantages to this, but two potential reasons to think hard about it occur to me right away. First, if this process is carried out to a sufficient extreme the objects that hold my data end up sucking in all the functionality of my program and my objects stop resembling natural concepts.
    In your shopping example, say you want to generate price tags for the items. The price tags can be generated with ONLY the raw price, because we do not want the VAT on them. They are simple GIF graphics that have the price printed on a an irregular polygon. Should all that graphics generating code really go into the item objects, or should we just get the price out of the object with a simple getter method and then make the tags?
    My second concern is that the more instance methods I put into my bottom level data objects the bigger they get, and I intend to have thousands of these things in memory. Is there a balance to strike at some point?
    It's not really a setter. Outsiders are not setting
    the items price - it's rather updating its own price
    given an argument. This is exactly how it should be,
    see my above point. A breach of encapsulation would
    be: another object gets the item price, re-calculates
    it using a date it knows, and sets the price again.
    You can see yourself that pushing the date into the
    item's method is much beter than breaching
    encapsulation and getting and setting the price.So the point is not "don't allow access to the members" (which after all you are still doing, albeit less directly) so much as "make sure that any functionality implicated in working with the members is handled within the object," right? Take your shopping example. Say we live in a country where there is no VAT and the app will never be used internationally. Then we would resort to a simple setter/getter scheme, right? Or is the answer that if the object really is pure data are almost so, then it should be turned into a standard java.util collection instead of a custom class?
    Thanks for the help.
    Drake

  • Help with exporting and image size or boundaries?

    I am trying to slide the cat into the scene a little at a time foir an animation project I am working on. However, when I export the image the back ground of the image expands with a checkered back ground( showing here in white) and shows the whole cat.
    How do I just show a little of the cat on the image at a time when exporting. I am trying to give the impression that the cat is walking into the room. I do not want to have to cut the cat up.
    I would be thankful for any suggestions.

    Provide the name of the program you are using so a Moderator may move this message to the correct program forum
    This Cloud forum is not about help with program problems... a program would be Photoshop or Lighroom or Muse or ???

  • If you need help with CPS and Contribute

    After over a month of contacting support, I have come to the conclusion that Adobe does not offer advance support for CPS. The only thing that the low level tech support agents are capable of doing is
    1. transferring you to someone else,
    2. Sending you links to the online manual and livedocs that you have probably already read.
    After spending over a month and roughly 100+ hours I have determine that CPS cannot handle multiple client certificates sent via a Department of Defense Common Access Card. I did learn the following info that you might find useful.
    1.      Contribute must be able to write a file to the root (when you 1st connect it writes TMPjaisd8ua89ua.htm then deletes it) If this failes for any reason, contribute gives you the ever so helpful could not connect error
    2.      contribute must be able to write / delete files in root/_mm
    3.      If you want users to send drafts contribute must have access to root/MMWIP
    4.      If you are using Contribute CS3 or newer and you remove a connection from a computer, the connection isn't really removed 100%, you must go into regedit, current user, software, adobe, contribute41 and clear out keystore, trusted CPS Server, Admin Servers. Just leave the defaults. This might be different for version 5
    5.      Work with an LDAP admin to get the correct LDAP settings so CPS can view the directory
    6.      If using multi LDAP servers ensure that replication is working correctly on them all otherwise your users won't be able to access the site if connected to a faulty LDAP server. Also make sure users can get to the directory via windows if using local/Network connection
    7.      Work with Network admin to have security logging enable on the web server so anytime contribute gives an error they can check the log to see exactly what your account was trying to do at the time of the error.
    8.      Read the Manuals, in fact memorize them.
    http://help.adobe.com/en_US/Contribute/4.1_CPS/help.html?content=con_overview_ov_3.html
    http://help.adobe.com/en_US/Contribute/4.1_CPS/help.html?content=con_setup_install_si_18.h tml
    http://livedocs.adobe.com/contribute/311/deploying_en/wwhelp/wwhimpl/js/html/wwhelp.htm?hr ef=00000049.htm#134387
    I hope this will shed a little light on CPS and contribute or if not then at least give you some direction on how to debug your problems since Adobe will never help you.

    Addition:
    9.      Create a folder on your desktop called "ctnetperformancelog" and then launch Contribute.  Information logged in these files can provide invaluable insight in pinpointing where problems originate.
    For example:
    135 07/05/11 12:31:53 PM mmoreno netio/LAN PutData ACCESS_DENIED 5 5 0.0017 file://webdev/Dev/ /Dev/_mm/contribute.xml
    This was the result of /_mm/contribute.xml inadvertently being marked read-only due to a dreamweaver misconfiguration.
    See http://kb2.adobe.com/cps/195/tn_19506.html for more details.
    Don't forget to delete or rename this folder (e.g. "ctnetperformancelog-DISABLED") after debugging since the log files can grow quite large.

Maybe you are looking for

  • I forgot my admin password for my mac and need to reset it, any help?

    Im not sure how long ago I set up the admin password and have tried every password I can remember ever using in the last 5 years and cant seem to get anywyere. There must be some alternative to changing my admin password. I have any and all info pert

  • Safari 4.0.5 OSX & Windows

    I have both Safari 4.0.5 for Windows and Safari 4.0.5 under OSX 10.5.8. I have one site that displays a Flash page peel ad using IE and Safari 4.0.5 for Windows, but the same site does not display the page peel ad using Safari 4.0.5 OSX (although oth

  • Arris 862

    I AM HAVING PROBLEMS CONNECTING TO WIFI ON MY PANASONIC ST30 TV WITH ARRIS 862. DOES COMCAST HAVE A BETTER MODEM NOW? WOULDI BE BETTER OFF BUYING MY OWN SEPERATE MODEM AND ROUTER,IF SO WHAT DO YOU SUGGEST. I AM A SENIOR CITIZEN WITH LIMITED KNOWLEDGE

  • Condition Records not to be calculated if base value is negative

    Dear all I have configured a pricing procedure which is being used while performing DP90 with reference to service order. Now the values are getting populated in condition type EK02 and based on this value various other charges like service tax, supe

  • How Badly Do You Abuse Reserved Words in Column Names

    I have a challenge for all you DBA's out there.  Most of us agree that reserved words as column names is a bad practice but how clean is your database and some people are quit outspoken about it.  Run the following query on some of your custom, non-C