Question

In: Computer Science

: Let’s say we are working with shapes having different types like 2d, 3D and so...

: Let’s say we are working with shapes having different types like 2d, 3D and so on. Using private access to fields of class design a class for rectangle.    

c# for both 2d and 3d rectangle

Solutions

Expert Solution

private void Draw2d3d(Graphics gr, Rectangle rect,

rectStyle rect_style, bool sunken)

{

if (rect_style == RectStyle.FixedSingle)

{

rect.Width -= 1;

rect.Height -= 1;

gr.DrawRectangle(Pens.Black, rect);

}

else if (rect_style == RectStyle.Fixed3D)

{

Color[] colors;

if (sunken)

{

colors = new Color[]

{

SystemColors.ControlDark,

SystemColors.ControlDarkDark,

SystemColors.ControlLightLight,

SystemColors.ControlLight

};

}

else

{

colors = new Color[]

{

SystemColors.ControlLightLight,

SystemColors.ControlLight,

SystemColors.ControlDark,

SystemColors.ControlDarkDark

};

}

using (Pen p = new Pen(colors[0]))

{

gr.DrawLine(p, rect.X, rect.Bottom - 1,

rect.X, rect.Y);

gr.DrawLine(p, rect.X, rect.Y,

rect.Right - 1, rect.Y);

}

using (Pen p = new Pen(colors[1]))

{

gr.DrawLine(p, rect.X + 1, rect.Bottom - 2,

rect.X + 1, rect.Y + 1);

gr.DrawLine(p, rect.X + 1, rect.Y + 1,

rect.Right - 2, rect.Y + 1);

}

using (Pen p = new Pen(colors[2]))

{

gr.DrawLine(p, rect.X, rect.Bottom - 1,

rect.Right - 1, rect.Bottom - 1);

gr.DrawLine(p, rect.Right - 1, rect.Bottom - 1,

rect.Right - 1, rect.Y);

}

using (Pen p = new Pen(colors[3]))

{

gr.DrawLine(p, rect.X + 1, rect.Bottom - 2,

rect.Right - 2, rect.Bottom - 2);

gr.DrawLine(p, rect.Right - 2, rect.Bottom - 2,

rect.Right - 2, rect.Y + 1);

}

}

}


Related Solutions

Let’s say you have a light shop where you sale and purchase having different types of...
Let’s say you have a light shop where you sale and purchase having different types of light and different electric appliances. Now using principles of OOP I want you want make an OOP program which can cater the aforementioned problem.(show different types of purchase and sales ) C#
So let’s say you have a beaker that contains 78.8g of ammonium carbonate and to this...
So let’s say you have a beaker that contains 78.8g of ammonium carbonate and to this you add 175 mL of 5.80 M hydrochloric acid according to the following chemical equation: 2HCl(aq) + (NH4)2CO3(s) -- > 2NH4Cl(aq) + H2O(l) + CO2(g) .DeltaH = -145 kJ A) Draw the beaker at the end of the reaction - what would e in the beaker and/or around it. What would the products look like on a molecular/atom/ion level? B) Why would water vapor...
1) We say that electrons in the 3d orbital are "better shielded" than those in the...
1) We say that electrons in the 3d orbital are "better shielded" than those in the 3p orbital. a) what does this mean? b) are the electrons in the 3d orbitals better shielded by electrons in the 2p orbital or int he 3p orbital? c) Based on fundamental physics principles not slater's rule, is it possible for electrons in the 4s orbital to partially shield an electron in the 3p orbital?
So let’s say you have a beaker that contains 15.2 g sodium sulfite and to this...
So let’s say you have a beaker that contains 15.2 g sodium sulfite and to this you add 150. mL of 1.25 M nitric acid according to the following chemical equation: Na2SO3(s) + 2HNO3 (aq)  2NaNO3 (aq)+ H2O(l) + SO2 (g)   H = -225. kJ A). Draw the beaker at the end of the reaction. What would e in the beaker and/or around it. What would the products look like on a molecular/atom/ion level? B). At STP, how many...
So let’s say you have a beaker that contains 6.02g ammonium chloride and to this you...
So let’s say you have a beaker that contains 6.02g ammonium chloride and to this you add 300.0mL of 0.450 M calcium hydroxide according to the following chemical equation: Ca(OH)2(aq) + 2NH4Cl(s)  CaCl2(aq) + 2H2O(l) + 2NH3(g) H = +90.66 kJ A) draw the beaker at the end of the reaction- what would be in the beaker and or around it. what would the products look like on a molecular/atom/ion level? B) at STP, how many L of your...
Let’s say you wanted to have a communications satellite orbit the Moon so that it stayed...
Let’s say you wanted to have a communications satellite orbit the Moon so that it stayed exactly above one point of the Moon’s equator (similar to a geosynchronous here on Earth). What would the linear speed and lunar altitude of your communications satellite be?
In class we discussed Transitive Trust. And we covered so many different types of attacks. Do...
In class we discussed Transitive Trust. And we covered so many different types of attacks. Do you think that there may be an attack on Trust? Explain your answer.
Let’s say that there are two types of grapefruits: Low-quality, and high-quality, and consumers buy a...
Let’s say that there are two types of grapefruits: Low-quality, and high-quality, and consumers buy a mix of the two, with high-quality grapefruits being more expensive. T/F/U: If the government puts a single, binding price floor on all grapefruits, the average quality of grapefruit consumed will rise.
5. Now let’s say you would like to generate ozone in a container of oxygen gas...
5. Now let’s say you would like to generate ozone in a container of oxygen gas at constant temperature and volume. A) At equilibrium, what is the relation between the chemical potentials of ozone and oxygen? B) Is the relevant equilibrium constant given by the usual ln Keq = ??G°/RT or instead by ln Keq = ??A°/RT? Here, ?A° is the change in Helmholtz free energy per mole of reaction. Justify your answer, either mathematically or conceptually. [Hint: The answer...
Let’s say that we have a 20-year mortgage with an original loan balance of $150,000 at...
Let’s say that we have a 20-year mortgage with an original loan balance of $150,000 at 7% interest per year. How much money (i.e., balance) do you still owe after the 7th year of the loan? (The loan is compounded monthly) . 1. $129,385 2. Cannot be determined 3. $118,902 4. $133,722
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT