答:
Assuming that your sample tables has data like below

Table1:

```<code>a   b   lon lat
---------------
22  33  11  22
</code>```

Table2:

```<code>c   d   lon lat
---------------
1   2   44  45
</code>```

Table3

```<code>e       f       lon lat
-----------------------
NULL    NULL    100 101
</code>```

Table4

```<code>g       h       lon lat
-----------------------
NULL    NULL    200 201
</code>```

and you want to merge the records, you can use union all.

```<code>select a,b,NULL as c, NULL as d,NULL as e, NULL as f, NULL as g, NULL as h, lon,lat
from table1
union all
select NULL, NULL,c,d,NULL as e, NULL as f, NULL as g, NULL as h, lon,lat
from table2
union all
select NULL, NULL,NULL,NULL,e,f, NULL as g, NULL as h, lon,lat
from table3
union all
select NULL, NULL,NULL,NULL,NULL,NULL,g,h, lon,lat
from table4
</code>```

Result:

```<code>+------+------+------+------+------+------+------+------+-----+-----+
|  a   |  b   |  c   |  d   |  e   |  f   |  g   |  h   | lon | lat |
+------+------+------+------+------+------+------+------+-----+-----+
| 22   | 33   | NULL | NULL | NULL | NULL | NULL | NULL |  11 |  22 |
| NULL | NULL | 1    | 2    | NULL | NULL | NULL | NULL |  44 |  45 |
| NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 100 | 101 |
| NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 200 | 201 |
+------+------+------+------+------+------+------+------+-----+-----+
</code>```

DEMO

Title: SQLite: full outer join with four tables

Body:
EDIT: An extension to this question can be found here

I want to join four different tables with SQLite which have just two columns in common. Please take a look at following example

+--------+---+-----+-----+
| table1 |   |     |     |
+--------+---+-----+-----+
| a      | b | lon | lat |
+--------+---+-----+-----+
| 1      | 2 | 111 | 222 |
+--------+---+-----+-----+
+--------+---+-----+-----+
| table2 |   |     |     |
+--------+---+-----+-----+
| c      | d | lon | lat |
+--------+---+-----+-----+
| 3      | 4 | 333 | 444 |
+--------+---+-----+-----+
+--------+---+-----+-----+
| table3 |   |     |     |
+--------+---+-----+-----+
| e      | f | lon | lat |
+--------+---+-----+-----+
| 5      | 6 | 555 | 666 |
+--------+---+-----+-----+
+--------+---+-----+-----+
| table4 |   |     |     |
+--------+---+-----+-----+
| g      | h | lon | lat |
+--------+---+-----+-----+
| 7      | 8 | 777 | 888 |
+--------+---+-----+-----+

The tables are not connected by any foreign key. Also, the lon/lat values are different for every row. An optimal output would be:

+------+------+------+------+------+------+------+------+-----+-----+
|  a   |  b   |  c   |  d   |  e   |  f   |  g   |  h   | lon | lat |
+------+------+------+------+------+------+------+------+-----+-----+
| None | None | 3    | 4    | None | None | None | NOne | 333 | 444 |
| 1    | 2    | None | None | None | None | None | None | 111 | 222 |
| None | None | None | None | 5    | 6    | None | None | 555 | 666 |
| None | None | None | None | None | None | 7    | 8    | 777 | 888 |
+------+------+------+------+------+------+------+------+-----+-----+

 Again, this is my end goal - lat/lon values are not interconnected between the tables:

 a | b | c | .. | lat | lon | instead of

 a | b | c | .. | table1.lat | table2.lat | ...

 Appreciate your help!

 My current code

-- First two tables
CREATE VIEW ab AS
SELECT * FROM table1 LEFT JOIN table2 ON ???
UNION ALL
SELECT * FROM table2 LEFT JOIN table1 ON ?? WHERE ?? IS NULL

-- 3rd and 4th table
CREATE VIEW cd AS
SELECT * FROM table3 LEFT JOIN table4 ON ??
UNION ALL
SELECT * FROM table4 LEFT JOIN table3 ON ?? WHERE ?? IS NULL

-- -- JOIN
SELECT * FROM cd LEFT JOIN ab ON ??
UNION ALL
SELECT * FROM cd LEFT JOIN ab ON ?? WHERE ?? IS NULL

Body:
Assuming that your sample tables has data like below

Table1:

a   b   lon lat
---------------
22  33  11  22

Table2:

c   d   lon lat
---------------
1   2   44  45

Table3

e       f       lon lat
-----------------------
NULL    NULL    100 101

Table4

g       h       lon lat
-----------------------
NULL    NULL    200 201

and you want to merge the records, you can use union all.

select a,b,NULL as c, NULL as d,NULL as e, NULL as f, NULL as g, NULL as h, lon,lat
from table1
union all
select NULL, NULL,c,d,NULL as e, NULL as f, NULL as g, NULL as h, lon,lat
from table2
union all
select NULL, NULL,NULL,NULL,e,f, NULL as g, NULL as h, lon,lat
from table3
union all
select NULL, NULL,NULL,NULL,NULL,NULL,g,h, lon,lat
from table4

Result:

+------+------+------+------+------+------+------+------+-----+-----+
|  a   |  b   |  c   |  d   |  e   |  f   |  g   |  h   | lon | lat |
+------+------+------+------+------+------+------+------+-----+-----+
| 22   | 33   | NULL | NULL | NULL | NULL | NULL | NULL |  11 |  22 |
| NULL | NULL | 1    | 2    | NULL | NULL | NULL | NULL |  44 |  45 |
| NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 100 | 101 |
| NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 200 | 201 |
+------+------+------+------+------+------+------+------+-----+-----+

DEMO


来源: stackexchange

问:
Replace Floating point numbers in a list with '0'
So my programming assignment wants me to take a user inputted list of numbers, ints and floating, and then order them in descending order and replace any of the floating with "0". I have got the reorder part done but the replace is getting me lost.

Reading Numbers
Write a program that shall ask the user to enter several integer numbers on
the same line, separated by vertical bars surrounded by zero or more spaces
(e.g., “|” or “ |” or “| ” or “ | ”). The program then shall display the entered
numbers in the descending sorted order (from the largest to the smallest),
all on the same line, separated by vertical bars and spaces (“ | ”). If
any entry on the command line is not an integer number, the program shall
replace it with a 0. Use only “for” loop(s) or list comprehensions. Use exception
handling.

```<code># takes input and split them to get a list
numbers = input("Please enter numbers separated by vertical bars '|' :
").split("|")
# replace the floating numbers with "0"
for number in numbers:
    print(type(number))
    if number.isdigit() == False:
        numbers.replace(number,'0')
# takes the list and reverse order sort and prints it with a "|" in between
numbers.sort(key = float , reverse = True)
[print(number,end = ' | ') for number in numbers]
</code>```

答:
One change I made was switching all of the for number in numbers to for i in range(len(numbers)).  This allows you to access the actual variable by index, while for number in numbers just gets the value.

Here is my solution.  I tried to add comments to explain why I did what I did, but if you have any questions, leave a comment:

```<code># takes input and split them to get a list
numbers = input("Please enter numbers separated by vertical bars '|'\n").split(
    "|")

# strip any extra spaces off the numbers
for i in range(len(numbers)):
    numbers[i] = numbers[i].strip(" ")

# replace the floating numbers and strings with "0"
for i in range(len(numbers)):
    try:
        # check if the number is an int and changes it if it is
        numbers[i] = int(numbers[i])
    except:
        # set the item to 0 if it can't be converted to a number
        numbers[i] = 0

# takes the list and reverse order sort and prints it with a "|" in between
numbers.sort(reverse = True)

# changes the numbers back into strings
numbers = [str(numbers[i]) for i in range(len(numbers))]
# makes sure that there are more than one numbers before trying
# to join the list back together
if len(numbers) > 1:
    print(" | ".join(numbers))
else:
    print(numbers[0])
</code>```

ContentLicense: CC BY-SA 3.0

Body:
So my programming assignment wants me to take a user inputted list of numbers, ints and floating, and then order them in descending order and replace any of the floating with "0". I have got the reorder part done but the replace is getting me lost.

Reading Numbers
Write a program that shall ask the user to enter several integer numbers on
the same line, separated by vertical bars surrounded by zero or more spaces
(e.g., “|” or “ |” or “| ” or “ | ”). The program then shall display the entered
numbers in the descending sorted order (from the largest to the smallest),
all on the same line, separated by vertical bars and spaces (“ | ”). If
any entry on the command line is not an integer number, the program shall
replace it with a 0. Use only “for” loop(s) or list comprehensions. Use exception
handling.

