问:
How do i call one Mutator/Setter from another in java?
```<code>package finalproject;

public class FinalProject

{

 //------------------------------- Attributes --------------------------------

    public String name;
    public double cout;
    public int choice;
    public Double temp;
    public Double salary;
    public  Double salary2;
    public  Double salary3;
    public Double share;
    public Double hdmf;
    public Double sss;
    public Double tax;
    public Double basicsalary;
    public Double netpay;

  //------------------------------- Constructor --------------------------------

 public FinalProject (){

    this.name="";
    this.cout=0.0;
    this.temp=0.0;
    this.choice = 0;
    this.basicsalary = 0.0;
    this.salary=0.0;
    this.salary2=salary;
    this.salary3=0.0;
    this.share=0.0;
    this.hdmf=0.0;
    this.sss=0.0;
    this.tax=0.0;
    this.netpay = 0.0;
    }

 //------------------------------- Setter --------------------------------

public void setName(String name){

    this.name=name;
}

public void setCout(Double salary){

    if (salary < 30000.00){
          System.out.print("\n ----------------- \n RESULT:");
       System.out.print("\nYour Position is Staff" + "\n");
    }

    else if (salary >= 30000.00 && salary <= 49999.00){
          System.out.print("\n ----------------- \n RESULT:");
        System.out.print("\nYour Position is Supervisor"+ "\n");
    }

    else if (salary >= 50000.00 && salary <= 79999.00){
          System.out.print("\n ----------------- \n RESULT:");
        System.out.print("\nYour Position is Manager"+ "\n");
    }

     else if (salary >= 80000.00 && salary <= 100000.00){
           System.out.print("\n ----------------- \n RESULT:");
        System.out.print("\nYour Position is Junior Officer"+ "\n");
    }

     else if (salary > 100001.00){
           System.out.print("\n ----------------- \n RESULT:");
        System.out.print("\nYour Position is Senior Officer"+ "\n");
    }
   // salary = cout;

}

public void setChoice(int choice){

    this.choice=choice;
}

public void setBasicsalary(Double basicsalary){

    this.basicsalary = basicsalary;
}

public void setNetpay(Double netpay){

    netpay = -this.salary - this.hdmf - this.salary3 - this.tax;
            this.netpay=netpay;
}

public void setSalary(Double salary){

    if(salary <= 8999.99 )
        {
            salary = 100.00;

        }

    else if(salary >= 9000 && salary <= 9999.99)
    {
        salary = 112.50;

    }

    else if(salary >= 10000 && salary <= 10999.99)
    {
        salary = 125.00;

    }

    else if(salary >= 11000 && salary <= 11999.99)
    {
        salary = 137.50;

    }

    else if(salary >= 12000 && salary <= 12999.99)
    {
        salary = 150.00;

    }

    else if(salary >= 13000 && salary <= 13999.99)
    {
        salary = 162.50;

    }

    else if(salary >= 14000 && salary <= 14999.99)
    {
        salary = 175.50;

    }

    else if(salary >= 15000 && salary <= 15999.99)
    {
        salary = 187.50;

    }

    else if(salary >= 16000 && salary <= 16999.99)
    {
        salary = 200.00;

    }

    else if(salary >= 17000 && salary <= 17999.99)
    {
        salary = 212.50;

    }

    else if(salary >= 18000 && salary <= 18999.99)
    {
        salary = 225.00;

    }

    else if(salary >= 19000 && salary <= 19999.99)
    {
        salary = 237.50;

    }

    else if(salary >= 20000 && salary <= 20999.99)
    {
        salary = 250.00;

    }

    else if(salary >= 21000 && salary <= 21999.99)
    {
        salary = 262.50;

    }

    else if(salary >= 22000 && salary <= 22999.99)
    {
        salary = 275.00;

    }

    else if(salary >= 23000 && salary <= 23999.99)
    {
        salary = 287.50;

    }

    else if(salary >= 24000 && salary <= 24999.99)
    {
        salary = 300.00;

    }

    else if(salary >= 25000 && salary <= 25999.99)
    {
        salary = 312.50;

    }

    else if(salary >= 26000 && salary <= 26999.99)
    {
        salary = 325.00;

    }

    else if(salary >= 27000 && salary <= 27999.99)
    {
        salary = 337.50;

    }

    else if(salary >= 28000 && salary <= 28999.99)
    {
        salary = 350.00;

    }

    else if(salary >= 29000 && salary <= 29999.99)
    {
        salary = 362.50;

    }

    else if(salary >= 30000 && salary <= 30999.99)
    {
        salary = 375.00;

    }

    else if(salary >= 31000 && salary <= 31999.99)
    {
        salary = 387.50;

    }

    else if(salary >= 32000 && salary <= 32999.99)
    {
        salary = 400.00;

    }

    else if(salary >= 33000 && salary <= 33999.99)
    {
        salary = 412.50;

    }

    else if(salary >= 34000 && salary <= 34999.99)
    {
        salary = 425.00;

    }

    else if(salary >= 35000)
    {
        salary = 437.50;

    }

    this.salary=salary;

}
public void setSalary2(Double salary2){

    this.salary2=salary2;
}

public void temp(Double temp){

    this.temp=temp;
}

public void setSalary3(Double salary3){

     if(this.salary3 < 30000){
       salary3 = salary3 * 0.05;
    }

    else if (this.salary3 >= 30000 && this.salary3 <= 49999){
       salary3 = salary3 * 0.07;
    }

    else if (this.salary3 >= 50000 && this.salary3 <= 79999){
        salary3 = salary3 * 0.08;
    }

     else if (this.salary3 >= 80000 && this.salary3 <= 100000){
         salary3 =salary3 * 0.1;
    }

     else if (this.salary3 > 100001){
        salary3 = salary3 * 0.15;
    }

    this.salary3=salary3;
}

public void setShare(Double share){

    this.share=share;
}

public void setTemp(Double temp){

    this.temp=temp;
}

public void setHdmf(Double hdmf){

    if(hdmf > 100){
            System.out.print("Prefered HDMF value has been entered" + "\n");

              this.hdmf = hdmf;

        }
        else if(hdmf == 0){
            System.out.print("Default has been chosen to deduct 100 HDMF" + "\n");
            salary2 = 100.00;
             this.hdmf = salary2;
        }

}

public void setSss(Double sss){

    this.sss = sss * 0.50;
}

public void setTax(Double tax){

    this.tax = tax * 0.50;

}

//getter

public String getName(){

    return this.name;
}

public Double getCout(){

    return this.cout;
}

public int getChoice(){

    return this.choice;
}

public Double getBasicsalary(){

    return this.basicsalary;
}

public Double getNetpay(){

    return this.netpay;
}

public Double getSalary(){

    return this.salary;
}

public Double getTemp(){

    return this.temp;
}

public Double getSalary2(){

    return this.salary2;
}

public Double getSalary3(){

    return this.salary3;
}

public Double getShare(){

    return this.share;
}

public Double getHdmf(){

    return this.hdmf;
}

public Double getSss(){

    return this.sss;
}

public Double getTax(){

    return this.tax;
}

}
</code>```

<p>//------------------------------- Main Class --------------------------------</p>

```<code>package finalproject;

import java.util.Scanner;

public class FinalProjectMain {

    public static void main(String[] args)
    {

        Scanner input = new Scanner(System.in);

        FinalProject output1 = new FinalProject();//name
        FinalProject output2 = new FinalProject();//share
        FinalProject output3 = new FinalProject(); //hdmf //salary2
        FinalProject output4 = new FinalProject();//sss
        FinalProject output5 = new FinalProject();//position
        FinalProject output6 = new FinalProject();//tax
        FinalProject output7 = new FinalProject();//Basicsalary
        FinalProject output8 = new FinalProject();//netpay

       FinalProject output = new FinalProject();

        System.out.print("Good day! To you Sir/ma`am Thanks for helping me our program requires you to input your (basic salary) multiple times in order for us to compute your netpay");
        System.out.print("\n");
        System.out.print("Thank you Sir Have a Good day.");

           System.out.print("\n");
              System.out.print("\n");
                 System.out.print("\n");
                    System.out.print("\n");
                       System.out.print("\n");

        System.out.print("Enter Employee name: ");
        output1.setName(input.nextLine());

        System.out.print("Enter your basic salary: ");
        output7.setBasicsalary(input.nextDouble());

        System.out.print("Please Enter Your basic salary again to compute the philhealth contribution: ");
        output2.setSalary(input.nextDouble());

        System.out.print("Please Enter your basic salary again to compute the hdmf: ");
        output3.setSalary2(input.nextDouble());

        System.out.print("Please Enter the amount of HDMF you want to share: \n otherwise Enter 0 to deduct the default 100 HDMF share: \n");
        output3.setHdmf(input.nextDouble());

        System.out.print("Please Enter your basic salary again to deduct the SSS in your salary: ");
        output4.setSalary3(input.nextDouble());

        System.out.print("\n\nSSS deduction is: " + output4.getSalary3());
        System.out.print("\n");

        System.out.print("(Please Enter the SSS duduction value above to compute the your tax): ");
        output6.setTax(input.nextDouble());

        System.out.print("Please Enter again your basic salary to compute your netpay: ");
        output8.setNetpay(input.nextDouble());

        System.out.print("Enter your basic salary again to determine your position: ");
        output5.setCout(input.nextDouble());

         System.out.print("Employee name is: " + output1.getName());
         System.out.print("\n");

         System.out.print("Your basic salary is: " + output7.getBasicsalary());
         System.out.print("\n");

         System.out.print("Philhealth contribution is: " + output2.getSalary());
         System.out.print("\n");

         System.out.print("Your HDMF share is: " + output3.getHdmf());
         System.out.print("\n");
         System.out.print("SSS deduction is: " + output4.getSalary3());
         System.out.print("\n");
         System.out.print("Your deduction Tax is: " + output6.getTax());
         System.out.print("\n");
         System.out.print("Your netpay is: " + output8.getNetpay());

    }
}
</code>```

答:
```<code>    Please check carefully that, you have initiate multiple "FinalProject" object,
</code>```

do just a single time "FinalProject output = new FinalProject();" at main method

```<code>    please find code here -

    /*--------------- FinalProject Class Begin ------------ */
    package teststack;

    public class FinalProject

    {

    //------------------------------- Attributes --------------------------------

    public String name;
    public double cout;
    public int choice;
    public Double temp;
    public Double salary;
    public  Double salary2;
    public  Double salary3;
    public Double share;
    public Double hdmf;
    public Double sss;
    public Double tax;
    public Double basicsalary;
    public Double netpay;

    //------------------------------- Constructor --------------------------------

    public FinalProject (){

    this.name="";
    this.cout=0.0;
    this.temp=0.0;
    this.choice = 0;
    this.basicsalary = 0.0;
    this.salary=0.0;
    this.salary2=salary;
    this.salary3=0.0;
    this.share=0.0;
    this.hdmf=0.0;
    this.sss=0.0;
    this.tax=0.0;
    this.netpay = 0.0;
    }

    //------------------------------- Setter --------------------------------

    public void setName(String name){

    this.name=name;

    }

    public void setCout(Double salary){

    if (salary < 30000.00){
          System.out.print("\n ----------------- \n RESULT:");
       System.out.print("\nYour Position is Staff" + "\n");
    }

    else if (salary >= 30000.00 && salary <= 49999.00){
          System.out.print("\n ----------------- \n RESULT:");
        System.out.print("\nYour Position is Supervisor"+ "\n");
    }

    else if (salary >= 50000.00 && salary <= 79999.00){
          System.out.print("\n ----------------- \n RESULT:");
        System.out.print("\nYour Position is Manager"+ "\n");
    }

     else if (salary >= 80000.00 && salary <= 100000.00){
           System.out.print("\n ----------------- \n RESULT:");
        System.out.print("\nYour Position is Junior Officer"+ "\n");
    }

     else if (salary > 100001.00){
           System.out.print("\n ----------------- \n RESULT:");
        System.out.print("\nYour Position is Senior Officer"+ "\n");
    }

    // salary = cout;

    }

    public void setChoice(int choice){

    this.choice=choice;

    }

    public void setBasicsalary(Double basicsalary){

    this.basicsalary = basicsalary;

    }

    public void setNetpay(Double netpay){

    netpay = -this.salary - this.hdmf - this.salary3 - this.tax;
            this.netpay=netpay;

    }

    public void setSalary(Double salary){

    if(salary <= 8999.99 )
        {
            salary = 100.00;

        }

    else if(salary >= 9000 && salary <= 9999.99)
    {
        salary = 112.50;

    }

    else if(salary >= 10000 && salary <= 10999.99)
    {
        salary = 125.00;

    }

    else if(salary >= 11000 && salary <= 11999.99)
    {
        salary = 137.50;

    }

    else if(salary >= 12000 && salary <= 12999.99)
    {
        salary = 150.00;

    }

    else if(salary >= 13000 && salary <= 13999.99)
    {
        salary = 162.50;

    }

    else if(salary >= 14000 && salary <= 14999.99)
    {
        salary = 175.50;

    }

    else if(salary >= 15000 && salary <= 15999.99)
    {
        salary = 187.50;

    }

    else if(salary >= 16000 && salary <= 16999.99)
    {
        salary = 200.00;

    }

    else if(salary >= 17000 && salary <= 17999.99)
    {
        salary = 212.50;

    }

    else if(salary >= 18000 && salary <= 18999.99)
    {
        salary = 225.00;

    }

    else if(salary >= 19000 && salary <= 19999.99)
    {
        salary = 237.50;

    }

    else if(salary >= 20000 && salary <= 20999.99)
    {
        salary = 250.00;

    }

    else if(salary >= 21000 && salary <= 21999.99)
    {
        salary = 262.50;

    }

    else if(salary >= 22000 && salary <= 22999.99)
    {
        salary = 275.00;

    }

    else if(salary >= 23000 && salary <= 23999.99)
    {
        salary = 287.50;

    }

    else if(salary >= 24000 && salary <= 24999.99)
    {
        salary = 300.00;

    }

    else if(salary >= 25000 && salary <= 25999.99)
    {
        salary = 312.50;

    }

    else if(salary >= 26000 && salary <= 26999.99)
    {
        salary = 325.00;

    }

    else if(salary >= 27000 && salary <= 27999.99)
    {
        salary = 337.50;

    }

    else if(salary >= 28000 && salary <= 28999.99)
    {
        salary = 350.00;

    }

    else if(salary >= 29000 && salary <= 29999.99)
    {
        salary = 362.50;

    }

    else if(salary >= 30000 && salary <= 30999.99)
    {
        salary = 375.00;

    }

    else if(salary >= 31000 && salary <= 31999.99)
    {
        salary = 387.50;

    }

    else if(salary >= 32000 && salary <= 32999.99)
    {
        salary = 400.00;

    }

    else if(salary >= 33000 && salary <= 33999.99)
    {
        salary = 412.50;

    }

    else if(salary >= 34000 && salary <= 34999.99)
    {
        salary = 425.00;

    }

    else if(salary >= 35000)
    {
        salary = 437.50;

    }

    this.salary=salary;

    } public void setSalary2(Double salary2){

    this.salary2=salary2;

    }

    public void temp(Double temp){

    this.temp=temp;

    }

    public void setSalary3(Double salary3){

     if(this.salary3 < 30000){
       salary3 = salary3 * 0.05;
    }

    else if (this.salary3 >= 30000 && this.salary3 <= 49999){
       salary3 = salary3 * 0.07;
    }

    else if (this.salary3 >= 50000 && this.salary3 <= 79999){
        salary3 = salary3 * 0.08;
    }

     else if (this.salary3 >= 80000 && this.salary3 <= 100000){
         salary3 =salary3 * 0.1;
    }

     else if (this.salary3 > 100001){
        salary3 = salary3 * 0.15;
    }

    this.salary3=salary3;

    }

    public void setShare(Double share){

    this.share=share;

    }

    public void setTemp(Double temp){

    this.temp=temp;

    }

    public void setHdmf(Double hdmf){

    if(hdmf > 100){
            System.out.print("Prefered HDMF value has been entered" + "\n");

              this.hdmf = hdmf;

        }
        else if(hdmf == 0){
            System.out.print("Default has been chosen to deduct 100 HDMF" + "\n");
            salary2 = 100.00;
             this.hdmf = salary2;
        }

    }

    public void setSss(Double sss){

    this.sss = sss * 0.50;

    }

    public void setTax(Double tax){

    this.tax = tax * 0.50;

    }

    //getter

    public String getName(){

    return this.name;

    }

    public Double getCout(){

    return this.cout;

    }

    public int getChoice(){

    return this.choice;

    }

    public Double getBasicsalary(){

    return this.basicsalary;

    }

    public Double getNetpay(){

    return this.netpay;

    }

    public Double getSalary(){

    return this.salary;

    }

    public Double getTemp(){

    return this.temp;

    }

    public Double getSalary2(){

    return this.salary2;

    }

    public Double getSalary3(){

    return this.salary3;

    }

    public Double getShare(){

    return this.share;

    }

    public Double getHdmf(){

    return this.hdmf;

    }

    public Double getSss(){

    return this.sss;

    }

    public Double getTax(){

    return this.tax;

    }

    }

    /*--------------- FinalProject Class End ------------ */

    /*--------------- FinalProjectMain Class Begin ------------ */

    package teststack;

import java.util.Scanner;

public class FinalProjectMain {

public static void main(String[] args)
{

    try{
    Scanner input = new Scanner(System.in);
    FinalProject output = new FinalProject();

    System.out.print("Good day! To you Sir/ma`am Thanks for helping me our program requires you to input your (basic salary) multiple times in order for us to compute your netpay");
    System.out.print("\nThank you Sir Have a Good day.\n\n\n");
    System.out.print("Enter Employee name: ");
    output.setName(input.nextLine());

    System.out.print("Enter your basic salary: ");
    output.setBasicsalary(input.nextDouble());

    System.out.print("Please Enter Your basic salary again to compute the philhealth contribution: ");
    output.setSalary(input.nextDouble());

    System.out.print("Please Enter your basic salary again to compute the hdmf: ");
    output.setSalary2(input.nextDouble());

    System.out.print("Please Enter the amount of HDMF you want to share: \n otherwise Enter 0 to deduct the default 100 HDMF share: \n");
    output.setHdmf(input.nextDouble());

    System.out.print("Please Enter your basic salary again to deduct the SSS in your salary: ");
    output.setSalary3(input.nextDouble());

    System.out.print("\n\nSSS deduction is: " + output.getSalary3());
    System.out.print("\n");

    System.out.print("(Please Enter the SSS duduction value above to compute the your tax): ");
    output.setTax(input.nextDouble());

    System.out.print("Please Enter again your basic salary to compute your netpay: ");
    output.setNetpay(input.nextDouble());

    System.out.print("Enter your basic salary again to determine your position: ");
    output.setCout(input.nextDouble());

     System.out.print("Employee name is: " + output.getName());
     System.out.print("\n");

     System.out.print("Your basic salary is: " + output.getBasicsalary());
     System.out.print("\n");

     System.out.print("Philhealth contribution is: " + output.getSalary());
     System.out.print("\n");

     System.out.print("Your HDMF share is: " + output.getHdmf());
     System.out.print("\n");
     System.out.print("SSS deduction is: " + output.getSalary3());
     System.out.print("\n");
     System.out.print("Your deduction Tax is: " + output.getTax());
     System.out.print("\n");
     System.out.print("Your netpay is: " + output.getNetpay());
    } catch (Exception e){
        System.out.println("ex : "+e);
    }

}

}

    /*--------------- FinalProjectMain Class End ------------ */
</code>```

Body:
package finalproject;

public class FinalProject

{

 //------------------------------- Attributes --------------------------------

    public String name;
    public double cout;
    public int choice;
    public Double temp;
    public Double salary;
    public  Double salary2;
    public  Double salary3;
    public Double share;
    public Double hdmf;
    public Double sss;
    public Double tax;
    public Double basicsalary;
    public Double netpay;

  //------------------------------- Constructor --------------------------------

 public FinalProject (){

    this.name="";
    this.cout=0.0;
    this.temp=0.0;
    this.choice = 0;
    this.basicsalary = 0.0;
    this.salary=0.0;
    this.salary2=salary;
    this.salary3=0.0;
    this.share=0.0;
    this.hdmf=0.0;
    this.sss=0.0;
    this.tax=0.0;
    this.netpay = 0.0;
    }

 //------------------------------- Setter --------------------------------

public void setName(String name){

    this.name=name;
}

public void setCout(Double salary){

    if (salary < 30000.00){
          System.out.print("\n ----------------- \n RESULT:");
       System.out.print("\nYour Position is Staff" + "\n");
    }

    else if (salary >= 30000.00 && salary <= 49999.00){
          System.out.print("\n ----------------- \n RESULT:");
        System.out.print("\nYour Position is Supervisor"+ "\n");
    }

    else if (salary >= 50000.00 && salary <= 79999.00){
          System.out.print("\n ----------------- \n RESULT:");
        System.out.print("\nYour Position is Manager"+ "\n");
    }

     else if (salary >= 80000.00 && salary <= 100000.00){
           System.out.print("\n ----------------- \n RESULT:");
        System.out.print("\nYour Position is Junior Officer"+ "\n");
    }

     else if (salary > 100001.00){
           System.out.print("\n ----------------- \n RESULT:");
        System.out.print("\nYour Position is Senior Officer"+ "\n");
    }
   // salary = cout;

}

public void setChoice(int choice){

    this.choice=choice;
}

public void setBasicsalary(Double basicsalary){

    this.basicsalary = basicsalary;
}

public void setNetpay(Double netpay){

    netpay = -this.salary - this.hdmf - this.salary3 - this.tax;
            this.netpay=netpay;
}

public void setSalary(Double salary){

    if(salary <= 8999.99 )
        {
            salary = 100.00;

        }

    else if(salary >= 9000 && salary <= 9999.99)
    {
        salary = 112.50;

    }

    else if(salary >= 10000 && salary <= 10999.99)
    {
        salary = 125.00;

    }

    else if(salary >= 11000 && salary <= 11999.99)
    {
        salary = 137.50;

    }

    else if(salary >= 12000 && salary <= 12999.99)
    {
        salary = 150.00;

    }

    else if(salary >= 13000 && salary <= 13999.99)
    {
        salary = 162.50;

    }

    else if(salary >= 14000 && salary <= 14999.99)
    {
        salary = 175.50;

    }

    else if(salary >= 15000 && salary <= 15999.99)
    {
        salary = 187.50;

    }

    else if(salary >= 16000 && salary <= 16999.99)
    {
        salary = 200.00;

    }

    else if(salary >= 17000 && salary <= 17999.99)
    {
        salary = 212.50;

    }

    else if(salary >= 18000 && salary <= 18999.99)
    {
        salary = 225.00;

    }

    else if(salary >= 19000 && salary <= 19999.99)
    {
        salary = 237.50;

    }

    else if(salary >= 20000 && salary <= 20999.99)
    {
        salary = 250.00;

    }

    else if(salary >= 21000 && salary <= 21999.99)
    {
        salary = 262.50;

    }

    else if(salary >= 22000 && salary <= 22999.99)
    {
        salary = 275.00;

    }

    else if(salary >= 23000 && salary <= 23999.99)
    {
        salary = 287.50;

    }

    else if(salary >= 24000 && salary <= 24999.99)
    {
        salary = 300.00;

    }

    else if(salary >= 25000 && salary <= 25999.99)
    {
        salary = 312.50;

    }

    else if(salary >= 26000 && salary <= 26999.99)
    {
        salary = 325.00;

    }

    else if(salary >= 27000 && salary <= 27999.99)
    {
        salary = 337.50;

    }

    else if(salary >= 28000 && salary <= 28999.99)
    {
        salary = 350.00;

    }

    else if(salary >= 29000 && salary <= 29999.99)
    {
        salary = 362.50;

    }

    else if(salary >= 30000 && salary <= 30999.99)
    {
        salary = 375.00;

    }

    else if(salary >= 31000 && salary <= 31999.99)
    {
        salary = 387.50;

    }

    else if(salary >= 32000 && salary <= 32999.99)
    {
        salary = 400.00;

    }

    else if(salary >= 33000 && salary <= 33999.99)
    {
        salary = 412.50;

    }

    else if(salary >= 34000 && salary <= 34999.99)
    {
        salary = 425.00;

    }

    else if(salary >= 35000)
    {
        salary = 437.50;

    }

    this.salary=salary;

}
public void setSalary2(Double salary2){

    this.salary2=salary2;
}

public void temp(Double temp){

    this.temp=temp;
}

public void setSalary3(Double salary3){

     if(this.salary3 < 30000){
       salary3 = salary3 * 0.05;
    }

    else if (this.salary3 >= 30000 && this.salary3 <= 49999){
       salary3 = salary3 * 0.07;
    }

    else if (this.salary3 >= 50000 && this.salary3 <= 79999){
        salary3 = salary3 * 0.08;
    }

     else if (this.salary3 >= 80000 && this.salary3 <= 100000){
         salary3 =salary3 * 0.1;
    }

     else if (this.salary3 > 100001){
        salary3 = salary3 * 0.15;
    }

    this.salary3=salary3;
}

public void setShare(Double share){

    this.share=share;
}

public void setTemp(Double temp){

    this.temp=temp;
}

public void setHdmf(Double hdmf){

    if(hdmf > 100){
            System.out.print("Prefered HDMF value has been entered" + "\n");

              this.hdmf = hdmf;

        }
        else if(hdmf == 0){
            System.out.print("Default has been chosen to deduct 100 HDMF" + "\n");
            salary2 = 100.00;
             this.hdmf = salary2;
        }

}

public void setSss(Double sss){

    this.sss = sss * 0.50;
}

public void setTax(Double tax){

    this.tax = tax * 0.50;

}

//getter

public String getName(){

    return this.name;
}

public Double getCout(){

    return this.cout;
}

public int getChoice(){

    return this.choice;
}

public Double getBasicsalary(){

    return this.basicsalary;
}

public Double getNetpay(){

    return this.netpay;
}

public Double getSalary(){

    return this.salary;
}

public Double getTemp(){

    return this.temp;
}

public Double getSalary2(){

    return this.salary2;
}

public Double getSalary3(){

    return this.salary3;
}

public Double getShare(){

    return this.share;
}

public Double getHdmf(){

    return this.hdmf;
}

public Double getSss(){

    return this.sss;
}

public Double getTax(){

    return this.tax;
}

}

//------------------------------- Main Class --------------------------------

package finalproject;

import java.util.Scanner;

public class FinalProjectMain {

    public static void main(String[] args)
    {

        Scanner input = new Scanner(System.in);

        FinalProject output1 = new FinalProject();//name
        FinalProject output2 = new FinalProject();//share
        FinalProject output3 = new FinalProject(); //hdmf //salary2
        FinalProject output4 = new FinalProject();//sss
        FinalProject output5 = new FinalProject();//position
        FinalProject output6 = new FinalProject();//tax
        FinalProject output7 = new FinalProject();//Basicsalary
        FinalProject output8 = new FinalProject();//netpay

       FinalProject output = new FinalProject();

        System.out.print("Good day! To you Sir/ma`am Thanks for helping me our program requires you to input your (basic salary) multiple times in order for us to compute your netpay");
        System.out.print("\n");
        System.out.print("Thank you Sir Have a Good day.");

           System.out.print("\n");
              System.out.print("\n");
                 System.out.print("\n");
                    System.out.print("\n");
                       System.out.print("\n");

        System.out.print("Enter Employee name: ");
        output1.setName(input.nextLine());

        System.out.print("Enter your basic salary: ");
        output7.setBasicsalary(input.nextDouble());

        System.out.print("Please Enter Your basic salary again to compute the philhealth contribution: ");
        output2.setSalary(input.nextDouble());

        System.out.print("Please Enter your basic salary again to compute the hdmf: ");
        output3.setSalary2(input.nextDouble());

        System.out.print("Please Enter the amount of HDMF you want to share: \n otherwise Enter 0 to deduct the default 100 HDMF share: \n");
        output3.setHdmf(input.nextDouble());

        System.out.print("Please Enter your basic salary again to deduct the SSS in your salary: ");
        output4.setSalary3(input.nextDouble());

        System.out.print("\n\nSSS deduction is: " + output4.getSalary3());
        System.out.print("\n");

        System.out.print("(Please Enter the SSS duduction value above to compute the your tax): ");
        output6.setTax(input.nextDouble());

        System.out.print("Please Enter again your basic salary to compute your netpay: ");
        output8.setNetpay(input.nextDouble());

        System.out.print("Enter your basic salary again to determine your position: ");
        output5.setCout(input.nextDouble());

         System.out.print("Employee name is: " + output1.getName());
         System.out.print("\n");

         System.out.print("Your basic salary is: " + output7.getBasicsalary());
         System.out.print("\n");

         System.out.print("Philhealth contribution is: " + output2.getSalary());
         System.out.print("\n");

         System.out.print("Your HDMF share is: " + output3.getHdmf());
         System.out.print("\n");
         System.out.print("SSS deduction is: " + output4.getSalary3());
         System.out.print("\n");
         System.out.print("Your deduction Tax is: " + output6.getTax());
         System.out.print("\n");
         System.out.print("Your netpay is: " + output8.getNetpay());

    }
}

Body:
    Please check carefully that, you have initiate multiple "FinalProject" object,

do just a single time "FinalProject output = new FinalProject();" at main method

    please find code here -

    /*--------------- FinalProject Class Begin ------------ */
    package teststack;

    public class FinalProject

    {

    //------------------------------- Attributes --------------------------------

    public String name;
    public double cout;
    public int choice;
    public Double temp;
    public Double salary;
    public  Double salary2;
    public  Double salary3;
    public Double share;
    public Double hdmf;
    public Double sss;
    public Double tax;
    public Double basicsalary;
    public Double netpay;

    //------------------------------- Constructor --------------------------------

    public FinalProject (){

    this.name="";
    this.cout=0.0;
    this.temp=0.0;
    this.choice = 0;
    this.basicsalary = 0.0;
    this.salary=0.0;
    this.salary2=salary;
    this.salary3=0.0;
    this.share=0.0;
    this.hdmf=0.0;
    this.sss=0.0;
    this.tax=0.0;
    this.netpay = 0.0;
    }

    //------------------------------- Setter --------------------------------

    public void setName(String name){

    this.name=name;

    }

    public void setCout(Double salary){

    if (salary < 30000.00){
          System.out.print("\n ----------------- \n RESULT:");
       System.out.print("\nYour Position is Staff" + "\n");
    }

    else if (salary >= 30000.00 && salary <= 49999.00){
          System.out.print("\n ----------------- \n RESULT:");
        System.out.print("\nYour Position is Supervisor"+ "\n");
    }

    else if (salary >= 50000.00 && salary <= 79999.00){
          System.out.print("\n ----------------- \n RESULT:");
        System.out.print("\nYour Position is Manager"+ "\n");
    }

     else if (salary >= 80000.00 && salary <= 100000.00){
           System.out.print("\n ----------------- \n RESULT:");
        System.out.print("\nYour Position is Junior Officer"+ "\n");
    }

     else if (salary > 100001.00){
           System.out.print("\n ----------------- \n RESULT:");
        System.out.print("\nYour Position is Senior Officer"+ "\n");
    }

    // salary = cout;

    }

    public void setChoice(int choice){

    this.choice=choice;

    }

    public void setBasicsalary(Double basicsalary){

    this.basicsalary = basicsalary;

    }

    public void setNetpay(Double netpay){

    netpay = -this.salary - this.hdmf - this.salary3 - this.tax;
            this.netpay=netpay;

    }

    public void setSalary(Double salary){

    if(salary <= 8999.99 )
        {
            salary = 100.00;

        }

    else if(salary >= 9000 && salary <= 9999.99)
    {
        salary = 112.50;

    }

    else if(salary >= 10000 && salary <= 10999.99)
    {
        salary = 125.00;

    }

    else if(salary >= 11000 && salary <= 11999.99)
    {
        salary = 137.50;

    }

    else if(salary >= 12000 && salary <= 12999.99)
    {
        salary = 150.00;

    }

    else if(salary >= 13000 && salary <= 13999.99)
    {
        salary = 162.50;

    }

    else if(salary >= 14000 && salary <= 14999.99)
    {
        salary = 175.50;

    }

    else if(salary >= 15000 && salary <= 15999.99)
    {
        salary = 187.50;

    }

    else if(salary >= 16000 && salary <= 16999.99)
    {
        salary = 200.00;

    }

    else if(salary >= 17000 && salary <= 17999.99)
    {
        salary = 212.50;

    }

    else if(salary >= 18000 && salary <= 18999.99)
    {
        salary = 225.00;

    }

    else if(salary >= 19000 && salary <= 19999.99)
    {
        salary = 237.50;

    }

    else if(salary >= 20000 && salary <= 20999.99)
    {
        salary = 250.00;

    }

    else if(salary >= 21000 && salary <= 21999.99)
    {
        salary = 262.50;

    }

    else if(salary >= 22000 && salary <= 22999.99)
    {
        salary = 275.00;

    }

    else if(salary >= 23000 && salary <= 23999.99)
    {
        salary = 287.50;

    }

    else if(salary >= 24000 && salary <= 24999.99)
    {
        salary = 300.00;

    }

    else if(salary >= 25000 && salary <= 25999.99)
    {
        salary = 312.50;

    }

    else if(salary >= 26000 && salary <= 26999.99)
    {
        salary = 325.00;

    }

    else if(salary >= 27000 && salary <= 27999.99)
    {
        salary = 337.50;

    }

    else if(salary >= 28000 && salary <= 28999.99)
    {
        salary = 350.00;

    }

    else if(salary >= 29000 && salary <= 29999.99)
    {
        salary = 362.50;

    }

    else if(salary >= 30000 && salary <= 30999.99)
    {
        salary = 375.00;

    }

    else if(salary >= 31000 && salary <= 31999.99)
    {
        salary = 387.50;

    }

    else if(salary >= 32000 && salary <= 32999.99)
    {
        salary = 400.00;

    }

    else if(salary >= 33000 && salary <= 33999.99)
    {
        salary = 412.50;

    }

    else if(salary >= 34000 && salary <= 34999.99)
    {
        salary = 425.00;

    }

    else if(salary >= 35000)
    {
        salary = 437.50;

    }

    this.salary=salary;

    } public void setSalary2(Double salary2){

    this.salary2=salary2;

    }

    public void temp(Double temp){

    this.temp=temp;

    }

    public void setSalary3(Double salary3){

     if(this.salary3 < 30000){
       salary3 = salary3 * 0.05;
    }

    else if (this.salary3 >= 30000 && this.salary3 <= 49999){
       salary3 = salary3 * 0.07;
    }

    else if (this.salary3 >= 50000 && this.salary3 <= 79999){
        salary3 = salary3 * 0.08;
    }

     else if (this.salary3 >= 80000 && this.salary3 <= 100000){
         salary3 =salary3 * 0.1;
    }

     else if (this.salary3 > 100001){
        salary3 = salary3 * 0.15;
    }

    this.salary3=salary3;

    }

    public void setShare(Double share){

    this.share=share;

    }

    public void setTemp(Double temp){

    this.temp=temp;

    }

    public void setHdmf(Double hdmf){

    if(hdmf > 100){
            System.out.print("Prefered HDMF value has been entered" + "\n");

              this.hdmf = hdmf;

        }
        else if(hdmf == 0){
            System.out.print("Default has been chosen to deduct 100 HDMF" + "\n");
            salary2 = 100.00;
             this.hdmf = salary2;
        }

    }

    public void setSss(Double sss){

    this.sss = sss * 0.50;

    }

    public void setTax(Double tax){

    this.tax = tax * 0.50;

    }

    //getter

    public String getName(){

    return this.name;

    }

    public Double getCout(){

    return this.cout;

    }

    public int getChoice(){

    return this.choice;

    }

    public Double getBasicsalary(){

    return this.basicsalary;

    }

    public Double getNetpay(){

    return this.netpay;

    }

    public Double getSalary(){

    return this.salary;

    }

    public Double getTemp(){

    return this.temp;

    }

    public Double getSalary2(){

    return this.salary2;

    }

    public Double getSalary3(){

    return this.salary3;

    }

    public Double getShare(){

    return this.share;

    }

    public Double getHdmf(){

    return this.hdmf;

    }

    public Double getSss(){

    return this.sss;

    }

    public Double getTax(){

    return this.tax;

    }

    }

    /*--------------- FinalProject Class End ------------ */

    /*--------------- FinalProjectMain Class Begin ------------ */

    package teststack;

