Skip to content

AlHood77/Java-Classes-and-TDD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Single Classes with methods using TDD

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages