Question

In: Computer Science

Write the class declarations for the following objects' descriptions. NO CODE. That means only properties and...

Write the class declarations for the following objects' descriptions. NO CODE. That means only properties and method declarations. Like...

class Lamp {

int mBulbs; void Explode();

};

1) A Laptop has a color, brand, and processor speed. You can open, close, turn on, and turn off a laptop.

2) A monitor has a screen size and a brightness.

3) Oh wait, a laptop has a monitor itself. To do this, would you add a line to answer #1 or answer #2, and what line would you add?

Solutions

Expert Solution

Answer:

1)

class Laptop {

String color;

String brand;

float proc_speed;

void open();

void close();

boolean turn_on();

boolean turn_off();

}

class Monitor{

float screen_size;

float brightness;

}

I would like to add monitor property in the Monitor class.

A monitor is a display which should be specified in the Monitor class itself.

But in our question, " a laptop has a monitor itself". For this, we can use the inheritance concept to do this. Use extends keyword to inherit the properties of Monitor class into Laptop.

Above description is the solution to this problem.

The following are the attribute values of display types of laptops.

HD, FHD, QHD, UHD, AMOLED, LED, LCD, OLED etc.

The final concluded Classes for the given requirement are as follows:

class Laptop {

String color; // Black, Red etc

String brand; // Dell, HP, Acer, Asus etc

float proc_speed; // the values will be 2.9, 3.1 in G.Hz.

void open(); // It doesn't return a value

void close(); // It doesn't return a value

boolean turn_on(); // It should be boolen type, since it is either return true(1) or false(0) state

boolean turn_off(); // It should be boolen type, since it is either return true(1) or false(0) state

}

class Monitor{

float screen_size; // 15.6, 16.0 in inch etc

float brightness; // 209, 301 nits etc

String monitor_type; // added in the Monitor class values like AMOLED, LED, LCD etc.

}


Related Solutions

For the following program descriptions, write step by step pseudo code that shows you understand the...
For the following program descriptions, write step by step pseudo code that shows you understand the problem and what it takes to solve it. The first one is done for you as an example. Please answer the questions in the same format as the example problem below so it is the same. Example #1 Problem A customer is purchasing five items. Design a program where you collect the amount of each item, calculate the subTotal of the items, the tax...
Write a C# code that creates objects and classes with their member functions for KrisFlyer, a...
Write a C# code that creates objects and classes with their member functions for KrisFlyer, a Singapore Airlines Loyalty program. You are asked to write an inheritance hierarchy discount system that benefits KrisFlyer members program to calculate their profit. A brief about KrisFlyer is that it is useful for those who fly on Singapore Airlines (its partners like Virgin Australia and Air New Zealand) frequently. KrisFlyer miles can be earned through credit cards, flying and bonus miles promotions. The miles...
write pseudocode for the following problems not c code Pseudocode only Write a C program to...
write pseudocode for the following problems not c code Pseudocode only Write a C program to print all natural numbers from 1 to n. - using while loop Write a C program to print all natural numbers in reverse (from n to 1). - using while loop Write a C program to print all alphabets from a to z. - using while loop Write a C program to print all even numbers between 1 to 100. - using while loop...
Provide some definitions and descriptions of the following objects with diagrams if necessary 1. White dwarf...
Provide some definitions and descriptions of the following objects with diagrams if necessary 1. White dwarf 2. Rotational Curve 3. HII region 4. Virial Theorem 5. Chandrasekar mass 6. Critical cosmological density 7. Gravitational wave 8. Clusters of galaxies
Write a c++ code: 2.2.1 Vehicle Class The vehicle class is the parent class of a...
Write a c++ code: 2.2.1 Vehicle Class The vehicle class is the parent class of a derived class: locomotive. Their inheritance will be public inheritance so react that appropriately in their .h les. The description of the vehicle class is given in the simple UML diagram below: vehicle -map: char** -name: string -size:int -------------------------- +vehicle() +setName(s:string):void +getName():string +getMap():char** +getSize():int +setMap(s: string):void +getMapAt(x:int, y:int):char +vehicle() +operator--():void +determineRouteStatistics()=0:void The class variables are as follows: map: A 2D array of chars, it will...
Write EBNF descriptions for the following: • a Java For each statement Assume that EBNF descriptions...
Write EBNF descriptions for the following: • a Java For each statement Assume that EBNF descriptions for statement(s), type, array, white space are given. (statmnts, type, array, and whitespace respectively) You have to create EBNF descriptions for For each statement and also variable. Use the following Java variable naming rules to create EBNF description for variable. o All variable names must begin with a letter of the alphabet, an underscore ( _ ) , or a dollar sign ( $...
Make a class whose objects each represent a battery. The only attribute an object will have...
Make a class whose objects each represent a battery. The only attribute an object will have is the battery type (one letter). Also, the class has to include the following services for its objects: -determine if two batteries are equal -change battery type -get battery type display battery information the program must include: 1.All / Part 2.Overloading of operators 3.Builder 4.Copy constructor 5.Destroyer 6.Dynamic memory C++
Write down descriptions for each of the following sets:
Write down descriptions for each of the following sets:● Three different countably infinite subsets of the real numbers.● Three different uncountably infinite subsets of the real numbers.● One uncountably infinite proper super set of the real numbers.
Which part of the following descriptions of a compound or element refers to its physical properties...
Which part of the following descriptions of a compound or element refers to its physical properties and which to its chemical properties? (a) Calcium carbonate is a white solid with a density of 2.71 g/cm^3. It reacts readily with an acid to produce gaseous carbon dioxide. (b) Gray powdered zinc metal reacts with purple iodine to give a white compound.
Which part of the following descriptions of a compound or element refers to its physical properties...
Which part of the following descriptions of a compound or element refers to its physical properties and which to its chemical properties?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT