Skip to content

Generalize Methods #20

@Stefan4472

Description

@Stefan4472

All methods should take Object and throw a NumberFormatException if the object is not of the required type. This will make printing error messages much easier.

Example:
public Vector3D multiply(Object o) throws NumberFormatException {
if(o.getClass() == Vector3D.class)
...vector dot product...
else if(o.getClass() == Double.class)
...scalar multiplication...
else
throw new NumberFormatException("Error: invalid type. The * operator requires an object of type Vector3D or double");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions