Starting from:

$30

Lab 02 - OOP Fundamentals Review

Lab 02 - OOP Fundamentals Review
Direction: Submit typed work in the Labs directory of your github repository and/or as an attachment on Google classroom
under the accurate Lab02 assessment. All submissions should have their appropiate extensions.
Part A: In class
A scrollbar allows users to scroll up and down a page whenever the content of the page is too long to fit in a single
window view. The scrollbar is a resizable bar on a ranged track as follows
J I
You can move the bar directly up and down the track, or move the bar by clicking on the arrow buttons on either end.
Your objective is to write a header file that contains the class Scrollbar which must contain:
 A public default constructor that initializes the fields of the scrollbar so that it represents a bar of a length of
5 at the very top of the track.
 A public copy constructor.
 A public assignment operator.
 A public empty destructor.
 A public int constant getter method named GetLength() that takes no parameters. It returns the length of
the bar.
 A public void setter method named SetLength() that takes an int parameter. If the parameter is a positive
number at most 50 (0 < n ≤ 50) , it makes the length of the bar equal to the parameter and repositions the
bar to the top of the track; otherwise, it will do nothing.
 A public int constant getter method named GetPosition() that takes no parameters. It returns the position
of the lower end of the bar.
 A public void setter method named SetPosition() that takes an int parameter. If the parameter is a
nonnegative number less than 50 (0n < 50) and the new position of the top end of the bar will not exceed
50 when the lower end of the bar is repositioned to the parameter, the lower end of the bar will become the
parameter; otherwise, it will do nothing.
 A public bool method named MoveUp() that takes no parameters. If the top end of the bar will not exceed
50, it moves the bar up 1 unit, and then, returns true; otherwise, it only returns false.
 A public bool method named MoveDown() that takes no parameters. If the lower end of the bar will not be
less than 0, it moves the bar down 1 unit, and then, returns true; otherwise, it only returns false.
 A public bool method named Drag() that takes an int parameter. If the parameter is between -50 and
50 exclusively (−50 < n < 50) and the ends of the bar will not pass the borders of the track when it is
repositioned, it moves the bar parameter units, and then, returns true; otherwise, it only returns false.
 A public string constant method named ToString() that takes no parameters. It returns a string of the
scrollbar vertically similar to the following:
*******************
- [ ] +
*******************
 A friend overloaded ostream operator that returns the display exactly like the return of the ToString()
method.
Note: the track is 50 units long, the difference between the ends of the bar is 1 less than the length, and you need to
define fields

More products