@Test public void testBond() { Fragment frag = new Fragment(mock(Element.class)); Atom a1 = new Atom(1, ChemEl.C, frag); Atom a2 = new Atom(2, ChemEl.C, frag); frag.addAtom(a1); frag.addAtom(a2); Bond bond = new Bond(a1, a2, 1); assertNotNull("Got bond", bond); assertEquals("From = 1", 1, bond.getFrom()); assertEquals("To = 2", 2, bond.getTo()); assertEquals("Order = 1", 1, bond.getOrder()); assertEquals(a1, bond.getFromAtom()); assertEquals(a2, bond.getToAtom()); assertEquals(a2, bond.getOtherAtom(a1)); assertEquals(a1, bond.getOtherAtom(a2)); assertEquals(null, bond.getBondStereo()); assertEquals(null, bond.getSmilesStereochemistry()); }
Bond(Atom from, Atom to, int order) { if (from == to){ throw new IllegalArgumentException("Bonds must be made between different atoms"); } if (order < 1 || order > 3){ throw new IllegalArgumentException("Bond order must be 1, 2 or 3"); } if (from == null){ throw new IllegalArgumentException("From atom was null!"); } if (to == null){ throw new IllegalArgumentException("To atom was null!"); } this.from = from; this.to = to; this.order = order; }
Bond { Bond(Atom from, Atom to, int order) { if (from == to){ throw new IllegalArgumentException("Bonds must be made between different atoms"); } if (order < 1 || order > 3){ throw new IllegalArgumentException("Bond order must be 1, 2 or 3"); } if (from == null){ throw new IllegalArgumentException("From atom was null!"); } if (to == null){ throw new IllegalArgumentException("To atom was null!"); } this.from = from; this.to = to; this.order = order; } }
Bond { Bond(Atom from, Atom to, int order) { if (from == to){ throw new IllegalArgumentException("Bonds must be made between different atoms"); } if (order < 1 || order > 3){ throw new IllegalArgumentException("Bond order must be 1, 2 or 3"); } if (from == null){ throw new IllegalArgumentException("From atom was null!"); } if (to == null){ throw new IllegalArgumentException("To atom was null!"); } this.from = from; this.to = to; this.order = order; } Bond(Atom from, Atom to, int order); }
Bond { Bond(Atom from, Atom to, int order) { if (from == to){ throw new IllegalArgumentException("Bonds must be made between different atoms"); } if (order < 1 || order > 3){ throw new IllegalArgumentException("Bond order must be 1, 2 or 3"); } if (from == null){ throw new IllegalArgumentException("From atom was null!"); } if (to == null){ throw new IllegalArgumentException("To atom was null!"); } this.from = from; this.to = to; this.order = order; } Bond(Atom from, Atom to, int order); @Override int hashCode(); @Override boolean equals(Object obj); }
Bond { Bond(Atom from, Atom to, int order) { if (from == to){ throw new IllegalArgumentException("Bonds must be made between different atoms"); } if (order < 1 || order > 3){ throw new IllegalArgumentException("Bond order must be 1, 2 or 3"); } if (from == null){ throw new IllegalArgumentException("From atom was null!"); } if (to == null){ throw new IllegalArgumentException("To atom was null!"); } this.from = from; this.to = to; this.order = order; } Bond(Atom from, Atom to, int order); @Override int hashCode(); @Override boolean equals(Object obj);  }