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
Concept explainers
Question
In-class Assignment Day 8
You should draw the hierarchy for your classes to understand how the coding should be structured. Be sure to notate any classes that are abstract.
- Write an abstract class for Shape. The intended subclasses are Polygon, Circle, Triangle, and Rectangle. All of these will have a name, an area, and a perimeter.
(Consider which methods might be abstract.) Add a toString method that will return the information about the Shape, for example: Triangle, Area: 7.5, Perimeter: 12.0
- Write the class Rectangle. A Rectangle is a Shape and should have a width and a height.
When a Rectangle is outputted, it should read: Rectangle, Length: #, Width: #, Area: #, Perimeter: #
- Write the class for Circle. Every circle is a Shape that has a radius. Be sure to provide an accessor method (getter) for the radius.
When a circle is outputted, it should read: Circle, Radius: #, Area: #, Circumference: #
- Write a TestShape class that has the main method, which creates Rectangle and Circle objects. Print out the specific attributes about the shape.
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 4 steps with 2 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
- Explain Order of public and private Members of a Class.arrow_forwardCLASS declaration We need to have a “class” created called ROOM that has width and length defined. This represents a rectangular room. From room we need to define:Bathroom, Livingroom, Bedroom and Kitchen.You also need to have methods that can calculate the area of the room and set the length and width. Given that we have the following house : Bedroom1 (L=15,W=10) Bathroom1 (L=10,W=7) Kitchen1(L=15, W= 10) Livingroom1 (L=25,W=20) Calculate the total area of the home based on adding all room areas together and DISPLAY the result. | |--------------------We also know that in a certain area in an area of homes. ALL homes are above 1000 square feet.Could the house above be located in this area in specific? ------------------------You must display your result including the square feet of the house above. C++ commentsarrow_forwardThe pillar that allows you to build a specialized version of a general class, but violates encapsulation principles isarrow_forward
- : Imagine you have a call center with three levels of employees: respondent, manager,and director. An incoming telephone call must be first allocated to a respondent who is free. If therespondent can't handle the call, he or she must escalate the call to a manager. If the manager is notfree or not able to handle it, then the call should be escalated to a director. Design the classes anddata structures for this problem. Implement a method dispatchCall () which assigns a call tothe first available employee.arrow_forwardLab Goal : This lab was designed to teach you more object oriented programming and start you down the path of creating larger programs and games like BlackJack and Elevens [ one of the new AP CS A Labs ]. You will create a Deck class that contains a List < Card >Lab Description : You need to design a class that contains an instance variables which is a List < Card > and an int that keeps track of the top card position . You then need to make a constructor and related methods. You will need a dealCard method and a shuffle method. Use the template shown below. /make a Deck classpublic static final int NUMCARDS = 52;public static String[] SUITS = "CLUBS HEARTS DIAMONDS SPADES".split(" ");private List<Card> cards;private int top;//make a Deck constructor//refer cards to new ArrayList//set top to the top of the deck 51//loop through all suits//loop through all faces 1 to 13//add a new BlackJackCard to the deck//make a dealCard() method that returns the top card//write…arrow_forwardExercise: • Some of the characteristics of a book are the title, author(s), publisher, ISBN, price, and year of publication. Design a class bookType that defines the book as an ADT. Each object of the class bookType can hold the following information about a book: title, up to four authors, publisher, ISBN, price, and number of copies in stock. To keep track of the number of authors, add another member variable. • Include the member functions to perform the various operations on objects of type bookType. For example, the usual operations that can be performed on the title are to show the title, set the title, and check whether a title is the same as the actual title of the book. Similarly, the typical operations that can be performed on the number of copies in stock are to show the number of copies in stock, set the number of copies in stock, update the number of copies in stock, and return the number of copies in stock. Add similar operations for the publisher, ISBN, book price, and…arrow_forward
- What happens if you write a class with no constructor whatsoever?arrow_forwardDesign a Ship class that the following members: A field for the name of the ship (a string). A field for the year that the ship was built (a string). A constructor and appropriate accessors and mutators. A toString method that displays the ship’s name and the year it was built. Design a CruiseShip class that extends the Ship class. The CruiseShip class should have the following members: A field for the maximum number of passengers (an int). A constructor and appropriate accessors and mutators. A toString method that overrides the toString method in the base class. The CruiseShip class’s toString method should display only the ship’s name and the maximum number of passengers. Design a CargoShip class that extends the Ship class. The CargoShip class should have the following members: A field for the cargo capacity in tonnage (an int). A constructor and appropriate accessors and mutators. A toString method that overrides the toString method in the base class. The…arrow_forwardWhat are the benefits of having a destructor for a class?arrow_forward
- This is Phython Programmingarrow_forwardTrue or False? Because child classes in generalizations inherit the attributes, operations, and relationships of the parent, you must only define for the child the attributes, operations, or relationships that are distinct from the parent.arrow_forwardDesign a class named Pet, which have the following fields: • Name - name of the pet. • Animal - type of animal that a pet is (Dog, Cat, Bird). • Age - age of the pet. The Pet class should also have the following methods: • setName • setAnimal • setAge • getName •.getAnimal .getAge a) Draw a UML diagram of the class. Be sure to include notation showing each field and method's access specification and data type. Also include notation showing any method parameters and their data types. b) Write the Java code for the Pet class. Create a main method in the same class and instantiate at least two objects of the class.arrow_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