Write 2 Classes:
The first class:
Dear recipient name:
first line of the body
second line of the body
. . .
last line of the body
Sincerely,
sender name
The second class
Dear John:
I am sorry we must part.
I wish you all the best.
Sincerely,
Mary
Hints:
Use the concat method or the + operator to form a longer string from two shorter strings.
The special string "n" represents a new line. For example, the statement
body = body.concat("Sincerely,").concat("(backslash)n");
Write a program with 3 classes that draws a picture of a house. It could be as simple as the accompanying figure, or if you like, more elaborate (3-D, skyscraper, marble columns in the entryway, whatever). Implement a class House and supply a method draw(Graphics2D g2) that draws the house. It should fit in a 400 by 400 window. Bonus points for the best house. Upload your House.java file. Here are two of the classes that you should leverage:
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JComponent;
/**
This component draws a house
*/
public class HouseComponent extends JComponent{
private static final long serialVersionUID = 5368385930392743141L;
public void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
House house = new House();
house.draw(g2);
}
}
import javax.swing.JFrame;
public class HouseViewer {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setSize(400, 400);
frame.setTitle("House");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
HouseComponent component = new HouseComponent();
frame.add(component);
frame.setVisible(true);
}
}