Q1: Write the Java code corresponding to the following UML diagram. The class School implements the interface Building. The method computeArea returns the area of the building as width * length. After that, add a testing class with a main method which defines an arrayList that contains three objects. From the main method, print the area of all the three objects. Building « Interface >> + computeArea() : double + toString() : String School - classroomNum: int |- width: double |- length: double + School(classroomNum: int, width: double, length: double) + computeArea() : double + toString() : String
Q: public interface Rational { /** * Determines whether this Rational object represents a value less…
A: I give the code in Java along with output and code screenshot
Q: Given the below Tesla class, update the class to inherit from the Comparable interface and also…
A: An abstract class can have implemented methods whereas an interface could contain only abstract…
Q: Implement the Comparable interface in the Laptop class. When you implement the compareTo() method…
A: Java is the programming languages that always refers to the object oriented programming languages.…
Q: We have a parking office class for an object-oriented parking management system using java Add…
A: Ans:) Here we need to implement the getCustomerIds method in ParkingOffice class. The parkingOffice…
Q: Implement the Deque interface given below using java,util.ArrayList as an adaptee. Implement as a…
A: It is subtype of queues in java. Deque means double-ended queue. It supports insertion and deletion…
Q: Implement the concept of polymorphism using interfaces in Java. • Create an interface class named…
A: Algorithm: Start Create an interface named Shape with draw() as its method Create a class named…
Q: Create a data class named Automobile that implements the Comparable interface. Give the class data…
A: the java program is an given below :
Q: in java : Implement the following class: Class name: Student - where an instance of class…
A: SOURCE CODE: import java.util.*; // import java.util.* to use Scannerpublic class Student{…
Q: Consider a scenario of Contacts Database, in which all information of user contacts will be stored.…
A: We will solve the given problem in Java language.
Q: Consider the class Arthropod and the interface Edible as described below: public class Arthropod…
A: Extra functions created for the part 6: public String getSpecies(): it return species value since…
Q: 1. Write a Java class that contains the following three attributes: String name, int age, double…
A: Java class: class Employee{ String name="Marry"; // initializing name with direct assignment…
Q: public class BankAccount implements Deposit, Withdraw {...} public interface Deposit {public void…
A: Below is the answer with explanation:
Q: Write the Java code corresponding to the following UML diagram. The class School implements the…
A: Solution: Programming language used: Java Program in Java: (Note: all solution steps are…
Q: MAT-521-Q2 Get the area of the square,circle, triangle and rectangle shapes using abstract classes…
A: let us see the answer:- Create a shape abstract class with two numbers and an empty function called…
Q: Do the following program in Java Eclipse. Java Class that can be used to create a Fruit object as…
A: Program Description –In the main() method, the objects of two classes are created and those classes…
Q: 2. The class PetShop has a single field as defined below: private ArrayList petList; Define a…
A: Given that petList is an ArrayList that stores cat details. private ArrayList petList can be…
Q: write program in java Design an abstract class GeometricObject. GeometricObject must ensure that…
A: The RectangleYourRegNo class is shown below. public static class RectangleYourRegNo extends…
Q: solve this by arraylist in the last of the question it has been told Create abstract class Pet ,…
A: Program: //Pet.java//Pet abstract classpublic abstract class Pet { private int legs; //Constructor…
Q: i. Create a generic class with a type parameter that simulates drawing an item at random out of a…
A: Note: The solution of the first subpart is shown below. Please repost the second subparts with the…
Q: Write two java methods 1)static void insertionSort(T[] array, Comparator cc){} This should run in…
A: Part1: static <T> void insertionSort(T[] array, Comparator<T> cc){} This should run in…
Q: Create an interface MessageDecoder that has a single abstract method decode(cipherText), where…
A: File name: “MessageDecoder.java” //create an interface public interface MessageDecoder {…
Q: Modify the Cage class to implement Comparable.The definition of the Comparable interface can be…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: Declare a generic interface called Pair that takes two type parameters K and V. This interface has…
A: It is defined as primarily a normal interface like any other. It can be used to declare a variable…
Q: Write a method with the name "eraser" that will get two arguments: “maparr_plants" (Map array of…
A: Here we have to provide the key for containsKey and remove methods not the indices. So the updated…
Q: Given a class Student that represents names and grades of a class: 1. How would we implement the…
A: The given problem is related to Java programming where the class Student needs to implement the…
Q: Create the class DynamicArrayOfStrings that implements the following two interfaces
A: Write a program that has the class DynamicArrayOfStrings that implements the following two…
Q: onsider the Person class in Problem 1. Implement the interface PersonPriorityQueueInterface provided…
A: class is a group of objects which have common properties. It is a template or blueprint from which…
Q: Q1: Write the Java code corresponding to the following UML diagram. The class School implements the…
A: Solution: Given,
Q: Create an abstract class that stores data about the shapes e.g. Number of Lines in a Shape, Pen…
A: import java.awt.*; abstract class Shape { protected int numberOfLines; protected Color…
Q: 3. The interface Range is defined below: public interface Range { void setLimits(int x, int y);…
A: According to the information given:- We hvae to follow the instruction and create the interface…
Q: Add static methods largest and smallest to the Measurable interface. The methods should return the…
A: Required: Required code with comments for explanation and screenshot of both code and output has…
Q: What methods are polymorphic in the Employee Hierarchy? How could we build a method like…
A: The classes Employee, SalariedWorker, HourlyWorker are given below: /* * Employee.java - Abstract…
Q: IntArray is a Java class that contains a single instance variable int[] numbers; In IntArray we wish…
A: IntArray is a Java class that contains a single instance variable int[] numbers; In IntArray we wish…
Q: Complete the Course class by implementing the courseSize() method, which returns the total number of…
A: Solution
Q: e box might contain Integers representing a random drawing for a lottery based on numeric lottery…
A: Q1.(java)Create a generic class with a type parameter that simulates drawing an item at random out…
Q: What is the difference between abstract class and interface?
A: Note: There are multiple questions are given in one question. According to the rule, you will get…
Q: Implement a superclass Appointment and subclasses Onetime, Daily, and Monthly. An appointment has a…
A: Solution: The Error in the program given in the question is due to Type Mismatch. Typecast error is…
Q: Implement the following UML Class diagrams. Create several Account objects and a Bank object, then…
A: Given: the Uml diagram, for Account and Bank class: Main class objects:
Q: uppose there is a class Roster. Roster has one variable, roster, which is a list of tuples…
A: The program is written in Python. Check the program screenshot for the correct indentation. Please…
Q: Use Netbeans to run the following decorator pattern code. Provide screenshot to prove that the code…
A: Firstly, open the Netbeans IDE. Steps to create a project with the name spaceship: Go to new->…
Q: Write the Java code corresponding to the following UML diagram. The class School implements the…
A: Q: Implement Java interface and OOP for give problem
Q: Write in java an abstract class Student that includes the following hidden attributes: id(int),…
A: Given: Write in java an abstract class Student that includes the following hidden attributes:…
Q: Modify the GeometricObject class to implement the Comparable interface and define a static max…
A: Code to Copy: import java.util.*; //Implementation of GeometricObject class public class…
Q: Create abstract class Ticket, and classes TrainTicket and PlaneTicket. Define all attributes and…
A: We need to implement the : Ticket.java TrainTicket.java PlaneTicket.java as per the given…
Q: The interface Range is defined below: public interface Range { void setLimits(int x, int y); int…
A: Here I have created a class named RandomInteger that implements the interface Range. In this class,…
Q: In the following code: public interface Shape extends Comparablel double getArea0: We have: Select…
A: Given, public interface Shape extends Comparable<Circle>{ double getArea(); } In Java when an…
Q: Define a class named ComparableCirclethat extends Circle and implements Comparable. Draw the UML…
A: UML stands for Unified modeling language. The tool which is used draws the class diagram and…
Write the Java code corresponding to the following UML diagram. The class School implements the interface Building. The method computeArea returns the area of the building as width * length. After that, add a testing class with a main method which defines an arrayList that contains three objects. From the main method, print the area of all the three objects.
Step by step
Solved in 4 steps with 2 images
- Consider the following class hierarchy: class Animal { ... } class Mammal extends Animal { ... } class Cat extends Mammal { ... } Write a generic method printArray that takes an array of any type and prints each element of the array. If the element is an instance of Animal or its subclass, the method should call the toString method of the object to print its details. Otherwise, the method should simply print the element. Your method should have the following signature: public static <T> void printArray(T[] array)Implement the Solver class. The point of the solver class is the solve method which takes a board/puzzle configuration represented as a 2D array of bytes and returns a byte array containing a minimal sequence of moves that will lead to the solved board. The 2D array of bytes is “triangular” and represents a valid board configuration. Namely, the 2D array has 5 rows (0 – 4) and the size of every row is 1 more than its index.The array contains one 0, five 1s, four 2s and five 3s. The solve method then returns an array of bytes representing a minimal sequence of moves that solves the puzzle. In other words, if the numbers from the returned array are used in order as inputs to the move method on the Board object representing the initial configuration, the resulting board configuration represents the solved board. If the input to the solve method is a board configuration that is already solved, then solution requires no moves and an array of size 0 must be returned. impliment the solver…Implement the Solver class. The point of the solver class is the solve method which takes a board/puzzle configuration represented as a 2D array of bytes and returns a byte array containing a minimal sequence of moves that will lead to the solved board. The 2D array of bytes is “triangular” and represents a valid board configuration. Namely, the 2D array has 5 rows (0 – 4) and the size of every row is 1 more than its index.The array contains one 0, five 1s, four 2s and five 3s. The solve method then returns an array of bytes representing a minimal sequence of moves that solves the puzzle. In other words, if the numbers from the returned array are used in order as inputs to the move method on the Board object representing the initial configuration, the resulting board configuration represents the solved board. If the input to the solve method is a board configuration that is already solved, then solution requires no moves and an array of size 0 must be returned. import…
- Implement the Solver class. The point of the solver class is the solve method which takes a board/puzzle configuration represented as a 2D array of bytes and returns a byte array containing a minimal sequence of moves that will lead to the solved board. The 2D array of bytes is “triangular” and represents a valid board configuration. Namely, the 2D array has 5 rows (0 – 4) and the size of every row is 1 more than its index.The array contains one 0, five 1s, four 2s and five 3s. The solve method then returns an array of bytes representing a minimal sequence of moves that solves the puzzle. In other words, if the numbers from the returned array are used in order as inputs to the move method on the Board object representing the initial configuration, the resulting board configuration represents the solved board. If the input to the solve method is a board configuration that is already solved, then solution requires no moves and an array of size 0 must be returned. import…Implement the Solver class. The point of the solver class is the solve method which takes a board/puzzle configuration represented as a 2D array of bytes and returns a byte array containing a minimal sequence of moves that will lead to the solved board. The 2D array of bytes is “triangular” and represents a valid board configuration. Namely, the 2D array has 5 rows (0 – 4) and the size of every row is 1 more than its index.The array contains one 0, five 1s, four 2s and five 3s. The solve method then returns an array of bytes representing a minimal sequence of moves that solves the puzzle. In other words, if the numbers from the returned array are used in order as inputs to the move method on the Board object representing the initial configuration, the resulting board configuration represents the solved board. If the input to the solve method is a board configuration that is already solved, then solution requires no moves and an array of size 0 must be returned. import java.util.Arrays;…Implement the Solver class. The point of the solver class is the solve method which takes a board/puzzle configuration represented as a 2D array of bytes and returns a byte array containing a minimal sequence of moves that will lead to the solved board. The 2D array of bytes is “triangular” and represents a valid board configuration. Namely, the 2D array has 5 rows (0 – 4) and the size of every row is 1 more than its index.The array contains one 0, five 1s, four 2s and five 3s. The solve method then returns an array of bytes representing a minimal sequence of moves that solves the puzzle. In other words, if the numbers from the returned array are used in order as inputs to the move method on the Board object representing the initial configuration, the resulting board configuration represents the solved board. If the input to the solve method is a board configuration that is already solved, then solution requires no moves and an array of size 0 must be returned. impliment the solver…
- In this problem, we are going to use ArrayLists and classes to design a road trip. You have three classes: GeoLocation.java which represents a geo location. A RoadTrip.java class, which represents a road trip (or an ordered list of places), and a RoadTripTester.java class which brings them all together. In GeoLocation.java: Add a private instance variable called name which is a String. This represents the name of the location. Modify the Geolocation class constructor so that it is now of the format public GeoLocation(String name, double theLatitude, double theLongitude) Add a getter method for name called getName(). Update the toString so that it returns a String of the format San Francisco (37.7833, -122.4167) Now, you’ll also need to create a RoadTrip class. RoadTrip stores an ordered list of locations, so you’ll need to have an ArrayList as an instance variable. The RoadTrip class constructor should initialize an ArrayList that stores a list of GeoLocations. You’ll also need to…2. The class PetShop has a single field as defined below: private ArrayList petList; Define a method to print out the details of all cats in petList in PetShop.Implement the Solver class. The point of the solver class is the solve method which takes a board/puzzle configuration represented as a 2D array of bytes and returns a byte array containing a minimal sequence of moves that will lead to the solved board. The 2D array of bytes is “triangular” and represents a valid board configuration. Namely, the 2D array has 5 rows (0 – 4) and the size of every row is 1 more than its index. (e.g. Row 0 has length 1). The array contains one 0, five 1s, four 2s and five 3s. The solve method then returns an array of bytes representing a minimal sequence of moves that solves the puzzle. In other words, if the numbers from the returned array are used in order as inputs to the move method on the Board object representing the initial configuration, the resulting board configuration represents the solved board. Furthermore, the solution must be minimal in the sense that there are no solutions that use fewer moves (although there could be other solutions that…
- Create a Cycle class, with subclasses Unicycle, Bicycle and Tricycle. Demonstrate that an instance of each type can be upcast to Cycle via a ride( ) method. Using the above Cycle hierarchy, add a balance( ) method to Unicycle and Bicycle, but not to Tricycle. Create instances of all three types and upcast them to an array of Cycle. Try to call balance( ) on each element of the array and observe the results. Downcast and call balance( ) and observe what happens.In java A supermarket wants to reward its best customer of each day, showing the customer’s name on a screen in the supermarket. For that purpose, the store keeps an ArrayList.Create a class customer having id, name, gender, and bill provide appropriate getters/setters and constructors also provide toString method.In the Store class, make an ArrayList of customers, store name, and address implement methods public void addSale(Customer c) that will add customers to the arraylist.public void RemoveCustomer(int id);public void UpdateCustomerRecord(int Id);public displayAll();public String nameOfBestCustomer() to record the sale and return the name of the customer with the largest sale. public ArrayList nameOfBestCustomers(int topN) so that it displays the top customers, that is, the topN customers with the largest sales, where topN is a value that the user of the program supplies. Write a program that prompts following menu and ============================================…Implement the following tasks by using concepts of object-oriented programming (Java). i. Create a generic class with a type parameter that simulates drawing an item at random out of a box. This class could be used for simulating a random drawing. For example, the box might contain Strings representing names written on a slip of paper, or the box might contain Integers representing a random drawing for a lottery based on numeric lottery picks. Create an add method that allows the user of the class to add an object of the specified type along with an isEmpty method that determines whether or not the box is empty. Finally, your class should have a drawItem method that randomly selects an object from the box and returns it. If the user attempts to drawn an item out of an empty box, return null. Write a main method that tests your class.ii. The following is a short snippet of code that simulates rolling a 6-sided dice 100 times. There is an equal chance of rolling any digit from 1 to…