# takes input and split them to get a list
numbers = input("Please enter numbers separated by vertical bars '|' :
").split("|")
# replace the floating numbers with "0"
for number in numbers:
    print(type(number))
    if number.isdigit() == False:
        numbers.replace(number,'0')
# takes the list and reverse order sort and prints it with a "|" in between
numbers.sort(key = float , reverse = True)
[print(number,end = ' | ') for number in numbers]

Body:
One change I made was switching all of the for number in numbers to for i in range(len(numbers)).  This allows you to access the actual variable by index, while for number in numbers just gets the value.

Here is my solution.  I tried to add comments to explain why I did what I did, but if you have any questions, leave a comment:

# takes input and split them to get a list
numbers = input("Please enter numbers separated by vertical bars '|'\n").split(
    "|")

# strip any extra spaces off the numbers
for i in range(len(numbers)):
    numbers[i] = numbers[i].strip(" ")

# replace the floating numbers and strings with "0"
for i in range(len(numbers)):
    try:
        # check if the number is an int and changes it if it is
        numbers[i] = int(numbers[i])
    except:
        # set the item to 0 if it can't be converted to a number
        numbers[i] = 0

# takes the list and reverse order sort and prints it with a "|" in between
numbers.sort(reverse = True)

# changes the numbers back into strings
numbers = [str(numbers[i]) for i in range(len(numbers))]
# makes sure that there are more than one numbers before trying
# to join the list back together
if len(numbers) > 1:
    print(" | ".join(numbers))
else:
    print(numbers[0])


问:
Duplicating docker container for debugging
I have a running docker container. I have done some useful works in the running docker container. I have done these works not part of dockerfile, i have done it inside the container.[Eg: I have installed ping inside the container, not from docker file]

Now, i got stuck at a place. I am not sure if i debug in the same container, i may loose the thing that i have done so far inside that container.

So i would like to create a duplicate copy of it with all the things available in that running container[like i don't want to build a container from image and repeat all the suucessful steps achieved in the running container and then start my debuggging. I don't want to re-install ping in my second container].

Totally, How can i duplicate a container? If not what are all the possibilities?

答:
currently broken again

below only works with version from around Dec 20 '17.  I have not yet looked into this after Jan 18.

docker commit is fine for saving file changes into a new image, but it will not preserve changes in memory, open processes etc. Contrary to the popular opinion, the latter is feasible with docker checkpoint. Documentation and example.

Note: right now, the --checkpoint-dir option is broken: issue, pull. That is why a workaround like checkpoint_dir (see code) is necessary here. This answer should probably be updated in a few weeks.

It is not possible to checkpoint a TTY. This might change soon. However, you can attach a new TTY after the restoring process using exec.

You need to have criu installed. After, first,

echo "{\"experimental\": true}" >> /etc/docker/daemon.json
systemctl restart docker
```
<p>, then</p>
<pre class="lang-shell prettyprint-override"><code>#!/bin/bash

# tty (-t) not supported
docker run -i -d --name sleeper\
     busybox sh -c 'sleep 10000'

# Makes a snapshot and stops the container (except if --leave-running is active). --checkpoint-dir is broken.
docker checkpoint create sleeper cp
# sleeper container exited

# Create the clone
docker create -i --rm --name clone\
    busybox

# Start the clone
checkpoint_dir="/var/lib/docker/containers/$(docker ps -aq --no-trunc -f name=sleeper)/checkpoints"
docker start --checkpoint-dir=$checkpoint_dir --checkpoint=cp clone

# Attach new TTY
docker exec -it clone sh
</code>```

Now in the tty, type ps -e and you will see the process which started in the sleeper container and now continues in the clone.

checkpoint makes a complete blueprint of the container to hard drive, exchangable between machines. This feature uses criu and is experimental. Criu cannot create a blueprint of X11 applications natively.

pause on the other hand only freezes the container internally. There is nothing you can do with a paused container other than unpause it.

Body:
currently broken again

below only works with version from around Dec 20 '17.  I have not yet looked into this after Jan 18.

docker commit is fine for saving file changes into a new image, but it will not preserve changes in memory, open processes etc. Contrary to the popular opinion, the latter is feasible with docker checkpoint. Documentation and example.

Note: right now, the --checkpoint-dir option is broken: issue, pull. That is why a workaround like checkpoint_dir (see code) is necessary here. This answer should probably be updated in a few weeks.

It is not possible to checkpoint a TTY. This might change soon. However, you can attach a new TTY after the restoring process using exec.

You need to have criu installed. After, first,

echo "{\"experimental\": true}" >> /etc/docker/daemon.json
systemctl restart docker

, then

#!/bin/bash

# tty (-t) not supported
docker run -i -d --name sleeper\
     busybox sh -c 'sleep 10000'

# Makes a snapshot and stops the container (except if --leave-running is active). --checkpoint-dir is broken.
docker checkpoint create sleeper cp
# sleeper container exited

# Create the clone
docker create -i --rm --name clone\
    busybox

# Start the clone
checkpoint_dir="/var/lib/docker/containers/$(docker ps -aq --no-trunc -f name=sleeper)/checkpoints"
docker start --checkpoint-dir=$checkpoint_dir --checkpoint=cp clone

# Attach new TTY
docker exec -it clone sh

Now in the tty, type ps -e and you will see the process which started in the sleeper container and now continues in the clone.

checkpoint makes a complete blueprint of the container to hard drive, exchangable between machines. This feature uses criu and is experimental. Criu cannot create a blueprint of X11 applications natively.

pause on the other hand only freezes the container internally. There is nothing you can do with a paused container other than unpause it.

ContentLicense: CC BY-SA 4.0


问:
How to access entries of a list using a numpy array without using a for loop
Given a list L = [0,1,2,3,4,5,6,7,8,9]. What's the best way to access/extract elements where their indices are given by a numpy array? Let nArr=np.array([0,-1,2,6]).

The resulting output should be another list P = [0,9,2,6].

It is clear that when the elements are uniform in shape, we can simply cast it into another numpy array, but what if it isn't? For example, M = [np.random.rand(5,5), np.random.rand(1)].

答:
Stock Python has a convenience class, itemgetter:

```<code>In [27]: from operator import itemgetter
In [28]: L = [0,1,2,3,4,5,6,7,8,9]
In [29]: nArr=np.array([0,-1,2,6])
In [30]: itemgetter(*nArr)
Out[30]: operator.itemgetter(0, -1, 2, 6)
In [31]: itemgetter(*nArr)(L)
Out[31]: (0, 9, 2, 6)
</code>```

Internally it does something equivalent to the list comprehension:

```<code>In [33]: [L[x] for x in nArr]
Out[33]: [0, 9, 2, 6]
</code>```

So it isn't a fast operation like the array indexing (look at its code).  It may be most useful as a way of doing sort or other operations where you'd like to define a key function that fetches multiple values.

https://stackoverflow.com/a/47585659/901925

Make a random nested list:

```<code>In [54]: arr = np.random.randint(0,10,(4,4))
In [55]: L = arr.tolist()
In [56]: L
Out[56]: [[9, 5, 8, 4], [1, 5, 5, 8], [8, 0, 5, 8], [1, 4, 5, 1]]
</code>```

lexical sort by 'column':

```<code>In [57]: sorted(L)
Out[57]: [[1, 4, 5, 1], [1, 5, 5, 8], [8, 0, 5, 8], [9, 5, 8, 4]]
</code>```

lexical sort by 'columns' 2 and 1 (in that order):

```<code>In [59]: sorted(L, key=itemgetter(2,1))
Out[59]: [[8, 0, 5, 8], [1, 4, 5, 1], [1, 5, 5, 8], [9, 5, 8, 4]]
</code>```

Body:
Stock Python has a convenience class, itemgetter:

In [27]: from operator import itemgetter
In [28]: L = [0,1,2,3,4,5,6,7,8,9]
In [29]: nArr=np.array([0,-1,2,6])
In [30]: itemgetter(*nArr)
Out[30]: operator.itemgetter(0, -1, 2, 6)
In [31]: itemgetter(*nArr)(L)
Out[31]: (0, 9, 2, 6)

Internally it does something equivalent to the list comprehension:

In [33]: [L[x] for x in nArr]
Out[33]: [0, 9, 2, 6]

So it isn't a fast operation like the array indexing (look at its code).  It may be most useful as a way of doing sort or other operations where you'd like to define a key function that fetches multiple values.

https://stackoverflow.com/a/47585659/901925

Make a random nested list:

In [54]: arr = np.random.randint(0,10,(4,4))
In [55]: L = arr.tolist()
In [56]: L
Out[56]: [[9, 5, 8, 4], [1, 5, 5, 8], [8, 0, 5, 8], [1, 4, 5, 1]]

lexical sort by 'column':

In [57]: sorted(L)
Out[57]: [[1, 4, 5, 1], [1, 5, 5, 8], [8, 0, 5, 8], [9, 5, 8, 4]]

lexical sort by 'columns' 2 and 1 (in that order):

In [59]: sorted(L, key=itemgetter(2,1))
Out[59]: [[8, 0, 5, 8], [1, 4, 5, 1], [1, 5, 5, 8], [9, 5, 8, 4]]


问:
Java Infinite While Loop
I am accepting multiple lines of info (strings until I parse them later). For example:

```<code>1 5 0
2 9 6
2 9 1
</code>```

I wrote this code to separate the lines because I'm going to have to manipulate each line in a way.

```<code>Scanner scan = new Scanner(System.in);
System.out.println("Enter input: ");
ArrayList<String> lines = new ArrayList<String>();

while(scan.hasNextLine()) {
    lines.add(scan.nextLine());
}

System.out.println(lines.get(0));
</code>```

And I tested this, it does indeed seperate each line of my input and add it into my arraylist, however the part inside the while loop that says scan.nextLine() is checking for more input, causing an infinite loop.
How do i fix this?

答: Scanner is always assumed to have more lines because you can always input more into the console. My suggestion would be to detect for an empty line within your while loop or have a line which has a default character, for example -1, as the first character to let your program know when to end the program. Alternatively, you could use file input which can actually detect if there are more lines.</p>

Title: Java Infinite While Loop

Body:
I am accepting multiple lines of info (strings until I parse them later). For example:

1 5 0
2 9 6
2 9 1

I wrote this code to separate the lines because I'm going to have to manipulate each line in a way.

Scanner scan = new Scanner(System.in);
System.out.println("Enter input: ");
ArrayList<String> lines = new ArrayList<String>();

while(scan.hasNextLine()) {
    lines.add(scan.nextLine());
}

System.out.println(lines.get(0));

And I tested this, it does indeed seperate each line of my input and add it into my arraylist, however the part inside the while loop that says scan.nextLine() is checking for more input, causing an infinite loop.
How do i fix this?


问:
WCF: Changing ClientCredentials produces "Manual addressing is enabled on this factory, so all messages sent must be pre-addressed."
can anyone help, i am trying to call a rest service via the channel factory but sending along my credentials... The rest service uses Windows authentication.

But with the following code i get "Manual addressing is enabled on this factory, so all messages sent must be pre-addressed."  error when using GetMessage

I know my service works as if i remove Windows authentication it works!  BUt with windows authentication on and not changing clientCredentials i get BAD REQUEST whioch i think is normal... so i need to send along my client credentials

I am a little lost.

```<code>   ChannelFactory<IService> cf = new ChannelFactory<IService>(new WebHttpBinding(), "http://localhost:8000");

  var defaultCredentials = cf.Endpoint.Behaviors.Find<ClientCredentials>();
  cf.Endpoint.Behaviors.Remove(defaultCredentials);

  // step two - instantiate your credentials
  ClientCredentials loginCredentials = new ClientCredentials();
  loginCredentials.UserName.UserName = "Test";
  loginCredentials.UserName.Password = "test";

  // step three - set that as new endpoint behavior on factory
  cf.Endpoint.Behaviors.Add(loginCredentials); //add required ones

        IService channel = cf.CreateChannel();

        Console.WriteLine(channel.GetMessage("Dhananjay Get"));

        Console.WriteLine(channel.PostMessage("Dhananjay Post"));
</code>```

答:
You need to add a webHttp behavior, and wire that behavior up to your endpoint.  The end result will look something like this:

```<code><system.serviceModel>
  <services>
    <service ...>
       <endpoint behaviorConfiguration="webHttpBehavior" ...>
       </endpoint>
    </service>
  </services>
  <behaviors>
    <endpointBehaviors>
    <behavior name="webHttpBehavior">
      <webHttp/>
    </behavior>
    </endpointBehaviors>
  </behaviors>
  ...
 </system.serviceModel>
</code>```

If this doesn't help, please post your web.config.

ContentLicense: CC BY-SA 2.5

Body:
can anyone help, i am trying to call a rest service via the channel factory but sending along my credentials... The rest service uses Windows authentication.

But with the following code i get "Manual addressing is enabled on this factory, so all messages sent must be pre-addressed."  error when using GetMessage

I know my service works as if i remove Windows authentication it works!  BUt with windows authentication on and not changing clientCredentials i get BAD REQUEST whioch i think is normal... so i need to send along my client credentials

I am a little lost.

   ChannelFactory<IService> cf = new ChannelFactory<IService>(new WebHttpBinding(), "http://localhost:8000");

  var defaultCredentials = cf.Endpoint.Behaviors.Find<ClientCredentials>();
  cf.Endpoint.Behaviors.Remove(defaultCredentials);

  // step two - instantiate your credentials
  ClientCredentials loginCredentials = new ClientCredentials();
  loginCredentials.UserName.UserName = "Test";
  loginCredentials.UserName.Password = "test";

  // step three - set that as new endpoint behavior on factory
  cf.Endpoint.Behaviors.Add(loginCredentials); //add required ones

        IService channel = cf.CreateChannel();

        Console.WriteLine(channel.GetMessage("Dhananjay Get"));

        Console.WriteLine(channel.PostMessage("Dhananjay Post"));

Body:
You need to add a webHttp behavior, and wire that behavior up to your endpoint.  The end result will look something like this:

<system.serviceModel>
  <services>
    <service ...>
       <endpoint behaviorConfiguration="webHttpBehavior" ...>
       </endpoint>
    </service>
  </services>
  <behaviors>
    <endpointBehaviors>
    <behavior name="webHttpBehavior">
      <webHttp/>
    </behavior>
    </endpointBehaviors>
  </behaviors>
  ...
 </system.serviceModel>

If this doesn't help, please post your web.config.


问:
How to keep a div on the right side of the page in CSS
I'm building a website, and I'm trying to get a div element to stick to the right side of the page.

However, when my other divs, that contain blog post data/images scroll over to the next page, the div gets entered down.

How do I prevent the right side column from being entered down, while still allowing my blog post entries to scroll over?

Here is my code, what's relevant anyways. I'm sorry if this is a beginner question (it really is). I appreciate all the help I can get.
Thanks.

```<code>.column {
    float:left;
}

.column.main {
    width:70%;
    min-height:1px;
}

.column.side {
    width:20%;
    min-height:1px;

}

.column.left {
    width:10%;
    background-color:012C40;
    height:85%;
    min-width:1px;
}

.column.right {
    width:10%;
    background-color:012C40;
    height:85%;
    float:right;
    min-height:1px;
}

.postAd {
    width:19%;
    height:32%;
    float:left;
    background-color:DAEBF2;
    text-align:center;
    display:inline-block;
    margin:.5%;
    overflow: auto;
}

.postAd img {
    width:80%;
    height:80%;*/
}

<div class="column left">
</div>
<!--middle content-->

<div class="postAd">

    <img src="images/Sunset.JPG" alt="sunset">
    <p>Text here!</p>
</div>

<div class="postAd">

    <img src="images/Sunset.JPG" alt="sunset">
    <p>Text here!</p>
</div>

<div class="postAd">

    <img src="images/Sunset.JPG" alt="sunset">
    <p>Text here!</p>
</div>

<div class="postAd">

    <img src="images/Sunset.JPG" alt="sunset">
    <p>Text here!</p>
</div>

<div class="postAd">
</div>

<!--right side content-->

<div class="column right">
</div>
</code>```

First of all, thanks for all of the proposed solutions! However, I've tried each one, and I'm running into problems. I have a navigation bar on top of my website, and each one overwrites that bar. When I try to make adaptations, I get the same problem as before. How do I implement these without completely destroying the layout of my website?

Again, huge thanks to everyone that responded.

答:
There are many different methods. One of the simpler ones is to use:

display:table-cell

I added a middle column for the example.

.column {
    display:table-cell;
    vertical-align:top;
}

.column.left {
    width:10%;
    background-color:#012C40;
    color:#ffffff;
}
.column.right {
    width:10%;
    background-color:#012C40;
    color:#ffffff;
}

.postAd {
    min-width:23.5%;
    height:32%;
    background-color:#DAEBF2;
    text-align:center;
    display:inline-block;
    margin:0.5%;
    overflow: auto;
}

.postAd img {
    width:80%;
    height:80%;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="column left">
[column left]
</div><!-- .column.left -->

<div class="column middle">
<div class="postAd">
    [image]
    <p>Text here!</p>
</div>
<div class="postAd">
    [image]
    <p>Text here!</p>
</div>
<div class="postAd">
    [image]
    <p>Text here!</p>
</div>
<div class="postAd">
    [image]
    <p>Text here!</p>
</div>
<div class="postAd">
    [image]
    <p>Text here!</p>
</div>
</div><!-- .column.middle -->

<div class="column right">
[column right]
</div><!-- .column.right --></code>```

Body:
I'm building a website, and I'm trying to get a div element to stick to the right side of the page.

However, when my other divs, that contain blog post data/images scroll over to the next page, the div gets entered down.

How do I prevent the right side column from being entered down, while still allowing my blog post entries to scroll over?

Here is my code, what's relevant anyways. I'm sorry if this is a beginner question (it really is). I appreciate all the help I can get.
Thanks.

.column {
    float:left;
}

.column.main {
    width:70%;
    min-height:1px;
}

.column.side {
    width:20%;
    min-height:1px;

}

.column.left {
    width:10%;
    background-color:012C40;
    height:85%;
    min-width:1px;
}

.column.right {
    width:10%;
    background-color:012C40;
    height:85%;
    float:right;
    min-height:1px;
}

.postAd {
    width:19%;
    height:32%;
    float:left;
    background-color:DAEBF2;
    text-align:center;
    display:inline-block;
    margin:.5%;
    overflow: auto;
}

.postAd img {
    width:80%;
    height:80%;*/
}

Text here!

Text here!

Text here!

Text here!

First of all, thanks for all of the proposed solutions! However, I've tried each one, and I'm running into problems. I have a navigation bar on top of my website, and each one overwrites that bar. When I try to make adaptations, I get the same problem as before. How do I implement these without completely destroying the layout of my website?

Again, huge thanks to everyone that responded.

Body:
There are many different methods. One of the simpler ones is to use:

display:table-cell

I added a middle column for the example.

.column {
    display:table-cell;
    vertical-align:top;
}

.column.left {
    width:10%;
    background-color:#012C40;
    color:#ffffff;
}
.column.right {
    width:10%;
    background-color:#012C40;
    color:#ffffff;
}

.postAd {
    min-width:23.5%;
    height:32%;
    background-color:#DAEBF2;
    text-align:center;
    display:inline-block;
    margin:0.5%;
    overflow: auto;
}

.postAd img {
    width:80%;
    height:80%;
}

<div class="column left">
[column left]
</div><!-- .column.left -->

<div class="column middle">
<div class="postAd">
    [image]
    <p>Text here!</p>
</div>
<div class="postAd">
    [image]
    <p>Text here!</p>
</div>
<div class="postAd">
    [image]
    <p>Text here!</p>
</div>
<div class="postAd">
    [image]
    <p>Text here!</p>
</div>
<div class="postAd">
    [image]
    <p>Text here!</p>
</div>
</div><!-- .column.middle -->

<div class="column right">
[column right]
</div><!-- .column.right -->


问:
How can I read certain elements from a text file?
I have a text file that has multiple sets of book information (title, author, etc). I need to be able to use a loop to read from the file and assign each piece of info to a corresponding string. I have it working to where I goes through the entire file, it's just messing up while going through the file.

```<code>Book readOne(ifstream &fin) {
string titleOne;
getline(fin, titleOne, ',');
string firstOne;
getline(fin, firstOne, ',');
string lastOne;
getline(fin, lastOne, ',');
string formatOne;
getline(fin, formatOne, ',');
string pubDateOne;
getline(fin, pubDateOne, ',');
string priceOne;
getline(fin, priceOne);
</code>```

Here is the text file:

```<code>Gone With the Wind, Margaret Mitchell, Hardcover, 1936, 17.49
The Adventures of Sherlock Holmes, Arthur Doyle, Paperback, 1892, 6.85
The Illustrated A Brief History of Time, Stephen Hawking, Hardcover, 1996, 9.59
Frankenstein, Mary Shelley, Paperback, 1818, 7.99
Command Authority, Tom Clancy, Paperback, 2013, 15.99
Origin, Dan Brown, Ebook, 2017, 14.99
The Lost Order, Steve Berry, Audiobook, 2017, 5.95
The Hunt for Red October, Tom Clacy, Audiobook, 1984, 7.00
Patriot Games, Tom Clancy, Audiobook, 1987, 22.50
The 14th Colony, Steve Berry, Paperback, 2016, 9.99
The Bishop's Pawn, Steve Berry, Ebook, 2018, 14.99
Pride and Prejudice, Jane Austen, Ebook, 1813, 8.99
Sense and Sensibility, Jane Austen, Hardcover, 1811, 19.99
Wuthering Heights, Emily Bronte, Paperback, 1847, 6.99
Jane Eyre, Charlotte Bronte, Hardcover, 1847, 10.95
Anna Karenina, Leo Tolstoy, Paperback, 1877, 5.99
Sahara, Clive Cussler, Ebook, 1992, 5.99
The Notebook, Nicholas Sparks, Hardcover, 1996, 12.59
A Walk to Remember, Nicholas Sparks, Ebook, 1999, 7.99
See Me, Nicholas Sparks, Ebook, 2015, 7.99
The Last Song, Nicholas Sparks, Paperback, 2009, 5.99
The Wedding, Nicholas Sparks, Ebook, 2003, 7.99
</code>```

My thinking was that it would read until a comma, assign that piece of info to the string, then continue. Instead, it outputs as if it didn't see certain commas.

```<code>Gone With the Wind by  Margaret Mitchell  Hardcover on  1936. Published on  17.49
The Adventures of Sherlock Holmes. It costs $0
The Illustrated A Brief History of Time by  Stephen Hawking  Hardcover on  1996. Published on  9.59
Frankenstein. It costs $0
Command Authority by  Tom Clancy  Paperback on  2013. Published on  15.99
Origin. It costs $0
The Lost Order by  Steve Berry  Audiobook on  2017. Published on  5.95
The Hunt for Red October. It costs $0
Patriot Games by  Tom Clancy  Audiobook on  1987. Published on  22.50
The 14th Colony. It costs $0
The Bishop's Pawn by  Steve Berry  Ebook on  2018. Published on  14.99
Pride and Prejudice. It costs $0
Sense and Sensibility by  Jane Austen  Hardcover on  1811. Published on  19.99
Wuthering Heights. It costs $0
Jane Eyre by  Charlotte Bronte  Hardcover on  1847. Published on  10.95
Anna Karenina. It costs $0
Sahara by  Clive Cussler  Ebook on  1992. Published on  5.99
The Notebook. It costs $0
A Walk to Remember by  Nicholas Sparks  Ebook on  1999. Published on  7.99
See Me. It costs $0
The Last Song by  Nicholas Sparks  Paperback on  2009. Published on  5.99
The Wedding. It costs $0
</code>```

答: This is nothing but a csv (comma separated value) file. And there are ample code samples to read it. Refer this sample.</p>

Body:
I have a text file that has multiple sets of book information (title, author, etc). I need to be able to use a loop to read from the file and assign each piece of info to a corresponding string. I have it working to where I goes through the entire file, it's just messing up while going through the file.

Book readOne(ifstream &fin) {
string titleOne;
getline(fin, titleOne, ',');
string firstOne;
getline(fin, firstOne, ',');
string lastOne;
getline(fin, lastOne, ',');
string formatOne;
getline(fin, formatOne, ',');
string pubDateOne;
getline(fin, pubDateOne, ',');
string priceOne;
getline(fin, priceOne);

Here is the text file:

Gone With the Wind, Margaret Mitchell, Hardcover, 1936, 17.49
The Adventures of Sherlock Holmes, Arthur Doyle, Paperback, 1892, 6.85
The Illustrated A Brief History of Time, Stephen Hawking, Hardcover, 1996, 9.59
Frankenstein, Mary Shelley, Paperback, 1818, 7.99
Command Authority, Tom Clancy, Paperback, 2013, 15.99
Origin, Dan Brown, Ebook, 2017, 14.99
The Lost Order, Steve Berry, Audiobook, 2017, 5.95
The Hunt for Red October, Tom Clacy, Audiobook, 1984, 7.00
Patriot Games, Tom Clancy, Audiobook, 1987, 22.50
The 14th Colony, Steve Berry, Paperback, 2016, 9.99
The Bishop's Pawn, Steve Berry, Ebook, 2018, 14.99
Pride and Prejudice, Jane Austen, Ebook, 1813, 8.99
Sense and Sensibility, Jane Austen, Hardcover, 1811, 19.99
Wuthering Heights, Emily Bronte, Paperback, 1847, 6.99
Jane Eyre, Charlotte Bronte, Hardcover, 1847, 10.95
Anna Karenina, Leo Tolstoy, Paperback, 1877, 5.99
Sahara, Clive Cussler, Ebook, 1992, 5.99
The Notebook, Nicholas Sparks, Hardcover, 1996, 12.59
A Walk to Remember, Nicholas Sparks, Ebook, 1999, 7.99
See Me, Nicholas Sparks, Ebook, 2015, 7.99
The Last Song, Nicholas Sparks, Paperback, 2009, 5.99
The Wedding, Nicholas Sparks, Ebook, 2003, 7.99

My thinking was that it would read until a comma, assign that piece of info to the string, then continue. Instead, it outputs as if it didn't see certain commas.

Gone With the Wind by  Margaret Mitchell  Hardcover on  1936. Published on  17.49
The Adventures of Sherlock Holmes. It costs $0
The Illustrated A Brief History of Time by  Stephen Hawking  Hardcover on  1996. Published on  9.59
Frankenstein. It costs $0
Command Authority by  Tom Clancy  Paperback on  2013. Published on  15.99
Origin. It costs $0
The Lost Order by  Steve Berry  Audiobook on  2017. Published on  5.95
The Hunt for Red October. It costs $0
Patriot Games by  Tom Clancy  Audiobook on  1987. Published on  22.50
The 14th Colony. It costs $0
The Bishop's Pawn by  Steve Berry  Ebook on  2018. Published on  14.99
Pride and Prejudice. It costs $0
Sense and Sensibility by  Jane Austen  Hardcover on  1811. Published on  19.99
Wuthering Heights. It costs $0
Jane Eyre by  Charlotte Bronte  Hardcover on  1847. Published on  10.95
Anna Karenina. It costs $0
Sahara by  Clive Cussler  Ebook on  1992. Published on  5.99
The Notebook. It costs $0
A Walk to Remember by  Nicholas Sparks  Ebook on  1999. Published on  7.99
See Me. It costs $0
The Last Song by  Nicholas Sparks  Paperback on  2009. Published on  5.99
The Wedding. It costs $0


问:
Sort an array of names except for one item
Considering that I have an object like the following where it's possible to have many names and that 'The others' can appear at any index, how can I sort the array having 'The others' always as the first element and the rest of the names sorted in alphabetical order?

```<code>var friends = [
{ id: 1, name: 'Paul' },
{ id: 2, name: 'Mary' },
{ id: 3, name: 'The others' },
{ id: 4, name: 'John' }
];
</code>```

For the sample array above, the desired result would be:

```<code>[
   { id: 3, name: 'The others' },
   { id: 4, name: 'John' },
   { id: 2, name: 'Mary' },
   { id: 1, name: 'Paul' }
]
</code>```

答:
There are some great ideas here but what I found to be the simpler solutions are the two bellow:

Using sort:

```<code>friends.sort((a, b) => a.name !== b.name ? a.name < b.name ? -1 : 1 : 0).sort((a, b) => +(!b.name.localeCompare("The others")));
</code>```

Using map and sort:

```<code>friends.map(o => o.name).sort((a,b) => a=="The others" ? -1 : b=="The others" ? 1 : a > b);
</code>```

Body:
Considering that I have an object like the following where it's possible to have many names and that 'The others' can appear at any index, how can I sort the array having 'The others' always as the first element and the rest of the names sorted in alphabetical order?

var friends = [
{ id: 1, name: 'Paul' },
{ id: 2, name: 'Mary' },
{ id: 3, name: 'The others' },
{ id: 4, name: 'John' }
];

For the sample array above, the desired result would be:

[
   { id: 3, name: 'The others' },
   { id: 4, name: 'John' },
   { id: 2, name: 'Mary' },
   { id: 1, name: 'Paul' }
]

Body:
There are some great ideas here but what I found to be the simpler solutions are the two bellow:

Using sort:

friends.sort((a, b) => a.name !== b.name ? a.name < b.name ? -1 : 1 : 0).sort((a, b) => +(!b.name.localeCompare("The others")));

Using map and sort:

friends.map(o => o.name).sort((a,b) => a=="The others" ? -1 : b=="The others" ? 1 : a > b);


答:
Sort like this:

var friends = [
   { id: 1, name: 'Paul' },
   { id: 2, name: 'Mary' },
   { id: 3, name: 'The others' },
   { id: 4, name: 'John' }
];

friends.sort((a, b) => {
     if (a.name == "The others") {
         return -1; // a comes first
     } else if (b.name == "The others") {
         return 1;
     } else {
         return (a.name < b.name ? -1 : 1);
     }
 });

console.log(friends);```

Title: Sort an array of names except for one item


问:
Is there any way we can also take the screenshot of entire page including the page which is there in down (scrollbar) using wedriver
I need to capture the full page of IE browser. I am using web driver. Pls help me.

below code is used to capture the present window only.

```<code>File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
// Now you can do whatever you need to do with it, for example copy somewhere
FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png"));
</code>```

答:
```<code>import java.io.File;
import javax.imageio.ImageIO;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import ru.yandex.qatools.ashot.AShot;
import ru.yandex.qatools.ashot.Screenshot;
import ru.yandex.qatools.ashot.shooting.ShootingStrategies;

public class TakeScreenshotWithScroll {
    static WebDriver driver;
    public static void main(String args[]) throws Exception{
        String key = "webdriver.gecko.driver";
        String value = "driver/geckodriver.exe";
        driver = new FirefoxDriver();
        System.setProperty(key, value);
        driver.get("ENTER THE URL HERE");
        Thread.sleep(2000);
        Screenshot fpScreenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(1000)).takeScreenshot(driver);
        ImageIO.write(fpScreenshot.getImage(),"PNG",new File("D:///FullPageScreenshot.png"));
    }
}
</code>```

Here is the download link of aShot Jar file

Body:
I need to capture the full page of IE browser. I am using web driver. Pls help me.

below code is used to capture the present window only.

File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
// Now you can do whatever you need to do with it, for example copy somewhere
FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png"));

Body:
import java.io.File;
import javax.imageio.ImageIO;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import ru.yandex.qatools.ashot.AShot;
import ru.yandex.qatools.ashot.Screenshot;
import ru.yandex.qatools.ashot.shooting.ShootingStrategies;

public class TakeScreenshotWithScroll {
    static WebDriver driver;
    public static void main(String args[]) throws Exception{
        String key = "webdriver.gecko.driver";
        String value = "driver/geckodriver.exe";
        driver = new FirefoxDriver();
        System.setProperty(key, value);
        driver.get("ENTER THE URL HERE");
        Thread.sleep(2000);
        Screenshot fpScreenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(1000)).takeScreenshot(driver);
        ImageIO.write(fpScreenshot.getImage(),"PNG",new File("D:///FullPageScreenshot.png"));
    }
}

Here is the download link of aShot Jar file


问:
Difference between Spring MVC and Spring Boot
I have just started learning Spring. In my next step, I would like to develop bigger web applications.

Now I am wondering if I should start with Spring Boot or Spring MVC. I have already read some stuff, but it is confusing because both look similar.

So what are the differences between the two?

答:
Using spring boot you will no need to build configuration. This will have done automatically when you create project.

If you use spring MVC you need to build configuration yourself. It is more complicated, but it is crucial.


问:
Eclipse (neon) with SonarLint (3.1) won't connect to SonarQube server (5.6.1)
There are some similar questions with older versions here, but the solutions provided there, didn't help in my case - so I hope for some insight on this more up to date configuration.

I installed the newest SonarLint (3.1) through Eclipse marketplace, but I can't get SonarLint to connect to our SonarQube server (5.6.1).

When I click Test connection in the SonarQube servers view, it fails to connect to https://our.sonarqube-server.com/api/system/status with javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed.

The browser will show the info (some id, version 5.6.1, UP) on https://our.sonarqube-server.com/api/system/status. So the server is up and running.

To make sure I have the right certificates installed, I checked under Help -> About Eclipse -> Installation Details -> Configuration that I'm running a jre1.8.0_131. I downloaded the 3 certificates from the chain of our.sonarqube-server.com and installed them with bin\keytool.exe -import -trustcacerts -keystore lib\security\cacerts -storepass changeit ... in the truststore and checked with -list that they're really there.

The versions should be compatible (SonarLint 3.1 is said to be compatible with SonarQube server 5.6+).

Do you have any idea what could be still wrong with this configuration? When I installed a local SonarQube server on my own machine, I could successfully connect to localhost:9000 the same way (with generating a token - just like I did on our.sonarqube-server.com). As localhost:9000 has no SSL involved, I guess that SonarLint plugin is looking somewhere else for the certificates, but I don't see how to find out, where it looks ...

Thanks for your help.

答:
I ran into something similar myself using SonarLint 3.1 and SonarQube 6.7.

In IntelliJ I kept running into this error message

```<code>Failed to connect to the server. Please check the configuration.
Error: Fail to request https://<SONARQUBE>/api/system/status
</code>```

However I could access that URL through my browser without any issues.

When you WireShark the requests coming from the browser and the IDE you can see that the cypher suite is quite different and that the IDE plugin gets a TLS handshake failure.

That lead me to discover that Java still ships with limited strength cryptographic functions. That’s either because of US export policy or because nobody has gotten around to fixing it. The internet isn’t quite sure.

Either way, you can download the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files from Oracle: http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html

Once I installed those onto the IntelliJ JVM, I no longer got the underlying TLS handshake failure when trying to connect to SonarQube and the connection works.

IntelliJ will ask you about the certificate, so all of that will be easier than messing with certs manually.

Body:
I ran into something similar myself using SonarLint 3.1 and SonarQube 6.7.

In IntelliJ I kept running into this error message

Failed to connect to the server. Please check the configuration.
Error: Fail to request https://<SONARQUBE>/api/system/status

However I could access that URL through my browser without any issues.

When you WireShark the requests coming from the browser and the IDE you can see that the cypher suite is quite different and that the IDE plugin gets a TLS handshake failure.

That lead me to discover that Java still ships with limited strength cryptographic functions. That’s either because of US export policy or because nobody has gotten around to fixing it. The internet isn’t quite sure.

Either way, you can download the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files from Oracle: http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html

Once I installed those onto the IntelliJ JVM, I no longer got the underlying TLS handshake failure when trying to connect to SonarQube and the connection works.

IntelliJ will ask you about the certificate, so all of that will be easier than messing with certs manually.


问:
Oracle SQL Error: ORA-0923 FROM keyword not found where expected
I run the following code through the command console and get the following error

ORA-0923 FROM keyword not found where expected.

I'm also using 11g.

```<code>SELECT c.customer# "C#", o.order# "ORDER#",
       o.orderdate "ORDER DATE",
       NVL2(o.shipdate, 'Not shipped', 'shipped'),
       o.shipdate "Ship date",
       o.shipdate-o.orderdate AS "lead time in days",
TRUNC((o.shipdate-o.orderdate)/30), 2) AS "lead time in months"
FROM customers c, orders o
ORDER BY "lead time in days" DESC, c.customer# ASC, o.order# ASC;
</code>```

答:
Please remove extra bracket in Trunc and run the below query:</p>

```<code>SELECT c.customer# "C#", o.order# "ORDER#",
o.orderdate "ORDER DATE",
NVL2(o.shipdate, 'Not shipped', 'shipped'),
o.shipdate "Ship date",
o.shipdate-o.orderdate  "lead time in days",
TRUNC((o.shipdate-o.orderdate)/30,2) "lead time in months"
FROM customers c, orders o
ORDER BY "lead time in days" DESC, c.customer# ASC, o.order# ASC;
</code>```

Body:
I run the following code through the command console and get the following error

ORA-0923 FROM keyword not found where expected.

I'm also using 11g.

SELECT c.customer# "C#", o.order# "ORDER#",
       o.orderdate "ORDER DATE",
       NVL2(o.shipdate, 'Not shipped', 'shipped'),
       o.shipdate "Ship date",
       o.shipdate-o.orderdate AS "lead time in days",
TRUNC((o.shipdate-o.orderdate)/30), 2) AS "lead time in months"
FROM customers c, orders o
ORDER BY "lead time in days" DESC, c.customer# ASC, o.order# ASC;

Body:
Please remove extra bracket in Trunc and run the below query:

SELECT c.customer# "C#", o.order# "ORDER#",
o.orderdate "ORDER DATE",
NVL2(o.shipdate, 'Not shipped', 'shipped'),
o.shipdate "Ship date",
o.shipdate-o.orderdate  "lead time in days",
TRUNC((o.shipdate-o.orderdate)/30,2) "lead time in months"
FROM customers c, orders o
ORDER BY "lead time in days" DESC, c.customer# ASC, o.order# ASC;


问:
Understanding BufferedReader and InputStreamReader
I am having trouble understanding what this line does exactly in terms of server side stuff.

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

I have read other S.O threads but I am still having trouble understanding simply what that line does.

I am very confident in C if anyone would like give an analogy with C code, thanks.

答:
System.in is the standard input.

InputStreamReader allows you to associate a stream that reads from the specified input (in this case the standard input), so now we have a stream.

BufferedReader is an "abstraction" to help you to work with streams. For example, it implements readLine instead of reading character by character until you find a '\n' to get the whole line. It just returns a String after this proccess.

In C, there are no "strings" you have to use a character array, but you can read data in to a character array from stdin with something like:

```<code>char input[100];
...
scanf("%99[^\n]", input);
</code>```

or

```<code>fgets (input, 100 , stdin)
</code>```

In C++, you'd use:

```<code>using namespace std;

string line;
getline(cin, line);
</code>```

BufferedReader

Read text from a character-input stream, buffering characters so as to provide for the efficient reading of characters, arrays, and lines. The buffer size may be specified, or the default size may be used. The default is large enough for most purposes. In general, each read request made of a Reader causes a corresponding read request to be made of the underlying character or byte stream. It is therefore advisable to wrap a BufferedReader around any Reader whose read() operations may be costly, such as FileReaders and InputStreamReaders.

BufferedReader#readLine()

Read a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed.

InputStreamReader

An InputStreamReader is a bridge from byte streams to character streams: It reads bytes and decodes them into characters using a specified charset. The charset that it uses may be specified by name or may be given explicitly, or the platform's default charset may be accepted. Each invocation of one of an InputStreamReader's read() methods may cause one or more bytes to be read from the underlying byte-input stream. To enable the efficient conversion of bytes to characters, more bytes may be read ahead from the underlying stream than are necessary to satisfy the current read operation.

System

The System class contains several useful class fields and methods. It cannot be instantiated.

Among the facilities provided by the System class are standard input, standard output, and error output streams; access to externally defined "properties"; a means of loading files and libraries; and a utility method for quickly copying a portion of an array.

System.in

The "standard" input stream. This stream is already open and ready to supply input data. Typically this stream corresponds to keyboard input or another input source specified by the host environment or user.

See

Body:
System.in is the standard input.

InputStreamReader allows you to associate a stream that reads from the specified input (in this case the standard input), so now we have a stream.

BufferedReader is an "abstraction" to help you to work with streams. For example, it implements readLine instead of reading character by character until you find a '\n' to get the whole line. It just returns a String after this proccess.

In C, there are no "strings" you have to use a character array, but you can read data in to a character array from stdin with something like:

char input[100];
...
scanf("%99[^\n]", input);

or

fgets (input, 100 , stdin)

In C++, you'd use:

using namespace std;

string line;
getline(cin, line);

BufferedReader

Read text from a character-input stream, buffering characters so as to provide for the efficient reading of characters, arrays, and lines. The buffer size may be specified, or the default size may be used. The default is large enough for most purposes. In general, each read request made of a Reader causes a corresponding read request to be made of the underlying character or byte stream. It is therefore advisable to wrap a BufferedReader around any Reader whose read() operations may be costly, such as FileReaders and InputStreamReaders.

BufferedReader#readLine()

Read a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed.

InputStreamReader

An InputStreamReader is a bridge from byte streams to character streams: It reads bytes and decodes them into characters using a specified charset. The charset that it uses may be specified by name or may be given explicitly, or the platform's default charset may be accepted. Each invocation of one of an InputStreamReader's read() methods may cause one or more bytes to be read from the underlying byte-input stream. To enable the efficient conversion of bytes to characters, more bytes may be read ahead from the underlying stream than are necessary to satisfy the current read operation.

System

The System class contains several useful class fields and methods. It cannot be instantiated.

Among the facilities provided by the System class are standard input, standard output, and error output streams; access to externally defined "properties"; a means of loading files and libraries; and a utility method for quickly copying a portion of an array.

System.in

The "standard" input stream. This stream is already open and ready to supply input data. Typically this stream corresponds to keyboard input or another input source specified by the host environment or user.

See


问:
Was writing code for a slot machine in java and and want to split into 3 files but it doesnt work
Dont know what isnt working

```<code>//slot machine class
package slotMachine;

//import java.util.Arrays;
import java.util.Random;

# public class SlotGame {

    private int winCreadits=0;
    private boolean winState;
    static int slotMidPosition= 0;
    Random rand = new Random();

    //wheel contains: "melon", "bell", "7", "lemon", "bar" (5 total icons)
    static String slotBand[] = {"melon", " bell", "    7", "lemon", "  bar"};

        // slotOut is used to store the output values for the slot machine
    static String slotOut[] = new String[]
            {
                    "melon","melon","melon"
            };
    public SlotGame()
     {
     init();

     }

     public void checkWin()
     {
    checkConections();
    if(winState)
    {
        if (slotOut[1]=="melon")
        {
            winCreadits=1;
        }
        else if (slotOut[1]=="lemon")
        {
            winCreadits=1;
        }
        else if (slotOut[1]=="bell")
        {
            winCreadits=2;
        }
        else if (slotOut[1]=="bar")
        {
            winCreadits=3;
        }
        else if (slotOut[1]=="7")
        {
            winCreadits=5;
        }
        else
        {
            winCreadits=0;
        }
    }

     }

     public int getWinAmount()
     {
        return winCreadits;
     }

     public String[] returnWheel()
     {
        return slotOut;
     }

     private void init()
     {
        getSlot( );

     }

     public void getSlot()
     {
    winState=false;
    for (int i=0;i<3;i++)
    {
        slotMidPosition = rand.nextInt(5);
        if (slotMidPosition==0)
        {
            slotOut[0]=slotBand[4];
        }
        else if(slotMidPosition>=0)
        {
            slotOut[0]=slotBand[slotMidPosition-1];
        }

        slotOut[1]=slotBand[slotMidPosition];

        slotOut[2]=slotBand[(slotMidPosition+1)%5];
         }
    checkWin();
     }

     private void outputArray(String[] slotOut)
     {
         for(int i = 0;i<3;i++)
        {

            System.out.print(slotOut[i]);
            System.out.print(" ");

        }
     }
  dont know wats going on at a point

         public void checkConections()
     {
    if(slotOut[0]==slotOut[1]&&slotOut[1]==slotOut[2])
        winState = true;
    else
        winState=false;
     }

     }
</code>```

CONTROLLER CLASS

```<code>    package slotMachine;

    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.ComponentEvent;
    import java.awt.event.ComponentListener;
    import java.awt.event.FocusEvent;
    import java.awt.event.FocusListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
    import java.awt.event.WindowEvent;
    import java.awt.event.WindowListener;
    import java.util.Arrays;

    import javax.swing.*;

    import edu.cuny.csi.csc330.swing.TTTGameView;

    public class SlotController implements
    ActionListener,
    WindowListener{

private boolean ifWork=false;
private SlotView gameView;
private SlotGame gameModel;
private int winAmount;
private String wheel[];

public SlotController() {
    init();
}

public void setGameView(SlotView gameView) {
    this.gameView = gameView;
}

private void init()
{
    gameModel = new SlotGame();
}

@Override
    public void actionPerformed(ActionEvent ae) {

    Object source = ae.getSource();
    ifWork= (source == this.gameView.getSpinButton());
    System.out.println(ifWork);
    System.out.println("Slot actionPerformed: "  +
    source.getClass().getSimpleName());
    // Spin button
    if(source == this.gameView.getSpinButton() )
    {
        winAmount = gameView.getCreadit();
        System.out.println(gameView.getCreadit());
        gameModel.getSlot();
        wheel=gameModel.returnWheel();
        winAmount+= gameModel.getWinAmount();
        System.out.println(Arrays.toString(wheel));
        gameView.setCredit(winAmount);
        gameView.spunWheelDec();
        gameView.importWheel(wheel);
        System.out.println(Arrays.toString(gameView.wheelSet()));

    }

}

@Override
public void windowActivated(WindowEvent e) {
    // TODO Auto-generated method stub

}

@Override
public void windowClosed(WindowEvent e) {
    // TODO Auto-generated method stub

}

@Override
public void windowClosing(WindowEvent e) {
    // TODO Auto-generated method stub

}

@Override
public void windowDeactivated(WindowEvent e) {
    // TODO Auto-generated method stub

}

@Override
public void windowDeiconified(WindowEvent e) {
    // TODO Auto-generated method stub

}

@Override
public void windowIconified(WindowEvent e) {
    // TODO Auto-generated method stub

}

@Override
public void windowOpened(WindowEvent e) {
    // TODO Auto-generated method stub

}

public static void main(String[] args) {
    SlotView.present();

    }
}
</code>```

//SlotView for gui

```<code>package slotMachine;

import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.WindowListener;
import java.lang.reflect.Array;
import java.util.Arrays;

import javax.swing.*;
import javax.swing.border.*;
import javax.swing.GroupLayout.Alignment;
import java.awt.event.ActionEvent;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.RowSpec;

import edu.cuny.csi.csc330.swing.TTTController;
import edu.cuny.csi.csc330.swing.TTTGameView;

public class SlotView extends JFrame{

private static Integer DEFAULT_X = 200;
private static Integer DEFAULT_Y = 200;
private static Integer DEFAULT_W = 1000;
private static Integer DEFAULT_H = 500;

private static String DEFAULT_TITLE = "Spinny Thing Game";

private String[] Wheel= new String[3];

private JButton spinButton;

private ImageIcon imageArr1;
private ImageIcon imageArr2;
private ImageIcon imageArr3;
private ImageIcon image;
private JLabel imageIcone;

private JPanel mainPanel;
private JLabel SlotPos_1;
private JLabel SlotPos_2;
private JLabel SlotPos_3;
private JPanel Slot_1;
private JPanel Slot_2;
private JPanel Slot_3;
private JPanel slotPanel;
private JPanel CreditPanel;
private JPanel betPanel;
private JPanel mainOutPut;

private JLabel  currentBet;
private JLabel  currentPoints;
private JLabel  pointsLabel;
private JLabel  betLabel;

private ActionListener actionListener;
private WindowListener windowListener;

private int credit, bet=1;

public SlotView() {
    guiInit();
}

public SlotView(SlotController listener) {
    actionListener = listener;
    windowListener = listener;
    guiInit();
}

    public SlotView(GraphicsConfiguration gc) {
    super(gc);
    guiInit();
}

public void setCredit(int cred)
{
    credit = cred;
}

public void spunWheelDec()
{
    credit-=bet;
    this.pointsLabel=createStatusLabel(String.format("%d", credit) );
}

public int getCreadit()
{
    return credit;
}
public JLabel getCurentPoints() {
    return this.currentPoints;
}

public JLabel getCurrentBet() {
    return currentBet;
}

public JButton getSpinButton(){
    return spinButton;
}

private void init()
{
    credit=50;
    this.setSize(DEFAULT_W, DEFAULT_H);
    this.getContentPane().setBackground(new Color(100, 149, 237));

    this.setLocation(DEFAULT_X, DEFAULT_X);
    //this.setBounds(100, 100, 1000, 500);
    this.setTitle(DEFAULT_TITLE);

    this.getContentPane().setLayout(null);

}

private void image()
{

      for(int i = 0; i<3;i++) {

        if (Wheel[i]=="melon")
            imageArr1 = new
        ImageIcon("C:\\Users\\bn\\Pictures\\images\\Watermelon.png");
        if (Wheel[i]=="bell")
            imageArr1= new
             ImageIcon("C:\\Users\\bn\\Pictures\\images\\Bell.png");
        if (Wheel[i]=="7")
            imageArr1= new
               ImageIcon("C:\\Users\\bn\\Pictures\\images\\Seven.png");
        if (Wheel[i]=="lemon")
            imageArr1= new
           ImageIcon("C:\\Users\\bn\\Pictures\\images\\Cherry.png");
        if (Wheel[i]=="bar")
            imageArr1= new
               ImageIcon("C:\\Users\\bn\\Pictures\\images\\Bar.png");
    }

    for(int i = 0; i<3;i++) {

        if (Wheel[i]=="melon")
            imageArr2 = new
          ImageIcon("C:\\Users\\bn\\Pictures\\images\\Watermelon.png");
        if (Wheel[i]=="bell")
            imageArr2= new
                 ImageIcon("C:\\Users\\bn\\Pictures\\images\\Bell.png");
        if (Wheel[i]=="7")
            imageArr2= new
             ImageIcon("C:\\Users\\bn\\Pictures\\images\\Seven.png");
        if (Wheel[i]=="lemon")
            imageArr2= new
         ImageIcon("C:\\Users\\bn\\Pictures\\images\\Cherry.png");
        if (Wheel[i]=="bar")
            imageArr2= new
              ImageIcon("C:\\Users\\bn\\Pictures\\images\\Bar.png");
    }

    for(int i = 0; i<3;i++) {

        if (Wheel[i]=="melon")
            imageArr3 = new
          ImageIcon("C:\\Users\\bn\\Pictures\\images\\Watermelon.png");
        if (Wheel[i]=="bell")
            imageArr3= new
             ImageIcon("C:\\Users\\bn\\Pictures\\images\\Bell.png");
        if (Wheel[i]=="7")
            imageArr3= new
         ImageIcon("C:\\Users\\bn\\Pictures\\images\\Seven.png");
        if (Wheel[i]=="lemon")
            imageArr3= new
     ImageIcon("C:\\Users\\bn\\Pictures\\images\\Cherry.png");
        if (Wheel[i]=="bar")
            imageArr3= new
    ImageIcon("C:\\Users\\bn\\Pictures\\images\\Bar.png");
    }

}

private JLabel createStatusLabel(String title)  {
    JLabel label = new JLabel(title);
    label.setName( title );
    label.setFont( new Font("Dialog", Font.BOLD, 18) );
    label.setPreferredSize(new Dimension(100, 35));
    label.setBackground(Color.YELLOW);

    return label;
}
public void importWheel(String[] W)
{
    Wheel=W;
}

public void setWheels()
{
    Slot_1.add(SlotPos_1);
    Slot_2.add(SlotPos_2);
    Slot_3.add(SlotPos_3);
}

public String[] wheelSet()
{
    return Wheel;
}

private void guiInit() {

    init();
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    currentBet = createStatusLabel("Bet: ");
    currentPoints = createStatusLabel("Credit: ");

    SlotPos_1= new JLabel(imageArr1);
    SlotPos_1.setBounds(0, 0, 181, 163);

    SlotPos_2= new JLabel(imageArr2);
    SlotPos_2.setBounds(0, 0, 181, 163);

    SlotPos_3=new JLabel(imageArr3);
    SlotPos_3.setBounds(0, 0, 181, 163);

    //set up a main panel for slot wheels
    slotPanel = new JPanel();
    slotPanel.setBackground(new Color(0, 0, 205));
    slotPanel.setBounds(40, 40, 914, 185);
    slotPanel.setLayout(null);

    //set up slot 1
    Slot_1 = new JPanel();
    Slot_1.add(SlotPos_1);
    Slot_1.setBackground(Color.BLACK);
    Slot_1.setBounds(10, 11, 181, 163);
    slotPanel.add(Slot_1);
    Slot_1.setLayout(null);

    //set slot 2
    Slot_2 = new JPanel();
    Slot_2.add(SlotPos_2);
    Slot_2.setBackground(Color.BLACK);
    Slot_2.setBounds(360, 11, 181, 163);
    slotPanel.add(Slot_2);
    Slot_2.setLayout(null);
    Slot_2.setVisible(true);

    //set slot 3
    Slot_3 = new JPanel();
    Slot_3.add(SlotPos_3);
    Slot_3.setBackground(Color.BLACK);
    Slot_3.setBounds(723, 11, 181, 163);
    slotPanel.add(Slot_3);
    Slot_3.setLayout(null);
    Slot_3.setVisible(true);

    // set up for data output and buttons
    mainOutPut = new JPanel();
    mainOutPut.setBackground(new Color(112, 128, 144));
    mainOutPut.setBounds(40, 283, 914, 160);
    mainOutPut.setLayout(null);

    // outputs credit value
    CreditPanel = new JPanel(new GridLayout(1,2), true);
    CreditPanel.setBackground(new Color(112, 128, 144));
    CreditPanel.setBounds(10, 65, 222, 57);
    CreditPanel.add(currentPoints);
    pointsLabel=createStatusLabel(String.format("%d", credit) );
    CreditPanel.add(pointsLabel);
    mainOutPut.add(CreditPanel);

    //output for bets
    betPanel = new JPanel();
    betPanel.setBackground(new Color(112, 128, 144));
    betPanel.setBounds(682, 65, 222, 65);
    betPanel.add(currentBet);
    betLabel = createStatusLabel(Integer.toString(bet));
    betPanel.add(betLabel);
    mainOutPut.add(betPanel);

    //creates button for spinning the wheel
    spinButton = new JButton("SPIN WHEEL");
    spinButton.setForeground(Color.BLACK);
    spinButton.setBackground(new Color(34, 139, 34));
    spinButton.setBounds(381, 57, 139, 65);
    mainOutPut.add(spinButton);

    this.getContentPane().add(slotPanel);
    this.getContentPane().add(mainOutPut);

    //this.setVisible(true);
    addActionListeners();
    addOtherListeners();
}

private void addActionListeners() {
    if(this.actionListener == null)
            return;

    this.spinButton.addActionListener(this.actionListener);
}

private void addOtherListeners() {
    addWindowListener(windowListener);

}

public static void present() {

     // The recommended way of startin a Swing / GUI Thread
      EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {

                SlotController listener = new SlotController();
                SlotView game = new SlotView(listener);
                listener.setGameView(game);

                game.setVisible(true);

            }
        }
      );
}

public static void main(String[] args) {

    present();
/*  JFrame frame = new JFrame();
    frame.setSize(new Dimension(1000,400));
    frame.getContentPane().setBackground(new Color(100, 149, 237));
    frame.setResizable(false);
    JPanel jpn = new JPanel();
    //frame.getContentPane().setLayout(null);
    frame.getContentPane().add(jpn);

    JButton spin= new JButton("spin");
    spin.setBounds(10,10,100,100);
    jpn.setBackground(new Color(100, 149, 237));
    jpn.add(spin);

    frame.setTitle("Test");
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    */
}
</code>```

}

