Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
1) Create class Cat
Add properties
What characteristics do they have?
Name, age, color, type (domestic / feral), etc.
What color(s) might they have?
White, cream, fawn, Cinnamon, Chocolate, Red, Lilac, Blue, Black,
Lavender, etc.
Add methods
eat(), play(), etc.
Constructors?
A class provides a special type of methods, known as constructors, which are
invoked to construct objects from the class
Create 2 different constructor with different initialization parameters
How to get the number of cats?
Add a static variable and a static method
Test Cat class by creating 2 Cat instances
Add properties
What characteristics do they have?
Name, age, color, type (domestic / feral), etc.
What color(s) might they have?
White, cream, fawn, Cinnamon, Chocolate, Red, Lilac, Blue, Black,
Lavender, etc.
Add methods
eat(), play(), etc.
Constructors?
A class provides a special type of methods, known as constructors, which are
invoked to construct objects from the class
Create 2 different constructor with different initialization parameters
How to get the number of cats?
Add a static variable and a static method
Test Cat class by creating 2 Cat instances
2) create a 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
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
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-engineering and related others by exploring similar questions and additional content below.Similar questions
- The ability to create classes with more specific attributes and methods that share the properties and methods of existing classes is referred to as: Abstraction Polymorphism Typecasting Inheritancearrow_forwardA cash processing company has a class called Account used to process transactions: Method/Constructor Description public Account (Client c) public boolean process (Transaction t) constaucts an account using client information processes the next transaction, returning true if transaction was approved, false otherwise Account objects interact with Transaction objects, which have many methods including: Method/Constructor Description returns the value of this transaction in pennies (could be negative, positive or zero) public int value() The company wishes to create a slight modification to the Account class that filters out zero-valued transactions. Design a new class called FilteredAccount whose instances can be used in place of an Account object but which include the extra behavior of not processing transactions with a value of 0. More specifically, the new class should indicate that a zero-valued transaction was approved but shouldn't call the process method in the Account class to…arrow_forwardWhy might a class need to implement a destructor?arrow_forward
- Object adapters and class adapters each provide a unique function. These concepts are also significant due to the significance that you attach to them.arrow_forwardIndicate whether the statement is true or false. 13. The non-static methods of a class are called instance method. 14. A constructor has no type and is therefore a void method. 15. A class can have only two constructors. 16. In shallow copying, each reference variable refers to its own object. 21. The method finalize automatically executes when the class objects goes out of scope. 22. A mutator method of a class changes the values of data members of the class. 23. In java, the reference this is used to refer to only the methods, not the instance variables of a class. 24. Classes that are defined within other classes are called inside classes. 25. Modifiers are used to alter the behavior of the class 26. A constructor has the same name as the class. 27. Constructors are called like any other method. 28. You can perform some arithmetic operations on class objects.arrow_forwardDesign a Ship class that has 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.Disign a CruiseShip class that extends the Ship class. The CruiseShip class should have thefollowing 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 CruiseShipclass's toString method should display only the ship's name and the maximum number ofpassengers.Design a CargoShip class that extends the Ship class. The CargoShip class should have thefollowing 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 CargoShipclass's…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY