Cmpe 160
Introduction to Object Oriented Programming

Assignment 1

Design and Implement Cube3D, RBlock3D and Shape3D classes as shown below. (pdf document). Test Data is here

Requirements

Cube3D, RBlock3D classes should have default constructors which can take parameters. Cube3D(size, position), RBlock3D(length, width, height, position), Shape3D def. constructor takes no parameters. Default Cube3D is a unit cube at (0,0,0). Default RBlock3D is a length 2 width 1 height 1 block at (0,0,0). Shape3D is an array of RBlock3D objects. Default Shape3D is an empty array. All parameters and position coordinates are integer.

You should use the Vector3D class without a default constructor.

You should overload + operator for the following. For these operations to be carried out certain alignments are required.

Cube3D + Cube3D -> RBlock3D in the case of an allignment error a default RBlock3D should be returned

RBlock3D + RBlock3D -> RBlock3D in the case of an allignment error a default RBlock3D should be returned

RBlock3Ds within a Shape3D should be a connected set but not intersecting each other.

+= operator should be overloaded for adding elements to a Shape3D

All three classes should have their own draw() functions. Shape3D.draw() should call RBlock3D.draw for its elements.

 

Bonus

Cube3D + RBlock3D -> RBlock3D

RBlock3D + Cube3D -> RBlock3D

Dynamic Allocation for Shape3D

Hand drawn illustration of a shape generated in the application.