import java.util.Scanner;

public class FinalProjectMain {

public static void main(String[] args)
{

    try{
    Scanner input = new Scanner(System.in);
    FinalProject output = new FinalProject();

    System.out.print("Good day! To you Sir/ma`am Thanks for helping me our program requires you to input your (basic salary) multiple times in order for us to compute your netpay");
    System.out.print("\nThank you Sir Have a Good day.\n\n\n");
    System.out.print("Enter Employee name: ");
    output.setName(input.nextLine());

    System.out.print("Enter your basic salary: ");
    output.setBasicsalary(input.nextDouble());

    System.out.print("Please Enter Your basic salary again to compute the philhealth contribution: ");
    output.setSalary(input.nextDouble());

    System.out.print("Please Enter your basic salary again to compute the hdmf: ");
    output.setSalary2(input.nextDouble());

    System.out.print("Please Enter the amount of HDMF you want to share: \n otherwise Enter 0 to deduct the default 100 HDMF share: \n");
    output.setHdmf(input.nextDouble());

    System.out.print("Please Enter your basic salary again to deduct the SSS in your salary: ");
    output.setSalary3(input.nextDouble());

    System.out.print("\n\nSSS deduction is: " + output.getSalary3());
    System.out.print("\n");

    System.out.print("(Please Enter the SSS duduction value above to compute the your tax): ");
    output.setTax(input.nextDouble());

    System.out.print("Please Enter again your basic salary to compute your netpay: ");
    output.setNetpay(input.nextDouble());

    System.out.print("Enter your basic salary again to determine your position: ");
    output.setCout(input.nextDouble());

     System.out.print("Employee name is: " + output.getName());
     System.out.print("\n");

     System.out.print("Your basic salary is: " + output.getBasicsalary());
     System.out.print("\n");

     System.out.print("Philhealth contribution is: " + output.getSalary());
     System.out.print("\n");

     System.out.print("Your HDMF share is: " + output.getHdmf());
     System.out.print("\n");
     System.out.print("SSS deduction is: " + output.getSalary3());
     System.out.print("\n");
     System.out.print("Your deduction Tax is: " + output.getTax());
     System.out.print("\n");
     System.out.print("Your netpay is: " + output.getNetpay());
    } catch (Exception e){
        System.out.println("ex : "+e);
    }

}

}

    /*--------------- FinalProjectMain Class End ------------ */


来源: stackexchange

问:
Visual Studio solution explorer out of memory exception
When I open the visual studio 2010 premium, Solution explorer doesn't show up.
It was working and now its not.

It is showing a out of memory exception. Any help would be greatly appreciated.

Attached is the screen shot

答:
I would recommend submitting this to https://connect.microsoft.com as a bug.

They will most likely ask for more information.

ContentLicense: CC BY-SA 2.5


问:
Python - How to dynamically exclude a column name from a list of columns of a Panda Dataframe
So far I am able to get the list of all column names present in the dataframe or to get a specific column names based on its datatype, starting letters, etc...

Now my requirement is to get the whole list of column names or a sublist and to exclude one column from it (i.e Target variable / Label Column. This is a part of Machine Learning. So I am using the terms that are used in machine learning)

Please note I am not speaking about the data present in those columns. I am just taking the column names and want to exclude a particular column by its name

Please see below example for better understanding :

```<code># Get all the column names from a Dataframe
df.columns

Index(['transactionID', 'accountID', 'transactionAmountUSD',
       'transactionAmount', 'transactionCurrencyCode',
       'accountAge', 'validationid', 'LABEL'],
      dtype='object')

# Get only the Numeric Variables (Columns with numeric values in it)
df._get_numeric_data().columns

Index(['transactionAmountUSD', 'transactionAmount', 'accountAge', 'LABEL'],
      dtype='object')
</code>```

Now inorder to get remaining column names I am subtracting both the above commands

```<code>string_cols = list(set(list(df.columns))-set(df._get_numeric_data().columns))
</code>```

Ok everything goes well until I hit this.

I have found out that Label column though it has numeric values it should not be present in the list of numeric variables. It should be excluded.

(i.e) I want to exclude a particular column name (not using its index in the list but using its name explicitly)

I tried similar statements like the following ones but in vain. Any inputs on this will be helpful

```<code>set(df._get_numeric_data().columns-set(df.LABEL)
set(df._get_numeric_data().columns-set(df.LABEL.column)
set(df._get_numeric_data().columns-set(df['LABEL'])
</code>```

I am sure I am missing a very basic thing but not able to figure it out.

答:
Considering LABEL column as your output and the other features as your input, you can try this:

```<code>feature_names = [x for x in df._get_numeric_data().columns if x not in ['LABEL']]
input = df[feature_names]
output= df['LABEL']
</code>```

Hope this helps.

ContentLicense: CC BY-SA 3.0

Body:
So far I am able to get the list of all column names present in the dataframe or to get a specific column names based on its datatype, starting letters, etc...

Now my requirement is to get the whole list of column names or a sublist and to exclude one column from it (i.e Target variable / Label Column. This is a part of Machine Learning. So I am using the terms that are used in machine learning)

Please note I am not speaking about the data present in those columns. I am just taking the column names and want to exclude a particular column by its name

Please see below example for better understanding :

# Get all the column names from a Dataframe
df.columns

Index(['transactionID', 'accountID', 'transactionAmountUSD',
       'transactionAmount', 'transactionCurrencyCode',
       'accountAge', 'validationid', 'LABEL'],
      dtype='object')

# Get only the Numeric Variables (Columns with numeric values in it)
df._get_numeric_data().columns

Index(['transactionAmountUSD', 'transactionAmount', 'accountAge', 'LABEL'],
      dtype='object')

Now inorder to get remaining column names I am subtracting both the above commands

string_cols = list(set(list(df.columns))-set(df._get_numeric_data().columns))

Ok everything goes well until I hit this.

I have found out that Label column though it has numeric values it should not be present in the list of numeric variables. It should be excluded.

(i.e) I want to exclude a particular column name (not using its index in the list but using its name explicitly)

I tried similar statements like the following ones but in vain. Any inputs on this will be helpful

