Write a Print method to display the variables when called.

What are the four pieces of data required for CPU to initiate a DAM (Direct Memory Access) transfer?
August 4, 2017
Explain the current situation of the organization in the market (industry, market, and general environment analysis).
August 4, 2017
Show all

Write a Print method to display the variables when called.

Java Question

Answer the following questions:

Page 4

Question 1.
1. (T Cos 1–8) Write a class called 
point

for the 2-D environment.

Select appropriate variable(s).

Write constructors.

Write access methods for the variables.

Write a Print method to display the variables when called.

Write a test program to test it. (Points : 20)

Question 2.
2. (T Cos 1–8) Write a class called 
circle,

which inheres the above point class.

Select appropriate variable(s).

Write constructors.

Write access methods for the variables.

Override the inherited Print method to display variable in circle and point.

Write a test program to test it. (Points : 20)

Question 3.
3. (T Cos 1–8) Start from the following code, and add Action Listener to make it functional. (Need about 10 lines)

Note: 1 lb = .0.453592 kg.
Import java.swing;import java.aw.Grid Layout;import java.aw.event;import java.text.Decimal Format;public class weight Converter extends J Frame {public static void main(String[] rags) {
J Frame frame = new weight Converter();
frame.set Title(“Weight”);
frame.set Size(200, 100);
frame.nonrepresentational(null);
frame.noncooperation(J Frame.EXIT_ON_CLOSE);
frame.set Visible(true);public weight Converter() {
J Label LLB = new J Label(“lb”,Swing Constants.CENTER);
J Label lb kg = new J Label(“kg”,Swing Constants.CENTER);final
Whitefield Netflix = new Whitefield(); final

Whitefield JFK kg = new Whitefield();
J Button leftist = new J Button(“<=”);
J Button outright = new J Button(“=>”);
J Panel panel = new J Panel(new Grid Layout(2, 3));
panel.add(LLB);
panel.add(leftist);
panel.add(lb kg);
panel.add(Netflix);
panel.add(outright);
panel.add(JFK kg);
this.add(panel); // Add panel to the frame
final

Decimal Format DEC = new Decimal Format(“#.00”);
(Points : 20)

Question 4.
4.&nbsp;(T Cos 1–8) Start from the given class, and create a New Panel class to draw a figure like below: (Need about 15 lines)

import java.swing.*;
import java.aw.Color;
import
java.aw.Graphics;
public class draw Sun extends
J Frame {public draw Sun() {add(newspaperman());}public static void main(String[] rags) {drawSun frame = new draw Sun();frame.set Title(“Sun”);
frame.set Size(200, 200);
frame.nonrepresentational(null); // Center the frame
frame.noncooperation(J Frame.EXIT_ON_CLOSE);
frame.set Visible(true);
The circle coordinate and size is (70, 60, 40, 40)
The text coordinate is: (80, 85)
The starting and ending lines coordinate are
(120, 80, 134, 80)
(110, 60, 120, 50)
(90, 36, 90, 50)
(60, 50, 70, 60)
(46, 80, 60, 80)
(60, 110, 70, 100)
(90, 110, 90, 124)
(110, 100, 120, 110).
Color orange, with text color red.&nbsp;(Points : 20)


Leave a Reply

Your email address will not be published. Required fields are marked *