Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following game has 12 parts and I can't seem to understand the algorithm in 8 parts. I want you to re-do the whole code

The following game has 12 parts and I can't seem to understand the algorithm in 8 parts. I want you to re-do the whole code and propose to me changes that will make it more difficult(GAMEPLAY). Also make sure you explain each line of code and provide me with an output for the same. This game is very complicated please do not try if you don't know what you are doing.

/**

* Returns a string equivalent to the original string with n added to every integer number in

the string, where an integer number is defined as a contiguous sequence of digits, and signs * are ignored (i.e., all integers are considered to be positive). All leading zeros should be

* discarded.

*

* If 'flip' is true, the order of the digits within every number will be reversed (before adding n). * If 'flip' is false, the digits will remain in their original order within the string.

*

String addNumber(int n, boolean flip);

/**

* Returns a string equivalent to the original string with n added to every integer number in

* the string, where an integer number is defined as a contiguous sequence of digits, and signs

* are ignored (i.e., all integers are considered to be positive). All leading zeros should be

* discarded.

*

* If 'flip' is true, the order of the digits within every number will be reversed (before adding n).

* If 'flip' is false, the digits will remain in their original order within the string.

*

* Examples:

* - For n=2 and flip=false, "hello 90, bye 2" would be converted to "hello 92, bye 4".

* - For n=10 and flip=false, "-12345" would be converted to "-12355".

* - For n=0 and flip-true, "12345" would be converted to "54321".

* - For n=8 and flip-true, "hello 90, bye 2" would be converted to "hello 17, bye 10".

* - For n=100 and flip=true, "hello 2022, bye 2000" would be converted to "hello 2302, bye 102".

*

* @param n amount to add to every number

@param flip Boolean that indicates whether digits within a number should be reversed

* @return String with n added to every number in the string, with the number reversed, if indicated

* @throws NullPointerException If the current string is null

* @throws IllegalArgumentException If n is negative, and the current string is not

*/

null

* Examples:

* - For n=2 and flip-false, "hello 90, bye 2" would be converted to "hello 92, bye 4".

* - For n=10 and flip-false, "-12345" would be converted to "-12355".

* - For n=0 and flip=true, "12345" would be converted to "54321".

* - For n=8 and flip=true, "hello 90, bye 2" would be converted to "hello 17, bye 10".

* - For n=100 and flip=true, "hello 2022, bye 2000" would be converted to "hello 2302, bye 102".

*

* @param n amount to add to every number

* @param flip Boolean that indicates whether digits within a number should be reversed

* @return String with n added to every number in the string, with the number reversed, if indicated

* @throws NullPointerException If the current string is null

* @throws IllegalArgumentException If n is negative, and the current string is not null */

String addNumber(int n, boolean flip);

"#include

#include

using namespace std;

class Customer

{

public:

int order;

int ID;

int price;

};

int main()

{

queue Q;

Q.push({2, 1, 50});

Q.push({3, 2, 30});

Q.push({1, 3, 10});

// To keep track of the order

int order_count = 1;

while (!Q.empty())

{

// Dequeue and print front

Customer order = Q.front();

cout << "Order " << order_count << ": "

<< "ID: " << order.ID << ", "

<< "Order: " << order.order << ", "

<< "Price: " << order.price << ' ';

Q.pop();

// Increment order_count

order_count++;

}

return 0;

}"

void execute_itype_except_load(Instruction instruction, Processor *processor) {

switch (instruction.itype.funct3) {

case 0x0:

// ADDI

break;

case 0x1:

// SLLI

break;

case 0x2:

// STLI

break;

case 0x4:

// XORI

break;

case 0x5:

// Shift Right (You must handle both logical and arithmetic)

case 0x6:

// ORI

break;

case 0x7:

// ANDI

break;

default:

handle_invalid_instruction(instruction);

break;

}

}

void execute_ecall(Processor *p, Byte *memory) {

Register i;

// syscall number is given by a0 (x10)

// argument is given by a1

switch(p->R[10]) {

case 1: // print an integer

printf("%d",p->R[11]);

break;

case 4: // print a string

for(i=p->R[11];i

printf("%c",load(memory,i,LENGTH_BYTE));

}

break;

case 10: // exit

printf("exiting the simulator ");

exit(0);

break;

case 11: // print a character

printf("%c",p->R[11]);

break;

default: // undefined ecall

printf("Illegal ecall number %d ", p->R[10]);

exit(-1);

break;

}

}

void execute_branch(Instruction instruction, Processor *processor) {

switch (instruction.sbtype.funct3) {

case 0x0:

// BEQ

break;

case 0x1:

// BNE

break;

default:

handle_invalid_instruction(instruction);

exit(-1);

break;

}

}

void execute_load(Instruction instruction, Processor *processor, Byte *memory) {

switch (instruction.itype.funct3) {

case 0x0:

// LB

break;

case 0x1:

// LH

break;

case 0x2:

// LW

break;

default:

handle_invalid_instruction(instruction);

break;

}

}

void execute_store(Instruction instruction, Processor *processor, Byte *memory) {

switch (instruction.stype.funct3) {

case 0x0:

// SB

break;

case 0x1:

// SH

break;

case 0x2:

// SW

break;

default:

handle_invalid_instruction(instruction);

exit(-1);

break;

}

}

void execute_jal(Instruction instruction, Processor *processor) {

/* YOUR CODE HERE */

int nextPC=processor->PC+(sWord)get_jump_offset(instruction);

processor->R[instruction.ujtype.rd]=processor->PC+4;

processor->PC=nextPC;

}

void execute_lui(Instruction instruction, Processor *processor) {

/* YOUR CODE HERE */

int imm = (instruction.utype.imm << 12);

processor->R[instruction.utype.rd] = imm;

processor->PC +=4;

}

void store(Byte *memory, Address address, Alignment alignment, Word value) {

/* YOUR CODE HERE */

if (address >= MEMORY_SPACE){

handle_invalid_write(address);

}

"rpart1": {

"mark": 2,

"comment": "Program did not run successfully. It either did not build or exited with error code 0" },

"rpart2": {

"mark": 0,

"comment": "Program ran and output matched."

"riparti": {

"mark": 0,

"comment": "Program ran and output matched."

},

"ripart2": {

"mark": 2,

"comment": "Program did not run successfully. It either did not build or exited with error code 0"

"ipart1": {

"mark": 14,

"comment": "Program ran, but output did not match. see log file"

"ipart2": {

"mark": 4,

"comment": "Program did not run successfully. It either did not build or exited with error code 0"

"spart1": {

"mark": 12,

"comment": "Program ran and output matched."

"spart2": {

"mark": 12,

"comment": "Program ran and output matched."

"sbpart1": {

"mark": 12, "comment": "Program ran and output matched."

"sbpart2": {

"mark": 12,

"comment": "Program ran and output matched."

if (head.x == food.x && head.y == food.y)

{

length++;

time_t a;

a = time(0);

srand(a);

food.x = rand() % 70;

if (food.x <= 10)

food.x += 11;

food.y = rand() % 30;

if (food.y <= 10)

food.y += 11;

}

else if (food.x == 0)

{

food.x = rand() % 70;

if (food.x <= 10)

food.x += 11;

food.y = rand() % 30;

if (food.y <= 10)

food.y += 11;

}

}

void Left(){

int i;

for (i = 0; i <= (bend[bend_no].x - head.x) && len < length; i++)

{

GotoXY((head.x + i), head.y);

{

if (len == 0)

printf("<");

else

printf("O");

}

body[len].x = head.x + i;

body[len].y = head.y;

len++;

}

Bend();

if (!kbhit())

head.x--;

}

void Right(){

int i;

for (i = 0; i <= (head.x - bend[bend_no].x) && len < length; i++)

{

// GotoXY((head.x-i),head.y);

body[len].x = head.x - i;

body[len].y = head.y;

GotoXY(body[len].x, body[len].y);

{

if (len == 0)

printf(">");

else

printf("O");

}

len++;

}

Bend();

if (!kbhit())

head.x++;

}

void Bend(){

int i, j, diff;

for (i = bend_no; i >= 0 && len < length; i--)

{

if (bend[i].x == bend[i - 1].x)

{

diff = bend[i].y - bend[i - 1].y;

if (diff < 0)

for (j = 1; j <= (-diff); j++)

{

body[len].x = bend[i].x;

body[len].y = bend[i].y + j;

GotoXY(body[len].x, body[len].y);

printf("O");

len++;

if (len == length)

break;

}

else if (diff > 0)

for (j = 1; j <= diff; j++)

{

body[len].x = bend[i].x;

body[len].y = bend[i].y - j;

GotoXY(body[len].x, body[len].y);

printf("O");

len++;

if (len == length)

break;

}

}

else if (bend[i].y == bend[i - 1].y)

{

1)Design at least one attack scenario.

For the purposes of this scenario, we will assume that the attacker is attempting to gain access to a server by using a method known as brute force. In order to carry out the attack, we will utilize the Hydra tool.

2) Show the difference with and without IDS tool.

To begin, we will conduct the attack without using any kind of IDS instrument. The adversary will be able to break through the SSH login and get access to the server by using the brute force attack.

Next, we will install an intrusion detection system (IDS) tool such as Snort. After that, we shall carry out the assault once more. This time, the intrusion detection system (IDS tool) will notice the attack and sound the alert. It is not going to be possible for the attacker to obtain access to the server successfully.

3)Use virtual machines for the demonstration.

We will be utilizing two different virtual computers for the sake of this presentation. It has been decided that one virtual machine would act as the server, while the second virtual machine will take on the role of the attacker.

4)Write down the detailed steps, screen captures and explanation in a report. Show all commands.

In the beginning, we will configure the server. Installing the SSH service and setting it up to need a password for authentication is next on our agenda.

Following that, we will configure the machine that will do the attacking. We will begin the SSH brute force attack by installing the Hydra tool and use it to carry it out.

Unix is important in today's world because it offers a standardized method for communicating with different kinds of hardware. This makes it easier for software developers to produce software that is compatible with a number of devices, and it also makes it easier for users to use the same program on a variety of devices. It is not necessary for the operating system to be custom-tailored for a particular kind of electronic gadget. This is significant because it makes it possible to achieve a higher level of compatibility between different operating systems and devices. It enables a higher level of compatibility between various devices. This is due to the fact that the operating system does not need to be concerned with determining whether or not a particular device is compatible with it. It enables a larger degree of freedom with regard to both the input and the output. This is due to the fact that the operating system is capable of reading and writing data from any kind of device. It makes for an easier and more pleasant experience for the user. This is due to the fact that the user does not need to be concerned with selecting the appropriate device in order to input or output data. When dealing with a variety of devices, it enables a larger degree of freedom to be utilized. This is significant because it indicates that operating systems can be used with a diverse range of devices without the user having to be concerned about compatibility difficulties. Operating systems can benefit from device independence, which can help to improve their overall performance. This is due to the fact that the operating system does not need to spend time figuring out how to operate with a specific device. Device-independence can help to make an operating system more reliable. This is due to the fact that the operating system does not need to be concerned with interacting with devices that it is unable to comprehend.

The Unix operating system provides a standardized approach for interfacing with a variety of hardware configurations and types. This not only makes it simpler for developers of software to create software that is compatible with a number of different devices, but it also simplifies the process for users of software to use the same program on a number of different types of devices.

It is not necessary for the operating system to be modified in a way that is specific to the kind of electronic device that is being used. This is significant because it makes it feasible to establish a better level of compatibility between various operating systems and devices. This is something that was previously impossible.

The fact of the issue is that it is not only highly valuable for making devices interoperable with one another, but it also offers a great deal of versatility as well. An illustration is the most helpful tool for gaining an understanding of how this operates. Imagine for a moment that there is a piece of software that, after displaying a collection of data points on the screen, goes on to do some kind of calculation on those points. When executed on computers that use the Unix operating system, this program will function admirably on a wide variety of portable electronic devices.

When you use an accessory that is compatible with your computer's operating system, the computer does not have to worry about how to interact with the accessory because it already knows how to do so.

This indicates that when you power on your computer, it will be able to load all of its processes immediately, negating the need for you to wait for them to initialize. Because of this, your computer system will be able to carry out commands more rapidly, which will make working with your computer more pleasurable and productive.

It is especially important to have device independence if your computer system is connected to a large number of different devices, as this will assist avoid any compatibility difficulties that may arise between the various devices that are connected.

Independent operation of peripheral hardware is a critical component that contributes to the dependability and adaptability of an operating system. It has the capacity to allow software programs to function without having to worry about how the operating system will perform, or if it will be compatible with a given device.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Computer Network questions

Question

Solve the following the equation. y=192+0.04y

Answered: 1 week ago