Commit a767d01f authored by Никита Савельев's avatar Никита Савельев
Browse files

HashMap

parent ed72bb19
No related merge requests found
Showing with 17 additions and 1 deletion
+17 -1
......@@ -8,4 +8,18 @@ public class KeyPair { // SparseMatrix
this.i = i;
this.j = j;
}
public void get(Integer index) { // проверка на то, есть ли нулевые значения
if(index >= this.i || index >= this.j) {
throw new IllegalArgumentException("invalid index");
}
}
public void set(Integer index, Integer value) {
if (index >= this.i || index >= this.j) {
throw new IllegalArgumentException("invalid index");
}
if(index != 0)
System.out.println(value);
}
}
\ No newline at end of file
......@@ -69,10 +69,12 @@ public class Main {
boolean value8 = x.contains("8");
if (value8) {
KeyPair m = new KeyPair(10,10);
KeyPair m = new KeyPair(10,10); // номер строки и столбца
KeyPair n = new KeyPair(10,10);
System.out.println(m);
System.out.println(n);
m.get(2);
n.set(3, 1);
String s = sc.nextLine();
boolean x1 = s.contains("1");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment