Question

******Java Programming Hi guys, I really need you help. I created a code for my java...

******Java Programming

Hi guys,

I really need you help. I created a code for my java course, but it keep giving me error messages. Majority of my code is fine but some keep display error on my console. I was hoping someone could pin points the problem. .There are three classes with the testCenter class being the main class. In the following is the assignment, and the bottom is my code. Please help!

Assignment:

Concepts:

GUI

User Design

Graphics

Deployment

Programming Project:

Create a GUI using Swing or Spring Boot for one of the previous programming projects. Convert all console input/output to be used in a GUI. Follow standard programming practices for the design of the GUI.  See this link for more details (Links to an external site.)

. Have fun with it.

Submission:

Submit the executable jar file so that I can run your program.  See this link on how to make an executable jar file.

Animal Class (I place error messages where the problems accures)

//error message

package testCenter;

//error message across the five javafx

import javafx.application.Application;

import javafx.scene.Scene;

import javafx.layout.Stackpane;

import javafx.scene.text.Text;

import javafx.stage.Stage;

//error message

public class Animal implements Runnable {

static boolean winner;

private String name;

private int position;

private int speed;

private int rest;

private Food food;

String read;

public Animal(String name, int pos, int speed, int rest, Food food) {

winner = false;

this.name = name;

this.position = pos;

this.speed = speed;

this.rest = rest;

this.food = food;

}

public void lamborgini() { //run

while(position < 100 && !winner) {

position += speed;

System.out.println(this);

food.eat(rest, read);

}//End of while loop.

winner = true;

System.exit(0);

}//End of void

public int getPosition() {

return position;

}

public String toString(){

read = "Player: " + name + "\nCurrent position in race: \n" + position;

return read;

}

}//end of class

Food Class:

import org.w3c.dom.Text;

class Food {

//error message

Text Message = new Text();

public synchronized void eat(int timeMachine, String textMsg) {

try {

//error message

Message.setText(textMsg + "I'm currently eating.");

System.out.println("I'm currently eating.");

Thread.sleep(timeMachine * 20);

//error message

Message.setText(textMsg + "I'm currently eating.");

System.out.println("I'm done eating.");

} catch(InterruptedException e){

e.printStackTrace();

}

}

} //end of class.

Test Center class:

//error message

public class testCenter extends Application {

//error message

public void start(Stage superStar) {

Food food = new Food();

Animal turtle = new Animal("Turtle", 0, 3, 100, food);

Animal rabbit = new Animal("Rabbit", 0, 5, 150, food);

Thread turtleT = new Thread(turtle);

Thread rabbitR = new Thread(rabbit);

turtleT.start();

rabbitR.start();

//error message

StackPane goGirl = new StackPane();

goGirl.getChildren().add(food.Message);

//error message

Scene action1 = new Scene(goGirl, 350, 200);

superStar.setScene(action1);

superStar.show();

}

public static void main(String[] args) {

//error message

launch(args);

}

} //end of class

0 0
Add a comment Improve this question Transcribed image text
Answer #1

It would have been easier if you included what the error messages were as well as the position. Its hard to fix the errors wirhout knowing what exactly they are. I'll provide a possible fix based on the errors I got while running the code.

1. Make sure the package name and the parent folder name are correct. Make sure you created a Java package properly.

2.You need to have JavaFX installed to import it. You can get the jar files and install it easily.

3. You dont need Animal to implement Runnable since it is not an abstract function.

4. You might have imported the wrong Text class. There is a JavaFX Text class as well. Install JavaFX and try including that. If it still doesnt work try using a JLabel instead.

5.You probably got this error because the Text you imported doesnt have a setText method. The above step should fix it.

6.Your class Food should extend Thread or implement Runnable if you want to use Threads.

7. The next few errors may be caused by a mistake in extending Application.

Again, this is merely speculation based on the errors I got. If this doesnt fix it include the error messages as well.

Add a comment
Know the answer?
Add Answer to:
******Java Programming Hi guys, I really need you help. I created a code for my java...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need help with my IM (instant messaging) java program, I created the Server, Client, and...

    I need help with my IM (instant messaging) java program, I created the Server, Client, and Message class. I somehow can't get both the server and client to message to each other. I am at a roadblock. Here is the question below. Create an IM (instant messaging) java program so that client and server communicate via serialized objects (e.g. of type Message). Each Message object encapsulates the name of the sender and the response typed by the sender. You may...

  • Java Programming: Hi, I need help Modifying my code that will throw an IllegalArgumentException. for the...

    Java Programming: Hi, I need help Modifying my code that will throw an IllegalArgumentException. for the following data entry error conditions: A number less than 1 or greater than 12 has been entered for the month A negative integer has been entered for the year utilizes a try and catch clause to display an appropriate message when either of these data entry errors exceptions occur. Thank you let me know if you need more info import java.util.*; //Class definition public...

  • Hey guys! Huge part of my grade !! My code works already but I need it...

    Hey guys! Huge part of my grade !! My code works already but I need it so it references to my node list class instead of my array, what would I need to change? My assignment  was to create a list from an assignment when we used an array, but I cant make it to work without the array, help! The professor said it was okay to either keep the array or to delete it altogether. package zipcode; import java.io.File; import...

  • I need help with adding comments to my code and I need a uml diagram for...

    I need help with adding comments to my code and I need a uml diagram for it. PLs help.... Zipcodeproject.java package zipcodesproject; import java.util.Scanner; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class Zipcodesproject { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner input=new Scanner(System.in); BufferedReader reader; int code; String state,town; ziplist listOFCodes=new ziplist(); try { reader = new BufferedReader(new FileReader("C:UsersJayDesktopzipcodes.txt")); String line = reader.readLine(); while (line != null) { code=Integer.parseInt(line); line =...

  • I need a shoppingcartmanager.java that contains a main method for this code in java Itemtopurchase.java public...

    I need a shoppingcartmanager.java that contains a main method for this code in java Itemtopurchase.java public class ItemToPurchase {    // instance variables    private String itemName;    private String itemDescription;    private int itemPrice;    private int itemQuantity;    // default constructor    public ItemToPurchase() {        this.itemName = "none";        this.itemDescription = "none";        this.itemPrice = 0;        this.itemQuantity = 0;    }    public ItemToPurchase(String itemName, int itemPrice, int itemQuantity,String itemDescription) {   ...

  • Hello! I have a problem in my code please I need help, I don't know How I can wright precondition, so I need help about assertion of pre_condition of peek. Java OOP Task is! Improve the circular a...

    Hello! I have a problem in my code please I need help, I don't know How I can wright precondition, so I need help about assertion of pre_condition of peek. Java OOP Task is! Improve the circular array implementation of the bounded queue by growing the elements array when the queue is full. Add assertions to check all preconditions of the methods of the bounded queue implementation. My code is! public class MessageQueue{ public MessageQueue(int capacity){ elements = new Message[capacity];...

  • Hey guys I am having trouble getting my table to work with a java GUI if...

    Hey guys I am having trouble getting my table to work with a java GUI if anything can take a look at my code and see where I am going wrong with lines 38-49 it would be greatly appreciated! Under the JTableSortingDemo class is where I am having erorrs in my code! Thanks! :) import java.awt.*; import java.awt.event.*; import java.util.*; import java.util.List; import javax.swing.*; public class JTableSortingDemo extends JFrame{ private JTable table; public JTableSortingDemo(){ super("This is basic sample for your...

  • I need help fixing my java code for some reason it will not let me run...

    I need help fixing my java code for some reason it will not let me run it can someone pls help me fix it. class LinearProbingHashTable1 { private int keyname; private int valuename; LinearProbingHashTable1(int keyname, int valuename) { this.keyname = keyname; this.valuename = valuename; } public int getKey() { return keyname; } public int getValue() { return valuename; } } class LinearProbingHashTable2 { private final static int SIZE = 128; LinearProbingHashTable2[] table; LinearProbingHashTable2() { table = new LinearProbingHashTable2[SIZE]; for (int...

  • I am getting this Error can you please fix my Java code. import java.awt.Dialog; import java.awt.Label;...

    I am getting this Error can you please fix my Java code. import java.awt.Dialog; import java.awt.Label; import java.awt.TextArea; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map.Entry; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; public class Fall_2017 {    public TextArea courseInput;    public Label textAreaLabel;    public JButton addData;    public Dialog confirmDialog;    HashMap<Integer, ArrayList<String>> students;    public Fall_2017(){    courseInput = new TextArea(20, 40);    textAreaLabel = new Label("Student's data:");    addData = new JButton("Add...

  • JAVA Modify the code to create a class called box, wherein you find the area. I...

    JAVA Modify the code to create a class called box, wherein you find the area. I have the code in rectangle and needs to change it to box. Here is my code. Rectangle.java public class Rectangle { private int length; private int width;       public void setRectangle(int length, int width) { this.length = length; this.width = width; } public int area() { return this.length * this.width; } } // CONSOLE / MAIN import java.awt.Rectangle; import java.util.Scanner; public class Console...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT