Java simple dusk cleaner game simulator

I am working on a dusk cleaner simulator on Java, in this case the shape of the cleaner is a circular ball.

The program is quite simple, the user puts in the width and length of the “room” and coordinates x and y.

What I want to do and cannot is create a series of commands, each represented by a character. There are three commands that I want to imnplement:

  1. char ‘A’ = Move forward 1 meter

  2. char ‘L’ = Turn left 90 degrees

  3. char ‘R’ = Turn right 90 degrees

Example of user input AALA, in this case the expected output is that the machine moves 2 meters and then turns left 90 degrees and then moves 1 meter again. Hope I am clear.

As you can see in the code, I have tried to create an array of chars but I dont know what the next step should be…

The code:

public class Cleaner extends JPanel {
/* int lx = 1, ly = 1;
int x = 200, y = 250;

*/
int x, y;
int width = 52, height = 50; // width and height of the "dust sucker"
int lx , ly;


// an array of chars
char() charArray ={ 'A', 'L', 'R'};     

java.util.Timer move; // making the instance of Timer class from the util package
static JFrame frame;
 
Cleaner()
{
    
    frame = new JFrame ("Cleaner started!"); // passing attributes to our fame
    frame.setSize (400, 400); // setting size of the starting window
    frame.setVisible (true);
    
    setForeground(Color.black); // setting color
    
    move = new java.util.Timer();
    
    move.scheduleAtFixedRate(new TimerTask()
    {
    
        
        public void run() 
        {
            if(x<0)
                lx = 1;
            if(x>=getWidth()-45)
                lx = -1; // -1 sets boundry for the dusk sucker
            if(y<0)
                ly = 1;
            if(y>=getHeight()-45)
                ly = -1; // -1 sets boundry for the dusk sucker
            
            x+=lx; // to make the machine move
            y+=ly;
            
            repaint();
        }
        
    }, 0, 5// speed of the machine
            );
    
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
}

public void paint (Graphics g) 
{
    super.paint(g);
    Graphics2D g2d = (Graphics2D) g;
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2d.fillOval(x, y, width, height);
}

public static void main (String() args) 
{
    // lx value
    
    String lxValue = 
             JOptionPane.showInputDialog( "Enter lx" );
    // ly value
    String lyValue =
              JOptionPane.showInputDialog( "Enter ly" );
    
    String xValue = 
             JOptionPane.showInputDialog( "Enter x value" );
    // ly value
    String yValue =
              JOptionPane.showInputDialog( "Enter y value" );


     // convert String inputs to int values 
      int firstInput = Integer.parseInt( lxValue ); 
      int secondInput = Integer.parseInt( lyValue );
      int thirdInput = Integer.parseInt( xValue ); 
      int forthInput = Integer.parseInt( yValue );

   
         Cleaner cleaner = new Cleaner();
         
            frame.add(cleaner);
      cleaner.lx = firstInput;
      cleaner.ly = secondInput;
      cleaner.x = thirdInput;
      cleaner.y = forthInput;       
    
}
    
}

All help is appreciated!

App Windows – OneSafe PC Cleaner Pro 7.3.0.2 Multilingual | NulledTeam UnderGround

File size: 6.0 MB

Fix Windows errors on your PC!​

Fix and correct all your errors, Clean up your PC thoroughly, Simplify your PC’s maintenance! Keep your computer clean and optimized and protect your privacy with OneSafe PC Cleaner.

Accelerate your computer’s startup time

Is your computer taking forever to start up? The OneSafe PC Cleaner Startup Manager makes it easy to identify and delete unwanted programs in your ‘Start’ menu. Startup and shutdown times can be improved dramatically when just a few programs are deleted from the Start menu.

Delete unwanted files and shortcuts

OneSafe PC Cleaner finds and deletes junk files and shortcuts that accumulate on your PC over time, taking up space on your hard drive. The software searches for and deletes invalid shortcuts and files left behind by uninstalled programs. OneSafe PC Cleaner also identifies and deletes unnecessary entries in the registry.

Optimize the settings for your security and Internet system

Optimize your computer’s settings to ensure that it runs in the fastest and most efficient way possible. With OneSafe PC Cleaner you can choose to follow our recommendations or customize your settings in order to optimize the performance of your computer.

Protect your privacy

Did you know that when you surf the web, information is often collected on your computer which tells people about your location and the sites you have visited? In fact, the history of your files, temporary files, and items left in your Recycle Bin leave a trail of private information for anyone who may be looking for it. OneSafe PC Cleaner detects and eliminates the risks associated with the protection of privacy on your PC and ensures that your private information remains secure.

Analyze and repair your PC problems

Elements to clean detection and outdated registry data

Unwanted files and private data cleaning

Windows boot configuration

Application Performance Improvement

Always keep your PC clean and powerful

Updates: official site does not provide any info about changes in this version.

DOWNLOAD
nitroflare

Comparing two arrays by index in python in a cleaner way

I have a simple task I want to do, I want to compare two arrays like this:

array 1 of data:  (0.0, 92.6, 87.8, 668.8, 0.0, 86.3, 0.0, 147.1)
array 2 of data:  (16.7, 0.0, 0.0, 135.3, 0.0, 205.5, 0.0, 93.8)

I want to find the difference between each value by index, and if the difference is lower than 50%, keep the value of the second array in a third array.

array 3 of data : (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 93.8)

Now I believe using a for loop would be the best option, iterating through each array since both have the same length, the code below is part of my code, array1 and array2 are arrays like above.

for scan in sensor:
        #here is some code where we build the Array1 and Array 2 from serial data which is inside the loop.
    if specialcount ==1: #build the first array
      #get data from dict and build first array
      datadict={ 0:(), 1:(), 2:(), 3:(), 4:(), 5:(), 6:(), 7:(), }
    if specialcount ==2: #build the second array.
        #get data from dict and build second array
      datadict={ 0:(), 1:(), 2:(), 3:(), 4:(), 5:(), 6:(), 7:(), }
    if specialcount ==3: #after we build 2 arrays, specialcount goes to 3, and we now compare the arrays
            indexsizeofArray1 = len(array1)
            indexsizeofArray2 = len(array2)
            if indexsizeofArray1 != indexsizeofArray2:
                print ("array mismatch, try again")
                break
            elif indexsizeofArray1 == indexsizeofArray2:
                print("array match, proccessing")
                array3 = (0,0,0,0,0,0,0,0)
                for X in range (indexsizeofArray2):
                    difference = array2(X)-array1(X)
                    fiftypercent = array1(X)-(array1(X)/2)
                    lowerrange = int(array1(X)-fiftypercent)
                    upperrange = int(array1(X)+fiftypercent)
                    if array2(X) in range (lowerrange,upperrange):
                        array3(X)=array2(X)
                    if X == indexsizeofArray2:
                        print("final array: ",array3)
    specialcount +=1

Above is my code ,I do get the result I want of course, but I believe I could make it cleaner mostly because I am in the code transforming float to int as they work with the range function. I am sure there is a cleaner way of doing this , that specialcount==3 is my condition since I build the 2 arrays inside the forloop before as soon as the second array is built, then we, this is inside a loop where I am polling constantly a sensor, the sensor is special in the sense that if I stop polling it and go out of the loop, it will not work again unless I restart it , as such I must be inside this loop all the time.

I am sure I can improve the speed of it if slightly, mostly on the reinitialization of the datadict, since I initialized it before , however inside the loop I populate it with the data up until a certain point, in which I then create the first array of data, and clear it so I can rebuild it. The goal is to build two arrays of 2 different variables that must be related, once those 2 lists are built, I need to compare them, ensure that they are not that different and if they are not , pass it to another function , if its too different, the value for that index in the list is 0 .

App Mac – Adware Zap Browser Cleaner 2.8.3 Multilingual macOS | NulledTeam UnderGround

Adware Zap Browser Cleaner 2.8.3 Multilingual | macOS | 22 mb
Adware Zap & Privacy Cleaner restores your browser back to its full health by removing unwanted extensions, cookies, caches and resetting your browser preferences.

Adware Zap & Privacy Cleaner restores your browser back to its full health by removing unwanted extensions, cookies, caches and resetting your browser preferences.
Adware Zap is your choice if:
+ Browser displays constant pop-up advertisements about dubious products and scams even from respected websites
+ Your browser is being hijacked and redirected to dubious websites
+ Your browser is slow and often freezes
+ You want to protect your privacy by removing sensitive files that were created during your browsing session
Privacy Cleaner function:
+ remove sensitive files from selected internet browsers such as history, download list, cookies and stored databases.
+ customise what to remove in the App Settings.
+ option to run automatic clean up when the browser quits.
To fully restore your browser, all cookies, extensions and caches will be removed. By default, browser bookmarks and internet history are not removed, but in the App Settings you can customise what to remove.
To continue to use extensions you previously installed and want to keep, you will need to reinstall them.
Compatibility: OS X 10.11 or later 64 bit
Mac App Store:

Recommend Download Link Hight Speed | Please Say Thanks Keep Topic Live

 

clean code – Is it cleaner to decrement a sleeping process counter in the waking process or the woken process?

Say I have a reader and a producer that share a buffer. I have a wait queue for the reader to put itself in if there is no contents in the buffer when it reads. I also have an atomic variable for keeping track of the number of readers.

The producer wakes readers when contents are added to the buffer.

Is it cleaner to decrement the reader counter in the producer, after it does the waking, or the reader, after it wakes?

Example code

void producer(){
    add_to_buffer();
    if(atomic_read(num_waiting_readers) > 0){
        wake_event(consumer_queue);
        // Cleaner here?
        atomic_decrement(num_waiting_readers);
    }
}

void consumer(){
    if(buffer_isempty()){
        atomic_increment(num_waiting_readers);
        wait_event(consumer_queue, 0);
        // Or here, after wake?
        // atomic_decrement(num_waiting_readers);
    }
    read_buffer();
}

What memory cleaner software exactly do?

You must have seen them as applications on mobile devices and I’ve been using one on mac OS. I was wondering what exactly memory cleaner software do? Do they free up memory in both ROM and RAM? And isn’t this something that can be a standard or a must in order to submit apps for public use?

react.js – React is there a way to write cleaner code when setting values?

I would like to know if there was a cleaner way of setting values in react.
The code just sets values onChange event for select lists. I’m used to using angular ((value))="form.CampaignID" directives and model binding. Is there a more succinct way? I’m going to have around 30 select lists.

import React from 'react';

const ImportToolBar = (props) => {

    const updateCampaign = function(e){
        var form = {...props.leadForm};
        form.campaignID = e.target.value;
        props.updateLeadForm(form);
    };

    const updateMarketingSource = function(e){
        var form = {...props.leadForm};
        form.marketingSource = e.target.value;
        props.updateLeadForm(form);
    };

    const updateMarketingType = function(e){
        var form = {...props.leadForm};
        form.marketingType = e.target.value;
        props.updateLeadForm(form);
    };
    
    const updateMarketingAdditional = function(e){
        var form = {...props.leadForm};
        form.marketingAdditional = e.target.value;
        props.updateLeadForm(form);
    };    

    return (
        <div>
            
            <label>Campaign</label>
            <select onChange={(e) => updateCampaign(e)}>
                {props.controls.campaigns.map(campaign => (
                        <option key={campaign.id} value={campaign.id}> {campaign.name} </option>
                ))}
            </select>  
            {/* <select>
                {props.controls.marketingCampaign.map(campaign => (
                        <option key={campaign} value={campaign}> {campaign} </option>
                ))}
            </select>     */}

            <label>Source</label>
            <select onChange={(e) => updateMarketingSource(e)}>
                {props.controls.marketingSource.map(source => (
                        <option key={source} value={source}> {source} </option>
                ))}
            </select> 


            <label>Type</label>
            <select  onChange={(e) => updateMarketingType(e)}>
                {props.controls.marketingType.map(type => (
                        <option key={type} value={type}> {type} </option>
                ))}
            </select> 


            <label>Additional</label>
            <select  onChange={(e) => updateMarketingAdditional(e)}>
                {props.controls.marketingAdditional.map(addtional => (
                        <option key={addtional} value={addtional}> {addtional} </option>
                ))}
            </select>             
        </div>
    );
}

export default ImportToolBar;

Looking cleaner code of Python Combining Image with PIL

Please review and help me write better codes.

Combining Pictures
We can use a conditional to copy just the non-white pixels from one picture to another picture. We can take this tiny image of the women and put her by the Eiffel tower in Paris, France. I have modified the code so that the code automatically swaps the image1 and image2; hence, always using the larger image as the canvas and the smaller picture as the insert.

”’

from PIL import Image

image1 = Image.open("lady_tiny.jpg")
image2 = Image.open("eiffel.jpg")

width = min(image1.size(0), image2.size(0))  # (x)
length = min(image1.size(1), image2.size(1))  # (y)

# check if smaller image then use it as insert
if width == image2.size(0) and length == image2.size(1):
    canvas = image1.load()  # larger pic
    insert = image2.load()  # smaller pic
else:
    insert = image1.load()
    canvas = image2.load()

for col in range( width):  
    for row in range(length):
        r, g, b = insert(col, row)  # read each pixel of insert(small)

        # Check if the pixel isn't white
        if r < 250 and g < 250 and b < 250:
            # Copy the color of insert (smaller) onto the canvas(larger)
            canvas(col, row + 130) = r, g, b

if (
    width == image2.size(0) and length == image2.size(1)
):  # if image2 is insert then image 1 is canvas
    image1.show()
else:
    image2.show()

”’

google – Best practice for GA goals and cleaner completion URLs?

Not sure how to look this up but some of what I’ve come across doesn’t seem to answer what I’m looking for.

So two things:

Is there a method to clear or track the URLs with ad parameters? (I still want to track the URLs). So my goals are set up and if someone converted at the home page it’ll show '/' which is correct but if they came from an ad the Goal Completion Location shows '/?-_property_name=&test...' something along those lines. Is there a way to attribute that ad url to the home page in GA?

Also, is there a best method to track a single form on two separate pages (/floor-plans/ and /new-homes/)? Like would it be wise to funnel the submissions to a single goal and spend some time looking at the data to look at where the conversions come from or create their own goals in GA?

Change Views BETWEEN min/max filter to a cleaner URL format?

Is there an easy way to change the default exposed BETWEEN filter to work with:

price=1000-2000

Instead of:

price[min]=1000&price[max]=2000?

Would it be reasonable to create my own Numeric filter or am I looking at a lot of modification?