
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
thumb_up100%
Using Java - Creating an Abstract Class Shape II
Create an abstract class "Shape" with the following specifications:
an abstract method "area()" of return type double
an abstract method "perimeter()" of return type double.
Put your code in a Java source file named "Shape.java."
I.
Create a class "Rectangle" that extends the Shape class with the following specifications:
Attributes:
width, length
Constructor:
Implement a parameterized constructor needed initialize the data.
toString:
Implement a "toString" method that prints out the area and perimeter.
Implement methods to compute the area and perimeter.
II.
Create a class "Circle" that extends the Shape class with the following specifications:
Attributes:
radius
Constructor:
Implement a parameterized constructor to initialize the data.
toString:
Implement a "toString" method that prints out the area and perimeter.
Implement methods to compute the area and perimeter.
III.
Create a class "Triangle" that extends the Shape class with the following specifications:
Attributes:
length of side1, length of side2, length of side3, each is a double
Constructor:
Implement a parameterized constructor to initialize the data.
toString:
Implement a "toString" method that prints out the area and perimeter.
Implement methods to compute the area and perimeter.
IV.
Create a driver class named "ShapeArray" with the following specifications:
Instantiate one triangle.
Instantiate one circle.
Instantiate one square.
Store the class instances into an array named "shapeArray."
Loop through the array and print out the instance data of each object
using the object instance's "toString" method.
Show a UML diagram of your project.

Transcribed Image Text:Create an abstract class "Shape" with the following specifications:
1. an abstract method "area()" of return type double
2. an abstract method "perimeter()" of return type double.
Put your code in a Java source file named "Shape.java."
I.
Create a class "Rectangle" that extends the Shape class with the following specifications:
1. Attributes:
O
II.
2. Constructor:
Implement a parameterized constructor needed initialize the data.
O
3. toString:
O
width, length
Implement methods to compute the area and perimeter.
O
Implement a "toString" method that prints out the area and perimeter.
Create a class "Circle" that extends the Shape class with the following specifications:
1. Attributes:
o radius
2. Constructor:
O
Implement a parameterized constructor to initialize the data.
3.toString:
Implement a "toString" method that prints out the area and perimeter.
Implement methods to compute the area and perimeter.

Transcribed Image Text:III.
Create a class "Triangle" that extends the Shape class with the following specifications:
1. Attributes:
length of side 1, length of side2, length of side3, each is a double
2. Constructor:
Implement a parameterized constructor to initialize the data.
O
IV.
O
3.toString:
o Implement a "toString" method that prints out the area and perimeter.
Implement methods to compute the area and perimeter.
Create a driver class named "ShapeArray" with the following specifications:
1. Instantiate one triangle.
2. Instantiate one circle.
3. Instantiate one square.
4. Store the class instances into an array named "shapeArray."
5. Loop through the array and print out the instance data of each object
6. using the object instance's "toString" method.
Show a UML diagram of your project.
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 8 steps with 7 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
- ZOOM + Press Esc to exit full screen Create a new java project named CH46EX 1. Create a class named Student 1. 2 private instance data fields – student name, student id 2. 1 final and static constant for a COLLEGE, set to "Fullerton" Create one programmer written constructor that accepts parameters for two instance data fields during instantiation Create a static method named demoStaticMethod ()-see output 3. | - print message, print college 4. Create a non-static method named demoObjectMethod ()– see output - print message, college, student name, student id 2. Create an application named StudentDemo 1. Create/instantiate 1 student object 2. Call each method correctly This demo is a static method Fullerton 3. Expected Output > This demo is a non-static method Fullerton Name: Wyle Coyote ID: 456arrow_forwardJava Program This assignment requires one project with two classes. Class Employee Class Employee- I will attach the code for this: //Import the required packages. import java.text.DecimalFormat; import java.text.NumberFormat; //Define the employee class. class Employee { //Define the data members. private String id, lastName, firstName; private int salary; //Create the constructor. public Employee(String id, String lastName, String firstName, int salary) { this.id = id; this.lastName = lastName; this.firstName = firstName; this.salary = salary; } //Define the getter methods. public String getId() { return id; } public String getLastName() { return lastName; } public String getFirstName() { return firstName; } public int getSalary() { return salary; } //Define the method to return the employee details. @Override public String toString() { //Use number format and decimal format //to…arrow_forward1 Jljull Create a class Student in java with the following :attributes Name Age MobileNo Level a. Declare an empty and a parameterized constructor .in student class b. Declare an accessor method displayStudent() to .show the student details c. Declare a mutator method updateAge() to update .the age of student by 2 years d. Create 2 objects sl and s2 and call the methods QupdateAge() and displayStudentarrow_forward
- Code: import java.util.*; //Bicycle interface interface Bicycle { abstract void changeCadence(int newValue); //will change value of candence to new value abstract void changeGear (int newValue); //changes gear of car abstract void speedUp(int increment); //increments speed of car by adding new Value to existing speed abstract void applyBrakes(int decrement); } //ACMEBicycle class definition class ACMEBicycle implements Bicycle { int cadence = 0; Â Â int speed = 0; Â Â int gear = 1; //methods of interface public void changeCadence(int newValue) { this.cadence=newValue; } public void changeGear (int newValue) { this.gear=newValue; } public void speedUp(int increment) { this.speed+=increment; } public void applyBrakes(int decrement) { this.speed-=decrement; } //display method void display() { System.out.println("Cadence: "+this.cadence); System.out.println("Gear: "+this.gear); System.out.println("Speed: "+this.speed); } } //KEYOBicycle class definition class KEYOBicycle implements…arrow_forwardInheritance in Java Create a class named “BankAccount” that has the attributes bank, accountNumber, accountName. Implement setters and getters for these attributes. Create two classes: “DebitAccount” and “CreditAccount”, which both inherit from BankAccount. DebitAccount class has the following additional attributes and methods: double balance - cannot be negative setter and getter for balance withdraw(double amount) - subtracts balance with the said amount and displays new balance. Does not do anything if amount is greater than balance deposit(double amount) - adds amount to balance and displays new balance CreditAccount class has the following additional attributes and methods: double creditBalance - can be negative setter and getter for balance pay(double amount) - subtracts creditbalance and displays new creditBalance interest(double rate) - adds (creditBalance * percentage) to creditBalance Note: 1 = 100% for rate Inputs 1. Char input for type of account (D/C) 2.…arrow_forwardCreate three files: Student.java - Abstract Class definition ENGRStudent.java - Derived Class definition Client.java - Contains main() method (1) Implement the abstract Student class with the following specifications: 3 private members String name int ID int yearAdmitted 1 constructors (public) A constructor with that accepts the student’s name, ID, and yearAdmitted as arguments. These values should be assigned to the object’s name, ID, and yearAdmitted fields. 2 public member methods A method named toString() that returns the values of name, ID, and yearAdmitted with String data type A abstract method name getRemainingHrs with int data type (2) Implement the derived class ENGRStudent class with the following specifications: 3 final private members with the following values : int MATHSCHRS=32 int MAJOR_HRS=66 int GenEdHrs=29 3 private members: int mathScHrs; int majorHrs; int GenEdHrs; 1 constructors (public) A constructor that accepts the student’s name, ID, and yearAdmitted…arrow_forward
arrow_back_ios
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