Figure 10-18 Rectangle and Cube classes Rectangle - length : double - width : double + Rectangle(len : double, w : double) + setLength(len : double) : void + setWidth(w : double) : void + getLength() : double + getWidth() : double + getArea() : double Cube - height : double + Cube(len : double, w : double, h: double) + getHeight() : double + getSurfaceArea() : double + getVolume() : double
Q: Using the card.java class file, write a program to simulate a Deck of Cards. See Programming…
A: PROGRAM CODE: import java.util.Scanner; public class Main { public static void main(String[]…
Q: and changing the account detains of some banks, to stop this practice, you have been tasked to…
A: Algorithm: Start Create class Abaaneke with attributes name, deposit, oldBalance, newBalance…
Q: Would it be legal to add the following method definition to the classDiscountSale?public static…
A: Would it be legal to add the following method definition to the classDiscountSale?public static…
Q: Implement the design of the Avengers class so that the following output is produced: [You are not…
A: Here I have first of all created the class named Avengers. In this class, I have created a…
Q: Change the Fraction class so that its instance variables (numerator and denominator) are hidden…
A: Basic mistake here is that there were two classes in which main method is present. Hence one…
Q: You can see that students have a name, a number, some marks for subjects they are studying and the…
A: The given UML diagram is:
Q: In this exercise, you are going to complete the Rectangle class. You need to complete the class so…
A: Java code is as follows:-
Q: In this second exercise, we are going to look at the iIn this exercise, you are going to complete…
A: EXPLANATION: - Methods of Rectangle class: - public String toString(): - This method is overridden…
Q: I just want you to do the second part only using java class, but i have attached the answer for…
A: Solution:: Assignment 1: public class LoanAccount { // properties…
Q: Implement the design of the Chillox and Customer classes so that the following code generates the…
A: Algorithm: Start Create Chillox class with menu and order_id as its static varibales Implement…
Q: Could you tell me how to fix the error in testing the following code: class Employee: """ The…
A: In the second last line of the program use object to call member function of class Employee. result…
Q: PLZ help with the following IN JAVA Given the following Which line of code will instantiate an…
A: Answer is below d)InnerCat cat = new Animal.InnerCat(); So, we use the new keyword to create an…
Q: This is the question I am struggling with - Create a class in JobApplicant.java that holds data…
A: Program Plan: Create a class name, JobApplicant. Generate a constructor that accepts the arguments…
Q: Write the Game class with the required properties to give the following outputs as shown. # Write…
A: Algorithm: Start Create a class with name Game and class members dueList, sentinelList as empty…
Q: I have already written the program and have it right, but I need help write print statement for the…
A: The print statement in java is: System.out.println(); where System is a package name, out is its…
Q: The following methods should output simple text messages on the screen for feedback, when…
A: As the student only asked about the plane class. Im Providing the Plane Class in Java Program below:
Q: There are common attributes and methods between kids and trainers. What is the best choice for…
A: Answer: Main.java public class Main { public static void main(String[] args) { // create 7…
Q: / Is my code correct? //please make it more efficient as you can. Thank you //please correct it if…
A: Solution: error free and successfully executed program is following - Programming language -…
Q: Implement the design of the Chillox and Customer classes so that the following code generates the…
A: The answer is
Q: I need help putting this java code into something I can copy/paste. Given the code below, write a…
A: Java Code: ShapeDriver.java public class ShapeDriver {public static void main(String[] args) {Circle…
Q: To rectify the problem identified in the following program,add a public method called isZero() to…
A: Purpose of the program: According to the given question, we need to modify the program adding a…
Q: Imagine a tollbooth at a bridge. Cars passing by the booth are expected to pay a 50 cent toll.…
A: NOTE: As the programming language is not mentioned the following code is in C++ CODE: #include…
Q: Write a program by creating an 'Employee' class having the following methods and print the final…
A: Create Employee class. Inside Employee class initialize variable salary and hours. Add Given…
Q: can you please answer number 4 for me 1. Create a class called Student, with the following…
A: Class declaration is given below: public class Student{private String studentName;private int…
Q: In java programming, how can I retrieve an int instance variable from another class without…
A: In Java variables can be called from another Class in two ways:First :By creating an object of the…
Q: Answer the questions How many classes we have on the above example? What is the role of the…
A: Question given: A program code is given, answer all subparts of question based on this program…
Q: Write short notes on a) Checked and unchecked keyword b) Partial and sealed classes
A: a) Checked and Unchecked keyword : The checked keyword is usually used when there is a condition of…
Q: Given the code below, which statement is incorrect? Choose the best answer. class Artist(): def init…
A: Given code is class Artist(): def init (self, name): self.name = name def namePrint (self): print…
Q: In example B are the classes that scott teaches referring the same object as the classes…
A: Yes is correct answer
Q: plz help with the following: In JAVA Given the following: Which line of code will instantiate an…
A: The line of code that will instantiate an InnerCat object if inserted after the creation of animal…
Q: Given the GVCoin class, complete the method flipForHeads() in the TossingCoins class that counts and…
A: Answer; The project consists of flipping a coin and using various methods to detect how many heads…
Q: Task: Implement the following class and test its methods Account -accountNumber:int -balance:double…
A: Given:
Q: ????????: Python question Write the Game class with the required properties to give the following…
A: Input : Partial python code along with the output. Output : Complete python code that includes…
Q: Imagine a tollbooth at a bridge. Cars passing by the booth are expected to pay a 50 cent toll.…
A: Code: #include <iostream>using namespace std; class tollbooth { private: int…
Q: Given the classes below, what are the class types of instance sc? Check all correct answers. -1…
A: OOP or Object-Oriented Programming is a software model that is designed around data or objects…
Q: Is this overload constructor? But what is behavior methods? Do I need to add walk, feed and bark…
A: Below is the answer:
Q: Given the classes below, what are the class types of instance yt? Check all correct answers. -1…
A: When multiple classes are involved and their parent-child relation is formed in a chained way then…
Q: Write a class called Pants that contains the following information: 1. Private instance variables…
A: use throw new IllegalArgumentException() to throw this kind of exception when input is beyond range.…
Q: We know that a pentagon is made up of five different points, so we can say that a pentagon "has"…
A: Disclaimer: Since you have posted a question with multiple sub-parts, we will solve the first three…
Q: Write a class called widget with an dollars; those values are passed in when a widget is created.…
A: class Widget: name = "" cost = 0 def __init__(self, name, cost): self.name =…
Q: What is the output of the following code? ( Assume each class is defined in a separate java file).…
A: According to the Question below the solution:
Q: Given the classes below, what are the class types of instance m? Check all correct answers. -1…
A: Concepts used in the above program: Inheritance: It is OOP concept where one class inherits all the…
Q: I need help understanding what's wrong with my java code using methods. Task: Complete method…
A: As per the code given, there are 2 following bugs : 1. The class PopcornTimer is not properly…
Q: Write a Temperature class that will hold a temperature in Fahrenheit, and provide methods to get the…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: What will be returned from the following method? public double testing ( ) {…
A: Answer: The following method(testing()) will return the value of 'a' which is 18.8.
Recall the Rectangle and Cube classes discussed earlier, as shown in Figure 10-18.
a) Is the following statement legal or illegal? If it is illegal, why?
Rectangle r = new Cube(10, 12, 5);
b) If you determined that the statement in part a is legal, are the following statements
legal or illegal? (Indicate legal or illegal for each statement.)
System.out.println(r.getLength());
System.out.println(r.getWidth());
System.out.println(r.getHeight());
System.out.println(r.getSurfaceArea());
c) Is the following statement legal or illegal? If it is illegal, why?
Cube c = new Rectangle(10, 12);
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- In an n-sided regular polygon, all sides havethe same length and all angles have the same degree (i.e., the polygon is both equilateraland equiangular). Design a class named RegularPolygon that contains:■■ A private int data field named n that defines the number of sides in the polygon with default value 3. ■■ A private double data field named side that stores the length of the side withdefault value 1.■■ A private double data field named x that defines the x-coordinate of the polygon’scenter with default value 0.■■ A private double data field named y that defines the y-coordinate of the polygon’scenter with default value 0.■■ A no-arg constructor that creates a regular polygon with default values.■■ A constructor that creates a regular polygon with the specified number of sidesand length of side, centered at (0, 0).■■ A constructor that creates a regular polygon with the specified number of sides,length of side, and x- and y-coordinates.■■ The accessor and mutator methods for all data…In an n-sided regular polygon, all sides have the same length and all angles have the same degree (i.e., the polygon is both equi-lateral and equiangular). Design a class named RegularPolygon that contains:■ ■ A private int data field named n that defines the number of sides in the polygon with default value 3. A private double data field named side that stores the length of the side with default value 1.■ ■ A private double data field named x that defines the x-coordinate of the poly-gon’s center with default value 0.■ ■ A private double data field named y that defines the y-coordinate of the poly-gon’s center with default value 0.■ ■ A no-arg constructor that creates a regular polygon with default values.■ ■ A constructor that creates a regular polygon with the specified number of sides and length of side, centered at (0, 0).■ ■ A constructor that creates a regular polygon with the specified number of sides, length of side, and x- and y-coordinates.■ ■ The accessor and mutator…Class: Square Create a class called "Square", which is inherited from“TwoDimensionShape” class. The "Square" class is used to calculate theArea and the Perimeter of square shapes when their side-length is given, or in contrast,finding the side-length of the square when the Area or the Perimeter of the square is given.The specifications of this class are below. Data Members (Attributes): All are private. sideLength: the sidelight (L) of the square. Methods/Operations/Getters/Setters: Default Constructor: when creating an object this constructor must set the side-length of the square by calling the method setSideLength(). Also, this constructor willcall the findArea() and the findPerimeter() in addition to summaryPrint() to calculateand print all needed information. User-Defined Constructor: when creating an object this constructor shouldfind the side-length of the square by calling the method findSquareSideLength()and pass the Area or the…
- Design a new Account class as follows:■■ Add a new data field name of the String type to store the name of thecustomer.■■ Add a new constructor that constructs an account with the specified name, id,and balance.■■ Add a new data field named transactions whose type is ArrayList thatstores the transaction for the accounts. Each transaction is an instance of theTransaction class, which is defined as shown in Figure ■■ Modify the withdraw and deposit methods to add a transaction to thetransactions array list. Write a test program that creates an Account with annual interest rate 1.5%,balance 1000, id 1122, and name George. Deposit $30, $40, and $50 to theaccount and withdraw $5, $4, and $2 from the account. Print an account summarythat shows the account holder name, interest rate, balance, and all transactions.Use java programming language 1.1 Create a Student Object project. Create a Student class and use the provided UML diagram to code the instance fields, constructors and methods. Note: The module mark is the average of the participation mark and the examination mark - calculate this using the calcModuleMark() method. The determineStNumber() method should compile a student number with the first 3 letters of the student's name, a '#' symbol, and a 3-digit randomly generated number (make use of a for-loop to concatenate these 3-digits). The stNumber data field should be set in the constructor by calling the determineStNumber() method. The toString() method must compile a string to display the student number, participation mark, examination mark, and module mark, formatted in table format. Student number PMark EMark MMark Mar#9186 81 64 72.00 1.2 Create a testStudents class. Do the following: -Write a static method called display() which receives…The Robot class models the state and behavior of virtual robots. Each robot corresponds to an object that is an instance of this class. Each robot: properties: Has a modelNumber (int) Has a direction(String): given by the direction attribute that takes one of the values "North", "East", "South" or "West" Has a makeYear (int): the year the robot was made. Methods: Can turn left 90 ° to change direction (if its direction was "North" it becomes "West", if it was "West" it becomes "South", if it was "South" it becomes "North", etc.). with the method without parameter turnLeft () Can display its detail with the method myInfo().
- Define the MyRectangle2D class that contains: Two double data fields named x and y that specify the center of the rectangle with getter and setter methods. (Assume the rectangle sides are parallel to x- or y-axis.) The data fields width and height with getter and setter methods. A no-arg Constructor that creates a default rectangle with (0, 0) for (x, y) and 1 for both width and height. A Constructor that creates a rectangle with the specified x, y, width, and height. A method getArea() that returns the area of the rectangle. A method getPerimeter() that returns the perimeter of the rectangle. A method contains(double x, double y) that returns true if the specified point (x, y) is inside this rectangle (see Figure 10.24a ). A method contains(MyRectangle2D r) that returns true if the specified rectangle is inside this rectangle (see Figure 10.24b ). A method overlaps(MyRectangle2D r) that returns true if the specified rectangle overlaps with this rectangle (see Figure 10.24c) NOTE:…Java Object Oriented Programming Create a Shape class that shall have color and filled instance variables of enum Color and boolean type. The filled boolean variable shall show, whether the shape is filled (colored). The enum Color shall be defined within the class having 4 color names (choose any four). Also define getArea and getPerimeter method in Shape class, both shall return 0. Create Rectangle class with length and width attributes and a Circle class with radius attribute, of type double. Properly encapsulate all fields. Circle and Rectangle shall extend Shape class and override getArea and getPerimters methods as per its type and specific formula. In Test class, create an object of Rectangle and Circle, by initializing all attributes in constructor and print both shapes' area and perimters. In Test class, define a static method with following signature, public static void printEachShapeCount(Shape... shapes) As you know, the parent type variable can hold the…create a class rectangle with attributes length and width both encapsulated, each of which defaults to 1. provide methods that calculate the rectangle’s perimeter and area. write set and get methods for both length and width tp allow their access through behaviors. the set methods should verify that length and width are each floating-point numbers larger than 0.0 and less than 20.0. write a program to test class rectangle
- C# (Shape Hierarchy) Implement the Shape hierarchy of. Omit the Triangle and Tetrahedron classes. Each TwoDimensionalShape should contain read-only abstract property Area to calculate the area of the two-dimensional shape. Each ThreeDimensionalShape should have read-only abstract properties Area and Volume to calculate the surface.area and volume, respectively, of the three-dimensional shape. Create an app that uses an array of Shape references to objects of each concrete class in the hierarchy. Display 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 whether each shape is a TwoDimensionalShape or a ThreeDimensionalShape. If a shape is a TwoDimensionalShape, display its area. If a shape is a ThreeDimensionalShape, display its area and volume.solve with java opp Create a class named “Rectangle” having length and width as attribute. There should be behaviors to set the values of length and width (individually and collectively), and get their values individually. There should also be behavior to display the perimeters and area of the rectangle. Create another class named as Main which has two objects of Rectangle (r1, r2) having length (3.2, 20) and width (4.5, 36) respectively. Also display the length, width, perimeter and area of both rectangles.use the design pattern for collecting objects. We are going to model a Orchard with trees. An Orchard uses an ArrayList to keep track of Tree objects. You will write both a Orchard class and a Tree class. A Tree has a type and a height. Provide a constructor that takes type and height, in that order. Provide getters and setters for the instance variables. This is the design pattern for managing properties of objects. An Orchard has a constructor that takes no parameters. Remember it must initialize the instance variable. It also has methods ○ add() Adds the specified Tree to the Orchard ○ tallest() Gets the type of the tallest Tree in the Orchard or null if the Orchard is empty. Initialize the tallest with the first element. ○ contains() determines if a Tree of the given type is in the Orchard. Returns true if a Tree of the given type is in the Orchard. Otherwise false. ○ treeList() gets an ArrayList<String> containing the types of all…