it does not take the images that i am requesting of it anddisplaying them.
also the credit does not get updated

答:
because you do not create a folder within your project that is in the same package and then move them there and no longer uses such external routes I'll give you an example
let's say that they create a folder called images in the package where I have my project so the routes will only have to give it

```<code>ImageIcon("imagenes/imagen.png");
</code>```

change

```<code>ImageIcon ("C: \\ Users \\ bn \\ Pictures \\ images \\ Watermelon.png");
</code>```

by

```<code> ImageIcon ("C: \ Users \ bn \ Pictures \\ images \ Watermelon.png");
</code>```

Body:
Dont know what isnt working

//slot machine class
package slotMachine;

//import java.util.Arrays;
import java.util.Random;

# public class SlotGame {

    private int winCreadits=0;
    private boolean winState;
    static int slotMidPosition= 0;
    Random rand = new Random();

    //wheel contains: "melon", "bell", "7", "lemon", "bar" (5 total icons)
    static String slotBand[] = {"melon", " bell", "    7", "lemon", "  bar"};

        // slotOut is used to store the output values for the slot machine
    static String slotOut[] = new String[]
            {
                    "melon","melon","melon"
            };
    public SlotGame()
     {
     init();

     }

     public void checkWin()
     {
    checkConections();
    if(winState)
    {
        if (slotOut[1]=="melon")
        {
            winCreadits=1;
        }
        else if (slotOut[1]=="lemon")
        {
            winCreadits=1;
        }
        else if (slotOut[1]=="bell")
        {
            winCreadits=2;
        }
        else if (slotOut[1]=="bar")
        {
            winCreadits=3;
        }
        else if (slotOut[1]=="7")
        {
            winCreadits=5;
        }
        else
        {
            winCreadits=0;
        }
    }

     }

     public int getWinAmount()
     {
        return winCreadits;
     }

     public String[] returnWheel()
     {
        return slotOut;
     }

     private void init()
     {
        getSlot( );

     }

     public void getSlot()
     {
    winState=false;
    for (int i=0;i<3;i++)
    {
        slotMidPosition = rand.nextInt(5);
        if (slotMidPosition==0)
        {
            slotOut[0]=slotBand[4];
        }
        else if(slotMidPosition>=0)
        {
            slotOut[0]=slotBand[slotMidPosition-1];
        }

        slotOut[1]=slotBand[slotMidPosition];

        slotOut[2]=slotBand[(slotMidPosition+1)%5];
         }
    checkWin();
     }

     private void outputArray(String[] slotOut)
     {
         for(int i = 0;i<3;i++)
        {

            System.out.print(slotOut[i]);
            System.out.print(" ");

        }
     }
  dont know wats going on at a point

         public void checkConections()
     {
    if(slotOut[0]==slotOut[1]&&slotOut[1]==slotOut[2])
        winState = true;
    else
        winState=false;
     }

     }

