Android: How can I get id/text of all selected radiobuttons in recyclerview

I am building a quiz application.
I have a recyclerview which holds multiple cards, each containing many radiobuttons.
I have a submit button at the end of recyclerview. When a user clicks on submit he gets his scores on how he fared in the quiz.
One approach I thought was to check the selected radiobutton in each view individually and compare its string with the correct answer.
How to implement this functionality?

Screenshots from my app:
Image1
Image2

Android Nullpointer exception crash from SkuDetails

When I run my app on Android 6.0 +, I get this error

Process: com.screenoflight.android2, PID: 21013
                                     java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String utils.SkuDetails.getPrice()' on a null object reference
                                     at com.screenoflight.android2.PurchaseActivity$3.onIabSetupFinished(PurchaseActivity.java:282)
                                     at utils.IabHelper$1.onServiceConnected(IabHelper.java:292)
                                     at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1227)
                                     at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1244)
                                     at android.os.Handler.handleCallback(Handler.java:739)
                                     at android.os.Handler.dispatchMessage(Handler.java:95)
                                     at android.os.Looper.loop(Looper.java:148)
                                     at android.app.ActivityThread.main(ActivityThread.java:5517)
                                     at java.lang.reflect.Method.invoke(Native Method)
                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

I don’t understand why this is happening because when I run on my personal phone Android 5.1, the price of the in-app purchase shows up fine. But when I try my test phone on 6.0 it crashes giving me a null pointer. I’m really stumped on what the issue here is.

mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
        @Override
        public void onIabSetupFinished(IabResult result) {
            if (!result.isSuccess()) {
                Log.d(TAG, result.toString());
            } else {

                Log.d(TAG, "allgood");

            }
        }

    });

    mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
        @Override
        public void onIabSetupFinished(IabResult result) {
            try {
                String price = mHelper.queryInventory(true, null, null).getSkuDetails(ITEM_SKU_5).getPrice();

                Log.d(TAG, price);

                activateButton.setText("Purchase " + price);

I’ve gathered that it’s an issue with the Runtime permissions. I have added the prompt to allow the permissions to run but I’m not sure why it’s not working.

String[] perms = {"android.permission.READ_PHONE_STATE", "android.permission.CALL_PHONE", "android.permission.READ_EXTERNAL_STORAGE", "android.permission.WRITE_EXTERNAL_STORAGE"};

    int permsRequestCode = 200;

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            requestPermissions(perms, permsRequestCode);
        }

I’m completely lost on the reason for this crash aswell, I just don’t get why it’s even after I allow the permissions through.

I just destroyed my Company’s project. What now? [on hold]

This code used to work and I don’t know what I did but if I add servlets in my web.xml everything stops working…

I get a huge error:

SEVERE: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1015)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:991)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at
org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1899)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at
com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at
org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:618)
at
org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:565)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at
com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at
javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
at
javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
at
javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
at
javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401)
at
javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
at sun.rmi.transport.Transport$1.run(Transport.java:200) at
sun.rmi.transport.Transport$1.run(Transport.java:197) at
java.security.AccessController.doPrivileged(Native Method) at
sun.rmi.transport.Transport.serviceCall(Transport.java:196) at
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
at java.security.AccessController.doPrivileged(Native Method) at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748) Caused by:
java.lang.NoClassDefFoundError:
com/github/dockerjava/core/DockerClientConfig at
java.lang.Class.getDeclaredFields0(Native Method) at
java.lang.Class.privateGetDeclaredFields(Class.java:2583) at
java.lang.Class.getDeclaredFields(Class.java:1916) at
org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106)
at
org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:270)
at
org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:139)
at
org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:65)
at
org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:417)
at
org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:891)
at
org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:388)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5519)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
… 42 more Caused by: java.lang.ClassNotFoundException:
com.github.dockerjava.core.DockerClientConfig at
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1892)
at
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1735)
… 56 more

out 20, 2017 4:10:24 PM org.apache.tomcat.util.modeler.BaseModelMBean
invoke SEVERE: Exception invoking method manageApp
java.lang.IllegalStateException: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1019)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:991)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at
org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1899)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at
com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at
org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:618)
at
org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:565)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at
com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at
javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
at
javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
at
javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
at
javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401)
at
javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
at sun.rmi.transport.Transport$1.run(Transport.java:200) at
sun.rmi.transport.Transport$1.run(Transport.java:197) at
java.security.AccessController.doPrivileged(Native Method) at
sun.rmi.transport.Transport.serviceCall(Transport.java:196) at
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
at java.security.AccessController.doPrivileged(Native Method) at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

out 20, 2017 4:10:24 PM org.apache.tomcat.util.modeler.BaseModelMBean
invoke SEVERE: Exception invoking method createStandardContext
javax.management.RuntimeOperationsException: Exception invoking method
manageApp at
org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:309)
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at
com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at
org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:618)
at
org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:565)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at
com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at
javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
at
javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
at
javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
at
javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401)
at
javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
at sun.rmi.transport.Transport$1.run(Transport.java:200) at
sun.rmi.transport.Transport$1.run(Transport.java:197) at
java.security.AccessController.doPrivileged(Native Method) at
sun.rmi.transport.Transport.serviceCall(Transport.java:196) at
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
at java.security.AccessController.doPrivileged(Native Method) at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748) Caused by:
java.lang.IllegalStateException: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1019)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:991)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at
org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1899)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
… 33 more

Code structure

The code works without the servlet tags but there is no errors only a warning “Configure Data Sources”….

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">

    <servlet>
        <servlet-name>GeneralSetup</servlet-name>
        <servlet-class>com.atp.Controllers.ManageGeneralSetup</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>GeneralSetup</servlet-name>
        <url-pattern>/GeneralSetup</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>Clients</servlet-name>
        <servlet-class>com.atp.Controllers.ManageClients</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Clients</servlet-name>
        <url-pattern>/Clients</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>Accounts</servlet-name>
        <servlet-class>com.atp.Controllers.ManageAccounts</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Accounts</servlet-name>
        <url-pattern>/Accounts</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>Transactions</servlet-name>
        <servlet-class>com.atp.Controllers.ManageTransactions</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Transactions</servlet-name>
        <url-pattern>/Transactions</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>Login</servlet-name>
        <servlet-class>com.atp.Controllers.Login</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Login</servlet-name>
        <url-pattern>/Login</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>Logout</servlet-name>
        <servlet-class>com.atp.Controllers.Logout</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Logout</servlet-name>
        <url-pattern>/Logout</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>DockerIntegration</servlet-name>
        <servlet-class>com.atp.Controllers.DockerIntegration</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>DockerIntegration</servlet-name>
        <url-pattern>/DockerIntegration</url-pattern>
    </servlet-mapping>

</web-app>

Communication in Netty Nio java

I want to create a communication system with two clients and a server in Netty nio. More specifically, firstly, I want when two clietns are connected to send a true message from the server and after that to be able to echnage information between the two clients. I am using the code provided from this example. The code from ClientHandler:

public class ClientHandler extends ChannelInboundHandlerAdapter {
 public final Promise<Object> promise;
 public ClientHandler(Promise<Object> promise) {
    this.promise = promise;
 }
 @Override
 public void channelActive(ChannelHandlerContext ctx) throws Exception {
    RequestData msg = new RequestData();
    msg.setIntValue(123);
    msg.setStringValue("all work and no play makes jack a dull boy");
    ctx.writeAndFlush(msg);
 }

 @Override
 public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
    System.out.println(msg);
    promise.trySuccess(msg);
    ctx.close();
 }
} 

The code for the server handler:

public class ProcessingHandler extends ChannelInboundHandlerAdapter {
 final ChannelGroup channels =
         new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
 @Override
 public void channelActive(ChannelHandlerContext ctx) throws Exception {
 }
 @Override
 public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
     RequestData requestData = (RequestData) msg;
     ResponseData responseData = new ResponseData();
     channels.add(ctx.channel());

     for (Channel ch : channels) {
         System.out.println(ch);
     }

     if(channels.size() == 2) {
         responseData.setIntValue(1);
         ChannelFuture future = ctx.writeAndFlush(responseData);
         future.addListener(ChannelFutureListener.CLOSE);
         System.out.println(requestData);
     }
     else {
         responseData.setIntValue(0);
         ChannelFuture future = ctx.writeAndFlush(responseData);
         future.addListener(ChannelFutureListener.CLOSE);
         System.out.println(requestData);
     }
 }
}

And the main code for the Client is:

public class NettyClient {
 public static void main(String[] args) throws Exception {
     String host = "localhost";
     int port = 8080;
     EventLoopGroup workerGroup = new NioEventLoopGroup();
     Promise<Object> promise = workerGroup.next().newPromise();

     try {
         Bootstrap b = new Bootstrap();
         b.group(workerGroup);
         b.channel(NioSocketChannel.class);
         b.option(ChannelOption.SO_KEEPALIVE, true);
         b.handler(new ChannelInitializer<SocketChannel>() {
             @Override
             public void initChannel(SocketChannel ch) throws Exception {
                ch.pipeline().addLast(new RequestDataEncoder(), new ResponseDataDecoder(), new ClientHandler(promise));
             }
         });

         ChannelFuture f = b.connect(host, port).sync();

         Object msg = promise.get();
         System.out.println(msg.toString());

         f.channel().closeFuture().sync();
     }
     finally {
         workerGroup.shutdownGracefully();
     }
 }
}

It seems that the channelRead in the serverHandler works when the first client is connceted so it always return 1 but when a second client is connected does not change to 2. How can I check properly from the server when both clients are connected to the server? How can I read this value dynamically from my main function of the Client? Then which is the best way to let both clients communicate?

How do I avoid using if statements with a large amount of variables in java

I am attempting to create a program that asks for the user to input the name of 6 items out of a large list. It then totals up all the attributes of said items and displays the total of all the attributes as well as the cost. The only way I can see doing this would require a huge amount of if and else if statements along with a for loop. With the amount of items I need to use it would be atleast 1000 lines long of if and else statements and that would take a whole lot of time to write out.

Here is a sample of my code

import java.util.Scanner;
public class MyProgram
{
public static void main(String[] args)
  {
    Scanner one = new Scanner(System.in);
    System.out.print("Champion: ");
    String champion = one.next();
    System.out.print("Item 1: ");
    String item1 = one.next();
    System.out.print("Item 2: ");
    String item2 = one.next();
    System.out.print("Item 3: ");
    String item3 = one.next();
    System.out.print("Item 4: ");
    String item4 = one.next();
    System.out.print("Item 5: ");
    String item5 = one.next();
    System.out.print("Item 6: ");
    String item6 = one.next();
    int totalhealth = 0;
    int totalad = 0;
    int totalap = 0;
    int totalarmor = 0;
    int totalmr = 0;
    int totalcdr = 0;
    int totalmana = 0;
    int totalcstr= 0;
    int totalls = 0;
    int totalatcksp = 0;
    int totalcost = 0;
    for(int i = 0; i < 6; i++)
    {
        int itemhealth = 0;
        int itemad = 0;
        int itemap = 0;
        int itemarmor = 0;
        int itemmr = 0;
        int itemcdr = 0;
        int itemmana = 0;
        int itemcstr = 0;
        int itemls = 0;
        int itematcksp = 0;
        int itemcost = 0;
        if(i == 0)
        {
            if(item1.equals("abyssal mask"))
        {
            itemhealth = 350;
            itemmana = 300;
            itemmr = 55;
            itemcdr = 10;
            itemcost = 2900;
        }
        else if (item1.equals("adaptive helm"))
        {
            itemhealth = 350;
            itemmr = 55;
            itemcdr = 10;
            itemcost = 2800;
        }
        else if (item1.equals("aegis of the legion"))
        {
            itemarmor = 30;
            itemmr = 30;
            itemcost = 1100;
        }
        else if (item1.equals("aether wisp"))
        {
            itemap = 30;
            itemcost = 850;
        }
        else if (item1.equals("amplifying tome"))
        {
         itemap = 20;
         itemcost = 435;
        }
        else if (item1.equals("ancient coin"))
        {
            itemcdr = 5;
            itemcost = 350;
        }
        else if (item1.equals("archangel's staff"))
        {
            itemap = 80;
            itemmana = 250;
            itemcost = 3100;
        }
        else if (item1.equals("ardent censer"))
        {
            itemap = 60;
            itemcdr = 10;
            itemcost = 2300;
        }
        else if (item1.equals("athene's unholy grail"))
        {
            itemap= 30;
            itemmr = 30;
            itemcdr = 10;
            itemcost = 2100;
        }
        else if (item1.equals("b.f.sword"))
        {
            itemad = 40;
            itemcost = 1300;
        }
        else if (item1.equals("bami's cinder"))
        {
            itemhealth = 200;
            itemcost = 900;
        }
    }
        if(i == 1)
    {
        if(item2.equals("abyssal mask"))
        {
            itemhealth = 350;
            itemmana = 300;
            itemmr = 55;
            itemcdr = 10;
            itemcost = 2900;
        }
        else if (item2.equals("adaptive helm"))
        {
            itemhealth = 350;
            itemmr = 55;
            itemcdr = 10;
            itemcost = 2800;
        }
        else if (item2.equals("aegis of the legion"))
        {
            itemarmor = 30;
            itemmr = 30;
            itemcost = 1100;
        }
        else if (item2.equals("aether wisp"))
        {
            itemap = 30;
            itemcost = 850;
        }
        else if (item2.equals("amplifying tome"))
        {
         itemap = 20;
         itemcost = 435;
        }
        else if (item2.equals("ancient coin"))
        {
            itemcdr = 5;
            itemcost = 350;
        }
        else if (item2.equals("archangel's staff"))
        {
            itemap = 80;
            itemmana = 250;
            itemcost = 3100;
        }
        else if (item2.equals("ardent censer"))
        {
            itemap = 60;
            itemcdr = 10;
            itemcost = 2300;
        }
        else if (item2.equals("athene's unholy grail"))
        {
            itemap= 30;
            itemmr = 30;
            itemcdr = 10;
            itemcost = 2100;
        }
        else if (item2.equals("b.f.sword"))
        {
            itemad = 40;
            itemcost = 1300;
        }
        else if (item2.equals("bami's cinder"))
        {
            itemhealth = 200;
            itemcost = 900;
        }

    }
    if(i == 2)
    {
        if(item3.equals("abyssal mask"))
        {
            itemhealth = 350;
            itemmana = 300;
            itemmr = 55;
            itemcdr = 10;
            itemcost = 2900;
        }
        else if (item3.equals("adaptive helm"))
        {
            itemhealth = 350;
            itemmr = 55;
            itemcdr = 10;
            itemcost = 2800;
        }
        else if (item3.equals("aegis of the legion"))
        {
            itemarmor = 30;
            itemmr = 30;
            itemcost = 1100;
        }
        else if (item3.equals("aether wisp"))
        {
            itemap = 30;
            itemcost = 850;
        }
        else if (item3.equals("amplifying tome"))
        {
         itemap = 20;
         itemcost = 435;
        }
        else if (item3.equals("ancient coin"))
        {
            itemcdr = 5;
            itemcost = 350;
        }
        else if (item3.equals("archangel's staff"))
        {
            itemap = 80;
            itemmana = 250;
            itemcost = 3100;
        }
        else if (item3.equals("ardent censer"))
        {
            itemap = 60;
            itemcdr = 10;
            itemcost = 2300;
        }
        else if (item3.equals("athene's unholy grail"))
        {
            itemap= 30;
            itemmr = 30;
            itemcdr = 10;
            itemcost = 2100;
        }
        else if (item3.equals("b.f.sword"))
        {
            itemad = 40;
            itemcost = 1300;
        }
        else if (item3.equals("bami's cinder"))
        {
            itemhealth = 200;
            itemcost = 900;
        }
    }
        if(i == 3)
    {
        if(item4.equals("abyssal mask"))
        {
            itemhealth = 350;
            itemmana = 300;
            itemmr = 55;
            itemcdr = 10;
            itemcost = 2900;
        }
        else if (item4.equals("adaptive helm"))
        {
            itemhealth = 350;
            itemmr = 55;
            itemcdr = 10;
            itemcost = 2800;
        }
        else if (item4.equals("aegis of the legion"))
        {
            itemarmor = 30;
            itemmr = 30;
            itemcost = 1100;
        }
        else if (item4.equals("aether wisp"))
        {
            itemap = 30;
            itemcost = 850;
        }
        else if (item4.equals("amplifying tome"))
        {
         itemap = 20;
         itemcost = 435;
        }
        else if (item4.equals("ancient coin"))
        {
            itemcdr = 5;
            itemcost = 350;
        }
        else if (item4.equals("archangel's staff"))
        {
            itemap = 80;
            itemmana = 250;
            itemcost = 3100;
        }
        else if (item4.equals("ardent censer"))
        {
            itemap = 60;
            itemcdr = 10;
            itemcost = 2300;
        }
        else if (item4.equals("athene's unholy grail"))
        {
            itemap= 30;
            itemmr = 30;
            itemcdr = 10;
            itemcost = 2100;
        }
        else if (item4.equals("b.f.sword"))
        {
            itemad = 40;
            itemcost = 1300;
        }
        else if (item4.equals("bami's cinder"))
        {
            itemhealth = 200;
            itemcost = 900;
        }
    }
        if(i == 4)
    {
        if(item5.equals("abyssal mask"))
        {
            itemhealth = 350;
            itemmana = 300;
            itemmr = 55;
            itemcdr = 10;
            itemcost = 2900;
        }
        else if (item5.equals("adaptive helm"))
        {
            itemhealth = 350;
            itemmr = 55;
            itemcdr = 10;
            itemcost = 2800;
        }
        else if (item5.equals("aegis of the legion"))
        {
            itemarmor = 30;
            itemmr = 30;
            itemcost = 1100;
        }
        else if (item5.equals("aether wisp"))
        {
            itemap = 30;
            itemcost = 850;
        }
        else if (item5.equals("amplifying tome"))
        {
         itemap = 20;
         itemcost = 435;
        }
        else if (item5.equals("ancient coin"))
        {
            itemcdr = 5;
            itemcost = 350;
        }
        else if (item5.equals("archangel's staff"))
        {
            itemap = 80;
            itemmana = 250;
            itemcost = 3100;
        }
        else if (item5.equals("ardent censer"))
        {
            itemap = 60;
            itemcdr = 10;
            itemcost = 2300;
        }
        else if (item5.equals("athene's unholy grail"))
        {
            itemap= 30;
            itemmr = 30;
            itemcdr = 10;
            itemcost = 2100;
        }
        else if (item5.equals("b.f.sword"))
        {
            itemad = 40;
            itemcost = 1300;
        }
        else if (item5.equals("bami's cinder"))
        {
            itemhealth = 200;
            itemcost = 900;
        }
    }
        if(i == 5)
    {
        if(item6.equals("abyssal mask"))
        {
            itemhealth = 350;
            itemmana = 300;
            itemmr = 55;
            itemcdr = 10;
            itemcost = 2900;
        }
        else if (item6.equals("adaptive helm"))
        {
            itemhealth = 350;
            itemmr = 55;
            itemcdr = 10;
            itemcost = 2800;
        }
        else if (item6.equals("aegis of the legion"))
        {
            itemarmor = 30;
            itemmr = 30;
            itemcost = 1100;
        }
        else if (item6.equals("aether wisp"))
        {
            itemap = 30;
            itemcost = 850;
        }
        else if (item6.equals("amplifying tome"))
        {
         itemap = 20;
         itemcost = 435;
        }
        else if (item6.equals("ancient coin"))
        {
            itemcdr = 5;
            itemcost = 350;
        }
        else if (item6.equals("archangel's staff"))
        {
            itemap = 80;
            itemmana = 250;
            itemcost = 3100;
        }
        else if (item6.equals("ardent censer"))
        {
            itemap = 60;
            itemcdr = 10;
            itemcost = 2300;
        }
        else if (item6.equals("athene's unholy grail"))
        {
            itemap= 30;
            itemmr = 30;
            itemcdr = 10;
            itemcost = 2100;
        }
        else if (item6.equals("b.f.sword"))
        {
            itemad = 40;
            itemcost = 1300;
        }
        else if (item6.equals("bami's cinder"))
        {
            itemhealth = 200;
            itemcost = 900;
        }
    }
System.out.println("Champion: " + champion);
System.out.println("Total health: " + totalhealth);
System.out.println("Total AD: " + totalad);
System.out.println("Total AP: " + totalap);
System.out.println("Total armor: " + totalarmor);
System.out.println("Total magic resist" + totalmr);
System.out.println("Total CDR: %" + totalcdr);
System.out.println("Total mana: " + totalmana);
System.out.println("Total Critical Strike Chance: " + totalcstr);
System.out.println("Total Life Steal: %" + totalls);
System.out.println("Total Attack Speed: " + totalatcksp);
System.out.println("Total Cost: " + totalcost + "g");


    }
  }
}

