5A
Write an application, Holidays
. In the main method do the following
Things to note:
For the draft, do the first four steps.
5B
WallpaperJob
(hw4a)
Neither the length or the width of the room should be negative
setDimensions:
If the length is less than 0, set it to 0. If the width is less than 0, set it to 0setDimensions
so that you only do the checking once.Powerwall
(hw3b)
DEFAULT_MAX_CAPACITY
use
method do not let the amount of electricity go below 0 or the amount to use be less than 0.
Powerwall
, set the amount in the Powerwall to 0. charge
method do not let the amount of electricity go above the maximum or the the amount to add be negative.
Powerwall above the maximum
, set the amount in the Powerwall to maximum. AustrailianBeardedDragon
(hw3a)
climb()
method, do not allow the dragon to go over the top of the tree (10 units). If this climb would put the dragon over the top, do not climb. Remember not to have an empty if or else clause. Use a constant for the top of the pole. Call it TREE_TOPpublic static final int TREE_TOP = 10;
setGender()
and call setGender
from the constructor.For the draft, modify WallpaperJob
For the final, you will modify the other two classes and submit them
5C
Write a class called IntegerProcessor
that represents a positive integer . IntegerProcessor
has a constructor that takes a positive integer.
Provide the constructor:
public IntegerProcessor(int integer)
if integer is negative, multiply if by -1 so that you have a positive integer. Call the instance variable integer (given)Provide methods
public int getInteger()
gets this IntegerProcessor
. (Provided)public void setInteger(int value)
sets a new integer. if value is negative, multiply if by -1 so that you have a positive integer. In final, have the constructor call setInteger so you do not write the validity check code twice.public boolean isBig()
determines if the number qualifies as "big" A big integer is bigger than 500,000 (updated 9/24). Returns true if the integer is big, otherwise false.public boolean isSmall()
determines if the number qualifies as "small" A small integer is less than 100. returns true if the integer is small, otherwise false.public String formatWithCommas()
gets a string representing the integer in the comma format, if the integer is less than 1,000,000. If the integer is greater than or equal to 1,000,000, return the string "too big" See the hint below.Hint: You can get a String version of a number by concatenating it with the empty string
String stringVersion = "" + number;
Once you have a string, you can use String methods
For the draft, provide, the constructor and the setInteger method.