CONTROLLER CLASS

    package slotMachine;

    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.ComponentEvent;
    import java.awt.event.ComponentListener;
    import java.awt.event.FocusEvent;
    import java.awt.event.FocusListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
    import java.awt.event.WindowEvent;
    import java.awt.event.WindowListener;
    import java.util.Arrays;

    import javax.swing.*;

    import edu.cuny.csi.csc330.swing.TTTGameView;

    public class SlotController implements
    ActionListener,
    WindowListener{

private boolean ifWork=false;
private SlotView gameView;
private SlotGame gameModel;
private int winAmount;
private String wheel[];

public SlotController() {
    init();
}

public void setGameView(SlotView gameView) {
    this.gameView = gameView;
}

private void init()
{
    gameModel = new SlotGame();
}

@Override
    public void actionPerformed(ActionEvent ae) {

    Object source = ae.getSource();
    ifWork= (source == this.gameView.getSpinButton());
    System.out.println(ifWork);
    System.out.println("Slot actionPerformed: "  +
    source.getClass().getSimpleName());
    // Spin button
    if(source == this.gameView.getSpinButton() )
    {
        winAmount = gameView.getCreadit();
        System.out.println(gameView.getCreadit());
        gameModel.getSlot();
        wheel=gameModel.returnWheel();
        winAmount+= gameModel.getWinAmount();
        System.out.println(Arrays.toString(wheel));
        gameView.setCredit(winAmount);
        gameView.spunWheelDec();
        gameView.importWheel(wheel);
        System.out.println(Arrays.toString(gameView.wheelSet()));

    }

}

@Override
public void windowActivated(WindowEvent e) {
    // TODO Auto-generated method stub

}

@Override
public void windowClosed(WindowEvent e) {
    // TODO Auto-generated method stub

}

@Override
public void windowClosing(WindowEvent e) {
    // TODO Auto-generated method stub

}

@Override
public void windowDeactivated(WindowEvent e) {
    // TODO Auto-generated method stub

}

@Override
public void windowDeiconified(WindowEvent e) {
    // TODO Auto-generated method stub

}

@Override
public void windowIconified(WindowEvent e) {
    // TODO Auto-generated method stub

}

@Override
public void windowOpened(WindowEvent e) {
    // TODO Auto-generated method stub

}

public static void main(String[] args) {
    SlotView.present();

    }
}

