Giter Club home page Giter Club logo

year-11-cs-unit-6-classes-tutorial-cube's Introduction

Year-11-CS-Unit-6-Classes-Tutorial-Cube

Your job is to create one class called Cube. You should pass all of the tests in the CubeTester class (provided).

Create a class called Cube. Cube has one single private integer variable called side, which represents the length of a side of the cube, a getter method called getSide(), a setter method called setSide(int side), a method that returns the surface area of the cube called getSurfaceArea(), a method that returns the volume of the cube called getVolume(), and a toString method that returns a String in the format, for example:

Cube{side=4} .

The Cube class has two constructors. One takes no arguments (has no parameters) and sets side to 1. The other will take a single integer argument that is used to initialize the side property. Side should never be less than 1. If a user attempts to create a Cube with a side length less than 1, an IllegalArgumentException will be thrown. The message “A cube’s side length cannot be less than 1!” will be displayed in the console when the exception occurs. If a user attempts to change the side length of an already existing Cube to a value less than 1, again, an IllegalArgumentException will be thrown, and the message “A cube’s side length cannot be less than 1!” will be displayed in the console when the exception occurs.

You will need to add JUnit4 to your classpath. Hover your cursor over the red coloured 'junit' within the import statement on line 1 and click on 'Add 'JUnit4' to classpath'.

image

year-11-cs-unit-6-classes-tutorial-cube's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.