Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Background Information: The Unified Modeling Language (UML) provides a useful notation for designing and developing object-oriented software systems. One of the basic components of

Java

Background Information:

The Unified Modeling Language (UML) provides a useful notation for designing and developing object-oriented software systems. One of the basic components of the UML is a class diagram, which are used to depict the attributes and behaviors of a class. A basic class diagram (as shown in the figure below) has three components. The first is the class name. The second component includes the class's attributes or fields. Each attribute is followed by a colon (:) and its data type. The third component includes the class's behaviors or methods. If the method takes parameters, their types are included in parentheses. Each behavior is also followed by a colon (:) and its return type. If the return value of a method is void, the return type can be omitted. For more information on the UML, refer to http://www.uml.org/.

Project Requirements:

1)Develop a Screen(computer screen) class:

a.Screen structure - The pixels are represented by dots (.).

b.Static Variables: ScreenCount a static integer variable that represents the number of screen objects created in a given run of the program.

c.Instance variables

i.height an integer representing the height of the screen, in pixels

ii.width an integer representing the width of the screen, in pixels

d.Constructors - Default (no parameter constructor)

i.sets the instance variables and static variable to zero

ii.Note the program will use mutator methods to change screens height and width to values other than zero.

e.Methods

i.getHeight returns the screens height, in pixels.

ii.getWidth returns the screens width, in pixels.

iii.setHeight (int newHeight)

1.Changes the value of the screens height, in pixels

2.Ensures the height is within a range of 5 to 20.

3.Returns a boolean

a.true indicating height is within range and height is set to parameter value.

b.false indicating height not in range and height instance variable unchanged.

iv.setWidth (int newWidth)

1.Changes the value of the screens width, in pixels

2.Ensures the width is within a range of 10 to 50.

3.Returns a boolean

a.true indicating width is within range and width is set to parameter value.

b.false indicating height not in range and height instance variable unchanged.

v.getScreenCount returns the value of the screenCount static variable.

vi.draw

1.Uses the width and height instance variable to draw a screen of the appropriate dimension.

2.Increments the screenCount variable.

2)Create a ScreenBuilder class to draw a computer screen.

a.Creates a Screen object

b.Prompt user to enter the height, include heights range in prompt.

c.Calls the setHeight on the screen objects.

i.If the returned boolean value of the setHeight method is false

1.Display an error message that the height is not within range

2.Returns to step 2b and prompt for a new height value.

d.Calls the setWidth on the screen objects

i.If the returned boolean value of the setWidth method is false

1.Display an error message that the width is not within range

2.Returns to step 2d and prompt for a new width value

e.Calls the draw on the screen object method display the screen.

f.Prompts the user if they would like to draw another screen.

i.if so return to step 2b.

ii.if not continue

g.Call the getScreenCount method to display the number of screen created by in a statement such as, There were 4 screens drawn.

.

3)Below is the UML diagram of the Screen class.

Screen

height : int

width : int

static screenCount : int

Screen()

Screen (int, int)

getHeight():int

setHeight(int newHeight)

getWidth(): int

setWidth(int newWidth)

getScreenCount():int

draw()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Horse Betting The Road To Absolute Horse Racing 2

Authors: NAKAGAWA,YUKIO

1st Edition

B0CFZN219G, 979-8856410593

More Books

Students also viewed these Databases questions