rezivor

FlashDrive.cpp

Aug 5th, 2013
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.29 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include "FlashDrive.h"
  4. using namespace cs52;
  5. using namespace std;
  6.  
  7. std::ostream& operator <<(std::ostream& outs, const FlashDrive * drive )
  8. {
  9.    outs << drive->name_;
  10.    return outs;
  11. }
  12.  
  13. std::istream& operator >>( std::istream& ins, FlashDrive * & drive )
  14. {
  15.     ins >> drive->name_;
  16.     return ins;
  17. }
  18.  
  19. FlashDrive::FlashDrive( ) {
  20.  my_StorageCapacity = 0;
  21.  my_StorageUsed = 0;
  22.  my_IsPluggedIn = false;
  23. }
  24.  
  25. FlashDrive::FlashDrive( int capacity, int used, bool pluggedIn ) {
  26.   my_StorageCapacity = capacity;
  27.   my_StorageUsed = used;
  28.   my_IsPluggedIn = pluggedIn;
  29. }
  30.  
  31. void FlashDrive::plugIn( ) {
  32.   my_IsPluggedIn = true;
  33. }
  34.  
  35. void FlashDrive::pullOut( ) {
  36.   my_IsPluggedIn = false;
  37.  
  38. }
  39. void FlashDrive::writeData( int amount ) {
  40.  my_StorageUsed += amount;
  41. }
  42. void FlashDrive::eraseData( int amount ) {
  43.   my_StorageUsed -= amount;
  44. }
  45. void FlashDrive::formatDrive( ) {
  46.   my_StorageUsed = 0;
  47. }
  48. int  FlashDrive::getCapacity( ) {
  49.   return( my_StorageCapacity );
  50. }
  51. void FlashDrive::setCapacity( int amount ) {
  52.   my_StorageCapacity = amount;
  53. }
  54. int  FlashDrive::getUsed( ) {
  55.   return( my_StorageUsed );
  56. }
  57. void FlashDrive::setUsed( int amount ) {
  58.   my_StorageUsed = amount;
  59. }
  60. bool FlashDrive::isPluggedIn( ) {
  61.   return( my_IsPluggedIn );
  62. }
Advertisement
Add Comment
Please, Sign In to add comment