-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMemBlock.java
More file actions
47 lines (43 loc) · 1.41 KB
/
MemBlock.java
File metadata and controls
47 lines (43 loc) · 1.41 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package MMS;
/*
Assignment number :10
File Name : MemBlock.java
Name: Ran Zaaroor
Student ID : 209374040
Email : Ran.zaaroor@gmail.com
*/
/**
* Represents a memory block.
* A memory block has a base address, and a length in words.
* <br> (Part of Homework 10 in the Intro to CS course, Efi Arazi School of CS)
*/
public class MemBlock {
int baseAddress; // The address where this mempry block begins
int length; // The length of this memory block, in words
/**
* Constructs a memory block with the given base address and length
*
* @param baseAddress The address of the first word in this memory block
* @param length The length of this memory block, in words
*/
public MemBlock(int baseAddress, int length) {
this.baseAddress = baseAddress;
this.length = length;
}
/**
* Checks if this memory block has the same base address and length as the other memory block
*
* @param other The other memory block
* @return true if this memory block is the same as the other memory block, false otherwise
*/
public boolean equals(MemBlock other) {
return baseAddress == other.baseAddress && length == other.length;
}
/**
* A textual representation of this memory block object, useful for debugging
* @return a string representing this memory block
*/
public String toString() {
return "(" + baseAddress + " , " + length + ")";
}
}