set(df._get_numeric_data().columns-set(df.LABEL)
set(df._get_numeric_data().columns-set(df.LABEL.column)
set(df._get_numeric_data().columns-set(df['LABEL'])

I am sure I am missing a very basic thing but not able to figure it out.

Body:
Considering LABEL column as your output and the other features as your input, you can try this:

feature_names = [x for x in df._get_numeric_data().columns if x not in ['LABEL']]
input = df[feature_names]
output= df['LABEL']

Hope this helps.


问:
How to create table to store large data in SQL Server 2008
I am developing a VB.NET application that will communicate with an external device over serial port. It is a testing device in which a single lamp will be tested for 2000 hours continuously.

This device will give data pertaining lamp parameter (e.g. current) every 10 seconds, that means I will have 720000 readings per test. This data will be logged into some database for future reference.

I searched on the internet about saving such a big amount of data, but learnt that no database supports these many columns in a single table.

Please guide me as to how to log such a huge data.

答:
Instead of having multiple columns on the same table, try with multiple rows for each test. ie; for each test, I will insert a new record into the table for that particular Lamp against that particular time slot and you can filter it later. So If you decide to change the Test interval or Duration, you do not need to worry about the table design as it is already designed in such a way that It can store any number of values against any record. I recommend a design like this

Some sample data for a Lamp for the first 3 tests will be as below

Hope This helps


问:
How to show iTunesconnect sales and financial report on web?
I need to display sales and financial report on HTML web page, reports data should be from iTunesConnect.

Can someone please describe how can i achieve this ?

Need to get data like below iTunes image.

答:
You can use Apple Reporter technique, that provides you data in XML and CSV format.

You need to follow below commands.

```<code>(1) Lion:Reporter bv$ java -jar Reporter.jar p=Reporter.properties m=Robot.XML Finance.getReport AppleID, US, Financial, 2016, 10

Successfully downloaded AppleID_0716_US.txt.gz
(2) Lion:Reporter bv$ java -jar Reporter.jar p=Reporter.properties m=Robot.XML Sales.getReport AppleID, US, Financial, 2016, 10

201
Invalid report type specified. Valid values include: Sales, Newsstand, Pre-order, Cloud, Event, Customer, Content, Station, Control, amEvent, amContent, amControl, amStreams, Subscription and SubscriptionEvent.
(3) Lion:Reporter bv$ java -jar Reporter.jar p=Reporter.properties m=Robot.XML Finance.getReport AppleID, US, Sales, 2016, 10

301
Invalid report type specified. Valid values include: Financial, Match, Radio, RadioSummary, AppleMusic, AppleMusicSummary, News, and BeatsRadio.
(4) java -jar Reporter.jar p=Reporter.properties m=Robot.XML Sales.getReport AppleID, Sales, Summary, Daily, 20162811
</code>```

Using (1) Reporter.properties and (2) Reporter.jar files. Make sure to configure Reporter.properties carefully. Like below.

```<code>UserId= your apple account email address

Password= your apple account password

Mode=Robot.xml
</code>```

Refer

https://help.apple.com/itc/appsreporterguide/#/itcbe21ac7db

Body:
You can use Apple Reporter technique, that provides you data in XML and CSV format.

You need to follow below commands.

(1) Lion:Reporter bv$ java -jar Reporter.jar p=Reporter.properties m=Robot.XML Finance.getReport AppleID, US, Financial, 2016, 10

Successfully downloaded AppleID_0716_US.txt.gz
(2) Lion:Reporter bv$ java -jar Reporter.jar p=Reporter.properties m=Robot.XML Sales.getReport AppleID, US, Financial, 2016, 10

201
Invalid report type specified. Valid values include: Sales, Newsstand, Pre-order, Cloud, Event, Customer, Content, Station, Control, amEvent, amContent, amControl, amStreams, Subscription and SubscriptionEvent.
(3) Lion:Reporter bv$ java -jar Reporter.jar p=Reporter.properties m=Robot.XML Finance.getReport AppleID, US, Sales, 2016, 10

301
Invalid report type specified. Valid values include: Financial, Match, Radio, RadioSummary, AppleMusic, AppleMusicSummary, News, and BeatsRadio.
(4) java -jar Reporter.jar p=Reporter.properties m=Robot.XML Sales.getReport AppleID, Sales, Summary, Daily, 20162811

Using (1) Reporter.properties and (2) Reporter.jar files. Make sure to configure Reporter.properties carefully. Like below.

UserId= your apple account email address

Password= your apple account password

Mode=Robot.xml

Refer

https://help.apple.com/itc/appsreporterguide/#/itcbe21ac7db

ContentLicense: CC BY-SA 4.0


问:
AppDynamics with Azure Functions
Has anybody solved to monitor Azure functions using AppDynamics ? I don't see any option to add a AppDynamics extension to the Azure functions app.</p>

答:
We could install the AppDynamics extension use Azure portal or Kudu tool(https://functionAppname.scm.azurewebsites.net/).

Azure Portal:

Kudu UI

After installation

Title: AppDynamics with Azure Functions


问:
I want to create an HTML template guide for designers, is there pre-existing materials to help with this?
I use number of designers to create HTML templates from PSD designs. What I would like to receive back is a html page containing the most common HTML elements and how they will render based on the derived CSS and HTML. Essentially the content of the page would be common amongst the templates but it would be a key aide in seeing how the various elements from H1 to H6, form elements and ul/ol etc would look with that template and css.

Is there a name for this sort of skeleton file or are there examples of this out there, I cant find anything on the googles.

Many thanks for your help :-)

S

答:
Do you want something along the lines of this?
http://snipplr.com/view/8121/html-test-page-for-css-style-guide/

From what it sounds like, you want something that goes from PSD -> test html template? I am unfamiliar with PSD, but you should be able to just strip the CSS and toss it into a test page like the above.

If you want to test the html and css you just view it in a browser.

If you are using a standard CMS often they have empty templates filled with "Lorem Ipsum" which will allow you to see how the styles work in the CMS.


问:
Git bash: how to change where the MinTTY configuration file is stored?
I'm using Portable Git, but it still creates some files in my user home folder. I would like complete portability.

I followed this answer and set the HOME variable to point to the folder I created, PortableGit\home\user (where PortableGit is my Git installation folder). Now I'm discovering that the .minttyrc configuration file that's created after I change the font size is still being stored in my user home folder, instead of \home\user.

How do I make it so git-bash stores and runs the configuration files for MinTTY in my specified folder instead?

Changing the HOME variable successfully worked for the global .gitconfig file. With this Portable Git installation, I'll be working both on repos on my computer, as well as repos located on my USB, if that information matters...

答:
Consider the mintty wiki Tips:

For its configuration file, it reads /etc/minttyrc, $APPDATA/mintty/config, ~/.config/mintty/config, ~/.minttyrc, in this order.

For resource files to configure a colour scheme, wave file for the bell character, or localization files, it looks for subfolders themes, sounds, or lang, respectively, in one of the directories ~/.mintty, ~/.config/mintty, $APPDATA/mintty, /usr/share/mintty, whichever is found first.

The ~/.config/mintty folder is the XDG default base directory. The $APPDATA/mintty folder is especially useful to share common configuration for various installations of mintty (e.g. cygwin 32/64 Bit, MSYS, Git Bash).

In your case, try and move the C:\User\<yourLogin>\.minttyrc to the right HOME folder and see if it is taken into account by launching again a bash session.

Make sure HOME has been defined as a User environment variable, and that you open a new Window, in order to inherit said environment variable new value.


问:
Pgsql configuration file in Maven + web application
I wanted to connect my JSF web application to PostgreSQL database. There is example for ActiveJDBC connection through Maven in GitHub. Maven plugin is like:

```<code><plugin>
<groupId>org.javalite</groupId>
<artifactId>db-migrator-maven-plugin</artifactId>
<version>${activejdbc.version}</version>
<configuration>
    <configFile>
${project.basedir}/src/main/resources/database.properties
    </configFile>
    <environments>${environments}</environments>
</configuration>
<dependencies>
    <dependency>
        <groupId>postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.1-901.jdbc4</version>
    </dependency>
</dependencies>
</plugin>
</code>```

And, my database.properties file is as follows:

```<code>development.driver=org.postgresql.Driver
development.username=postgres
development.password=****
development.url=jdbc:postgresql://localhost:5432/first
</code>```

When I run console java, it works perfectly, but when I try to run Tomcat server and web application, server gives me error:

Caused by: org.javalite.activejdbc.DBException: Could not find configuration in a property file for environment: development. Are you sure you have a database.properties file configured?

答:
You are configuring the Migration plugin. The database management is described here:
http://javalite.io/database_connection_management

Take some time to read an understand the docs:
http://javalite.io/documentation :)

Body:
I wanted to connect my JSF web application to PostgreSQL database. There is example for ActiveJDBC connection through Maven in GitHub. Maven plugin is like:

<plugin>
<groupId>org.javalite</groupId>
<artifactId>db-migrator-maven-plugin</artifactId>
<version>${activejdbc.version}</version>
<configuration>
    <configFile>
${project.basedir}/src/main/resources/database.properties
    </configFile>
    <environments>${environments}</environments>
</configuration>
<dependencies>
    <dependency>
        <groupId>postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.1-901.jdbc4</version>
    </dependency>
</dependencies>
</plugin>

And, my database.properties file is as follows:

development.driver=org.postgresql.Driver
development.username=postgres
development.password=****
development.url=jdbc:postgresql://localhost:5432/first

When I run console java, it works perfectly, but when I try to run Tomcat server and web application, server gives me error:

Caused by: org.javalite.activejdbc.DBException: Could not find configuration in a property file for environment: development. Are you sure you have a database.properties file configured?


问:
Connection to solr cloud collection using pysolr
I have configured a multicore solr cloud.
Created a collection with 2 shrads and no replication.

Through the solr UI 192.168.1.56:8983, I am able to get results to the query.

I want to do the same with pysolr, so tried running following:

```<code>import pysolr
zookeeper = pysolr.ZooKeeper("192.168.1.56:2181,192.168.1.55:2182")
solr = pysolr.SolrCloud(zookeeper, "random_collection")
</code>```

the last line is not able to find the collection even though its there.
Below is a error trace:

```<code>---------------------------------------------------------------------------
SolrError                                 Traceback (most recent call last)
<ipython-input-43-9f03eca3b645> in <module>()
----> 1 solr = pysolr.SolrCloud(zookeeper, "patent_colllection")

/usr/local/lib/python2.7/dist-packages/pysolr.pyc in __init__(self, zookeeper, collection, decoder, timeout, retry_timeout, *args, **kwargs)
   1176
   1177     def __init__(self, zookeeper, collection, decoder=None, timeout=60, retry_timeout=0.2, *args, **kwargs):
-> 1178         url = zookeeper.getRandomURL(collection)
   1179
   1180         super(SolrCloud, self).__init__(url, decoder=decoder, timeout=timeout, *args, **kwargs)

/usr/local/lib/python2.7/dist-packages/pysolr.pyc in getRandomURL(self, collname, only_leader)
   1315
   1316     def getRandomURL(self, collname, only_leader=False):
-> 1317         hosts = self.getHosts(collname, only_leader=only_leader)
   1318         if not hosts:
   1319             raise SolrError('ZooKeeper returned no active shards!')

/usr/local/lib/python2.7/dist-packages/pysolr.pyc in getHosts(self, collname, only_leader, seen_aliases)
   1281         hosts = []
   1282         if collname not in self.collections:
-> 1283             raise SolrError("Unknown collection: %s", collname)
   1284         collection = self.collections[collname]
   1285         shards = collection[ZooKeeper.SHARDS]

SolrError: (u'Unknown collection: %s', 'random_collection')
</code>```

Solr version is 6.6.2 and zookeeper version is 3.4.10

How to create a connection to solr cloud collection?

答:
Pysolr currently does not support external zookeeper cluster. Pysolr checks for collections in clusterstate.json which Solr has improvised to state.json for each cluster, and clusterstate.json is kept empty.

To solve your problem for single collection you can hard-code ZooKeeper.CLUSTER_STATE variable in pysolr.py as follows:

```<code>ZooKeeper.CLUSTER_STATE = '/collections/random_collection/state.json'
</code>```

pysolr.py could be found at /usr/local/lib/python2.7/dist-packages and maybe try reinstalling it with

```<code>pip install -e /usr/local/lib/python2.7/dist-packages/pysolr.py
</code>```

Body:
I have configured a multicore solr cloud.
Created a collection with 2 shrads and no replication.

Through the solr UI 192.168.1.56:8983, I am able to get results to the query.

I want to do the same with pysolr, so tried running following:

import pysolr
zookeeper = pysolr.ZooKeeper("192.168.1.56:2181,192.168.1.55:2182")
solr = pysolr.SolrCloud(zookeeper, "random_collection")

the last line is not able to find the collection even though its there.
Below is a error trace:

---------------------------------------------------------------------------
SolrError                                 Traceback (most recent call last)
<ipython-input-43-9f03eca3b645> in <module>()
----> 1 solr = pysolr.SolrCloud(zookeeper, "patent_colllection")

/usr/local/lib/python2.7/dist-packages/pysolr.pyc in __init__(self, zookeeper, collection, decoder, timeout, retry_timeout, *args, **kwargs)
   1176
   1177     def __init__(self, zookeeper, collection, decoder=None, timeout=60, retry_timeout=0.2, *args, **kwargs):
-> 1178         url = zookeeper.getRandomURL(collection)
   1179
   1180         super(SolrCloud, self).__init__(url, decoder=decoder, timeout=timeout, *args, **kwargs)

/usr/local/lib/python2.7/dist-packages/pysolr.pyc in getRandomURL(self, collname, only_leader)
   1315
   1316     def getRandomURL(self, collname, only_leader=False):
-> 1317         hosts = self.getHosts(collname, only_leader=only_leader)
   1318         if not hosts:
   1319             raise SolrError('ZooKeeper returned no active shards!')

/usr/local/lib/python2.7/dist-packages/pysolr.pyc in getHosts(self, collname, only_leader, seen_aliases)
   1281         hosts = []
   1282         if collname not in self.collections:
-> 1283             raise SolrError("Unknown collection: %s", collname)
   1284         collection = self.collections[collname]
   1285         shards = collection[ZooKeeper.SHARDS]

SolrError: (u'Unknown collection: %s', 'random_collection')

Solr version is 6.6.2 and zookeeper version is 3.4.10

How to create a connection to solr cloud collection?

Body:
Pysolr currently does not support external zookeeper cluster. Pysolr checks for collections in clusterstate.json which Solr has improvised to state.json for each cluster, and clusterstate.json is kept empty.

To solve your problem for single collection you can hard-code ZooKeeper.CLUSTER_STATE variable in pysolr.py as follows:

ZooKeeper.CLUSTER_STATE = '/collections/random_collection/state.json'

pysolr.py could be found at /usr/local/lib/python2.7/dist-packages and maybe try reinstalling it with

pip install -e /usr/local/lib/python2.7/dist-packages/pysolr.py


问:
Your project is not referencing the "UAP,Version=v10.0.10240" framework
I am using Visual Studio Community Edition 2017 and trying to create a UWP application.

I get the following error

Your project is not referencing the "UAP,Version=v10.0.10240" framework. Add a reference to "UAP,Version=v10.0.10240" in the "frameworks" section of your project.json, and then re-run NuGet restore.

答:
I agree with Jeff. Ken  Not sure if you should be giving any answers with this kind of attitude.

The error message is misleading there is not project.json at least you cannot see it in the Visual Studio explorer.

I had the same issue and have min and target version set to the same number but it would not build.

The fix was to make sure in Nuget package manager setting to tick checkbox 'Allow Nuget to download missing packages' and the one below it as well and rebuild the project.


问:
UINavigation controller: present and dismiss programmatically
I have a TableViewController which I want to present modally and I need it to have a NavigationBar.

To get that navbar, I have an embedded UINavigationController and as far as I know, that UINavigationController is what I have to present modally, so that's what I've done.

Everything works just fine, but I can't manage to dismiss that controller properly. Here is what I've got so far:

```<code>func presentErrorMessages(errorMessages: [String]) {
    let storyBoard: UIStoryboard = UIStoryboard(name: "Message", bundle: nil)

    let infoMessagesNavigationViewController = storyBoard.instantiateViewController(withIdentifier: "InfoMessagesNavigation") as! ModalNavigationController

    let infoMessagesTableViewController = infoMessagesNavigationViewController.viewControllers[0] as! InfoMessagesTableViewController
    infoMessagesTableViewController.errorMessages = errorMessages

    self.navigationController?.present(infoMessagesNavigationViewController, animated: true)
}
</code>```

I use that to present ModalNavigationController, and this to dismiss it:

```<code>class ModalNavigationController: BaseNavigationController {

    var backNavItem = UINavigationItem()
    var okNavItem = UINavigationItem()

    override func viewDidLoad() {
        super.viewDidLoad()

        let backButton = UIBarButtonItem(title: "Back", style: .plain, target: self, action:  #selector(dismissModal))
        backNavItem.leftBarButtonItem = backButton

        ...

        var items = [UINavigationItem]()
        items.append(backNavItem)

        self.navigationBar.items = items
    }

    @objc func dismissModal() {
        self.dismiss(animated: true)
    }
}
</code>```

When I press that back button, there is no change but the navbar which gets blank (with no title). I have the feeling that the application just 'forgets' what is the NavigationController used before the new one is presented.

How can I solve this?

答:
Try something like this:</p>

```<code>override func viewDidLoad() {
    super.viewDidLoad()

    self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Back", style: .done, target: self, action:  #selector(dismissModal))
    ...
}

@objc func dismissModal() {
    self.dismiss(animated: true, completion: nil)
}
</code>```

Body:
I have a TableViewController which I want to present modally and I need it to have a NavigationBar.

To get that navbar, I have an embedded UINavigationController and as far as I know, that UINavigationController is what I have to present modally, so that's what I've done.

Everything works just fine, but I can't manage to dismiss that controller properly. Here is what I've got so far:

func presentErrorMessages(errorMessages: [String]) {
    let storyBoard: UIStoryboard = UIStoryboard(name: "Message", bundle: nil)

    let infoMessagesNavigationViewController = storyBoard.instantiateViewController(withIdentifier: "InfoMessagesNavigation") as! ModalNavigationController

    let infoMessagesTableViewController = infoMessagesNavigationViewController.viewControllers[0] as! InfoMessagesTableViewController
    infoMessagesTableViewController.errorMessages = errorMessages

    self.navigationController?.present(infoMessagesNavigationViewController, animated: true)
}

I use that to present ModalNavigationController, and this to dismiss it:

class ModalNavigationController: BaseNavigationController {

    var backNavItem = UINavigationItem()
    var okNavItem = UINavigationItem()

    override func viewDidLoad() {
        super.viewDidLoad()

        let backButton = UIBarButtonItem(title: "Back", style: .plain, target: self, action:  #selector(dismissModal))
        backNavItem.leftBarButtonItem = backButton

        ...

        var items = [UINavigationItem]()
        items.append(backNavItem)

        self.navigationBar.items = items
    }

    @objc func dismissModal() {
        self.dismiss(animated: true)
    }
}

When I press that back button, there is no change but the navbar which gets blank (with no title). I have the feeling that the application just 'forgets' what is the NavigationController used before the new one is presented.

How can I solve this?

Body:
Try something like this:

override func viewDidLoad() {
    super.viewDidLoad()

    self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Back", style: .done, target: self, action:  #selector(dismissModal))
    ...
}

@objc func dismissModal() {
    self.dismiss(animated: true, completion: nil)
}


问:
nativescript installation android virtual device issue
I am very new to nativescript. While I am installing nativescript as a first time user, I followod the instruction in the official website. Quick setup does not work properly. So, I follewed the advanced setup for windows in the website. While installing Android requirements for nativescript. I stuck with @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://www.nativescript.org/setup/win'))" command.

Then I decided to install every dependency one by one. I followed the http://docs.nativescript.org/angular/start/ns-setup-win instructions. Then in step 6, I cannot find the sdk Manager. Because of that, I download the sdk using the android studio. After that I cannot find the virtual device manager without using android studio.  So, my emulator setup does not complete. I am stuck here and I don't know what I have to do?

Thanx.

Sorry for bad English.

答: You can open your command prompt and type in android. Then the SDK manager will launch without Android Studio. There you can open your AVD by click on tools then AVD Manager.


问:
Simple mediaplayer play mp3 from file path?
I have a very simple mediaplayer that play background. It calls file from the apk, but I want it to play from any directory like as music or sdcard.

Here is my code:

```<code>private MediaPlayer mpintro;

.
.

mpintro = MediaPlayer.create(this, R.raw.intro);
        mpintro.setLooping(true);
        mpintro.start();
</code>```

答:
I use this class for Audio play. If your audio location is raw
  folder.

Call method for play:

```<code>new AudioPlayer().play(mContext, getResources().getIdentifier(alphabetItemList.get(mPosition)
                        .getDetail().get(0).getAudio(),"raw", getPackageName()));
</code>```

AudioPlayer.java class:

```<code>public class AudioPlayer {

    private MediaPlayer mMediaPlayer;

    public void stop() {
        if (mMediaPlayer != null) {
            mMediaPlayer.release();
            mMediaPlayer = null;
        }
    }
    // mothod for raw folder (R.raw.fileName)
    public void play(Context context, int rid){
        stop();

        mMediaPlayer = MediaPlayer.create(context, rid);
        mMediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mediaPlayer) {
                stop();
            }
        });

        mMediaPlayer.start();
    }

    // mothod for other folder
    public void play(Context context, String name) {
        stop();

        //mMediaPlayer = MediaPlayer.create(c, rid);
        mMediaPlayer = MediaPlayer.create(context, Uri.parse("android.resource://"+ context.getPackageName()+"/your_file/"+name+".mp3"));
        mMediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mediaPlayer) {
                stop();
            }
        });

        mMediaPlayer.start();
    }

}
</code>```

Body:
I have a very simple mediaplayer that play background. It calls file from the apk, but I want it to play from any directory like as music or sdcard.

Here is my code:

private MediaPlayer mpintro;

.
.

mpintro = MediaPlayer.create(this, R.raw.intro);
        mpintro.setLooping(true);
        mpintro.start();

Body:
I use this class for Audio play. If your audio location is raw
  folder.

Call method for play:

new AudioPlayer().play(mContext, getResources().getIdentifier(alphabetItemList.get(mPosition)
                        .getDetail().get(0).getAudio(),"raw", getPackageName()));

AudioPlayer.java class:

public class AudioPlayer {

    private MediaPlayer mMediaPlayer;

    public void stop() {
        if (mMediaPlayer != null) {
            mMediaPlayer.release();
            mMediaPlayer = null;
        }
    }
    // mothod for raw folder (R.raw.fileName)
    public void play(Context context, int rid){
        stop();

        mMediaPlayer = MediaPlayer.create(context, rid);
        mMediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mediaPlayer) {
                stop();
            }
        });

        mMediaPlayer.start();
    }

    // mothod for other folder
    public void play(Context context, String name) {
        stop();

        //mMediaPlayer = MediaPlayer.create(c, rid);
        mMediaPlayer = MediaPlayer.create(context, Uri.parse("android.resource://"+ context.getPackageName()+"/your_file/"+name+".mp3"));
        mMediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mediaPlayer) {
                stop();
            }
        });

        mMediaPlayer.start();
    }

}


