
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 an Abstract class AbstractCat with the same
properties and methods as Cat...
. Create class AbstractCat.
How to secure data?
To protect it from direct access and manipulation from outside of the class
we need to make our instance data fields private.
To let clients still manipulate data under our control we can provide them
public getters and setters.
. create getters, setters, constructors and toString()
. Test AbstractCat class
![examplesecou...
Circle.java
음... 1 public class TestCat {
3
4
5
20 public static void main(String[] args) {
A WNHO CO
8
9
232222
10
11
12
13
14
15 }
}
Headsori
EmallPass.java
// Test methods
catl.eat ();
cat2.play();
// Create two Cat instances using different constructors
Cat cat1 = new Cat ("Whiskers", 3, "White", "Domestic");
Cat cat2 = new Cat ("Smokey", 2);
Averagescor...
// Get the number of cats
int numberOfCats = Cat.getNumberOfCats ();
System.out.println("Number of cats:
" + numberOfCats);
Cat.java
3
"Bar](https://content.bartleby.com/qna-images/question/2ae76079-938b-4b5d-8ceb-1dfbc10f88ce/07b044e0-1824-43bc-a7e8-82781b7ada24/8gxvcg9_thumbnail.png)
Transcribed Image Text:examplesecou...
Circle.java
음... 1 public class TestCat {
3
4
5
20 public static void main(String[] args) {
A WNHO CO
8
9
232222
10
11
12
13
14
15 }
}
Headsori
EmallPass.java
// Test methods
catl.eat ();
cat2.play();
// Create two Cat instances using different constructors
Cat cat1 = new Cat ("Whiskers", 3, "White", "Domestic");
Cat cat2 = new Cat ("Smokey", 2);
Averagescor...
// Get the number of cats
int numberOfCats = Cat.getNumberOfCats ();
System.out.println("Number of cats:
" + numberOfCats);
Cat.java
3
"Bar

Transcribed Image Text:examplesecou...
1 public class Cat {
2
3
4
5
6
7
8
9
10
11
120
13
14
15
16
17
18
19
200
21
22
23
24
250
26
27
28
290
30
31
32
33
340
35
36
37 1
}
◄
// Properties
String name;
int age;
String color;
String type;
}
// Static variable to keep track of the number of cats
static int numberOfCats = 0;
Circle.java
}
// Constructors
public Cat (String name, int age, String color, String type) {
this.name = name;
this.age = age;
this.color = color;
this.type = type;
numberOfCats++; // Increment the count of cats when a new one is created
public Cat (String name, int age) {
}
HeadsOrTail...
// Methods
public void eat () {
}
this (name, age, "Unknown", "Domestic");
}
public void play() {
System.out.println (name + is playing.");
System.out.println (name + " is eating.");
EmailPass.java
// Static method to get the number of cats.
public static int getNumberOfCats () {
return numberOfCats;
AverageScor...
*Cat.java X*BankAccoun...
Writable
Smart Insert
TestBankAcc...
9:33: 202
D
Expert Solution

arrow_forward
Step 1: Define the problem statement
The Java code asks to create a code abstract class for implementing the class Cat
The problem has 3 parts
- Abstract class for Cat class
- Cat class for implementing the method of eat and play
- Create the Test class
Step by stepSolved in 5 steps with 5 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
- Define a BankAccount classthat has• accNum (int)• Balance (double)• A constructor• Four methodso deposito withdrawo getAccNumo getBalance 2. Implement a test classTestBankAccount that• Initialize an BankAccountinstance with initial values:• deposit: 500.0• accNum: 1001• Deposit 30.50• Withdraw 50.0• Print out the remainingbalancearrow_forwardIn Java!!!!!This is a multi-part question. Consider the following UML diagram on attached image: 1.Write Java classes corresponding to the UML diagram. 2. Write getters and setters for all classes 3. Write non-default constructors for each class that initializes all instance variables to values passed as arguments to the constructor 4. Write toString method for each class 5. Modify Vehicle class to maintain inventory (list of all vehicles created) and print the list. What variable(s) you need to add? What additional method(s) you need? What else needs to be modified in the Vehicle class? Do you need to modify any of the descendant classes and explain your answer (if not: why not; if yes, describe what changes). Vehicle {Abstract} manufacturer:String - color:String Car Truck TwoWheeler {Abstract} -numberOfDoors:int -numberOfAxels:int -passengerSeats:int -fuelType:String -fuelLevel:int -fuelType:String -numberOfSeats:int -fuelLevel:int Truck Motorcycle -numberOfAxels:int -fuelType:String…arrow_forward
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