2023 Original answers only no copy or paste These are short answer questions please follow the | Assignment Collections
Computer Science 2023 java script
2023 Original answers only no copy or paste These are short answer questions please follow the | Assignment Collections
Original answers only no copy or paste. These are short answer questions, please follow the instructions and provide detailed answers.
1. (TCOs 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.
2. (TCOs 1–8) Write a class called square,
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 square and point.
Write a test program to test it.
3. Start from the following code, and add Action Listener to make it functional. (Need about 10 lines)
Note: 1 lb = .0.453592 kg.
import javax.swing.*;
import
java.awt.GridLayout;
import
java.awt.event.*;
import
java.text.DecimalFormat;
public class weightConverter extends JFrame {
public static void
main(String[] args) {
JFrame frame = new weightConverter();
frame.setTitle(“Weight”);
frame.setSize(200, 100);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public
weightConverter() {
JLabellbllb = new JLabel(“lb”,SwingConstants.CENTER);
JLabellblkg = new JLabel(“kg”,SwingConstants.CENTER);
final
JTextFieldjtflb = new JTextField();
final
JTextFieldjtfkg = new JTextField();
JButtonjbtLeft = new JButton(“<=”);
JButtonjbtRight = new JButton(“=>”);
JPanel panel = new JPanel(new GridLayout(2, 3));
panel.add(lbllb);
panel.add(jbtLeft);
panel.add(lblkg);
panel.add(jtflb);
panel.add(jbtRight);
panel.add(jtfkg);
this.add(panel); // Add panel to the frame
final
DecimalFormatdec = new DecimalFormat(“#.00”);
}
}
4. Start from the given class, and create a NewPanel class to draw a figure like below. (Need about 15 lines)
import javax.swing.*;
import
java.awt.Graphics;
import java.awt.Color;
public class drawPerson extends
JFrame {
public
drawPerson() {
add(new
NewPanel());
}
public static void
main(String[] args) {
drawPerson frame = new drawPerson();
frame.setTitle(“Person”);
frame.setSize(200, 200);
frame.setLocationRelativeTo(null); // Center the frame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
The circle coordinate and size is (80, 15, 20, 25).
The text coordinate is (70, 135).
The starting and ending lines coordinate are
(90, 40, 90, 80);
(60, 50, 120, 50);
(90, 80, 70, 120); and
(90, 80, 110, 120).
Color pink, with text color magenta.
We give our students 100% satisfaction with their assignments, which is one of the most important reasons students prefer us to other helpers. Our professional group and planners have more than ten years of rich experience. The only reason is that we have successfully helped more than 100000 students with their assignments on our inception days. Our expert group has more than 2200 professionals in different topics, and that is not all; we get more than 300 jobs every day more than 90% of the assignment get the conversion for payment.