I am a highschool student on my first year of CS. This may have a simple answer that I am unaware of so I am open to all answers, even the most obvious.

API call Throwing error during verification in JAVA

I am try to make an API call with below code . I am able to print till “getMMHost();” in below code . After that , I get error as :

[java] org.apache.http.impl.client.ClientParamsStack@3e694b3f
[java] res  code  : 405
[java] java.lang.ArrayIndexOutOfBoundsException: 1
BUILD SUCCESSFUL

Code :

String url ="/api//sr?bid="+cluster+"&mode=1";
	System.out.println(url);  
	
	HttpHost httpHost = getMMHost();
	System.out.println(httpHost);  //(I am able to print till here )
	

	DefaultHttpClient httpclient = (DefaultHttpClient) verifiedClient(new DefaultHttpClient());
	
	
	HttpPost httpost = verifiedPost(url,user,password);
	
	HttpResponse response = httpclient.execute(httpHost, httpost);
	
	System.out.println(response.getParams());
	int respCode = response.getStatusLine().getStatusCode();

I aint sure if the info I have provided is enough . Can it be related to the SSL of httpClient ? DO I need to POST the URL and the credentials ? THis thing is driving me crazy .Any help is much appreciated .

which paypal api to use to accept both paypal and credit/debit card from any country

