Last active
February 8, 2024 16:44
-
-
Save ansisec/1c52564d9f6bcb688e94e1fe20796a93 to your computer and use it in GitHub Desktop.
PA - Aula 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Auxiliary files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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+"}"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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