Question

Java - Object Oriented Programming From the game slither.io Identify objects that you can see ...

Java - Object Oriented Programming

From the game slither.io

  1. Identify objects that you can see on the picture.

  2. Pick one object from part a. Create a class (Java code) for that object which contain data member, method and constructor. Implement the class inside main function by creating that object.

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

a.

The objects which i am able to find are

1. Snake

2. Earthworm.

b.

import java.util.Scanner;

public class Snake {

String name;

String length;

String category;

boolean isPoisonous;

String origin;

  

Snake(String name, String length, String category, boolean isPoisonous, String origin) {

this.name = name;

this.length = length;

this.category = category;

this.isPoisonous = isPoisonous;

this.origin = origin;

}

  

public void snakeDescription(String length, boolean isPoisonous, String category, String name, String origin) {

String poison = "";

if (isPoisonous == true) {

   poison = "poisonous" ;

}

else {

   poison = "not poisonous" ;

}

System.out.println("This snake is "+name+ ".It is found in "+origin+".The average length of these types of snakes is "+length+". It comes under the category of "+category+".It is "+poison);

}

  

}

import java.util.Scanner;
public class Main
{
   public static void main(String[] args) {
   Scanner scan = new Scanner(System.in);
System.out.println("Enter name");
String name = scan.nextLine();
System.out.println("Enter length");
String length = scan.nextLine();
System.out.println("Enter category");
String category = scan.nextLine();
System.out.println("Enter origin");
String origin = scan.nextLine();

Snake sn = new Snake(name,length,category,true,origin);
sn.snakeDescription(length,true,category,name,origin);

   }
}

Output is in the image below

In Enter name cobra Enter length 100 Enter category python nter origin africa phis snake is eobra.It is found in africa.The a

If you have any doubt please ask in the comment section and please like the answer :)

Add a comment
Know the answer?
Add Answer to:
Java - Object Oriented Programming From the game slither.io Identify objects that you can see ...
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
  • Java - Object Oriented Programming Declare a class named Customer that has two private fields? Write...

    Java - Object Oriented Programming Declare a class named Customer that has two private fields? Write a set method to make sure that if age > 125 years or less than 0 then it is set to 0 (default value) What does it indicate when declaring a class's instance variables with private access modifier? What is the role of a constructor? The data part of by an object's instance variables is known as? Do all methods have to always return...

  • Java is an object-oriented programming language that enables us to define classes and to instantiate them...

    Java is an object-oriented programming language that enables us to define classes and to instantiate them into objects. These objects then call each other’s methods to implement the behavior of the application. The Unified Modeling Language (UML) is an object-oriented visual notation to document the design of object-oriented classes. For this discussion, you will practice designing a Java class called Course, drawing a UML class diagram for the Course class, and then implementing the Course class in Java code. Review...

  • OBJECT ORIENTED PROGRAMMING C++ B- The programming section has 2 parts: Part 1 - Create a...

    OBJECT ORIENTED PROGRAMMING C++ B- The programming section has 2 parts: Part 1 - Create a class - (35 points) Create a class called CustomDressInvoice. It should have 5 data members: designTime (int), designRate (int), sewing Time (int), sewingRate (int), and materialsCost. The invoice amount is calculated with this formula: Invoice Amount = (designTime * designRate) + (sewingTime * sewing Rate) + materialCost All times are charged by the hours, and rates are charged by the dollars (no cents). The...

  • Programming Assignment 6: Object Oriented Programming Due date: Check Syllabus and Canvas Objectives: After successfully completing...

    Programming Assignment 6: Object Oriented Programming Due date: Check Syllabus and Canvas Objectives: After successfully completing this assignment, students will practice Object Oriented design and programming by creating a Java program that will implement Object Oriented basic concepts. RetailItem Class: Part 1: Write a class named RetailItem that holds data about an item in a retail store. The class should have the following fields: • description. The description field references a String object that holds a brief description of the...

  • In 6A, you created an object class encapsulating a Trivia Game which INHERITS from Game. Now...

    In 6A, you created an object class encapsulating a Trivia Game which INHERITS from Game. Now that you have successfully created Trivia objects, you will continue 6B by creating a linked list of trivia objects. Add the linked list code to the Trivia class. Your linked list code should include the following: a TriviaNode class with the attributes: 1. trivia game - Trivia object 2. next- TriviaNode 3. write the constructor, accessor, mutator and toString methods. A TriviaLinkedList Class which...

  • 1) Using the Object-Oriented Programming Paradigm,implement the necessary code in Python creating a ‘Car’ class with...

    1) Using the Object-Oriented Programming Paradigm,implement the necessary code in Python creating a ‘Car’ class with a constructor that stores all the Car information (ID, MAKE, MODEL, YEAR , COLOR, MILEAGE, PRICE_TO_DEALER, SALE_PRICE, PROFIT) as attributes. 2) Implement and add the following methods to the ‘Car' class in Question 1. a) necessary getter methods b) necessary setter methods c) method to display all the information to the screen d) a method to calculate the profit

  • You will need to first create an object class encapsulating a Trivia Game which INHERITS from...

    You will need to first create an object class encapsulating a Trivia Game which INHERITS from Game. Game is the parent class with the following attributes: description - which is a string write the constructor, accessor, mutator and toString methods. Trivia is the subclass of Game with the additional attributes: 1. trivia game id - integer 2. ultimate prize money - double 3. number of questions that must be answered to win - integer. 4. write the accessor, mutator, constructor,...

  • In object-oriented programming, the object encapsulates both the data and the functions that operate on the...

    In object-oriented programming, the object encapsulates both the data and the functions that operate on the data. True False Flag this Question Question 101 pts You must declare all data members of a class before you declare member functions. True False Flag this Question Question 111 pts You must use the private access specification for all data members of a class. True False Flag this Question Question 121 pts A private member function is useful for tasks that are internal...

  • I Need Help with this using Java Programming : Class name fname lname Class variable total...

    I Need Help with this using Java Programming : Class name fname lname Class variable total Number Constructor (no arguments) Constructor (takes two arguments, fname and lname) One getter method to return the fname and lname One setter method for fname and lname Inside Main: Create three objects with the following names Jill Doe John James Jack Smith When creating the first object (Should not be an anonymous object) use the argument-less constructor Then use the setter method to assign...

  • CS102 : JAVA Object-Oriented Programming. 1 Write a class Card whose instances represent a single playing...

    CS102 : JAVA Object-Oriented Programming. 1 Write a class Card whose instances represent a single playing card from a deck of cards. Playing cards have two distinguishing properties an integer for the rank (1 (corresponding to Ace) ,2,3, 13 (correspond ing to King) and suit (Spades, Hearts, Diamonds, or Clubs). Make the suit an enumerated data type. Include getters and setters and a method that tests if a card is valid. Write a class named Deck whose instances are full...

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
ADVERTISEMENT