whic paypal api should i use if i have a paypal merchant account, to which i would like to accept paypal e-wallet and credit/debit card payments from any country?

i would later also like to be able to refund payments(in some cases), and also to transfer money to other paypal accounts.

i see the REST API doe not support accepting payments via credit/debit cards. is this correct?

what about using BrainTree new SDK API?

we are using Java in our web server, and would like to use java SDK or REST API..

Add Security header to SOAP Request for Skillsoft (Java)

I’m a Java/SQL developer with no experience in web services, but I’ve been tasked with developing an automation solution for synchronizing the users and user groups in our HR system with Skillsoft. I have installed Ant 1.9.9, Axis 1.4, Olsa Toolkit 8.0, and SoapUI 5.3.0. We are generating a csv for users and groups from a separate database, and I have a Java class (from another project) that reads a csv, transforms the data to the required format, and spits out another csv.

So far in SoapUI, I have been able to read the WSDL and create a mock service that responds to requests. I know I can read the csv and output the entire SOAP request in a text file of some kind, but this is where I’m unsure of how to proceed. Skillsoft requires a WSS username token that can’t be hardcoded, so I’m unsure of how to programmatically add it and execute the request from a command line.

What tools should I explore? How do I run all of this from the command line on our application server?

codename one Mediaplayer slider

I am trying to create a music playing app in codename one ,I am having problems when adding a slider to the media player.the slider is displayed when the app runs but it doesnt show the progress when the file is being played .this is the code i used to add custom play and pause buttons as well as the slider

     try {
     video = MediaManager.createMedia(sample_url, false);
     myslider.setMinValue(0);
     myslider.setMaxValue(video.getDuration()/1000);
     myslider.setIncrements(1);
     myslider.addDataChangedListener(new DataChangedListener(){
         @Override
         public void dataChanged(int type, int index) {
            video.setTime(myslider.getProgress()*1000);

         }
     });


      } catch (Exception err) {
        Log.e(err);
        ToastBar.Status status = ToastBar.getInstance().createStatus();
           status.setMessage(" error loading sample file");
           status.show();
           status.clear();

    }
     sample.add(BorderLayout.SOUTH,myslider);

    play.addActionListener(new ActionListener(){
        @Override
        public void actionPerformed(ActionEvent evt) {
           //To change body of generated methods, choose Tools | Templates.
           //StreamFile(songDetails,sample_url);

          if(!video.isPlaying()){

          video.play();
           sample.removeComponent(play);
           sample.revalidate();
           sample.add(BorderLayout.WEST,pause);
           sample.revalidate();


          }

        }
    });
    pause.addActionListener(new ActionListener(){
        @Override
        public void actionPerformed(ActionEvent evt) {
            //To change body of generated methods, choose Tools | Templates.
            if(video.isPlaying()){
            video.pause();
            sample.removeComponent(pause);
            sample.revalidate();
           sample.add(BorderLayout.WEST,play);
           sample.revalidate();

            }
        }
    });