Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
I need help fix this Java code described below so that it can be followed in the image below
package classPackage;
import interfaces.RatInterface;
public class Rat implements RatInterface {
private int ratEnergy = 5;
@Override
public String move() {
// TODO Auto-generated method stub
returnnull;
}
@Override
publicint getAliveState() {
// TODO Auto-generated method stub
return 0;
}
@Override
publicvoid refresh() {
ratEnergy = 5;
}
@Override
publicvoid wearDown() {
ratEnergy -= 1;
}
@Override
public String getId() {
// TODO Auto-generated method stub
returnnull;
}
}
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps
Knowledge Booster
Similar questions
- what are the positives and negatives of the two designs attached. The Java code next to each design shows an example of how the constructors are implemented in the subclasses. Constructor code for the other two other subclasses is same as the Bipedal constructor in each design (except the number of legs value). designs attachedarrow_forwardHi, can you please help me out with these?arrow_forwardWrite in Java a code give out what is on the image. Essentially write in the main function so that it prints what is in the image. Im stuck at that part it would be much appreciated if you could help. package javaapplication31; import java.util.Random;import java.util.Scanner;/**** @author */public class JavaApplication31 {String name;/*** @param args the command line arguments*/public static void main(String[] args) {int totalScore = 300;int itrcount =12;int reward;char direction;int x = 0;int y = 0;System.out.println(reward());System.out.println(inputDirection());}public static void displayInfo(int x, int y, int itrCount, int totalScore){x = 0;y = 0;itrCount = 0;totalScore =300;System.out.println("");}public static boolean doesExceed (int x,int y, char direction){return (y > 4 && Character.toLowerCase(direction) == 'u' || x < 0 && Character.toLowerCase(direction) == '1'||y < 0 && Character.toLowerCase(direction) == 'd' || x > 4 &&…arrow_forward
- For this assignment, create a child class of car that creates a car of a randomly generated color. Using the existing car classes, add code to add 20 colored cars to the existing pane in 20 visible, random locations. You will end up with 4 classes: CarViewer.java CarComponent.java Car.java (unchanged from Chapter 3) ColorCar.java (extends Car)arrow_forwardI need help with creating a Java program described in the image below: StringInstrument.java: // TODO: Define a class: StringInstrument that is derived from the Instrument classpublic class StringInstrument extends Instrument { // TODO: Declare private fields // TODO: Define mutator methods - // setNumOfStrings(), setNumOfFrets(), setIsBowed() // TODO: Define accessor methods - // getNumOfStrings(), getNumOfFrets(), getIsBowed() } Instrument.java: public class Instrument { protected String instrumentName; protected String instrumentManufacturer; protected int yearBuilt, cost; public void setName(String userName) { instrumentName = userName; } public String getName() { return instrumentName; } public void setManufacturer(String userManufacturer) { instrumentManufacturer = userManufacturer; } public String getManufacturer(){ return instrumentManufacturer; } public void setYearBuilt(int…arrow_forwardHi I want to create a JAVA program that will allow me to create a canvas (specifically in eclipse). Can someone straighten my code import java.awt.*;import javax.swing.*;class Main extends JFrame { // constructor Main() { super("canvas"); // create a empty canvas Main c = new Main() { // paint the canvas public void paint(Graphics g) { // set color to red g.setColor(Color.red); // set Font g.setFont(new Font("Bold", 1, 20)); // draw a string g.drawString("This is a canvas", 100, 100); } }; // set background c.setBackground(Color.black); add(c); setSize(400, 300); show(); } // Main Method public static void main(String args[]) { Main c = new Main(); }} ReplyForwardarrow_forward
- please write code in java Create a right triangle class with instance variables(double) for sideA, sideB and the hypo. write three constructors -the 2-param version assigns to sides A and B respectively. the 1-param version assigns the same value to both sides. the 0-param version assigns 10.0 to each side. the constructor also computes the hypotenuse based on the other two sides and saves that in the hypotenuse variable. Create accessors for all three variables. Write a toString() that will print/label the three sides. write some main code to create three instances of your class, one to test each of your constructors. you can input values or use fixed values. Display each instance using an implicit toString() call.arrow_forwardImplement the Board class. Make sure to read through those comments so that you know what is required. import java.util.Arrays; import java.util.Random; public class Board { // You don't have to use these constants, but they do make your code easier to read public static final byte UR = 0; public static final byte R = 1; public static final byte DR = 2; public static final byte DL = 3; public static final byte L = 4; public static final byte UL = 5; // You need a random number generator in order to make random moves. Use rand below private static final Random rand = new Random(); private byte[][] board; /** * Construct a puzzle board by beginning with a solved board and then * making a number of random moves. Note that making random moves * could result in the board being solved. * * @param moves the number of moves to make when generating the board. */ public Board(int moves) { // TODO } /** * Construct a puzzle board using a 2D array of bytes to indicate the contents *…arrow_forwardCreate the UML Diagram for this java code import java.util.Scanner; interface Positive{ void Number();} class Square implements Positive{ public void Number() { Scanner in=new Scanner(System.in); System.out.println("Enter a number: "); int a = in.nextInt(); if(a>0) { System.out.println("Positive number"); } else { System.out.println("Negative number"); } System.out.println("\nThe square of " + a +" is " + a*a); System.out.println("\nThe cubic of "+ a + " is "+ a*a*a); }} class Sum implements Positive{ public void Number() { Scanner in = new Scanner(System.in); System.out.println("\nEnter the value for a: "); int a = in.nextInt(); System.out.println("Enter the value for b" ); int b= in.nextInt(); System.out.printf("The Difference of two numbers: %d\n", a-b); System.out.printf("The…arrow_forward
- Please answer the following questions:arrow_forwardDebug this program to create the desired result attached in the picture. public class Library { // Add the missing implementation to this class public static void main(String[] args) { // Create two libraries Library firstLibrary = new Library("10 Main St."); Library secondLibrary = new Library("228 Liberty St."); // Add four books to the first library firstLibrary.addBook(new Book("A Tale of Two Cities ")); firstLibrary.addBook(new Book("Le Petit Prince")); firstLibrary.addBook(new Book("The DaVinci Code")); firstLibrary.addBook(new Book("The Lord of the Rings")); // Print opening hours and the addresses System.out.println("Library hours:"); printOpeningHours(); System.out.println(); System.out.println("Library addresses:"); firstLibrary.printAddress(); secondLibrary.printAddress(); System.out.println(); // Try to borrow The Lords of the Rings from both libraries System.out.println("Borrowing The Lord of the Rings:"); firstLibrary.borrowBook("The Lord of the Rings");…arrow_forwardPythonarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY