Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(10 marks) P2: Register classes Focus: Inheritance In this part of the project, you will create classes representing more components of our simulated machine, specifically
(10 marks) P2: Register classes Focus: Inheritance In this part of the project, you will create classes representing more components of our simulated machine, specifically we will create classes to model the different registers in the Central Processing Unit (CPU) MEMORY 0 0799 0798 0198 0499 1008 1108 0899 Input Device 2 3 4 5 6 7 8 9 Program Counter CENTRAL PROCESSING UNIT 0898 Instruction Register Accumulator Output Device Start by creating a new package P2 and copy to it the two classes you created in P1 (i.e. Memory and Terminal). Then add more classes to P2 as indicated below. Note that you can also use the classes from P1 solution" that is posted on Connect instead of your own previous classes (A) The simulated CPU contains 3 registers o Program counter (PC): stores the memory address of the next instruction to execute o Instruction register (IR): stores the current instruction to execute o Accumulator (ACC): stores the temporary computational results A good way to organize your classes is to 1- Create a Register class that has a private attribute: int value, a constructor which mark] sets value to a given value, and basic setter and getter methods for value 2- Create three classes PC, IR and ACC which inherit from Register. Here, we can say marks] that: [2 marks] A PC is a Register that can increment its value. (i.e. you needa method to increment value) [3 marks] An IR is a Register that can decode the instruction by the use of two methods: getOpCode which returns the "operation code" part of the instruction o o
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started