问:
Unchecked cast when casting an object of type Any? into a lambda in kotlin
My code works as intended but I am curious on why the following warning exists:

Is it safe to ignore the warning?
I know that Kotlin can't check erased types at runtime, but isn't Any the most generic (toplevel) object in Kotlin.

What am I'm looking for is a way to check if an object is of type "lambda".
Btw: Any? -> Any? does not get rid of the problem either.

答:
The JVM provides you only with the raw type at runtime, e.g. java.lang.List instead of java.lang.List<String>. This also applies to kotlin lambdas: When you write (Any?) -> Unit in kotlin, it gets translated to the JVM type kotlin.jvm.functions.Function1<java.lang.Object, kotlin.Unit>.

Now, you have an object of type Any?. You can write Any? as? Function1<*, *> without any problems. You can also use as instead of as?, but risk a ClassCastException to be thrown.

But now comes the problem: The type (Any?) -> Unit and (Int) -> String are different types at compile time, but only because of their generic type arguments. At runtime, both are instances of Function1, which is why the compiler will issue a warning when you cast it to anything with generic arguments other than *.

Is it safe to ignore the warning?

If you know what you are doing - Yes, it's just the limitation of the Java language. If you can rely on the type being what you expect it there is no error, however you will not get any exception if the generic arguments are different than what you expect.

