
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Create a TestTriangle class in an individual .java file. In the main method,
(1) Create a Triangle object with default base and height values.
(2) Create a Triangle object with specified base = 3 and height =4.

Transcribed Image Text:➡ eclipse-workspace - project2/src/project2/Triangle.java - Eclipse IDE
File Edit Source Refactor Navigate Search Project Run Window Help
Q
©
95.
TestPrintPri...
1 package project2;
2 public class Triangle extends SimpleGeometricObject {
3 private double base;
4 private double height;
5 public Triangle() {
€ super();
7 base= 5;
reportsum6.java
this.base= base;
this.height = height;
19
}
20 public double getBase () {
21
return base;
22
}
23 public void setBase (double base) {
24
this.base = base;
25
}
26 public double getHeight () {
27
return height;
8 height = 10;
9
}
10 public Triangle (double base, double height) {
11 super();
12 this.base = base;
13 this.height = height;
14
}
150 public Triangle (double base, double height, String color, boolean filled) {
16 super (color, filled);
17
18
}
32 public double getArea() {
33
34
task8A.java
28
}
29 public void setHeight (double height) {
30
this.height = height;
31
34°F
Cloudy
#
}
A35 public String toString() {
36
37
38 }
}
return 0.5 * base* height;
task8C.java
▬▬
■
NO 1
task8D.java
Q Search
return "Triangle with base = " + base + " and height = " + height + "\n" + super.toString();
SimpleGeome...
Writable
a
P
square.java
SquareTest.java
Smart Insert
17:18:412
overide.java
Triangle.java X
"83
Q
10:53 PM
3/21/2023
X
* * * + @ 隐旦
8
%
鼎
凰
@

Transcribed Image Text:X b Answered: we are goin X
←
→ C ✰ liveexample.pearsoncmg.com/html/SimpleGeometricObject.html
Lab 5: Inheritance
Show Code With Line Numbers
public class SimpleGeometricObject {
private String color = "white";
private boolean filled;
private java.util.Date dateCreated;
/** Construct a default geometric object */
public SimpleGeometricObject() {
dateCreated new java.util.Date();
/** Construct a geometric object with the specified color
and filled value */
public SimpleGeometricObject(String color, boolean filled) {
dateCreated = new java.util.Date();
this.color= color;
this filled filled;
}
/** Return color */
public String getColor() {
return color;
}
/** Set a new color */
public void setColor (String color) {
this.color= color;
}
/** Return filled. Since filled is boolean,
its get method is named isFilled */
public boolean isFilled() {
return filled;
}
/** Set a new filled /
public void setFilled (boolean filled) {
this filled filled;
}
/** Get dateCreated */
public java.util.Date getDateCreated() {
return dateCreated;
}
/** Return a string representation of this object */
public String toString() {
+
return "created on dateCreated + "\ncolor: "+color+
and filled: " + filled;
}
34°F
Cloudy
▬▬
■
Introduction to Java Pix
Q Search
Unit 7 AS1: Assignmer X
a
Files
X
G how do you zoom in cx | +
Q
Pa
0
10:53 PM
3/21/2023
X
:
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 5 steps with 1 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
- Only the Store.java files can be edited between lines 2-4 only.arrow_forwardTo use any of the prewritten classes besides those in the java.lang package, you must___ a. use the entire path with the class name b. import the class c. import the package of which the class you are using is a part d. use any of these methodsarrow_forwardonly Voicemail.java files can have input added inbetween lines 4 and 7. not in the gery code sections.arrow_forward
- Create a program using classes that does the following in the zyLabs developer below. For this lab, you will be working with two different class files. To switch files, look for where it says "Current File" at the top of the developer window. Click the current file name, then select the file you need.(1) Create two files to submit: ItemToPurchase.java - Class definition ShoppingCartPrinter.java - Contains main() method Build the ItemToPurchase class with the following specifications: Private fields String itemName - Initialized in default constructor to "none" int itemPrice - Initialized in default constructor to 0 int itemQuantity - Initialized in default constructor to 0 Default constructor Public member methods (mutators & accessors) setName() & getName() setPrice() & getPrice() setQuantity() & getQuantity() (2) In main(), prompt the user for two items and create two objects of the ItemToPurchase class. Before prompting for the second item, call…arrow_forwardWhich of the following, can be done, with the help of the this reference?arrow_forwardNew JAVA code can only be added to Client.java file between lines of grey code (or between lines 2 and 4, as seen in image).arrow_forward
- Write a class that instantiates a Scanner object and asks the user for their grade, represented by an integer, and then full name, represented by a String, (in that order specifically) on separate lines, and then prints it a string in the format given below with the user input printed. The output should look like below, with bold text in brackets representing user input. Grade: [11] Name: [John Smith] Welcome John Smith, you are in grade 11!arrow_forwardCreate "People.java" Class for a "Person" with following functionality. People object should have following attributes/fields.. (make them private) their name as String, their address in next String and their phone number in 7 digit integer Put all this information in “People" object by doing the following Create a default Blank constructor - (Name should be "No Name", Address should be "000 Street, 000 City, North Pole, Earth", and Phone number should be 1234567) Create a full constructor Create accessors for all fields Create mutators for all fields (use proper this.) Create toString method for Peoplearrow_forwardJava Code. Create a Driver class to use your Farm and Animal classes and create instances of them. In the main method do the following: Create a Farm of size 10 Create 5 Animal Objects with the details specified in the table below Add the 5 Animal objects to the Farm Call the printDetails method from the Farm to print all the Farm and Animal details.arrow_forward
- In python: The program should ask users for their email address and password for connecting to the mail server. You can create a new gmail account and use it for this assignment. Once the connection is complete, the program should ask for the receiver''s email address, and lastly send the email. Write "Hello" for the subject and "Email from Python" as body. Use the getpass library to hide password from shell. Instantiate an object and call it. Submit the .py file as well as screenshots showing the code runs and email received.arrow_forwardCreate a program using classes that does the following in the zyLabs developer below. For this lab, you will be working with two different class files. To switch files, look for where it says "Current File" at the top of the developer window. Click the current file name, then select the file you need.(1) Create two files to submit: ItemToPurchase.java - Class definition ShoppingCartPrinter.java - Contains main() method Build the ItemToPurchase class with the following specifications: Private fields String itemName - Initialized in default constructor to "none" int itemPrice - Initialized in default constructor to 0 int itemQuantity - Initialized in default constructor to 0 Default constructor Public member methods (mutators & accessors) setName() & getName() setPrice() & getPrice() setQuantity() & getQuantity() (2) In main(), prompt the user for two items and create two objects of the ItemToPurchase class. Before prompting for the second item, call…arrow_forwardWrite a ONE java program to implement the following requirements: Design 3 classes: Shape8, Circle8, Square8 and 1 interface ComputeData as shown below. Shape8 is an abstract class ComputeData is an interface Italicized methods mean abstract methods Shape8 -color: String ComputeData + getDiagonal (): double note: diagonal = Math.sqrt(width*width*2) -area: double + Shape8(String color) + getArea ():double + setArea (area: double):void +getColor():String +compareto(o: Shape8): int +toString(): String Square8 -width: double Circle8 -radius: double | +Circle8(color: String, radius: double) +toString(): String + Square8( color: String, width: double) +toString(): String ..necessary methods note: area=radius*radius*Math.PI ·..necessary methods note: area=width*widtharrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education