//SlotView for gui

package slotMachine;

import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.WindowListener;
import java.lang.reflect.Array;
import java.util.Arrays;

import javax.swing.*;
import javax.swing.border.*;
import javax.swing.GroupLayout.Alignment;
import java.awt.event.ActionEvent;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.RowSpec;

import edu.cuny.csi.csc330.swing.TTTController;
import edu.cuny.csi.csc330.swing.TTTGameView;

public class SlotView extends JFrame{

private static Integer DEFAULT_X = 200;
private static Integer DEFAULT_Y = 200;
private static Integer DEFAULT_W = 1000;
private static Integer DEFAULT_H = 500;

private static String DEFAULT_TITLE = "Spinny Thing Game";

private String[] Wheel= new String[3];

private JButton spinButton;

private ImageIcon imageArr1;
private ImageIcon imageArr2;
private ImageIcon imageArr3;
private ImageIcon image;
private JLabel imageIcone;

private JPanel mainPanel;
private JLabel SlotPos_1;
private JLabel SlotPos_2;
private JLabel SlotPos_3;
private JPanel Slot_1;
private JPanel Slot_2;
private JPanel Slot_3;
private JPanel slotPanel;
private JPanel CreditPanel;
private JPanel betPanel;
private JPanel mainOutPut;

private JLabel  currentBet;
private JLabel  currentPoints;
private JLabel  pointsLabel;
private JLabel  betLabel;

private ActionListener actionListener;
private WindowListener windowListener;

private int credit, bet=1;

public SlotView() {
    guiInit();
}

public SlotView(SlotController listener) {
    actionListener = listener;
    windowListener = listener;
    guiInit();
}

    public SlotView(GraphicsConfiguration gc) {
    super(gc);
    guiInit();
}

public void setCredit(int cred)
{
    credit = cred;
}

public void spunWheelDec()
{
    credit-=bet;
    this.pointsLabel=createStatusLabel(String.format("%d", credit) );
}

public int getCreadit()
{
    return credit;
}
public JLabel getCurentPoints() {
    return this.currentPoints;
}

public JLabel getCurrentBet() {
    return currentBet;
}

public JButton getSpinButton(){
    return spinButton;
}

private void init()
{
    credit=50;
    this.setSize(DEFAULT_W, DEFAULT_H);
    this.getContentPane().setBackground(new Color(100, 149, 237));

    this.setLocation(DEFAULT_X, DEFAULT_X);
    //this.setBounds(100, 100, 1000, 500);
    this.setTitle(DEFAULT_TITLE);

    this.getContentPane().setLayout(null);

}

private void image()
{

      for(int i = 0; i<3;i++) {

        if (Wheel[i]=="melon")
            imageArr1 = new
        ImageIcon("C:\\Users\\bn\\Pictures\\images\\Watermelon.png");
        if (Wheel[i]=="bell")
            imageArr1= new
             ImageIcon("C:\\Users\\bn\\Pictures\\images\\Bell.png");
        if (Wheel[i]=="7")
            imageArr1= new
               ImageIcon("C:\\Users\\bn\\Pictures\\images\\Seven.png");
        if (Wheel[i]=="lemon")
            imageArr1= new
           ImageIcon("C:\\Users\\bn\\Pictures\\images\\Cherry.png");
        if (Wheel[i]=="bar")
            imageArr1= new
               ImageIcon("C:\\Users\\bn\\Pictures\\images\\Bar.png");
    }

    for(int i = 0; i<3;i++) {

        if (Wheel[i]=="melon")
            imageArr2 = new
          ImageIcon("C:\\Users\\bn\\Pictures\\images\\Watermelon.png");
        if (Wheel[i]=="bell")
            imageArr2= new
                 ImageIcon("C:\\Users\\bn\\Pictures\\images\\Bell.png");
        if (Wheel[i]=="7")
            imageArr2= new
             ImageIcon("C:\\Users\\bn\\Pictures\\images\\Seven.png");
        if (Wheel[i]=="lemon")
            imageArr2= new
         ImageIcon("C:\\Users\\bn\\Pictures\\images\\Cherry.png");
        if (Wheel[i]=="bar")
            imageArr2= new
              ImageIcon("C:\\Users\\bn\\Pictures\\images\\Bar.png");
    }

    for(int i = 0; i<3;i++) {

        if (Wheel[i]=="melon")
            imageArr3 = new
          ImageIcon("C:\\Users\\bn\\Pictures\\images\\Watermelon.png");
        if (Wheel[i]=="bell")
            imageArr3= new
             ImageIcon("C:\\Users\\bn\\Pictures\\images\\Bell.png");
        if (Wheel[i]=="7")
            imageArr3= new
         ImageIcon("C:\\Users\\bn\\Pictures\\images\\Seven.png");
        if (Wheel[i]=="lemon")
            imageArr3= new
     ImageIcon("C:\\Users\\bn\\Pictures\\images\\Cherry.png");
        if (Wheel[i]=="bar")
            imageArr3= new
    ImageIcon("C:\\Users\\bn\\Pictures\\images\\Bar.png");
    }

}

private JLabel createStatusLabel(String title)  {
    JLabel label = new JLabel(title);
    label.setName( title );
    label.setFont( new Font("Dialog", Font.BOLD, 18) );
    label.setPreferredSize(new Dimension(100, 35));
    label.setBackground(Color.YELLOW);

    return label;
}
public void importWheel(String[] W)
{
    Wheel=W;
}

public void setWheels()
{
    Slot_1.add(SlotPos_1);
    Slot_2.add(SlotPos_2);
    Slot_3.add(SlotPos_3);
}

public String[] wheelSet()
{
    return Wheel;
}

private void guiInit() {

    init();
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    currentBet = createStatusLabel("Bet: ");
    currentPoints = createStatusLabel("Credit: ");

    SlotPos_1= new JLabel(imageArr1);
    SlotPos_1.setBounds(0, 0, 181, 163);

    SlotPos_2= new JLabel(imageArr2);
    SlotPos_2.setBounds(0, 0, 181, 163);

    SlotPos_3=new JLabel(imageArr3);
    SlotPos_3.setBounds(0, 0, 181, 163);

    //set up a main panel for slot wheels
    slotPanel = new JPanel();
    slotPanel.setBackground(new Color(0, 0, 205));
    slotPanel.setBounds(40, 40, 914, 185);
    slotPanel.setLayout(null);

    //set up slot 1
    Slot_1 = new JPanel();
    Slot_1.add(SlotPos_1);
    Slot_1.setBackground(Color.BLACK);
    Slot_1.setBounds(10, 11, 181, 163);
    slotPanel.add(Slot_1);
    Slot_1.setLayout(null);

    //set slot 2
    Slot_2 = new JPanel();
    Slot_2.add(SlotPos_2);
    Slot_2.setBackground(Color.BLACK);
    Slot_2.setBounds(360, 11, 181, 163);
    slotPanel.add(Slot_2);
    Slot_2.setLayout(null);
    Slot_2.setVisible(true);

    //set slot 3
    Slot_3 = new JPanel();
    Slot_3.add(SlotPos_3);
    Slot_3.setBackground(Color.BLACK);
    Slot_3.setBounds(723, 11, 181, 163);
    slotPanel.add(Slot_3);
    Slot_3.setLayout(null);
    Slot_3.setVisible(true);

    // set up for data output and buttons
    mainOutPut = new JPanel();
    mainOutPut.setBackground(new Color(112, 128, 144));
    mainOutPut.setBounds(40, 283, 914, 160);
    mainOutPut.setLayout(null);

    // outputs credit value
    CreditPanel = new JPanel(new GridLayout(1,2), true);
    CreditPanel.setBackground(new Color(112, 128, 144));
    CreditPanel.setBounds(10, 65, 222, 57);
    CreditPanel.add(currentPoints);
    pointsLabel=createStatusLabel(String.format("%d", credit) );
    CreditPanel.add(pointsLabel);
    mainOutPut.add(CreditPanel);

    //output for bets
    betPanel = new JPanel();
    betPanel.setBackground(new Color(112, 128, 144));
    betPanel.setBounds(682, 65, 222, 65);
    betPanel.add(currentBet);
    betLabel = createStatusLabel(Integer.toString(bet));
    betPanel.add(betLabel);
    mainOutPut.add(betPanel);

    //creates button for spinning the wheel
    spinButton = new JButton("SPIN WHEEL");
    spinButton.setForeground(Color.BLACK);
    spinButton.setBackground(new Color(34, 139, 34));
    spinButton.setBounds(381, 57, 139, 65);
    mainOutPut.add(spinButton);

    this.getContentPane().add(slotPanel);
    this.getContentPane().add(mainOutPut);

    //this.setVisible(true);
    addActionListeners();
    addOtherListeners();
}

private void addActionListeners() {
    if(this.actionListener == null)
            return;

    this.spinButton.addActionListener(this.actionListener);
}

private void addOtherListeners() {
    addWindowListener(windowListener);

}

public static void present() {

     // The recommended way of startin a Swing / GUI Thread
      EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {

                SlotController listener = new SlotController();
                SlotView game = new SlotView(listener);
                listener.setGameView(game);

                game.setVisible(true);

            }
        }
      );
}

