1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
nirvana33 [79]
4 years ago
11

This lab is another relatively short exercise in which you will code part of an existing project. In this case, you will be work

ing with a doubly-linked list. To make this topic more interesting, the list that you work on will be part of a Turing Machine. A Turing Machine is a kind of very simple, abstract computing device that was introduced in the 1930's by Alan Turing as a way of studying computation and its limitations.
The classes that you need for the lab are in a package named turing. You will define a new class named Tape in this package. You can find the Java source in the code directory. You should copy this directory into an Eclipse project. There will be errors, since the existing classes depend on the Tape class, which you have not yet written.
Computers and Technology
1 answer:
Anika [276]4 years ago
4 0

Answer:

Below is the code for Tape.java. Since it is in the package turing, you have to define it in the beginning.

Tape.java:

package turing;

public class Tape {

private Cell currentCell; // Current cell pointer

public Tape() { //Constructor to create a blank tape with a single cell, which contains a blank space.

Cell newCell = new Cell();

newCell.content = ' ';

newCell.prev = null;

newCell.next = null;

currentCell = newCell;

}

public Cell getCurrentCell() { //The pointer to current cell.

return currentCell;

}

public char getContent() { //The content of current cell.

return currentCell.content;

}

public void setContent(char ch) { //ch The character to be set into the current cell.

currentCell.content = ch;

}

public void moveLeft() { //Moves the current cell one position to the left along the tape.

if (currentCell.prev == null) {

Cell newCell = new Cell();

newCell.content = ' ';

newCell.prev = null;

newCell.next = currentCell;

currentCell.prev = newCell;

}

currentCell = currentCell.prev;

}

public void moveRight() { //Moves the current cell one position to the right along the tape.

if (currentCell.next == null) {

Cell newCell = new Cell();

newCell.content = ' ';

newCell.next = null;

newCell.prev = currentCell;

currentCell.next = newCell;

}

currentCell = currentCell.next;

}

public String getTapeContents() { //Returns a String consisting of the chars from all the cells on the tape.

Cell pointer = currentCell;

while (pointer.prev != null)

pointer = pointer.prev;

String strContent = "";

while (pointer != null) {

strContent += pointer.content;

pointer = pointer.next;

}

strContent = strContent.trim(); //Returns a copy of the string, with leading and trailing whitespace omitted.

return strContent;

}

}

Explanation:

You might be interested in
You are the CISO of a company and you need to create logging policies. Please review NIST SP800-92, specifically sections 4–3 th
Kitty [74]

<u>The various systems on a network and develop a logging policy based on the information in the aforementioned sections:</u>

Cisco is router, which is physical device appliance where placed in LAN OR WAN for connecting workstation or desktop or laptop of other offices in organization.

It is a security device and purpose to make organization to access or connected to end use of other networks.

Basically there routers are used ISDN LINE, LEASE LINE or VPN for connecting varies WAN

Purpose of keeping the logging polices to do further analysis how the network packets or traffic is executed and passed different tcpip address. If case any hackers or packet loss the network administrator will do further analysis and protect the system form packet loss or from hackers.  Keeping network logs is policy driven. So network administrator keeps logs for no. of days.

Some network administration export log and keep as reference.

4 0
4 years ago
A vast global network that is made up of many smaller interconnected networks is known as:
Galina-37 [17]

The answer is The Internet.   It is a vast global network that is made up of many smaller interconnected networks. It connects to millions of computer units world wide, in which any computer can communicate with any other computer as long as they are both connected to the Internet. It also made access to information and communication easier.

6 0
4 years ago
Read 2 more answers
Which tab is used to edit objects on the Slide Master and layouts?
andreev551 [17]
When your trying to master the slide layouts you must go to the Slide Layout tab.
4 0
3 years ago
When you call a ____________ method, it executes statements it contains and then returns a value back to the program statement t
Maksim231197 [3]

Answer:

The answer is a VOID method.

Explanation:

A void method is one that simply performs a task and then terminates.

4 0
4 years ago
Read 2 more answers
_____ is a valid URL, or internet address. In this URL, ______ indicates the protocol.
Natalija [7]

Answer:

1. B.http://www.example.com

2. A. http

Explanation:

7 0
3 years ago
Other questions:
  • 3) Write a program named Full_XmasTree using a nested for loop that will generate the exact output. This program MUST use (ONLY)
    6·1 answer
  • What is it called when someone attempts to befriend you online for the purpose of stealing confidential or sensitive information
    10·1 answer
  • Discuss some design considerations that you should keep in mind when you want to design a professional-looking flyer or newslett
    5·2 answers
  • The standard toolbar appears whenever you select text.
    5·1 answer
  • Reflect on the questions below.
    7·1 answer
  • Write a program that inputs a text file. The program should print the unique words in the file in alphabetical order. Uppercase
    11·1 answer
  • Select the correct answer from each drop-down menu.
    12·1 answer
  • Who is known as the first computer programmer?​
    13·1 answer
  • Hahaahhaahahuahaahahhahqha
    13·1 answer
  • You have an application running on multiple ec2 instances, however every time an instance fails, your users complain that they l
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!