If you don't know what you are doing, e.g. getting the parameter from code that you can't control - take this warning serious.


问:
Django 1.11.4 : django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet
I'm learning how to do web programming with Django framework and I got this error message when I try to create an instance of my Artist from my app models. I use Python 3.6 version and Django 1.11.4 version.

```<code> File "<stdin>", line 1, in <module>
      File ".\app\models.py", line 9, in <module>
        class Artist(models.Model):
      File "C:\Users\kadjo\documents\visual studio 2015\Projects\DatabaseFun\DatabaseFun\env\lib\site-packages\django\db\models\base.py", line 110, in __new__
        app_config = apps.get_containing_app_config(module)
      File "C:\Users\kadjo\documents\visual studio 2015\Projects\DatabaseFun\DatabaseFun\env\lib\site-packages\django\apps\registry.py", line 247, in get_containing_app_config
        self.check_apps_ready()
      File "C:\Users\kadjo\documents\visual studio 2015\Projects\DatabaseFun\DatabaseFun\env\lib\site-packages\django\apps\registry.py", line 125, in check_apps_ready
        raise AppRegistryNotReady("Apps aren't loaded yet.")
    django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
</code>```

答:
How are you running this code? If you are running it standalone, then you must use django.setup().

See: https://docs.djangoproject.com/en/1.11/topics/settings/#calling-django-setup-is-required-for-standalone-django-usage

Body:
I'm learning how to do web programming with Django framework and I got this error message when I try to create an instance of my Artist from my app models. I use Python 3.6 version and Django 1.11.4 version.

 File "<stdin>", line 1, in <module>
      File ".\app\models.py", line 9, in <module>
        class Artist(models.Model):
      File "C:\Users\kadjo\documents\visual studio 2015\Projects\DatabaseFun\DatabaseFun\env\lib\site-packages\django\db\models\base.py", line 110, in __new__
        app_config = apps.get_containing_app_config(module)
      File "C:\Users\kadjo\documents\visual studio 2015\Projects\DatabaseFun\DatabaseFun\env\lib\site-packages\django\apps\registry.py", line 247, in get_containing_app_config
        self.check_apps_ready()
      File "C:\Users\kadjo\documents\visual studio 2015\Projects\DatabaseFun\DatabaseFun\env\lib\site-packages\django\apps\registry.py", line 125, in check_apps_ready
        raise AppRegistryNotReady("Apps aren't loaded yet.")
    django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.


问:
jQueryValidate - check if a control is required without triggering validation
I'm trying to show asterisks for controls which are required. The code was working fine with required class but now I have two fields, company and name. Only one of them is required based on other elements value. Is it possible to check if an input is required without validating the control or the form?

Example html structure:

```<code><div class="form-group">
    <label class="control-label" for="CompanyName">Company Name</label>
    <div>
        <input type="text" id="CompanyName" name="CompanyName" class="form-control required">
    </div>
</div>
</code>```

JS:

```<code>validationOptions: {
    ignore: ":disabled,:hidden",

    rules: {
        CompanyName: {
            required: function () {
                return ($("#ContactName").val().length === 0);
            }
        },
        ContactName: {
            required: function () {
                return ($("#CompanyName").val().length === 0);
            }
        }
    },

    onkeyup: function (element) {
        const $parent = $(element).parents(".form-group");

        if ($(element).valid()) {
            $parent.removeClass("invalid");
        } else {
            $parent.addClass("invalid");
        }
    },

    onfocusout: function () {
        if ($("form").valid()) {
            $("form.error").removeClass("error");
            $("form .invalid").removeClass("invalid");
        }
    },

    errorPlacement: function (error, element) {
        const $parent = $(element).parents(".form-group");

        if ($(element).hasClass("error")) {
            $parent.addClass("invalid");
        } else {
            $parent.removeClass("invalid");
        }
    },

    invalidHandler: function (event, validator) {
        $.each(validator.successList, function (index, item) {
            $(item).parents(".form-group").removeClass("invalid");
        });
        const errors = validator.numberOfInvalids();
        if (errors) {
            $.each(validator.errorList, function (index, item) {
                $(item.element).parents(".form-group").addClass("invalid");
            });
        }
    }
}
</code>```

Of course I can have my code inside required callbacks above but that wouldn't be a generic solution.

I want to be able to call following function many times to update (bootstrap) asterisks on the form based on required state of the fields.

```<code>appendFormControlAsterisk: function ($panel) {
    //removeFormControlAsterisk($panel);

    let $controls = $(".form-control.required");

    $controls.each(function () {
        const $label = $(this).parents(".form-group").find(">.control-label");

        $label.html($label.html() + " <span class='text-danger'>*</span>");
    });
},
</code>```

Trying to accomplish something like:

```<code>appendFormControlAsterisk: function ($panel) {
    //removeFormControlAsterisk($panel);

    let $controls = $(".form-control");

    $controls.each(function () {
        if ($(this).isRequired()) {
            const $label = $(this).parents(".form-group").find(">.control-label");

            $label.html($label.html() + " <span class='text-danger'>*</span>");
        }
    });
},
</code>```

答:
So as I understand, each of your input element will have form-control class, and required class would be only for selected elements. Based on this, below is a snippet that will assign asterisk only to those, that have required as class.

Logic:
Looping through elements that have form-control class, and check using hasClass(), if they have required class too. If yes, append the danger asterisk to it.

