Skip to content

Instantly share code, notes, and snippets.

@ansisec
Last active February 8, 2024 16:44
Show Gist options
  • Save ansisec/1c52564d9f6bcb688e94e1fe20796a93 to your computer and use it in GitHub Desktop.
Save ansisec/1c52564d9f6bcb688e94e1fe20796a93 to your computer and use it in GitHub Desktop.
PA - Aula 1
public class IntegerPairs
{
    private int i1, i2;
    public IntegerPairs(int i1, int i2)
    {
        this.i1 = i1;
        this.i2 = i2;
    }
    public int getI1() {
        return i1;
    }
    public int getI2() {
        return i2;
    }
                
    public int getSum()
    {
        return i1 + i2;
    }
    @Override
    public String toString()
    {
        return("{"+i1+";"+i2+"}");
    }
}
public class SumIntegerPairs
{
public static void main(String args[])
{
int i1, i2;
System.out.println();
if(args.length != 2){
System.out.println("Specify two integer parameters!");
return;
}
i1 = Integer.parseInt(args[0]);
i2 = Integer.parseInt(args[1]);
IntegerPairs p = new IntegerPairs(i1, i2);
System.out.println(p);
System.out.println(i1 + " + " + i2 + " = " + p.getSum());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment