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

/*Design and code and test a class MaxMin that has the following properties * two integer...
/*Design and code and test a class MaxMin that has the following properties * two integer member variables, min and max where min is smaller or equal than max at all times * A default constructor that sets both min and max to 0 * A constructor that accepts one integer and sets both min and max to that integer * A constructor that accepts two integers and sets min the smallest and max the largest * * Setters and...
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...
I. Design and code a class Rectangle that has the following properties: Two private members double...
I. Design and code a class Rectangle that has the following properties: Two private members double length and width A constructor that accepts two parameters for the private members Default constructor that sets both members to 0 Setters/getters for each private member Method area() that returns the area of the rectangle Method Perim() that returns the perimeter of the rectangle Method toString that return the param as a String Method Add that accepts a Rectangle and returns a rectangle with...
Python Create a move function that is only defined in the base class called Objects. The...
Python Create a move function that is only defined in the base class called Objects. The move function will take two parameters x,y and will also return the updated x,y parameters.
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...
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 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...
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 ( $...
Using C#: Write a class named Employee that has the following properties: Name - The Name...
Using C#: Write a class named Employee that has the following properties: Name - The Name property holds the employee's name IdNumber - The IdNumber property holds the employee's ID number Department - The Department property holds the name of the department in which the employee works Position - The Position property holds the employee's job title The class should have the following overloaded constructors: A constructor that accepts the following values as arguments and assigns them to the appropriate...
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT