This command-line Java application was created for CMSC 335 to demonstrate object-oriented programming (OOP) principles using geometric shapes. The program allows users to calculate areas of 2D shapes and volumes of 3D shapes interactively.
- Text-based menu for user interaction
- Calculate area for 2D shapes: Circle, Rectangle, Square, Triangle
- Calculate volume for 3D shapes: Sphere, Cube, Cone, Cylinder, Torus
- Clean structure using inheritance and polymorphism
- Error handling for invalid user input
- Inheritance: Common shape classes share traits through abstract base classes
- Polymorphism: Unified interface for different shapes (
getArea(),getVolume()) - Abstraction: Abstract classes for 2D and 3D shapes
- Encapsulation: Private fields and public methods
When the program runs:
- The user sees a menu of shape options
- They choose a shape to construct
- The program prompts for relevant dimensions
- It calculates and displays the result
- The user can repeat or exit
Example: *********Welcome to the Java OO Shapes Program **********
Construct a Circle
Construct a Rectangle ...
Exit the program
Shape– abstract base class for all shapesTwoDimensionalShape&ThreeDimensionalShape– extended base classes- Concrete classes like
Circle,Cube,Cylinder, etc. implement area or volume logic Main.java– handles user interaction and program flow
- Java (JDK 17 or higher recommended)
- No external libraries required – runs in terminal/console
- Clone the repo or download the
.javafiles - Compile all files using: javac *.java
- Run the program: java Main
- How to use OOP to create scalable, reusable code
- Designing a menu-driven interface in the terminal
- Structuring a project around user input and feedback
- Applying abstract classes and method overriding effectively
👩💻 Mackenzie Treadway
🎓 CMSC 335 – Object-Oriented Programming