Negative/positive graduated progressbar

Hello everybody,
I would like to develop a progressbar with graduation and be able to go in the negative and positive domain.
How can I carry out this ?
Now, I am using 2 progressbars, one for the positive domain, and the second is rotated to represent the negative domain. And for the graduation, I have developed a class with a thin rectangle and at the top a label. Do you think this solution is the best ?
Thank you in advance for your response.
Best regards,
WhiteTantale

There is no automatic way to do this in Aperture.
For your use, I recommend making positives using a program which does this directly -- and then import the positives into Aperture for further development, storage, and output.
You can invert the luminance curve in Aperture. I believe you can do this for individual color channels, but I have not tried it.

Similar Messages

  • Homing motors and negative positions

    Hello all,
    I am using two stepper motorized stages (an x axis and y axis) from ThorLabs and am having a problem controlling them with my program after they go to their forward home position. The forwrad position is with the actuators and stages all the way in so it reads 0mm. I have a program in LabView designed to move them both but the problem seems to be that any position with the the actuators and stages extended at all is a negative position. My code uses loops to provide the input to the move absolute method but its inputting a positive number and there is no more room for it to move in a positive direction. Negating the input doesn't seem to work either, I get an error message that say something about the parameter being out of bounds.
    Any suggestions would be great!

    I guess I'm not 100% sure what you mean so I'll just guess. I'm using a dual channelThorLabs controller, and the motors are using theactivex methods in my code to move. Is this what you meant?
    Thanks,

  • Key difference between Negative & Positive Time Managment

    Dear Consultants,
    Please provide the information regarding the key differences between Negative Time Management & Positive Time Management.
    Under what circumstances, we shouldn't recommend for Positive Time Management?
    What are the major challenges for the client/end-user in using Positive Time Management?
    What would be the duration required to implement Negative TM?
    What would be the duration required to implement Positive TM?
    What are the limitations of Negative TM?
    Can a client opt for both Positive & Negative TM?
    Regards,

    See the re
    Please provide the information regarding the key differences between Negative Time Management & Positive Time Management.
    Time Management can be bifurcated types:
    1. Positive Time (+ve Time) ? Positive time is plays the total role of workflow. All the processes related to time are automatically gets executed in the background. E.g., in our case it is done only partially to validate the attendance as per punches and other documents with shift timing and generate absence automatically in case of any discrepancy. 
    2. Negative Time (-ve Time) ? Where the all time related activities like validation of the attendance, posting of absence for wage deduction etc are done manually. It has less level of integration among the different components of time management.
    Negative Time Recording:
    1. Records time deviations to Planned Working Time
    2. Valid deviations include: Absences, Special Absences, On Call Duty, Overtime, Substitutions, Time off in lieu
    3. Deviations are manually entered according to type & duration.
    Positive Time Recording:
    1. Records the attendance time of the employee
    2. Records the deviation times of the employee
    3. Valid attendances include: Training, Business Trips, Seminars, Overtime.
    4. Attendances & deviations can be entered either:
    - Front end system
    - Manually.
    Positive Time Management we have two types of recordings:
    1. With Clock times - Complete time recording is captured
    2. With out Clock times - Only Number of hourse worked is captured
    Negetive time Management:
    1. No clock times and assumed employee is working unless and until his or her absences are entered.
    How is the process of getting data from time recording system to SAP how can we connect time recording system to SAP? How do we interface for positive time management?
    To simplify:
    We can consider two independent systems:
    1. SAP System which contains Planned Working time
    2. Time recorder system which contains the actual timings
    Now as Time recorder system will contain all Clock in & Clock outs, the data needs to be uploaded to SAP system either as Scheduled job at back end or online in critical cases.
    Based on our Time pair and other IMG settings in SAP System and comparison of IT2011 with IT2000, it generates values of OT,Absences etc etc.
    This job can be effectively done in proper coordination with Basis, ABAPers and Time Consultants.
    Under what circumstances, we shouldn't recommend for Positive Time Management?
    >>>If the company has only salaried employees /exempt empls, where you dont record their OT, DT, etc..
    >>>If Company has already another system which records time and can provide just total hours to be paid off in Regular / OT/ DT and also could update quotas
    What are the major challenges for the client/end-user in using Positive Time Management?
    >>>Integration between 3rd party system and SAP - Interface, logics
    >>> Accruals and Quota
    What would be the duration required to implement Negative TM?
    >>> Few months *
    What would be the duration required to implement Positive TM?
    >>> Depends on volume diversity you have in time recording. May be between few months to a year.
    What are the limitations of Negative TM?
    >>> Detailed reporting may not be available in SAP and Posting Timesheets to CO/Billing would out of scope
    >>> Also refer to SAP documents and presentation by clients in market place for more details
    Can a client opt for both Positive & Negative TM?
    >>> Yes you can

  • Tuning a servo while encoder gives negative position feedback

    I want to tune my servo motor (voice coil) manually in MAX. Stable step response is possible, but two problems occure:
    1) When the step is done, the curve displayed on the "Calibration>Servo tune>Step response" tab shows an excitation step line from -70000 to the value I entered under "step length", although I reset the current position in the "1-D interactive" to zero beforehand.
    2) No matter how I change the "step length" value or Ki, the motor step always goes from this above mentioned -70000 to +50000.
    To facilitate any hint, mazbe this causes the problems: My encoder head is mounted the way that it gives back negative count values in the positive motor direction. Does this have to be changed or is it possible to also tune the servo with this negative encoder position feedback. Is it even possible the position feedback from - to + within MAX?
    Thanks in advance for any help.

    Customer solved the problem:
    "Sehr geehrter Herr Wagner,
    bzgl meiner Anfrage für die Regelung meines "Vertikal-Servos" habe ich
    meine Probleme lösen können:
    - Das Vorzeichen der Encoder-Counts konnte ich durch vertauschen der
    Encoder-A-B-Polaritäts-Kabel am Encodereingang des Motor Drives umdrehen.
    - Wie erwartet war es dann (wenn auch nur mit viel Geduld) möglich,
    PID-Einstellungen zu finden, die meine Achse auch mit dem aufliegenden
    Gewicht vertikal kontrollieren lassen.
    Ihnen nochmals vielen Dank für Ihre Unterstützung.... Die nächsten
    Probleme kommen für mich bestimmt.
    Freundliche Grüsse,
    Henri Hagenmüller"

  • SD condition for both positive and negative....

    Hi Gurus,
    I have struck with on e issue please explain the below case:
    I have  SD Condition types:z105, z118.z115,ziet.
    Z105 assigned to AcconTING key  ERF  For ERF One gl account has been linked that is 404001(12) this is Freight Chg for CST value in V/06(SD)
    Z118 assigned to  ERF  For ERF One gl account has been linked that is 404001(12) this is Freight Allow Cond.(-) value in v/06.
    Z115 Assigned to JET for JET one gl has been linked that is 408011(11) this is Freight Surchage in V/06.
    ZIET Assigned to JET for JET one gl has been linked that is 408011(11) this is State Entry Tax (+/-) in V/06.
    The  z105, z118.ziet three condition types linked to one value field VVFRO(This value field they are showing under deductions)
    Z115 assigned to VVFRE(This is Revenue)
    But in report I am not able to match the sum of these two GL balances with Sum of two value filds?
    IN  KE4I NO +_ symbol was assignd to any VALUE FIELD..
    Please clear my confusion.
    Thanks,
    Chandu

    Hi,
    The following table shows an overview of how condition values are updated in CO-PA for billing documents from SD:
    Billing document (normal) "With +/- sign"    "Without +/- sign"
    Debit posting                         negative           positive
      (such as sales deductions)
    Credit posting                        positive           positive
      (such as sales revenues)
    Credit memo/return       "With +/- sign"    "Without +/- sign"
    Debit posting                         negative           negative
      (such as sales revenues)
    Credit posting                        positive           negative
      (such as sales deductions)
    regards
    Waman

  • Can you help me understand the use of the word POSITION in TR and CFM?

    Hi,
    I am trying to have a view of typical BI reports in TR and TM/CFM so through my research I came to the following link:.
    http://help.sap.com/saphelp_nw2004s/helpdata/en/62/08193c38f98e1ce10000000a11405a/frameset.htm
    My problem on this link and other postings on this site seem to be the same. Can you help me understand the use of the word POSITIONS in these context:
    1. Our client has asked for financial transaction reports in BW, such as position of Borrowings, Investments and Hedge Operations (TM data).
    2. I have a requirement on, some reports related to Money Market (Fixed Term Deposits, Deposits at Notice) something on FSCM-Treasury and Risk Manager. These reports will be similar to that of Loans, i.e. Position statement, flow statement, etc.
    3. The set of position values for a single position or a limited amount of positions can be reported by transactions TPM12 and TPM13 in R3.
    4. 0CFM_C10 (Financial Positions Cube)
    Do you have some simple report outputs to help clarify how the word POSITION is used in such environments?
    Thanks
    Edited by: AmandaBaah on Feb 15, 2010 4:39 PM

    If I future buy 10 shares in company at £1 per share - at the end of the day my potential value is £10
    The next day the shares drop tp £0.9 per share - I have a negative position - my shares are only worth £9
    I haven;t bought them yet - but I have a negative position - ie if things stayed as they are - I am going to realise (ie end up with)  a loss
    Now you can use this for loans and foreign exchange banks as well...

  • Alv Grid download to xl sheet: Column position mismatching

    Hi All,
    As we know that while downloading the alv grid report data into xl sheet the date cloumn and might some other column positon get shifted to extreme right.
    My problem is with five columns in my grid report  that got shifted to extreme right while downloading to the xl sheet. They have the data type CURR and DEC. As both the types are basically packed.
    I tried to convert one of them into character, but had short dumpfor this conversion.I
    Please suggest me to resolve this issue. I shall be greatful to the valuable answer.
    Note: My internal table fields order and fields order in fieldcatalog are same.
    Thnaks in advance.

    Answer is to convert it to CHAR .
    Conversion error could you post..
    Might be the size was not enough to accomodate the DEC/CURR value .
    Or the  field was not able to recognise the negative/positive signs .
    Other option is to play with excel and  manually convert all fields to Text by formatting the column in excel.

  • COPA report showing as positive values which should be show as Nagitive val

    Dear Experts
    I have one issue with COPA and Profit center reports reconciliation where the both have same structure
    user  compareing the (Period :dec 2011)  report PCA and COPA there identified some values are difference  so we started investgation
    one of the cost element showing in nagitive value in accoungint document and same  it is showing postive value in COPA report
    that values for debit and credit line items are adding (,) insted of Cancellation  (+,-) , so that COPA report is incresed the value for one value field when compare with PCA report line items
    could you please let any guide me where is the problem is occuring
    thanks
    Rana

    Hi,
       The COPA sign logic depends on the cost element type used (costs or revenues) and also the customizing of the '+/-  transfer sign' in tcode KE4I.
    The following table shows an overview of how condition values are
    updated in CO-PA for billing documents from SD:
    Billing document (normal) "With +/- sign"    "Without +/- sign"
    Debit posting                          negative            positive
      (such as sales deductions)
    Credit posting                         positive            positive
      (such as sales revenues)
    Credit memo/return         "With +/- sign"    "Without +/- sign"
    Debit posting                          negative            negative
      (such as sales revenues)
    Credit posting                         positive            negative
      (such as sales deductions)
    The "+/- sign" refers to the "Transfer +/- sign" flag in tcode KE4I where you assign SD conditions to COPA value fields.
    If the system is behaving as shown above and you want a different behavior then you could change the sign in user exit COPA0002.
    regards
    Waman

  • Printing a PDF in negative

    Hi all,
    I have a number of PDFs with black background. They look great on screen but require a lot of ink to print.
    I would love to print them in "negative" i.e. black becomes white and vice-versa.
    Any idea how I can do that?
    And is it possible to save a "negative" version of an existing PDF?
    Thanks a lot.

    Is the text present as text elements or as image? In Preview you can select text and/or image material from PDF using two different tools. If it is text you could copy it into a more friendly text editor and modify what you need with font characteristics. I suspect that your text isn't really text but an image of text. You can grab the pdf file as an image in Preview, save to a file or copy, and then use an image editor program that has a negative/positive function. I'm sure Photoshop has that option, though there may be some cheaper or even free editors out there that can do that. Most of my image software dates from OS9 generation so I am not up on the OSX applications for that.
    Brian

  • What's wrong here?

    Hi, im getting a strange output on parts 3 and 4 of my program, they are the same, when they should be different. Here is the output:
    Laboratory 3 written by me..
    Frog: Position = 6, hops = 100, max position = 11, min position = -1, number home = 8
    -------- Part 3 --------
    Experiment # 1: Frog: Position = -14, hops = 100, max position = 1, min position = -18, number home = 2
    Experiment # 2: Frog: Position = 6, hops = 100, max position = 10, min position = -6, number home = 15
    Experiment # 3: Frog: Position = 2, hops = 100, max position = 15, min position = 0, number home = 1
    Experiment # 4: Frog: Position = -2, hops = 100, max position = 0, min position = -14, number home = 1
    Experiment # 5: Frog: Position = -4, hops = 100, max position = 6, min position = -5, number home = 6
    Experiment # 6: Frog: Position = 6, hops = 100, max position = 12, min position = 0, number home = 4
    Experiment # 7: Frog: Position = 4, hops = 100, max position = 10, min position = -2, number home = 8
    Experiment # 8: Frog: Position = 8, hops = 100, max position = 13, min position = -7, number home = 1
    Experiment # 9: Frog: Position = 18, hops = 100, max position = 19, min position = -2, number home = 3
    Experiment # 10: Frog: Position = 8, hops = 100, max position = 9, min position = -6, number home = 14
    After 10 experiments:
    Average Position = 3.2
    Maximum Position = 19 // same as in part 4
    Minumum Position = -18
    -------- Part 4 --------
    Kirby hopped 50 times.
    After the experiment:
    Average Position = 19.5
    Maximum Position = 19 // same as in part 3
    Minumum Position = -18
    now heres the code for my frog class:
    package frogs;
    import java.util.*;
    public class Frog {
        private static Random rand;
        private int hops;
        private int numberHome;
        private int maximum;
        private int minimum;
        private int position;
        public Frog() {
            hops = 0;
            numberHome = 0;
            maximum = 0;
            minimum = 0;
            position = 0;
            rand = new Random();
             public int getHops(){
                 return hops;
             public int getMaximum(){
                 return maximum;
             public int getMinimum(){
                 return minimum;
             public int getNumberHome(){
                 return numberHome;
             public int getPosition(){
                 return position;
             public void hop () {
                 if (rand.nextInt(2) == 0)
                     position++;
                 else
                     position--;
                 if (position > maximum)
                     maximum = position;
                 if (position < minimum)
                     minimum = position;
                 if (position == 0)
                     numberHome++;
                 hops++;
             public void hop (int n){
                 for (int i = 0; i < n ; i++)
                     hop();
             public String toString(){
                 return "Frog: Position = " + position + ", hops = " + hops +
                         ", max position = " + maximum + ", min position = " + minimum + ", number home = " + numberHome;
    }heres my FrogTester class: ( i think the problem is in here, not sure though)
    package frogs;
    public class FrogTester {
        public static void main(String[] args) {
            System.out.println("Laboratory 3 written by Me. ");
            Frog kermit = new Frog();
                kermit.hop(100);
            System.out.println(kermit);
            System.out.println("-------- Part 3 --------");
            int averagePosition = 0;
            int maxPosition = 0;
            int minPosition = 0;
            for (int exp = 0; exp < 10; exp++){
                Frog aFrog = new Frog();
                aFrog.hop(100);
                System.out.println("Experiment # " + (exp+1) +": " + aFrog);
                averagePosition += aFrog.getPosition();
                if (aFrog.getMaximum() >maxPosition){
                    maxPosition = aFrog.getMaximum();
                if (aFrog.getMinimum() < minPosition) {
                        minPosition = aFrog.getMinimum();
      System.out.println("After 10 experiments: " );
      System.out.println("Average Position = " + (double) averagePosition/10);
      System.out.println("Maximum Position = " + maxPosition);
      System.out.println("Minumum Position = " + minPosition);
      System.out.println("-------- Part 4 --------");
                Frog kirby = new Frog();
                   int hops2 = 0;
                   while (hops2 < 50){
                        kirby.hop();
                        hops2++;
                        averagePosition += kirby.getPosition();
                     if (kirby.getMaximum() > maxPosition){
                         maxPosition = kirby.getMaximum();
                     if (kirby.getMinimum() < minPosition) {
                             minPosition = kirby.getMinimum();
                   System.out.println("Kirby hopped " + hops2 + " times.");
                   System.out.println("After the experiment: " );
                   System.out.println("Average Position = " + (double) averagePosition/10);
                   System.out.println("Maximum Position = " + maxPosition);
                   System.out.println("Minumum Position = " + minPosition);
    }Here's what the program is about just to be more clear:
    Random walks are used to model many physical phenomena, such as an ideal gas. In the 1-dimensional case, the walker flips a coin (randomly chooses 0 or 1) and takes one step left or right based on the outcome. In this laboratory will you develop a Frog class that represents a random walk on 1-dimensional line.
    The Frog starts at position 0. Each time the Frog hops, it randomly chooses a 0 or 1 and increments its position if a 0 is chosen or decrements its position if a 1 is chosen. The Frog also keeps track of the total number of hops it has taken, its current position, its minimum position (the most negative position that it has visited so far), and its maximum position (the most positive position that it has visited so far).
    Message was edited by:
    kevin123

    Even though your code format is ABSOLUTELY DIABOLICAL (you not heard of indenting?) I think I can see what your prob is.
    In part 4 you are not working out the average position by dividing by 10 even though there are 50 hops. (And you are not resetting the mi/max positions like the other dude said).
    Seriously, next time you post remove all that useless white space and indent properly. It helps a remarkable amount.
    Ted.

  • When I record an audio track, there is a waveform. When I stop recording, the waveform disappears and becomes a straight line. It also disappears from the track edit window. But the sound is there. How can I stop the waveform from disappearing?

    When I record an audio track using Logic Pro X, there is a visible waveform which appears as I record. When I stop recording, the waveform disappears and becomes a straight line. It also disappears from the track edit window. But the sound is still there. How can I stop the waveform from disappearing? And can I do something to view it after it has disappeared? Anyone know the anser?

    In Logic:
    Preferences/Audio Set Recording Delay to 0 <zero>
    This should always be set to zero unless a specific set of circumstances exist and you're audio drivers do not report position correctly.
    On occasion, usually when importing a Logic 9 project, Logic-X randomly changes this to a negative/positive number.  It's actually a bug in Logic, as it should always display the waveform.

  • Creation of a database engine for mobile devices using j2me

    am trying to develop a database engine for mobile devices.. it is to develop a miniature version of the DBMS that
    can be deployed on a mobile phone..I have to develop my own code for performing tasks such a s creating a table,
    inserting values into it, selecting from it etc..
    I limited my self to develop the software so that it can perform 3 functionalities of create, insert,select..
    I should be taking the details such as table name and its parameters from the user and then should be able to
    create a suitable data structure for it(i tried to develop a class)...
    Usage of RMS package helps me partially in this.. I did that and ll be doing that..
    I got stuck while developing the code for creation of a table.. I am facing problems in creating a dynamic data
    structure for a table and also to use such data structure else where in my project..
    I need help in developing an algorithm for this..
    I would be very grateful to u all if u help me out in developing the code for this project..

    I'm sorry for the amount of time it took me to get back. Derby is an open source database written entirely in Java. I do not know if it can support resource constrained devices like MIDP compliant, but may work okay with CLDC.
    But outside of Derby being a solution, let me give you a few ideas off the top of my head.
    Set up a database server in a separate thread. This server will really be your controller for RMS access.
    Since RMS is just a big sequential 'pipe' you will have to think of data as 'frames' - (starttable) (tableID) (tablename) (data) (tablename) (data).....(endtable).
    When you need to write additional data, just append it to the end of the RMS object.
    When you need to retrieve data, thing are more complex.
    1. Read in all data, looking for your particular tableID. This may be made much easier using RMS filters - (I'm not sure, I've never used them)
    2. Once start of table of interest is found, stick the data elements in either a java vector or array until you reach the table end identifier. I think vector will be a better choice - trust me. (I think its available in J2ME...)
    3. Package this into a do while loop until the element you are searching for is read. If you need to do some sorts on the data or something else that requires the all the data to be present then you need all the data for that particular table. One thing will always be clear. The first data you grab will always be some start table identifier and the last data you grab will be an end table identifier. We just don't know which table because of how we put stuff in the RMS resource.
    This provides you a few positives as well as negatives:
    Positive:
    1. Fast data writes, no need to search for a particular table before accessing it, nor do you need to search for an index in that table.
    2. When looking for data, data may* be found without searching through the entire table. This is accomplished with RMS filters or logic test within the RMS read loop.
    Negative:
    1. Slow when all data of a table is needed (i.e. compute sums or averages of entries). The entire RMS database must be read to ensure all the entries are searched. An example of how this is a problem is as follows: You have 5000 entries in you RMS database resource and you are looking to compute the average of a value in some table. When you first wrote the data to the table, it was done sequentially and no other data for that table exist. But we can't tell if that's the case, so we have to read through all 5000 entries to make sure we looked for every piece of data.
    Beacuse of this issue, this database structure, performance may be fine for 50K - 100K entries (depending on table element size), if the reading requirements don't force full data reads. Otherwise, 25K may be an upper limit.
    I hope this helps.
    Edited by: estarkey on Mar 17, 2009 9:15 PM
    Edited by: estarkey on Mar 17, 2009 10:01 PM

  • Accounting document not generating in billing

    Hi,
    When try to clearing accounting document through VF02 it showing *"check value field assignment for condition FREE"
    when I am double click this log it showing message
    Check value field assignment for condition FREE
    Message no. KE/AD243
    Diagnosis
    When condition "FREE" (application "V") was transferred to the value field "VVDIC" in operating concern "CPLG" in Profitability Analysis, the following became apparent:
    u2022     The condition can take both positive and negative values
    u2022     The flag "Transfer values with +/- signs" has not be set in Customizing for value field assignment.
    Inconsistencies in the data could occur as a consequence.
    System response
    It is not possible to post the document in Profitability Analysis.
    Procedure
    Set the flag "Transfer values with +/- signs" for the condition "FREE".
    You should set the flag "Transfer values with +/- signs" selectively for individual conditions if:
    1. The conditions can take both negative and positive values (for example, in the case of conditions that describe a transfer price surcharge or a loss deduction).
    2. The conditions appear several times in a billing document and thus cause a debit posting as well as a credit posting (this is the case, for example, when creating or cancelling reserves).
    By activating the flag "Transfer values with +/- signs", you balance the positive and negative values in a condition. You can thereby guarantee that the sum of the negative and positive condition values is displayed as the correct total value in the value field assigned to the condition.
    Caution when in the production system!
    If you have already used condition "FREE" to post data in the production system, then the sign in Profitability Analysis may differ from the previous sign as a result of the flag "Transfer values with +/- signs" having been activated. See the F1 Help documentation on the field "Transfer values with +/- signs" or the OSS note 52849. If deviating signs occur, it makes sense to move condition "FREE" to a new value field! Contact your system adviser or SAP.
    The +/- signs are handled as follows for the flag "Transfer values with +/- signs":
    Billing document(normal) "trans.with signs"  "trans.w/o signs"
    Debit posting                   negative        positive
      (such as sales deductions)
    Credit posting                     positive        positive
      (such as revenues)
    Credit memos/returns    "trans.with signs"  "trans.w/o signs"
    Debit posting                   negative        negative
      (such as revenues)
    Credit posting                     positive        negative
      (such as sales deductions)
    Maintain Condition Assignment to Value Fields - SD Condition

    Hello,
      The error message KE/AD243 generally appears due to incorrect customizing in the tcode KE4I.                                           
    Since you mention that this issue cannot be reproduced in your testing environment could you please check if there is a difference in customizing in this tcode between your testing and PRD environment for assignment of value field VVCDI to condition type FREE ? The +/- transfer flag could be the problem.                                      
    As of Release 4.6, the system checks the value field assignment during the transfer of billing documents to the Profitabilty Analysis.          
    To prevent an inconsistent update of data in CO-PA (see notes 33178 and 52849), the system checks whether the flag 'Transfer with the appropriate plus/minus sign' is set in the Customizing ( 'KE4I' ) for condition types of which there are several on a billing document with different plus/minus signs. So if the flag is not set, error message KE/AD243 is issued.                                                      
    You can bypass this logic by using  note 626529. Also check if this is present in your testing environment. You may only use this modification if the +/- sign handling of the affected conditions occurs in a CO-PA user exit. If you have not implemented an own +/- sign handling in an exit the modification results in a data inconsistency in CO-PA .                          
    I hope that the information are helpful.
    Regards
    Claudia
    If you are satisfied with the answer, please give Reward Points.

  • A question about arrays (brace yourself this is a long post)

    I am working on an assignment that is about generating a random rabbit race by using arrays:
    Rabbit Race
    Write a program to simulate a race between 4 rabbits (numbered 0 to 3). Initially, all contestants are at the start of the race track (position 0) and must race on a 20 meter track (positions numbered 0 to 19). Each participant has its own technique; some run fast, but are sometimes lazy; while others run slowly but steadily. All rabbits make 1 movement one after the other and the one who arrives at the end of the track before the others, wins the race. Here are the rabbit?s strategies :
    At each turn, rabbit 0:
    - sleeps (so does not run), 50% of the time;
    - runs 4 meters, 30% of the time;
    - runs 3 meters, 20% of the time.
    At every turn, rabbit 1 runs 2 meters.
    At each turn, rabbit 2:
    - sleeps, 30% of the time;
    - runs 3 meters, 70% of the time.
    At each turn, rabbit 3:
    - runs 1 meter, 80% of the time;
    - runs 10 meters, 20% of the time.
    The difficulty in the race is that the track has little slippery hills. So after each movement, rabbits can slide down a hill bringing them either closer to the finishing line, or closer to the starting line. How much they slide and in what direction depends on the slope of the hill at their current position, and how many meters they ran during this turn. Each position (or meter) of the hill has a slope represented by an integer between -3 and +2. If the slope is :
    - zero : then, there is no hill at this position and rabbits that reach this position stay there.
    - a negative integer : then, there is a declining side of a hill at this position, and all rabbits reaching this position will slide down
    to a new position that is closer to the finishing line. The new position will be the current position minus the slope times the number of meters the rabbit ran.
    For example, assume a rabbit was in position 10, then ran 5 meters to position 15. If the slope at position 15 is -2, then the new position of the rabbit will be 15 - (-2 x 5) = 25.
    - a positive integer : then, there is a rising side of hill at that position, and all rabbits reaching this position will slide down to a new position that is closer to the starting line. The new position will be the current position minus the slope times the number of meters the rabbit ran.
    For example, assume a rabbit was in position 10, then ran 5 meters to position 15. If the slope at position 15 is +1, then the new position of the rabbit will be 15 - (+1 x 5) = 10.
    Notes on the race:
    - Rabbits have 40 turns to reach the finish line. If after 40 turns no one has managed to reach position 19 (or beyond), then the race is cancelled and no winner is declared.
    - A rabbit?s position can never go below 0. If, after calculating a rabbit?s position, you arrive at a negative position (ex. position -3), then consider that it is at position 0.
    - Consider that any position outside the track (ex. position 0 or position 20) has a slope of 0.
    - If a rabbit reaches position 19 (or goes beyond it), it does not immediately win the race. If any other rabbit reaches position 19 (or beyond) during the same turn, then there is a tie.
    - If at the same turn, one rabbit reaches position 19, and another reaches a position higher than 19, the second rabbit does not win the race because it went further than the first. They both win.
    Ok I know this is long and boring to read but I already completed the majority of the assignment here is my code:
    public class Assignment_3 {
        public static void main (String args[])
             int[] position = new int[20];
             int[] slope = new int[20];
             int[] moveRabbit = new int[4];
                   moveRabbit[1] = 2;
             int[] currentPosition = new int[4];
             int currentPositionandSlope = 0;
             for (int i=0;i<position.length;i++)
             {     position=i;
              System.out.print(position[i] + " ");
         System.out.println();
         for (int i=0;i<(position.length-5);i++)
         {     slope[i]=(int) (-3 + Math.random()*5);
         for (int i=0;i<position.length;i++)
              System.out.print(slope[i] + " ");
         System.out.println();
         for (int turn=1;turn<=40;turn++)
              int randomNb0 = (int) (Math.random () * 100);
    int randomNb2 = (int) (Math.random () * 100);
    int randomNb3 = (int) (Math.random () * 100);
              if (randomNb0<=50)
                   moveRabbit[0] = 0;
              else if (randomNb<=30)
                   moveRabbit[0] = 4;
              else
              moveRabbit[0] = 3;
              if (randomNb2<=30)
                   moveRabbit[2] = 0;
              else
              moveRabbit[2] = 3;
              if (randomNb3<=80)
                   moveRabbit[3] = 1;
                   else
              moveRabbit[3] = 10;
    for (int j=0;j<=3;j++)           
    System.out.println ("Rabbit" + j + " is at position " + position[currentPosition[j]]);
    if (slope[currentPosition[j]+moveRabbit[i]] < 0)
         currentPositionandSlope = position[currentPosition[j]+moveRabbit[j]] - (slope[currentPosition[j]+moveRabbit[j]] * moveRabbit[j]);
    else if (slope[currentPosition[j]+moveRabbit[i]] > 0)
         currentPositionandSlope = position[currentPosition[j]+moveRabbit[j]] - (slope[currentPosition[j]+moveRabbit[j]] * moveRabbit[j]);
    else
         currentPositionandSlope = (currentPosition[j]+moveRabbit[j]);
    System.out.println ("it will move by " + moveRabbit[j] + ", but at position " + (position[currentPosition[j]] + moveRabbit[j]) + " there is a slope of " + slope[currentPosition[j] + moveRabbit[j]]);
    System.out.println ("so it will slip by " + (position[currentPositionandSlope] - moveRabbit[j]) + " positions, and end up at position " + position[currentPositionandSlope]);
    currentPosition[j] += currentPositionandSlope;
    *Ok basically my question is that in the assignment there is an example output where the rabbit is at position 21 but the array is only 20 in length and my program crashes if i go beyond the array length.*
    The example output is here:
    Welcome to the 4 rabbit race:
    position: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
    slopes: 0 0 1 -2 1 0 -1 -1 1 -2 1 0 -1 -1 1 0 0 0 0 0
    TURN #1
    rabbit 0 is at position 0
    it will move by 3, but at position 3 there is a slope of -2
    so it will slip by 6 positions, and end up at position 9
    rabbit 1 is at position 0
    it will move by 2, but at position 2 there is a slope of 1
    so it will slip by -2 positions, and end up at position 0
    rabbit 2 is at position 0
    it will move by 3, but at position 3 there is a slope of -2
    so it will slip by 6 positions, and end up at position 9
    rabbit 3 is at position 0
    it will move by 1, but at position 1 there is a slope of 0
    so it will slip by 0 positions, and end up at position 1
    TURN #2
    rabbit 0 is at position 9
    it will move by 0, but at position 9 there is a slope of -2
    so it will slip by 0 positions, and end up at position 9
    rabbit 1 is at position 0
    it will move by 2, but at position 2 there is a slope of 1
    so it will slip by -2 positions, and end up at position 0
    rabbit 2 is at position 9
    it will move by 3, but at position 12 there is a slope of -1
    so it will slip by 3 positions, and end up at position 15
    rabbit 3 is at position 1
    it will move by 1, but at position 2 there is a slope of 1
    so it will slip by -1 positions, and end up at position 1
    TURN #3
    rabbit 0 is at position 9
    it will move by 3, but at position 12 there is a slope of -1
    so it will slip by 3 positions, and end up at position 15
    rabbit 1 is at position 0
    it will move by 2, but at position 2 there is a slope of 1
    so it will slip by -2 positions, and end up at position 0
    rabbit 2 is at position 15
    it will move by 3, but at position 18 there is a slope of 0
    so it will slip by 0 positions, and end up at position 18
    rabbit 3 is at position 1
    3
    it will move by 10, but at position 11 there is a slope of 0
    so it will slip by 0 positions, and end up at position 11
    TURN #4
    rabbit 0 is at position 15
    it will move by 0, but at position 15 there is a slope of 0
    so it will slip by 0 positions, and end up at position 15
    rabbit 1 is at position 0
    it will move by 2, but at position 2 there is a slope of 1
    so it will slip by -2 positions, and end up at position 0
    *rabbit 2 is at position 18*
    *it will move by 3, but at position 21 there is a slope of 0*
    *so it will slip by 0 positions, and end up at position 21*
    *We have a potential winner...*
    rabbit 3 is at position 11
    it will move by 1, but at position 12 there is a slope of -1
    so it will slip by 1 positions, and end up at position 13
    So yeah :) that's basically my question (all this text for a simple question like that lol)
    If you've managed to get to the end of my post then any guidance on my code would be appreciated too :)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    I'm not going to read that long post. As suggested, produce an SSCCE
    and paste in the exact, complete error message, and indicate clearly which line causes it.
    I did notice this though:
    Ok basically my question is that in the assignment there is an example output where the rabbit
    is at position 21 but the array is only 20 in length and my program crashes if i go beyond the array length.Either you're misunderstanding something, or the assignment has a typo. If you have an array of length 20, then the indices are 0..19.
    Maybe the instructor is calling index 0 position 1--separating Java's array impelementation details from
    colloquial 1-based counting, so that the rabbit starts at "position 1" (index 0) goes through "position 20"
    (index 19), and when he's done, he's "at postion 21"--i.e., past the finish line, off the end of the course, etc.
    This won't correspond to any index in the array, but can still be considered a logical position in the race. "Oh, he's
    at position 21. He's done. There's nothing more to do with the array, as it has no slot corresponding to
    this 'done' position."
    That's pure speculation on my part. You'll have to ask your instructor or figure out for yourself what's going on.

  • Establishing a socket connection between a .swf file and a socket-test program (TCP/IP builder - Windows), in AS3.

    I have an issue with a college project I'm working on.
    Using Actionscript 3, I made a simple .swf program, an animated, interactive smiley, that 'reacts' to number inputs in a input-box.
    For the sake of the project, I now need to make the framework for establishing a socket connection with the smiley .swf, and another program.
    This is where I encounter issues. I have very little knowledge of AS3 programming, so I'm not certain how to establish the connection - what's required code-wise for it, that is.
    To test the connection, I'm attempting to use the "TCP/IP builder" program from windows, which lets me set up a server socket. I need to program the .swf file into a client - to recognize it, connect to it, then be able to receive data (so that the data can then be used to have the smiley 'react' to it - like how it does now with the input-box, only 'automatically' as it gets the data rather than by manual input).
    My attempts at coding it are as follows, using a tutorial (linked HERE):
    //SOCKET STUFF GOES HERE
        var socket:XMLSocket;        
        stage.addEventListener(MouseEvent.CLICK, doConnect); 
    // This one connects to local, port 9001, and applies event listeners
        function doConnect(evt:MouseEvent):void 
        stage.removeEventListener(MouseEvent.CLICK, doConnect); 
        socket = new XMLSocket("127.0.0.1", 9001);   
        socket.addEventListener(Event.CONNECT, onConnect); 
        socket.addEventListener(IOErrorEvent.IO_ERROR, onError); 
    // This traces the connection (lets us see it happened, or failed)
        function onConnect(evt:Event):void 
            trace("Connected"); 
            socket.removeEventListener(Event.CONNECT, onConnect); 
            socket.removeEventListener(IOErrorEvent.IO_ERROR, onError); 
            socket.addEventListener(DataEvent.DATA, onDataReceived); 
            socket.addEventListener(Event.CLOSE, onSocketClose);             
            stage.addEventListener(KeyboardEvent.KEY_UP, keyUp); 
        function onError(evt:IOErrorEvent):void 
            trace("Connect failed"); 
            socket.removeEventListener(Event.CONNECT, onConnect); 
            socket.removeEventListener(IOErrorEvent.IO_ERROR, onError); 
            stage.addEventListener(MouseEvent.CLICK, doConnect); 
    // Here, the flash tracks what keyboard button is pressed.
    // If 'q' is pressed, the connection ends.
            function keyUp(evt:KeyboardEvent):void 
            if (evt.keyCode == 81) // the key code for q is 81 
                socket.send("exit"); 
            else 
                socket.send(evt.keyCode); 
    // This one should handle the data we get from the server.
            function onDataReceived(evt:DataEvent):void 
            try { 
                trace("From Server:",  evt.data ); 
            catch (e:Error) { 
                trace('error'); 
        function onSocketClose(evt:Event):void 
            trace("Connection Closed"); 
            stage.removeEventListener(KeyboardEvent.KEY_UP, keyUp); 
            socket.removeEventListener(Event.CLOSE, onSocketClose); 
            socket.removeEventListener(DataEvent.DATA, onDataReceived);
    Trying to connect to the socket gives me either no result (other than a 'connection failed' message when I click the .swf), or the following error:
    Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation: file:///C|/Users/Marko/Desktop/Završni/Flash%20documents/Smiley%5FTCP%5FIP%5Fv4.swf cannot load data from 127.0.0.1:9001.
        at Smiley_TCP_IP_v4_fla::MainTimeline/doConnect()[Smiley_TCP_IP_v4_fla.MainTimeline::frame1:12] 

    Tried adding that particular integer code, ended up with either errors ("use of unspecified variable" and "implicit coercion") , or no effect whatsoever (despite tracing it).
    Noticed as well that the earlier socket code had the following for byte reading:
    "sock.bytesAvailable > 0" (reads any positive number)
    ...rather than your new:
    "sock.bytesAvailable != 0" (reads any negative/positive number)
    Any difference as far as stability/avoiding bugs goes?
    So then, I tried something different: Have the program turn the "msg" string variable, into a "sentnumber" number variable. This seemed to work nicely, tracing a NaN for text (expected), or tracing the number of an actual number.
    I also did a few alterations to the input box - it now no longer needs the 'enter' key to do the calculation, it updates the animation after any key release.
    With all this considered and the requirements of the project, I now have a few goals I want to achieve for the client, in the following order of priority:
    1) Have the "sentnumber" number variable be recognized by the inputbox layer, so that it puts it into the input box. So in effect, it goes: Connect -> Send data that is number (NaN's ignored) -> number put into input box -> key press on client makes animation react. I optionally might need a way to limit the number of digits that the animation reacts to (right now it uses 1-3 digit numbers, so if I get sent a huge number, it might cause issues).
    - If the NaN can't be ignored (breaks the math/calculus code or some other crash), I need some way of 'restricting' the data it reads to not include NaN's that might be sent.
    - Or for simplicity, should I just detect the traced "NaN" output, reacting by setting the number variable to be "0" in such cases?
    2) After achieving 1), I'll need to have the process be automatic - not requiring a keyboard presses from the client, but happening instantly once the data is sent during a working connection.
    - Can this be done by copying the huge amounts of math/calculus code from the inputbox layer, into the socket layer, right under where I create the "sentnumber" variable, and modifying it delicately?
    3) The connection still has some usability and user issues - since the connection happens only once, on frame 1, it only connects if I already have a listening server when I run the client, and client can't re-connect if the server socket doesn't restart itself.
    I believe to do this, I need to make the connection happen on demand, rather than once at the start.
    For the project's requirement, I also need to allow client users to define the IP / port it's going to connect to (since the only alternative so far is editing the client in flash pro).
    In other words, I need to make a "Connect" button and two textboxes (for IP and port, respectively), which do the following:
    - On pressing "Connect", the button sets whatever is in the text boxes as the address of the IP and port the socket will connect to, then connects to that address without issues (or with a error message if it can't due to wrong IP/port).
    - The connection needs to work for non-local addresses. Not sure if it can yet.
    - On re-pressing connect, the previous socket is closed, then creates a new socket (with new IP/port, if that was altered)
    It seems like making the button should be as simple as putting the existing socket code under the function of a button, but it also seems like it's going to cause issues similar to the 'looping frames' error.
    4) Optional addition: Have a scrolling textbox like the AIR server has, to track what the connection is doing on-the-fly.
    The end result would be a client that allows user to input IP/Port, connects on button press (optionally tracking/display what the socket is doing via scrollbox), automatically alters the smiley based on what numbers are sent whilst the connection lasts, and on subsequent button presses, makes a new connection after closing off the previous one.
    Dropbox link to new client version:
    https://www.dropbox.com/s/ybaa8zi4i6d7u6a/Smiley_TCP_IP_v7.fla?dl=0
    So, starting from 1), can I, and how can I, get the number variable recognized by "inputbox" layer's code? It keeps giving me 'unrecognized variable' errors.

Maybe you are looking for

  • Commitment Item in SD Billing document (Fund Managment) ECC6

    Hi, We are upgrading from 4.6C to ECC6 and have activated Fund Managment (EA-PS). At the time of carrying out the Billing in SD we are getting a error that no commitment item available for gl account but if I use the same revenue account and create a

  • I need help finishing my assignment

    this is the program public class CableInstallationTestClass { public static void main(String[] args) {   CableInstallationClass  ci = new CableInstallationClass();   ci.setNumOutlets(1);   double subTotal = ((ci.getNumOutlets() -1 ) * ci.getCostPerOu

  • Reverse Stock In Transit

    Hello all, Case is In PO qty = 5.008 KG Delivery = 5.00 KG PGI = 5.00 KG When doing GR in receiving plant: Error for Qty Exceeded by xxx KG In MB5T qty = 5.008 KG Now i want to reverse the PGI When I reverse the PGI [641 Mvt] thru VL09, i get error m

  • Jerky playback in QT pro

    I have a 1 year old sony laptop with 1.5 gb ram and am trying to view a quicktime movie 2 gb file from QT pro. Even If I select the preload into ram option the movie refuses to run smoothly, the movie and sound are both jerky except in places where t

  • Elements 6 for Mac;  RAW processing

    I just bought Elements 6 for Mac.  I also recently bought a Leica Dlux 4 camera and would like to start working in Raw....Can someone tell me where to begin with regards to the Photoshop Elements 6.  Do I need to download special programs?  It doesnt