Generate a unique identification number for each object


1. Keeping in mind all object-oriented programming best practices, create a class for a Chair, with the following specifications:

-. Specify two data members

-. Default Constructor

-. Overloaded Constructor which takes both data member values as input.

-. Generate a unique identification number for each object instantiated from this class. Use a static data member to keep track of the identification number last assigned to an object so that duplications will not occur. 

-. Show a statement which instantiates an object of this class using the overloaded constructor.

You do not need to provide any accessor/mutator methods or other methods.

2. Given the following list of classes, attributes and methods, 

- identify which items are classes, which items are attributes and which items are methods;

- identify which class each attribute and method belongs to; and

- suggest a class hierarchy given your list of classes.

*Note - no particular capitalization scheme is used in the list below to differentiate between classes, methods, and attributes.

AdhereToBuilding, NumberOfPetals, Photosynthesize, EmitFragrance, Length, Plant, Height, DaysToGermination, Rose, Grow, LosePetals, ConsumeWater, FloweringSeason, Vine, Color, LeavesPerInch

3. Briefly describe what an interface is and how it can be used in an object-oriented program. Provide example pseudocode showing how an s Interface might be constructed. 

4. How do you make an abstract method? When a class contains abstract method, what will happen? Can we still treat the class like a normal class? Provide pseudocode that represents an abstract class with at least one abstract method.

5. Define and implement the overloaded constructors that support the following test function for a Rectangle class. The data members for the Rectangle class are length and width. Both are integer data types.

public static void main(String args[])

//r1 will take all default value
Rectangle r1 = Rectangle(); 

//r2 will take all supplied value
Rectangle r2 = Rectangle(4, 5); 

//r3 will take supplied length. width will take default value
Rectangle r3 = Rectangle(10); 

//r4 will take the same value of r2
Rectangle r4= r2; 

//the rest of the code

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Generate a unique identification number for each object
Reference No:- TGS01575731

Now Priced at $25 (50% Discount)

Recommended (99%)

Rated (4.3/5)