$(".form-control").each(function() {
  var requiredHtml = "*";
  if ($(this).hasClass('required')) {
    $(this).closest('.form-group').find('label').append(requiredHtml);
  }
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="form-group">
  <label class="control-label" for="CompanyName">Company Name</label>
  <div>
    <input type="text" id="CompanyName" name="CompanyName" class="form-control required">
  </div>
</div>
<div class="form-group">
  <label class="control-label" for="designation">Designation</label>
  <div>
    <input type="text" id="designation" name="designation" class="form-control">
  </div>
</div></code>```

Body:
I'm trying to show asterisks for controls which are required. The code was working fine with required class but now I have two fields, company and name. Only one of them is required based on other elements value. Is it possible to check if an input is required without validating the control or the form?

Example html structure:

    Company Name

        <input type="text" id="CompanyName" name="CompanyName" class="form-control required">

JS:

validationOptions: {
    ignore: ":disabled,:hidden",

    rules: {
        CompanyName: {
            required: function () {
                return ($("#ContactName").val().length === 0);
            }
        },
        ContactName: {
            required: function () {
                return ($("#CompanyName").val().length === 0);
            }
        }
    },

    onkeyup: function (element) {
        const $parent = $(element).parents(".form-group");

        if ($(element).valid()) {
            $parent.removeClass("invalid");
        } else {
            $parent.addClass("invalid");
        }
    },

    onfocusout: function () {
        if ($("form").valid()) {
            $("form.error").removeClass("error");
            $("form .invalid").removeClass("invalid");
        }
    },

    errorPlacement: function (error, element) {
        const $parent = $(element).parents(".form-group");

        if ($(element).hasClass("error")) {
            $parent.addClass("invalid");
        } else {
            $parent.removeClass("invalid");
        }
    },

    invalidHandler: function (event, validator) {
        $.each(validator.successList, function (index, item) {
            $(item).parents(".form-group").removeClass("invalid");
        });
        const errors = validator.numberOfInvalids();
        if (errors) {
            $.each(validator.errorList, function (index, item) {
                $(item.element).parents(".form-group").addClass("invalid");
            });
        }
    }
}

Of course I can have my code inside required callbacks above but that wouldn't be a generic solution.

I want to be able to call following function many times to update (bootstrap) asterisks on the form based on required state of the fields.

appendFormControlAsterisk: function ($panel) {
    //removeFormControlAsterisk($panel);

    let $controls = $(".form-control.required");

    $controls.each(function () {
        const $label = $(this).parents(".form-group").find(">.control-label");

        $label.html($label.html() + " *");
    });
},

Trying to accomplish something like:

appendFormControlAsterisk: function ($panel) {
    //removeFormControlAsterisk($panel);

    let $controls = $(".form-control");

    $controls.each(function () {
        if ($(this).isRequired()) {
            const $label = $(this).parents(".form-group").find(">.control-label");

            $label.html($label.html() + " *");
        }
    });
},

Body:
So as I understand, each of your input element will have form-control class, and required class would be only for selected elements. Based on this, below is a snippet that will assign asterisk only to those, that have required as class.

Logic:
Looping through elements that have form-control class, and check using hasClass(), if they have required class too. If yes, append the danger asterisk to it.

$(".form-control").each(function() {
  var requiredHtml = "<span class='text-danger'>*</span>";
  if ($(this).hasClass('required')) {
    $(this).closest('.form-group').find('label').append(requiredHtml);
  }
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="form-group">
  <label class="control-label" for="CompanyName">Company Name</label>
  <div>
    <input type="text" id="CompanyName" name="CompanyName" class="form-control required">
  </div>
</div>
<div class="form-group">
  <label class="control-label" for="designation">Designation</label>
  <div>
    <input type="text" id="designation" name="designation" class="form-control">
  </div>
</div>


问:
add text , subtext & image in single table cell
I want to add text , subtext & image in single table cell like this =>

http://img153.imageshack.us/img153/5451/tablevcinterface.jpg

I want add subtext below main text (e.g. => Apple in main text & iphone is subtext which is shown below Apple)
How can i add ?
Any sample code or tutorial link is helpful.
Thanks in advance..

答: You should subclass UITableViewCell. This might be helpful. http://iappdevs.blog.co.in/tag/adding-image-to-uitableviewcell/</p>


问:
Implement Logistic Regression
I am applying multiple ML algorithm to this dataset so I tried logistic regression and I plotted the predictions and it seems completely off since the plot only shows data points from one class. Here is the data and what I attempted</p>

```<code>set.seed(10)

x1 <- runif(500) - 0.5

x2 <- runif(500) - 0.5

y <- ifelse(x1 ^ 2 - x2 ^ 2 > 0, 1, 0)

dat <- data.frame(x1, x2, y)

#Logistic Regression
fit.glm <- glm(y ~ x1 + x2, data = dat, family = "binomial")

y.hat.3 <- predict(fit.glm,dat)

plot(x1,x2,col = c("red","blue")[y.hat.3 + 1])
</code>```

答:
predict returns log-odds for a logistic regression by default. To get predicted classes, use type = "resp" to get predicted probabilities and then use a decision rule like p > 0.5 to turn them into classes:

```<code>y.hat.3 <- predict(fit.glm,dat, type = "resp") > 0.5

plot(x1,x2,col = c("red","blue")[y.hat.3 + 1])
</code>```

Title: Implement Logistic Regression

Body:
I am applying multiple ML algorithm to this dataset so I tried logistic regression and I plotted the predictions and it seems completely off since the plot only shows data points from one class. Here is the data and what I attempted

set.seed(10)

x1 <- runif(500) - 0.5

x2 <- runif(500) - 0.5

y <- ifelse(x1 ^ 2 - x2 ^ 2 > 0, 1, 0)

dat <- data.frame(x1, x2, y)

#Logistic Regression
fit.glm <- glm(y ~ x1 + x2, data = dat, family = "binomial")

y.hat.3 <- predict(fit.glm,dat)

plot(x1,x2,col = c("red","blue")[y.hat.3 + 1])

Body:
predict returns log-odds for a logistic regression by default. To get predicted classes, use type = "resp" to get predicted probabilities and then use a decision rule like p > 0.5 to turn them into classes:

y.hat.3 <- predict(fit.glm,dat, type = "resp") > 0.5

plot(x1,x2,col = c("red","blue")[y.hat.3 + 1])


问:
Safari getUserMedia() Unhandled Promise Rejection
As advised in internet i added the muted and playsinline attributes to my video element. I still cant get a vision in Safari 11 but only this error.
I also tried to remove autoplay from my video element.

Unhandled Promise Rejection: TypeError: Type error

Is it possible to get webrtc working in Safari 11 or am i losing time with this?

getUserMedia() works on all other browsers (Chrome,Firefox,Edge,Opera).

Thank you!

I use this shim, https://github.com/addyosmani/getUserMedia.js/blob/gh-pages/lib/getUserMedia.js this returns a success callback,

Then in the callback,

```<code>var video = camOptions.videoEl; //the video element

var vendorURL = window.URL || window.webkitURL;

try {
    video.src = vendorURL ? vendorURL.createObjectURL(stream) : stream;
}
catch(err) {
    //HERE IS THE TYPE ERROR IN SAFARI
}
</code>```

答:
The TypeError you are getting is because you are passing the wrong constraints when calling GetUserMedia. This error happens when you pass constrains which are not recorgnized by the device (browser) or have invalid values.

Also, you need to use video.srcObject and not video.src which is deprecated.

Here's a working example for Safari. Keep in mind this only works on iOS 11 and above:

```<code>// Get the <video> element
var video = document.getElementById('vid');

// Default constrains
var constraints = { audio: true, video: true };

navigator.mediaDevices.getUserMedia(constraints).then(handleSuccess);

var handleSuccess = function (stream) {
    video.srcObject = stream;
};
</code>```

Body:
As advised in internet i added the muted and playsinline attributes to my video element. I still cant get a vision in Safari 11 but only this error.
I also tried to remove autoplay from my video element.

Unhandled Promise Rejection: TypeError: Type error

Is it possible to get webrtc working in Safari 11 or am i losing time with this?

getUserMedia() works on all other browsers (Chrome,Firefox,Edge,Opera).

Thank you!

I use this shim, https://github.com/addyosmani/getUserMedia.js/blob/gh-pages/lib/getUserMedia.js this returns a success callback,

Then in the callback,

var video = camOptions.videoEl; //the video element

var vendorURL = window.URL || window.webkitURL;

try {
    video.src = vendorURL ? vendorURL.createObjectURL(stream) : stream;
}
catch(err) {
    //HERE IS THE TYPE ERROR IN SAFARI
}

Body:
The TypeError you are getting is because you are passing the wrong constraints when calling GetUserMedia. This error happens when you pass constrains which are not recorgnized by the device (browser) or have invalid values.

Also, you need to use video.srcObject and not video.src which is deprecated.

Here's a working example for Safari. Keep in mind this only works on iOS 11 and above:

// Get the <video> element
var video = document.getElementById('vid');

// Default constrains
var constraints = { audio: true, video: true };

navigator.mediaDevices.getUserMedia(constraints).then(handleSuccess);

var handleSuccess = function (stream) {
    video.srcObject = stream;
};


问:
database datatype performance: int or string
I'm storing phone country codes. They range from 1 to about 300. What's going to be more performant for datatype: int or string? I'm using SQL server 2008 and linq-to-sql.

Thanks.

答:
Given an option where I know the datatype will always be integer, I'll go for integer albeit smaller size - smallint / tinyint (depending on the required range).

I don't expect much difference in performance though.


问:
Android Studio change transparency of Image Assets
When I create new "Image Asset" (Action Bar and Tab Icon) in Android Studio using my own icon as base, I get finally semi-transparent icons.  (Android Studio change original color transparency). How to prevent it and save original colors?

This is image before download to Android studio (pure black)

This is after download to Android studio with image asset and I set white color. It has became transparent.

答:
Easy way to remove default background color in android studio 3.0

step 1: select new image assert in mipmap folder
           mipmap->new->image Assert

step 2: select foreground tab and load your icon image in file location path,
adjust  the image  set according to your view  the available option like (trim, resize)

step 3:  then select background tab and delete the path from the path locator tab.
step 4: go to ic_lancher.xml file under the mipmap folder,
then delete

the line of code.

step 5: do the same operation on ic-launcher_round.xml file under mipmap folder

```<code> <background  android :drawable="@mipmap/ic_lancher_round_background"/>
</code>```

then you can find your icon without android studio default green cover background.
step_1 step_2step_3
step_4

Body:
Easy way to remove default background color in android studio 3.0

step 1: select new image assert in mipmap folder
           mipmap->new->image Assert

step 2: select foreground tab and load your icon image in file location path,
adjust  the image  set according to your view  the available option like (trim, resize)

step 3:  then select background tab and delete the path from the path locator tab.
step 4: go to ic_lancher.xml file under the mipmap folder,
then delete

the line of code.

step 5: do the same operation on ic-launcher_round.xml file under mipmap folder

 <background  android :drawable="@mipmap/ic_lancher_round_background"/>

then you can find your icon without android studio default green cover background.
step_1 step_2step_3
step_4


问:
How to redirect to the signin page and display message in that page
In this code, OTPVerficationHTML() function having condition that data.rval == 2, where it should redirect to signin page and display the message in that page only

```<code>var flag = 0;
   $("#successPrimary").on('click', function(e) {
     e.preventDefault()
     user_name = $('#Login_UserName').val();
     password = $('#Login_Password').val();
     captcha = $('#Login_captcha').val();

     var PostData = {};
     PostData['put'] = true;
     PostData['form_login_username'] = user_name;
     PostData['form_login_password'] = password;
     PostData['form_login_captcha'] = captcha;

     Application.Post("/ajax/ajax_login", PostData, function(data){
        if(data.rval == 1){
          window.location = "/offerletter/index";
          Application.PageAlertBox.Show('Sucess', ['Login Successfully.']);
        }else if(data.rval == 2){
          OTPVerficationHTML()
          Application.PageAlertBox.Show('info', ['Enter OTP to Verify.']);
        }else{
          Application.PageAlertBox.Show('error',[data.Message]);
        }
      });
   });

   var OTPVerficationHTML = function () {
     initial_html = $('#otpfromlogin').html();
     $('#otpfromlogin').empty();
     $('#buttons').empty();
     $('#otpfromlogin').append(final_html);
     $('#Login_UserName').val(user_name);
     $('#Login_UserName').attr('readonly', 'true');
     $('#Login_UserName').focus();
   }

   $('#otpfromlogin').on('click', '#otp-verify', function(e) {
      e.preventDefault()
      otp = $('#form_otp').val();
       var PostData = {};
       PostData['put'] = true;
       PostData['form_login_otp'] = otp;

     Application.Post("/ajax/ajax_loginwithotp", PostData, function(data) {
        if(data.rval == 1) {
            window.location = "/offerletter/index";
            Application.PageAlertBox.Show('Sucess', ['Successfully Loggedin.']);
        } else if(data.rval == 2) {
            window.location = "/signin";
            Application.PageAlertBox.Show('info', ['OTP is Expired, Pleasem login with new OTP.']);
        } else if(data.rval == -4) {
            Application.PageAlertBox.Show('error', ['OTP is Invalid. Please Enter correct OTP.']);
        } else {
            Application.PageAlertBox.Show('error', [data.Message]);
        }
      });
   });
</code>```

It is not displaying the message on signin page. I don't know how to deal with this kind of situation.

答:
There are couple of ways doing this using jquery:

Window.loaction
Will return the url of the current page.
when assigned, changes the url of the page to the one assigned and shows it.

```<code>window.location = "/signin";
</code>```

As the above example

Window.location.replace

Navigates to the desired url, without adding record to history.

```<code>window.location.replace("http://someaddress");
</code>```

Window.location.assign

Navigates to the desired url, adding record to history.

```<code>window.location.assign("http://someaddress");
</code>```

Window.location.href

simulating user click.

```<code>window.location.href = "/signin";
</code>```

There is a Discussion Here about whether .location.href is of better use over .location if you are interested.

As the accepted answer stated, get the data using $_POST['q'].

Body:
In this code, OTPVerficationHTML() function having condition that data.rval == 2, where it should redirect to signin page and display the message in that page only

var flag = 0;
   $("#successPrimary").on('click', function(e) {
     e.preventDefault()
     user_name = $('#Login_UserName').val();
     password = $('#Login_Password').val();
     captcha = $('#Login_captcha').val();

     var PostData = {};
     PostData['put'] = true;
     PostData['form_login_username'] = user_name;
     PostData['form_login_password'] = password;
     PostData['form_login_captcha'] = captcha;

     Application.Post("/ajax/ajax_login", PostData, function(data){
        if(data.rval == 1){
          window.location = "/offerletter/index";
          Application.PageAlertBox.Show('Sucess', ['Login Successfully.']);
        }else if(data.rval == 2){
          OTPVerficationHTML()
          Application.PageAlertBox.Show('info', ['Enter OTP to Verify.']);
        }else{
          Application.PageAlertBox.Show('error',[data.Message]);
        }
      });
   });

   var OTPVerficationHTML = function () {
     initial_html = $('#otpfromlogin').html();
     $('#otpfromlogin').empty();
     $('#buttons').empty();
     $('#otpfromlogin').append(final_html);
     $('#Login_UserName').val(user_name);
     $('#Login_UserName').attr('readonly', 'true');
     $('#Login_UserName').focus();
   }

   $('#otpfromlogin').on('click', '#otp-verify', function(e) {
      e.preventDefault()
      otp = $('#form_otp').val();
       var PostData = {};
       PostData['put'] = true;
       PostData['form_login_otp'] = otp;

     Application.Post("/ajax/ajax_loginwithotp", PostData, function(data) {
        if(data.rval == 1) {
            window.location = "/offerletter/index";
            Application.PageAlertBox.Show('Sucess', ['Successfully Loggedin.']);
        } else if(data.rval == 2) {
            window.location = "/signin";
            Application.PageAlertBox.Show('info', ['OTP is Expired, Pleasem login with new OTP.']);
        } else if(data.rval == -4) {
            Application.PageAlertBox.Show('error', ['OTP is Invalid. Please Enter correct OTP.']);
        } else {
            Application.PageAlertBox.Show('error', [data.Message]);
        }
      });
   });

It is not displaying the message on signin page. I don't know how to deal with this kind of situation.

Body:
There are couple of ways doing this using jquery:

Window.loaction
Will return the url of the current page.
when assigned, changes the url of the page to the one assigned and shows it.

window.location = "/signin";

As the above example

Window.location.replace

Navigates to the desired url, without adding record to history.

window.location.replace("http://someaddress");

Window.location.assign

Navigates to the desired url, adding record to history.

window.location.assign("http://someaddress");

Window.location.href

simulating user click.

window.location.href = "/signin";

There is a Discussion Here about whether .location.href is of better use over .location if you are interested.

As the accepted answer stated, get the data using $_POST['q'].