public static void main(String[] args) {

    present();
/*  JFrame frame = new JFrame();
    frame.setSize(new Dimension(1000,400));
    frame.getContentPane().setBackground(new Color(100, 149, 237));
    frame.setResizable(false);
    JPanel jpn = new JPanel();
    //frame.getContentPane().setLayout(null);
    frame.getContentPane().add(jpn);

    JButton spin= new JButton("spin");
    spin.setBounds(10,10,100,100);
    jpn.setBackground(new Color(100, 149, 237));
    jpn.add(spin);

    frame.setTitle("Test");
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    */
}

}

it does not take the images that i am requesting of it anddisplaying them.
also the credit does not get updated

Body:
because you do not create a folder within your project that is in the same package and then move them there and no longer uses such external routes I'll give you an example
let's say that they create a folder called images in the package where I have my project so the routes will only have to give it

ImageIcon("imagenes/imagen.png");

change

ImageIcon ("C: \\ Users \\ bn \\ Pictures \\ images \\ Watermelon.png");

by

 ImageIcon ("C: \ Users \ bn \ Pictures \\ images \ Watermelon.png");


问:
Making the status bar background transparent
Hi I am pretty new to iOS development. I needed to hide the white bar that appears under the status bar. I tried out solutions but could not really get it to work. What is the simplest solution to do this? Is there something that I can do in the app delegate? I want the map to be under the status bar, like the Uber application. Thanks!

答: you can do this: (UIApplication.shared.value(forKey: "statusBar") as? UIView)?.backgroundColor = .clear</p>


问:
Autoscroll to TOP with ui-router and Angularjs
I've read so many different problems with this and none of the solution given seem to fit my use case.  I started by simply putting target="_top" on all my links, but that actually forces my app to reload which wont work.  I've also seen people say they use autoscroll="true" but that only seems to work if its within my ui-view.

