Skip to content

Latest commit

 

History

History
26 lines (18 loc) · 1.07 KB

README.md

File metadata and controls

26 lines (18 loc) · 1.07 KB

Java Classes and TDD

Single Classes with methods using TDD

Calculator

  • Create a Calculator class. This should have functions for Add, Subtract, Multiply and Divide. Your methods should take in two ints to perform the calculations on (except the Divide method. This should take two doubles as arguments).

Water Bottle

  • Create a water bottle class with a volume property.
  • The volume should start at 100.
  • Add a drink function that takes 10 from the volume each time it is called.
  • Create an empty function that brings the volume down to 0.
  • Create a fill function that fills the volume back to 100.

Extension:

Printer

  • Create a Printer class that has a property for number of sheets of paper left.
  • Add a method to print that takes in a number of pages and number of copies.
  • The print method will only run if the printer has enough paper. If it runs it will reduce the value of the paper left by number of copies * number of pages.
  • Add a toner volume property to the class.
  • Modify the printer so that it reduces the toner by 1 for each page printed.