How to display different shapes using GUI? Solution:

Problem Description:
How to display different shapes using GUI?
Solution:
Following example demonstrates how to display different shapes using Arc2D, Ellipse2D, Rectangle2D, RoundRectangle2D classes.
import java.awt.Shape; import java.awt.geom.*; publicclassMain{ publicstaticvoid main(String[] args){ int x1=1, x2=2, w=3, h=4, x=5, y=6, y1=1, y2=2, start=3; Shape line=newLine2D.Float(x1, y1, x2, y2); Shape arc=newArc2D.Float(x, y, w, h, start,1,1); Shape oval=newEllipse2D.Float(x, y, w, h); Shape rectangle=newRectangle2D.Float(x, y, w, h); Shape roundRectangle=newRoundRectangle2D.Float (x, y, w, h,1,2); System.out.println("Different shapes are created:"); } }Result:
The above code sample will produce the following result.
Different shapes are created.

2.
Write a value-returning method namedreverseDigit, that takes an int (integer) as a parameter and returns the number with its digits reversed as an int. For example, callingreverseDigit(12345) returns the int value of 54321.

3.
Page 1 of 2 The SMART home heating problem Overview You have been asked to design the user interface to a "smart" home thermostat. The system will be targeted at middle-income home owners, for both new and existing homes. The marketing strategy for the system will be to emphasize the cost-savings and environmental benefits of pre-setting the system to keep rooms warm only when they are likely to be in use. A preliminary market survey has shown that homeowners are quite receptive to this idea, and the survey has shown that a number of competing systems are already on the market. However, the marketing survey has also shown that existing systems are typically very complex and confusing for the homeowner to use effectively. The key to your system's success, therefore, will be its excellent user interface. Requirements The major requirements and constraints of the design are:  The control system will initially be marketed in cold-climate areas, so you should consider only heating functions, not air conditioning.  Different heating methods (such as hot air, hot water, steam, or electric) may have slightly different requirements. o In a real design situation, you would discuss this issue extensively with the appropriate engineers. For the purposes of this write a paper project, you are to act as your own engineering expert and consider only the kind of heating that you currently have in your home. o The supply of power to the heating system is NOT part of the design problem. You can assume that you have a continual and reliable supply of power from whatever power source you choose.  An important contribution to heating cost savings has been identified as "zoned" heating. For example, the bedrooms should be kept cool during the day when no one is using them, even if the kitchen or playroom is being heated during that period. o Design the system to support three or more zones, and assume the method of heating will also support this.  The marketing and production departments have a rough idea of how much hardware you can afford to incorporate into the interface. o It's assumed that you will need a simple microprocessor, ROM for program code, and non-volatile RAM for storing settings. o As a rough estimate, assume you have the processing power of a Macintosh or an IBM-PC.  The physical interface is more limited than the underlying processor. Marketing has determined that homeowners don't want large, complex controls on their walls. o You must incorporate the controls onto a control panel that is 150mm x 150mm (6 inch x 6 inch) at the most. o You are free to reduce the control panel size, if you think it appropriate. For example, would a 100mm x 150mm (4 inch x 6 inch) panel be a better fit? Page 2 of 2 o In this space you can put whatever you want: buttons, dials, gauges, LCD screens, touch screens, stylus pads, colour, etc. o Stay with hand-and-eye interactions; don't propose voice controlled systems.  Each zone can have its own control panel, or you can combine all controls on a single master panel. (Marketing likes a single panel, because that's cheaper and easier to install.)  Each zone has its own temperature sensor. The heating system will be able to maintain a set temperature for each zone. However, changes to temperature won't occur instantly.  Some of the tasks that marketing thinks the control system should support are: o Pre-setting temperatures that the heating system should maintain for zones at various times during various days of the week (for example, keep bedrooms at 150 C (590 F) in the daytime, except Sunday before 10 a.m.; then heat bedrooms to 220 C (720 C) between 5 p.m. and 11 p.m.); o Allow pre-set settings to be over-ridden for a few hours (for someone at home on a single-day holiday); o Allow pre-set settings to be over-ridden for a few days (when no one is at home during holidays). Your task and user analysis should confirm, deny, or expand on these. 

Comments

Popular posts from this blog

Freeman-Brown Private School Case Study

Assignments eg ECO 561 Final Exam

Unit 9 Assignment 1 3520 Social Psychology Application