The issue with this is that in my index.html file I have fixed nav and other static elements that are above my first ui-view.  This means when I go to other pages I lose the navigation as the page loads past those elements.  I've also tried putting this on the body with:

```<code><body autoscroll="true">
</body>
</code>```

This doesn't seem to do anything either.  So the question is, how can I make sure that new pages (new route changes from ui-router) result in starting at the top of the page? THANKS!

答:
Using version 1.0.6, the $stateChangeSuccess event is deprecated in favor of the $transitions service. Here is the code I used to scroll to the top on every state change:

```<code>app.run(['$transitions', function ($transitions) {
    $transitions.onSuccess({}, function () {
        document.body.scrollTop = document.documentElement.scrollTop = 0;
    })
}]);
</code>```

Body:
I've read so many different problems with this and none of the solution given seem to fit my use case.  I started by simply putting target="_top" on all my links, but that actually forces my app to reload which wont work.  I've also seen people say they use autoscroll="true" but that only seems to work if its within my ui-view.

The issue with this is that in my index.html file I have fixed nav and other static elements that are above my first ui-view.  This means when I go to other pages I lose the navigation as the page loads past those elements.  I've also tried putting this on the body with:

This doesn't seem to do anything either.  So the question is, how can I make sure that new pages (new route changes from ui-router) result in starting at the top of the page? THANKS!

Body:
Using version 1.0.6, the $stateChangeSuccess event is deprecated in favor of the $transitions service. Here is the code I used to scroll to the top on every state change:

app.run(['$transitions', function ($transitions) {
    $transitions.onSuccess({}, function () {
        document.body.scrollTop = document.documentElement.scrollTop = 0;
    })
}]);


问:
Difference between ListView and DataGrid in WPF?
I have to retrieve some questions from the database and display them on the user screen dynamically. I also need to add some controls in the columns of grid view, basically a question and input box for an answer.

Please suggest which one should I use? ListView or DataGrid?

答:
I'm not a WPF expert, but it terms of just the controls themselves.

When thinking of ListView think Windows Explorer, the pane where you see all you're files, thats a ListView.

When thinking data base its usually (I said usually) a data grid, mouse over the gridview tag and read the description.

Some very obvious reasons why you would want a gridview is its directly editable. You can have your user enter the questions and the answer in there. Note, since ListViewItem is an Content Control  you also could customize it easily like this article does.

Also see if this GridView tutorial helps.

You haven't given much of the description of how you need the UI, but you could play around and do anything you like.

You could even make a User Control for a [Question + Input box for Answer]. Then you could use a StackPanel (or even a listview) to list them out.

Hope that helped.


问:
Stop all webkit-animation on hover
Hello guys I'm trying to stop all animation when I hover on animated elements but it only pauses each element separately

```<code>    .wtfigo:hover {
    -webkit-animation-play-state: paused;
    animation-play-state: paused;
     }
#productstrategy,#businessd,#boardst,#coinfin,#mbdpng,#phonepng,#musanan {

    position: absolute;
    left: 880px;
    top: 425px;

    -webkit-animation: myOrbit 10s linear infinite; /* Chrome, Safari 5 */
       -moz-animation: myOrbit 10s linear infinite; /* Firefox 5-15 */
         -o-animation: myOrbit 10s linear infinite; /* Opera 12+ */
            animation: myOrbit 10s linear infinite; /* Chrome, Firefox 16+,
                                                      IE 10+, Safari 5 */
}
@-webkit-keyframes myOrbit {
    from { -webkit-transform: rotate(0deg) translateX(300px) rotate(0deg); }
    to   { -webkit-transform: rotate(360deg) translateX(300px) rotate(-360deg); }
}

@-moz-keyframes myOrbit {
    from { -moz-transform: rotate(0deg) translateX(300px) rotate(0deg); }
    to   { -moz-transform: rotate(360deg) translateX(300px) rotate(-360deg); }
}

@-o-keyframes myOrbit {
    from { -o-transform: rotate(0deg) translateX(300px) rotate(0deg); }
    to   { -o-transform: rotate(360deg) translateX(300px) rotate(-360deg); }
}

@keyframes myOrbit {
    from { transform: rotate(0deg) translateX(300px) rotate(0deg); }
    to   { transform: rotate(360deg) translateX(300px) rotate(-360deg); }
}

<div class="wtfigo"><div id="productstrategy"><img src=".../PS.png"><h3 style="color:white;">Product Strategy</h3></div>
<div style="animation-delay: 1.42s;" id="businessd"><img src=".../BD.png"><h3 style="color:white;text-align:center;">Business Development</h3></div>
<div style="animation-delay: 2.84s;" id="boardst"><img src=".../board.png"><h3 style="color:white;text-align:center;">Operations</h3></div>
<div style="animation-delay: 4.26s;" id="coinfin"><img src=".../coin.png"><h3 style="color:white;text-align:center;">Financial Advisors</h3></div>
<div style="animation-delay: 5.68s;" id="mbdpng"><img src=".../MBD.png"><h3 style="color:white;text-align:center;">Marketing<br />Brand<br />Degital</h3></div>
<div style="animation-delay: 7.1s;" id="phonepng"><img src=".../phone.png"><h3 style="color:white;text-align:center;">Call Center</h3></div>
<div style="animation-delay: 8.52s;" id="musanan"><img src=".../musanan.png"><h3 style="color:white;text-align:center;">Insurance</h3></div>
</div>
</code>```

Please let me know if there is any way I can pause all animations on hover

Cheers

答:
Add your animation to a single parent selector so that you can pause it via the same. See simplified code below:

```<code><style>
    #productstrategy,
    #businessd,
    #boardst,
    #coinfin,
    #mbdpng,
    #phonepng,
    #musanan {
        position: absolute;
        left: 880px;
        top: 425px;
    }

    .wtfigo .flyingthing {
        animation: myOrbit 10s linear infinite;
    }

    .wtfigo:hover .flyingthing {
        animation-play-state: paused;
    }

    @keyframes myOrbit {
        from { transform: rotate(0deg) translateX(300px) rotate(0deg); }
        to   { transform: rotate(360deg) translateX(300px) rotate(-360deg); }
    }
</style>

<div class="wtfigo"><div id="productstrategy"><img src="http://via.placeholder.com/150x150"><h3 style="color:white;">Product Strategy</h3></div>
<div class="flyingthing" style="animation-delay: 1.42s;" id="businessd"><img src="http://via.placeholder.com/150x150"><h3 style="color:white;text-align:center;">Business Development</h3></div>
<div class="flyingthing" style="animation-delay: 2.84s;" id="boardst"><img src="http://via.placeholder.com/150x150"><h3 style="color:white;text-align:center;">Operations</h3></div>
<div class="flyingthing" style="animation-delay: 4.26s;" id="coinfin"><img src="http://via.placeholder.com/150x150"><h3 style="color:white;text-align:center;">Financial Advisors</h3></div>
<div class="flyingthing" style="animation-delay: 5.68s;" id="mbdpng"><img src="http://via.placeholder.com/150x150"><h3 style="color:white;text-align:center;">Marketing<br />Brand<br />Degital</h3></div>
<div class="flyingthing" style="animation-delay: 7.1s;" id="phonepng"><img src="http://via.placeholder.com/150x150"><h3 style="color:white;text-align:center;">Call Center</h3></div>
<div class="flyingthing" style="animation-delay: 8.52s;" id="musanan"><img src="http://via.placeholder.com/150x150"><h3 style="color:white;text-align:center;">Insurance</h3></div>
</code>```

You have to make sure your wtfigo div fills the area that should be hoverable to stop the animation though.

Title: Stop all webkit-animation on hover

Body:
Hello guys I'm trying to stop all animation when I hover on animated elements but it only pauses each element separately

    .wtfigo:hover {
    -webkit-animation-play-state: paused;
    animation-play-state: paused;
     }
#productstrategy,#businessd,#boardst,#coinfin,#mbdpng,#phonepng,#musanan {

    position: absolute;
    left: 880px;
    top: 425px;

    -webkit-animation: myOrbit 10s linear infinite; /* Chrome, Safari 5 */
       -moz-animation: myOrbit 10s linear infinite; /* Firefox 5-15 */
         -o-animation: myOrbit 10s linear infinite; /* Opera 12+ */
            animation: myOrbit 10s linear infinite; /* Chrome, Firefox 16+,
                                                      IE 10+, Safari 5 */
}
@-webkit-keyframes myOrbit {
    from { -webkit-transform: rotate(0deg) translateX(300px) rotate(0deg); }
    to   { -webkit-transform: rotate(360deg) translateX(300px) rotate(-360deg); }
}

@-moz-keyframes myOrbit {
    from { -moz-transform: rotate(0deg) translateX(300px) rotate(0deg); }
    to   { -moz-transform: rotate(360deg) translateX(300px) rotate(-360deg); }
}

@-o-keyframes myOrbit {
    from { -o-transform: rotate(0deg) translateX(300px) rotate(0deg); }
    to   { -o-transform: rotate(360deg) translateX(300px) rotate(-360deg); }
}

@keyframes myOrbit {
    from { transform: rotate(0deg) translateX(300px) rotate(0deg); }
    to   { transform: rotate(360deg) translateX(300px) rotate(-360deg); }
}

Product Strategy

Business Development

Operations

Financial Advisors

Marketing
Brand
Degital

Call Center

Insurance

Please let me know if there is any way I can pause all animations on hover

Cheers

Body:
Add your animation to a single parent selector so that you can pause it via the same. See simplified code below:

<style>
    #productstrategy,
    #businessd,
    #boardst,
    #coinfin,
    #mbdpng,
    #phonepng,
    #musanan {
        position: absolute;
        left: 880px;
        top: 425px;
    }

    .wtfigo .flyingthing {
        animation: myOrbit 10s linear infinite;
    }

    .wtfigo:hover .flyingthing {
        animation-play-state: paused;
    }

    @keyframes myOrbit {
        from { transform: rotate(0deg) translateX(300px) rotate(0deg); }
        to   { transform: rotate(360deg) translateX(300px) rotate(-360deg); }
    }
</style>

<div class="wtfigo"><div id="productstrategy"><img src="http://via.placeholder.com/150x150"><h3 style="color:white;">Product Strategy</h3></div>
<div class="flyingthing" style="animation-delay: 1.42s;" id="businessd"><img src="http://via.placeholder.com/150x150"><h3 style="color:white;text-align:center;">Business Development</h3></div>
<div class="flyingthing" style="animation-delay: 2.84s;" id="boardst"><img src="http://via.placeholder.com/150x150"><h3 style="color:white;text-align:center;">Operations</h3></div>
<div class="flyingthing" style="animation-delay: 4.26s;" id="coinfin"><img src="http://via.placeholder.com/150x150"><h3 style="color:white;text-align:center;">Financial Advisors</h3></div>
<div class="flyingthing" style="animation-delay: 5.68s;" id="mbdpng"><img src="http://via.placeholder.com/150x150"><h3 style="color:white;text-align:center;">Marketing<br />Brand<br />Degital</h3></div>
<div class="flyingthing" style="animation-delay: 7.1s;" id="phonepng"><img src="http://via.placeholder.com/150x150"><h3 style="color:white;text-align:center;">Call Center</h3></div>
<div class="flyingthing" style="animation-delay: 8.52s;" id="musanan"><img src="http://via.placeholder.com/150x150"><h3 style="color:white;text-align:center;">Insurance</h3></div>

You have to make sure your wtfigo div fills the area that should be hoverable to stop the animation though.