Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- #include "FlashDrive.h"
- using namespace cs52;
- using namespace std;
- std::ostream& operator <<(std::ostream& outs, const FlashDrive * drive )
- {
- outs << drive->name_;
- return outs;
- }
- std::istream& operator >>( std::istream& ins, FlashDrive * & drive )
- {
- ins >> drive->name_;
- return ins;
- }
- FlashDrive::FlashDrive( ) {
- my_StorageCapacity = 0;
- my_StorageUsed = 0;
- my_IsPluggedIn = false;
- }
- FlashDrive::FlashDrive( int capacity, int used, bool pluggedIn ) {
- my_StorageCapacity = capacity;
- my_StorageUsed = used;
- my_IsPluggedIn = pluggedIn;
- }
- void FlashDrive::plugIn( ) {
- my_IsPluggedIn = true;
- }
- void FlashDrive::pullOut( ) {
- my_IsPluggedIn = false;
- }
- void FlashDrive::writeData( int amount ) {
- my_StorageUsed += amount;
- }
- void FlashDrive::eraseData( int amount ) {
- my_StorageUsed -= amount;
- }
- void FlashDrive::formatDrive( ) {
- my_StorageUsed = 0;
- }
- int FlashDrive::getCapacity( ) {
- return( my_StorageCapacity );
- }
- void FlashDrive::setCapacity( int amount ) {
- my_StorageCapacity = amount;
- }
- int FlashDrive::getUsed( ) {
- return( my_StorageUsed );
- }
- void FlashDrive::setUsed( int amount ) {
- my_StorageUsed = amount;
- }
- bool FlashDrive::isPluggedIn( ) {
- return( my_IsPluggedIn );
- }
Advertisement
Add Comment
Please, Sign In to add comment