-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisk.cpp
More file actions
29 lines (25 loc) · 765 Bytes
/
Copy pathDisk.cpp
File metadata and controls
29 lines (25 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//
// Created by Eshin Griffith on 9/26/17.
//
#include "Disk.h"
#include <iostream>
#include <stdlib.h>
#include <string>
#include <stdexcept>
// Writes string data to the array address
void Disk::write(int address, std::string data) {
if (address >= SIZE || address < 0)
throw std::invalid_argument("Disk write is out of bounds");
disk_data[address] = data;
}
// Reads string data from the array address
std::string Disk::read(int address) {
if (address >= SIZE || address < 0)
throw std::invalid_argument("Disk read is out of bounds " + std::to_string(address));
return disk_data[address];
}
// Construct Disk and set size to global variable SIZE
Disk::Disk() {
for (int i = 0; i < SIZE; i++)
disk_data[i] = "";
}