Microsoft Visual C#
7th Edition
ISBN: 9781337102100
Author: Joyce, Farrell.
Publisher: Cengage Learning,
expand_more
expand_more
format_list_bulleted
Question
Javascript
Create an object, Gremlin, that extends the Monster interface and takes the same argument language.
- Gremlins inherits how a monster eats.
- Gremlins speaks differently. Gremlins replace each word in a sentence with its only known language, "gar". For example, if the sentence is "I like chicken", the speak() method will turn it into "gar gar gar".
class Monster {
constructor(language){
this.language = language;
this.stomach = Array();
}
// takes a food_item STRING and returns everything eaten so far ARRAY
eat(food_item) {
this.stomach.push(food_item);
}
// takes in a sentence STRING and returns the passed in sentence STRING with no change
speak(sentence) {
returnsentence;
}
}
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 with 4 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- in javaarrow_forwardA Door Class A computer game usually has many different objects that can be seen and manipulated. One typical object is a door. Whether a player runs through a castle, attacks the forces of an evil empire, or places furniture in a room, a door often comes into play. Implement a Door class as described below as well as a TestDoor class that instantiates three Door objects labeled “Enter,” “Exit,” and “Treasure.” The “Enter” door should be left unlocked and opened. The “Exit” door should be left closed and locked. The “Treasure” door should be left open but locked. A Door class A Door object can • display an inscription, • be either open or closed, and • be either locked or unlocked. Here are some rules about how Door’s work. • Once the writing on a Door is set, it cannot be changed. • You may open a Door if and only if it is unlocked and closed. • You may close a Door if and only if it is open. • You may lock a Door if and only if it is unlocked, and unlock a Door if…arrow_forwardJava - Product Classarrow_forward
- Code the StudentAccount class according to the class diagramMethods explanation:pay(double): doubleThis method is called when a student pays an amount towards outstanding fees. The balance isreduced by the amount received. The updated balance is returned by the method.addFees(double): doubleThis method is called to increase the balance by the amount received as a parameter. The updatedbalance is returned by the method.refund(): voidThis method is called when any monies owned to the student is paid out. This method can onlyrefund a student if the balance is negative. It displays the amount to be refunded and set thebalance to zero. (Use Math.abs(double) in your output message). If there is no refund, display anappropriate message.Test your StudentAccount class by creating objects and calling the methods addFees(), pay() andrefund(). Use toString() to display the object’s data after each method calledarrow_forwardThere is a class hierarchy that includes three classes: class Animal { protected int age; public int getAge() { return age; } public void setAge(int age) { this.age = age; }}class Pet extends Animal { protected String name; public String getName() { return name; } public void setName(String name) { this.name = name; }}class Cat extends Pet { protected String color; public String getColor() { return color; } public void setColor(String color) { this.color = color; }} Given the following object: Pet cat = new Cat(); Select all invalid method invocations.arrow_forwardpublic class MyGenClass { private T1 name; private T2 stulD; private T3 CGPA; public void setStuData( ){ I/ parameters name = n; stulD = d: CGPA = g; } public void printAsString() { System.out.println( } ); I/ print all information as string public static void main(String args||) { Il Create an object stu by parameters String, Integer, Double Il Call setStuData() with any values you like /l Call printAsString() } }arrow_forward
- solve:arrow_forwardJava Program The assignment requires two classes. Put all classes in the same package. Class Employee Attributes (all private): id: String lastName: String firstName: String salary: int Methods: Parameterized constructor for initializing a new Employee instance Getters for all attributes toString method to display an Employee's attributes (See output of executable below) Executable Class Create an array of at least eight Employee objects. Be sure to use many with identical last names, but don't order them by name in the array. Create an ArrayList from the array. Sort the ArrayList first by last name and then by first name. Using the forEach method and a lambda expression, print all employees alphabetically sorted by name. Create a LinkedList from the ArrayList. Create an iterator capable of cycling both forward and backward through the LinkedList. Iterate forward through the LinkedList without generating any output. Then iterate backwards through the LinkedList to print…arrow_forwardShape Class JAVA Implement the Shapehierarchy shown in figure below. Shape TwoDimensionalShape ThreeDimensionalShape Circle Square Sphere Cube Each TwoDimensionalShape should contain method getArea to calculate thearea of the two-dimensional shape. • Each ThreeDimensionalShape should have methods getArea and getVolume tocalculate the surface area and volume, respectively, of the three- dimensional shape. Add OneDimensionalShape with sub classes , and add more shapes to classes (TwoDimensionalShape , ThreeDimensionalShape ). Create a program that uses an array of Shape references to objects of each concrete class in the hierarchy. The program should print a text description of the object to which each array element refers. • Also, in the loop that processes all the shapes in the array, determine OneDimensionalShape, whether each shape is a TwoDimensionalShape or a ThreeDimensionalShape. If it is a TwoDimensionalShape, it is display ThreeDimensionalShape, display its area and volume. its…arrow_forward
- java programming Robot Class : a robot has a name , located at a point with integer coordinates , faces north , east , south , or west and keeps a record of all its movements positions . The class has the following methods : A default constructor that initializes robot's name to " Unknown ” , location to ( 0,0 ) , direction to North , and travelled distance to 0 , and simulated movements to null . A constructor that given robot's name , starting location , and facing direction , Accessor methods to access all the instance variables and the simulated movements of the robot Mutator methods that change the instance variables to given values and they made the change for only suitable values . tumLeft and turn Right methods that change the direction of the robot but not the location move method that moves the robot by one unit in the direction it is facing . get Travelled Distance method that retums how many units has the robot moved .arrow_forwardTrue or False A class can implement more than one interface.arrow_forwardWrite a constructor for the IceCreamCup class. The constructor takes the name, and a List of Flavor s (name it fList) as parameters. It initializes the instance variables with the parameters. Use shallow copy for initializing the list of Flavor s. (Throw an IllegalArgumentException if the name is null, or the Flavor list is null or empty.) Note that successful instantiation should increase nCups by 1.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT