Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void addProduct(T t) {
- if (t.getClass().isInstance(ComputerPart.class)) {
- products.add(t);
- }
- if (t.getClass().isInstance(Service.class)) {
- products.add(t);
- }
- if (t.getClass().isInstance(Peripheral.class)) {
- products.add(t);
- }
- else System.out.println("Not the right type of object.");
- }
- ComputerPart c;
- c = new ComputerPart(12);
- ComputerOrder<Product> g3 = new ComputerOrder<>();
- g3.addProduct(c);
- g3.print();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement