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: 1. Implement the Searcher interface, using the more efficient approach (with a small helper array)…
A: In this question, we need to construct a cleversearcher class which implements the searcher…
Q: A supermarket wants to reward its best customer of each day, showing the customer’s name on a screen…
A: Actually, Java is an Object Oriented Programming language which is platform independent and robust…
Q: Write a java class Library for implementing a library application which accepts books into its list…
A: Solution: Find the below attached java code with all mentioned reuirements. The files are-…
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: Question 1 Consider the following Java program. Given an ArrayList a that stores the data items: 27,…
A: class TreeSort {ArrayList <Integer> avlSort(ArrayList<Integer> a){AVLTree…
Q: Develop a program in Java to demonstrate the operations of a Hash Table. Use the following class…
A: The code is below:
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: Why are the methods getlndexOf and removeEntry in the class ArrayBag private instead of public?…
A: The methods contains implementation details that the customer should be unaware of. Thus aren't ADT…
Q: write a class called rectangle that implements the Comparable The class should contain three fields:…
A: import java.util.*;//1. definition for Class Rectanglepublic class Rectangle implements…
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: at many prime numbers. Iterator() returns an Iterator object that will iterate through the primes,…
A: Validate all validations with 2 first and last numbers i.e. nbr1 and nbr2. Update nbr1 again and…
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: 2. Write a java program to create class Student with the following Marks) : States:Id, Name,…
A: The ArrayList is a type of list and it implements the List interface of Java. Unlike an array an…
Q: Implements an interface having three methods eat, travel, bark
A: Program Plan: Create an interface named Animal In that interface declare methods…
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: Write the classes as shown in the following class diagram. Add a tester where you make an array of 5…
A: Java is an object-oriented language, it is used to develop browser applications and mobile…
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: Complete the Course class by implementing the printRoster() method, which outputs a list of all…
A: To implement the required printRoster( ) function, the following 2 steps are to be taken:- Iterate…
Q: Three interfaces ForTwoD, Shape and ForThreeD - TwoD class implements ForTwoD and Shape interfaces -…
A: GivenThat :-- Summary : Implemented few shapes (circle, cuble ) with main logic . Output is…
Q: Using java Hamburger Class Write a Hamburger class with the following six attributes: • bun - the…
A: Actually, in the program given attributes are: Hamburger class with the following six attributes:•…
Q: Suppose we want to implement a drawing program that creates various shapes using keyboard…
A: Given: Abstract base class DrawableShape that knows the center (two integer values) and the color (a…
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: Make the following class generic so that it can deal with an arbitrary class rather than only String…
A: Generics mean parameterized types. The idea is to allow type (Integer, String, … etc, and…
Q: Using Java. Implement a deque, except base your implementation on an array. The constructor for the…
A: Actually, Java is a high level programming language. And also object oriented .It. Is a platform…
Q: Exercise #2 Implement an instance method belonging to the IntArrayBag class that takes two input…
A: Logic:- Define array elements . Read oldVal and newVal pass arrayName,oldVal and newVal to method…
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: Interface : - Question : Make the AECar class implement the Comparable Java interface. Write a…
A: Java is a programming language originally developed by James Gosling at Sun Microsystems (which is…
Q: Q1: Write the Java code corresponding to the following UML diagram. The class School implements the…
A: Algorithm: Start Implement an interface Building with methods computeArea() and toString() Create a…
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: In java A supermarket wants to reward its best customer of each day, showing the customer’s name…
A: Program plan: Define the respective arrays Prompt for the name and price values Call the…
Q: Define a Polygon interface that has methods area() and perimeter(). Then implement classes for…
A: I attached the working code below, Please go through that code.
Q: Use the Lottery class to the left as the superclass. Create the PowerBall class as a subclass of…
A: import java.util.ArrayList;import java.util.Random;class Lottery{public ArrayList<Integer>…
Q: Import Class a) Implement a class Rectangle with two attributes, width and height. b) Implement an…
A: Note: Answering the first three subparts as per the guidelines. Task : Define class name Rectangle…
Q: Implement the above system using inheritance in the best possible way. Keep every object size as…
A: The given system of classes for inheritance are implemented as follows: Class Region acts is…
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: n the following statement: public abstract class Vehicle extends DD implements Car{ . . . } DD must…
A: Note: Please note that we are only allowed to solve one question in one post. if you want to get…
Q: write the code in java. Write the class Student having attributes name (String), age (int) and cgpa…
A: Given: write the code in java. Write the class Student having attributes name (String), age (int)…
Q: X435: Generics - Comparable Cage Modify the Cage class to implement Comparable. The definition of…
A: Java Comparable interface is used to order the objects of the user-defined class. The interface is…
Q: In this problem, you will model a circuit consisting of an arbitrary configuration of resistors.…
A: Filename: Circuit.java public class Circuit { public double getResistance() { return 0;…
Q: In Java, please. Complete the Course class by implementing the findStudentHighestGpa() method,…
A: The solution for the above given question is given below:
Q: Write two Java classes: Student and Main as follow: Class Student: A. Create three private…
A: (1)First we need to define a Student class with the attributes Name, ID and Specialization (2)In…
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…
Q: Task-02: Implement the following UML class diagram and test the methods. GeometricObject…
A: Program: import java.util.Scanner; import java.lang.Math; public class AreaOfCircle…
Step by step
Solved in 3 steps with 2 images
- 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 > + computeArea() : double + toString() : String School classroomNum: int width: double - length: double + School(classroomNum: int, width: double, length: double) + computeArea() : double + toString() : StringComplete the Course class by implementing the courseSize() method, which returns the total number of students in the course. Given classes: Class LabProgram contains the main method for testing the program. Class Course represents a course, which contains an ArrayList of Student objects as a course roster. (Type your code in here.) Class Student represents a classroom student, which has three fields: first name, last name, and GPA. Ex. For the following students: Henry Bendel 3.6 Johnny Min 2.9 the output is: Course size: 2 public class LabProgram { public static void main (String [] args) { Course course = new Course(); // Example students for testing course.addStudent(new Student("Henry", "Bendel", 3.6)); course.addStudent(new Student("Johnny", "Min", 2.9)); System.out.println("Course size: " + course.courseSize()); } } public class Student { private String first; // first name private String last; // last name private…JAVA - PersonWrite the classes as shown in the following class diagram. Add a tester where you make an array of 5 person and ask the user to enter them. Then loop over the array and print them. The user may enter a Student, a Staff or even a Person. The ‘-‘ symbol means private field or method and ‘+’ means public. The classes Student and Staff inherit from Person
- Design and implement a Java class named Book with two data members: title and price. The class should have suitable constructors, get/set methods, and the toString method. Design and implement another Java class named BookShelf which has an ArrayList data member named bookList to store books. The class should have suitable constructors, get/set methods, and the toString method, as well as methods for people to add a book (prototype: addBook(Book book)), remove a book (prototype: removeBook(Book book)), and search for a book (prototype: findBook(Book book)). Test the two classes by creating a Bookshelf object and five Book objects. Add the books to the bookshelf. Display the contents of the bookshelf. Test the removeBook and findBook methods as well. Take screenshots of your tests and submit them with your Java code (not the whole project)In Java Write a complete program that implements the functionality of a deck of cards. In writing your program,use the provided DeckDriver and Card classes shown below. Write your own Deck class so that itworks in conjunction with the two given classes. Use anonymous objects where appropriate.Deck class details:Use an ArrayList to store Card objects.Deck constructor:The Deck constructor should initialize your ArrayList with the 52 cards found in a standarddeck. Each card is a Card object. Each Card object contains two instance variables ─ num andsuit. Study the Card class definition below for details.dealCard:This method removes the highest-indexed card in the ArrayList and returns it. In general, amethod should not do more than what it’s supposed to do. Thus, dealCard should not printanything.toString:This method returns the deck’s contents using the format shown in the output session. In particular,note that toString should insert a newline after every fifth card. Hint: In coming up…Exercise (Section 30/40): Implement a superclass Appointment and subclasses Onetime, Daily, and Monthly. An appointment has a description (for example, "see the dentist") and a date. Write a method occursOn(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. Then fill an array of Appointment objects with a mixture of appointments. Have the user enter a date and print out all appointments that occur on that date. Give the user the option to add new appointments. The user must specify the type of the appointment, the description, and the date.
- Using Java You will write the code to perform the following operations using the ArrayList class: Implement a Shoe class, encapsulating the concept of a shoe A shoe has a color, size, and brand. Implement a ShoeStore class, encapsulating the concept of a shoe store. Use the ArrrayList of Shoe objects. Fill the ArrayList object with Shoe objects. Implement a ShoeSearchEnginge class Print Shoe objects in the ArrayList. color: white size: 11 brand: Anne Klein color: yellow size: 13 brand: Calvin Klein color: black size: 9 brand: COACH color: blue size: 5 brand: CLARK color: black size: 7 brand: Cole Han color: blue size: 15 brand: FitFlo color: red size: 9 brand: CLARK Find all Shoe objects with CLARK as a brand in the ArrayList. Find the largest size of a Shoe object in the ArrayList.Write the definitions of the member functions of the classes arrayListType and unorderedArrayListType that are not given in this chapter. The specific methods that need to be implemented are listed below. Implement the following methods in arrayListType.h: isEmpty isFull listSize maxListSize clearList Copy constructor Implement the following method in unorderedArrayListType.h insertAt Also, write a program (in main.cpp) to test your function.Complete the Kennel class by implementing the following methods: addDog(Dog dog) findYoungestDog() method, which returns the Dog object with the lowest age in the kennel. Assume that no two dogs have the same age. Given classes: Class LabProgram contains the main method for testing the program. Class Kennel represents a kennel, which contains an array of Dog objects as a dog list. (Type your code in here.) Class Dog represents a dog, which has three fields: name, breed, and age. (Hint: getAge() returns a dog's age.) For testing purposes, different dog values will be used. Ex. For the following dogs: Rex Labrador 3.5 Fido Healer 2.0 Snoopy Beagle 3.2 Benji Spaniel 3.9 the output is: Youngest Dog: Fido (Healer) (Age: 2.0)
- Task 1:The first task is to make the maze. A class is created called Maze, in which a 2D array for the maze is declared. Your job is to implement the constructor according to the given javaDoc. When you completed this task, write a set of Junit test case to test your code.As you probably noticed, the maze is defined as a private variable. The second job for you is to write an accessor(getter) method that returns the maze. Other information about what is expected for this method is given in the starter code. public class PE1 { MazedogMaze; /** * This method sets up the maze using the given input argument * @param maze is a maze that is used to construct the dogMaze */ publicvoidsetup(String[][]maze){ /* insert your code here to create the dogMaze * using the input argument. */ }Q2: Write the Java code corresponding to the following UML diagram. Then, create two objects from the main method and print their areas and perimeters. Polygon {abstract} # color: String # numberOfSides: int + Shape() + Shape(color:String, numberOfSides:int) + getColor(): String + setColor(color:String): void + getNumberOfSides(): int + setNumberOfSides(sides:int): +abstract getArea(): double +abstract getPerimeter(): double Triangle - sides: int[ ] + Triangle(color:String, numberOfSides:int) + addSide(index:int, sideValue: int): void + getSide(index:int): int + getArea(): double + getPerimeter(): doubleCreate a class Animal Create a class Cat, and a class Dog, and a class Bearded Dragon which extend Animal. Add to your Animal class: Member: name Methods: Public Animal (String name) //constructor public void makes Sound () with the implementation printing out a generic animal sound. Next, override (add) the makes Sound() method to your Cat and Dog class, with the implementation specific to each animal (i.e, cat says purr..). Do not override the makesSound() for your Dragon (bearded dragons don't make sounds!) Note, you'll also need a constructor in each of your subclasses which calls super(name) to initialize the common 'name' member of Animal. Next (in your test harness) create a List of different Animals ( a couple cats, a dog, a dragon... ) and add these Animals to your list. Iterate through your list & call makeSound on each. (you should observe the makeSound method called will be: cat -> from Cat class, dog-> from Dog class, bearded Dragon -> from Animal class ) EC:…