Details attached.Software: EclipseAttaching sample codes, please apply the codes from the sample file, codes should not be complicated.
Assignment Image
2. Overview of the Assignment
2.1 Learning objectives
By doing this assignment you will learn how to:
• Design Encapsulation with UML
•
Draw graphic primitives (arc, oval, triangle, quad etc.);
● Compose complex shapes with primitives;
Animate the complex shape with translation and rotation;
Create a class as a container to hold properties and methods for the shape;
Instantiate an object and call its methods.
2.2. Programming Requirements
First of all, this assignment must be done using Java System Library. You will get 0 if you use
Processing library or any other 3rd party libraries.
This assignment has two iterative steps: Milestone 1: initial UML design and drawing the fish
and Pond, and Final Deliverable: updated UML design and animating the fish
Milestone 1: Design and Drawing Fish and Pond
UML Design:
1) Download VioletUmlEditor 2.1.0 and use it to draw the initial UML that should
include the Fish class that is designed with strict Encapsulation with minimal public
interface methods. The UML diagram must follow the UML notations for class and
encapsulation. Also the names of the class, fields and methods must follow the naming
convention with appropriate upper- or lower case for the initial and CamelCase
thereafter
Create window, panel and draw the background
2) Create the JFrame window and JPanel subclass for FishPanel by following the
examples of lecture and/or lab (It's OK for now if you don't fully understand them, just
follow the example and do it)
Assignment Image
3) Draw the pond: In the FishPanel class, create a method and name it drawPond, which
draws a rectangle filled with appropriate color, and objects (weeds, stones, bubbles,
corals etc.) to simulate the pond. Please note the pond size must be smaller than the
display window by at least 10 pixels on each of the sides. Then display the pond by
calling it in the paint() or paintComponent() method
Draw the fish:
4) Create the Fish class, which should incorporate all the properties and methods as per the
UML design, plus a constructor that initializes each of the fields with some parameter
5) The Fish class should have a draw Fish method that draws a fish, which must have the
following features (you can do more though):
- A head (made of arcs and/or other primitives that you feel appropriate) with an
eye and a gill
A body made of appropriate primitives and decorated with scales, stripes, or
dots
At least two body fins made of appropriate primitives (arc, triangle, quad,
polygon etc.) and decorated differently from the body
A tail decorated differently from the body and body fins
(Please also refer to Section 2.3 below, the last digit of your student number matters to
your feature design. For example, if the last digit of your student number is 1, and you
decorated your fish body with dots and scales only, you are still missing a feature.)
Submission of milestone 1: submit both the initial UML design and code per the submission
requirements and the deadline as specified in Section 1.
Final deliverable: Animate the Fish
Update the UML design:
1) Update the UML design by including FishPanel class and its relationship with the Fish
class (aggregation). Then make the FishPanel implement ActionListener (Again it's OK
for now if you don't fully understand them, just follow the example and do it)
2) Add a Timer object as field to FishPanel
Coding per the design:
3) Make the FishPanel implement ActionListener and thereby the method it declares
Assignment Image
4) Add the field of Timer(Make sure you use javax.swing.Timer rather than
java.util. Timer), and then initialize it with a new instance and start it within the FishPanel
constructor
5) Within the drawFish(Graphics g) method, type cast the graphics instance g into an
instance of Graphics2D, so that we can apply transformations with it
6) Animate the fish: create a method for moving (to be descriptive, name it either update or
move), it will work together with drawFish method to render and animate the fish. They
would:
Move the fish from left to right to simulate fish swimming (must involve
translation)
When it hits the edge of the pond, it should turn around and moves in reverse
direction
When the fish turns around, its tail must not go out of the boundaries of the
pond
The process will repeat (i.e. the fish will swim back and forth within the pond
repeatedly)
7) Please note the method for move must be called inside action Performed () method, and
then call repaint() for the animation to be functioning.
Submission of Final Deliverable: submit both the updated UML design and code per the
submission requirements and the deadline as specified in Section 1.
2.3 Visual Style
Please note visual style counts! Try to be original and creative when designing your pond and
fish, and there will be marks allocated for evaluating the esthetic aspects of your visual design.
Beyond those required features listed above, depending on the last digit of your student
number, you must have at least one of the following features in your fish*.
0 Your fish body must be decorated with scales made from arc
1: Your fish body must be decorated with stripes
2: Your fish body must be decorated with dots
3: Your fish body must be decorated with scales made of triangles
4: Your fish tail must be made of triangle(s)
5: Your fish tail must be made of arcs
6: Your fish tail must be made in shape like an opened scissors
7: Your two body fins must be made of one triangle and one quad
•
8: Your body fins must be made of one arc and one quad
• 9: Your body fins must be made of quads
* If you feel that your required feature will affect your design as a whole, talk to your TA or
instructor. We may relax the constraint if your design sounds reasonable.
Assignment Image
3. Bonus
You can win up to 2 pts bonus marks by adding some animated features to your fish, e.g. mouth
opening/closing or eye ball moving (up to 0.5), tails and/or fins flapping in certain way (up to 1
pt), making the fish move in waving pattern (i.e. moving forward with up and down oscillations,
up to 1 pt), or animating objects in the pond, e.g. making seaweeds wave (up to 1 pt), bubbles
moving up and popping at the surface (up to 1pt), or some other equivalent features that you
might come up with. Please note the bonus caps at 2 pts even if the add-up of your bonus
features goes over it.
Assignment Image
2. Milestone Code: Design and Drawing Fish and Pond (4 pts)
Using the fish and pond that you've created in assignment 1 as the template, redraw them using
Graphics2D object and the relevant geom primitive objects. Here are the requirements.
2.1 UML Design:
Draw the initial UML that should include the Fish class that is designed with strict
Encapsulation with minimal public interface methods and meet the following requirements:
a. The fish (as fields) and pond (including its decoration objects) must consist of geom
primitive objects - except for triangles and quadrangles that you can still use the
drawPolygon method to fill/draw for now - and involve at least one feature made of
Quadratic or Cubic curve
b. Beyond draw Fish (must involve translate) and update (or move) methods, it must
have the methods for the followings:
• At least one setter method for setting the locations and sizes of your fish
components (Please refer to the setBody Attributes or setHeadAttributes method of
Ladybug for example)
• Boundary detection
c. Design Fish Panel class and its relationship with the Fish class (aggregation of a Fish
object). Then add as fields a Timer object and pond object of appropriate geom primitive
class
d. Create FishApp class as a subclass of JFrame, and associate it with the FishPanel class
e. The UML diagram must follow the UML notations for class and encapsulation. Also the
names of the class, fields and methods must follow the naming convention with
appropriate upper- or lower case for the initial and CamelCase thereafter.
2.2 Coding per the design:
-
Like Assignment 1, the pond size must be smaller than the display window by at least 10
pixels on each of the sides except for the top. As you need to leave enough space for
the fishing line (see Fig 1 below), so make sure you have a margin for at least 100
pixels above the pond. The pond should have at least two décor objects drawn using
geom primitive shapes
Make your fish move left and right in the pond
They reverse and flip around when hitting left/right edges of the pond
When the fish turns around, its tail must not go out of the boundaries of the pond
Submission of milestone: submit both the initial UML design (in PDF) and code (in zip) per
the submission requirements and the deadline as specified in Section 1.
Assignment Image
2. Milestone Code: Design and Drawing Fish and Pond (4 pts)
Using the fish and pond that you've created in assignment 1 as the template, redraw them using
Graphics2D object and the relevant geom primitive objects. Here are the requirements.
2.1 UML Design:
Draw the initial UML that should include the Fish class that is designed with strict
Encapsulation with minimal public interface methods and meet the following requirements:
a. The fish (as fields) and pond (including its decoration objects) must consist of geom
primitive objects - except for triangles and quadrangles that you can still use the
drawPolygon method to fill/draw for now - and involve at least one feature made of
Quadratic or Cubic curve
b. Beyond drawFish (must involve translate) and update (or move) methods, it must
have the methods for the followings:
● At least one setter method for setting the locations and sizes of your fish
components (Please refer to the setBodyAttributes or setHeadAttributes method of
Ladybug for example)
• Boundary detection
c. Design FishPanel class and its relationship with the Fish class (aggregation of a Fish
object). Then add as fields a Timer object and pond object of appropriate geom primitive
class
e.
d. Create FishApp class as a subclass of JFrame, and associate it with the FishPanel class
The UML diagram must follow the UML notations for class and encapsulation. Also the
names of the class, fields and methods must follow the naming convention with
appropriate upper- or lower case for the initial and CamelCase thereafter.
2.2 Coding per the design:
Like Assignment 1, the pond size must be smaller than the display window by at least 10
pixels on each of the sides except for the top. As you need to leave enough space for
the fishing line (see Fig 1 below), so make sure you have a margin for at least 100
pixels above the pond. The pond should have at least two décor objects drawn using
geom primitive shapes
Make your fish move left and right in the pond
They reverse and flip around when hitting left/right edges of the pond
- When the fish turns around, its tail must not go out of the boundaries of the pond
Submission of milestone: submit both the initial UML design (in PDF) and code (in zip) per
the submission requirements and the deadline as specified in Section 1.
Assignment Code
/* A Ladybug App that create a JFrame window
* A demo program created for IAT-265 Spring 15
* Author: Eric Yang
* Date of creation: Jan 20 2015
* Date of Modification: Jan 22 2015
* ...
*/
public class BugApp extends javax.swing.JFrame {
public BugApp(String title) {
super(title);
this.setSize(600, 450);
this.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
this.add(new BugPanel());
this.setVisible(true);
}
public static void main(String[] args) {
new BugApp("LadybugApp");
}
}
Assignment Code
/* A Ladybug Panel that draws a ladybug in a garden with a happy face
* A demo program created for IAT-265 Spring 15
* Author: Eric Yang
* Date of creation: Jan 20 2015
* Date of Modification: Jan 22 2015
* ...
*/
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Rectangle2D;
import javax.swing.*;
public class BugPanel extends JPanel implements ActionListener{
public final static int GARDEN_W = 480;
public final static int GARDEN_H = 300;
public final static int GARDEN_X = 50;
public final static int GARDEN_Y = 50;
private Ladybug ladybug;
private Rectangle2D.Double garden;
private Timer timer;
public BugPanel() {
super();
this.setBackground(java.awt.Color.white);
garden = new Rectangle2D.Double();
double speedX = 2.0, speedY = 1.5;
ladybug = new Ladybug(GARDEN_X+50, GARDEN_Y + GARDEN_H / 2, speedX, speedY);
garden.setFrame(GARDEN_X, GARDEN_Y, GARDEN_W, GARDEN_H);
timer=new Timer(20, this);
timer.start();
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.setColor(new Color(0, 200, 0));
g2.fill(garden);
drawHappyFace(g2);
ladybug.drawBug(g2);
}
public void drawHappyFace(Graphics2D g) {
// Dimension size = getSize();
int d = Math.min(GARDEN_W, GARDEN_H); // diameter
int ed = d / 20; // eye diameter
int x = GARDEN_X + 100; // (TANK_WIDTH - d+25); //2;
int y = GARDEN_Y; // (TANK_WIDTH - d-25); //2;
// draw head (color already set to foreground)
g.setColor(Color.yellow);
g.fillOval(x, y, d, d);
g.setColor(Color.black);
g.drawOval(x, y, d, d);
// draw eyes
g.fillOval(x + d / 3 - (ed / 2), y + d / 3 - (ed / 2), ed, ed);
g.fillOval(x + (2 * (d / 3)) - (ed / 2), y + d / 3 - (ed / 2), ed, ed);
// draw mouth
g.drawArc(x + d / 4, y + 2 * (d / 5), d / 2, d / 3, 0, -180);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
ladybug.move();
repaint();
}
}
Assignment Code
/* A Ladybug class that draws and moves a ladybug
* A demo program created for IAT-265 Spring 15
* Author: Eric Yang
* Date of creation: Jan 20 2015
* Date of Modification: Jan 22 2015
* ...
*/
import java.awt.*;
import java.awt.geom.*;
public class Ladybug {
private Ellipse2D.Double body;
private Ellipse2D.Double dot;
private Ellipse2D.Double dot1;
private Ellipse2D.Double dot2;
private Ellipse2D.Double dot3;
private Line2D.Double line;
private Arc2D.Double head;
private QuadCurve2D.Double upAntenna;
private QuadCurve2D.Double dnAntenna;
private double bugX, bugY;
private double dx, dy;
private final int HEAD_WIDTH = 12;
private final int BODY_WIDTH = 34;
private final int BUG_HEIGHT = 30;
private final int DOT_SIZE = 6;
public Ladybug(double x, double y) {
bugX = x;
bugY = y;
body = new Ellipse2D.Double();
dot = new Ellipse2D.Double();
dot1 = new Ellipse2D.Double();
dot2 = new Ellipse2D.Double();
dot3 = new Ellipse2D.Double();
head = new Arc2D.Double();
line = new Line2D.Double();
upAntenna = new QuadCurve2D.Double();
dnAntenna = new QuadCurve2D.Double();
}
public Ladybug(double x, double y, double dx, double dy){
this(x,y);
this.dx=dx;
this.dy=dy;
}
// Set up body components' locations & sizes: Assume (0, 0) be the center of
// the body then draw others around it
public void setBodyAttributes() {
body.setFrame(-BODY_WIDTH / 2, -BUG_HEIGHT / 2, BODY_WIDTH, BUG_HEIGHT);
dot.setFrame(4, -10, DOT_SIZE, DOT_SIZE); // (4, -10): top-left corner
// of the dot
dot1.setFrame(4, 5, DOT_SIZE, DOT_SIZE);
dot2.setFrame(-8, -10, DOT_SIZE, DOT_SIZE);
dot3.setFrame(-8, 5, DOT_SIZE, DOT_SIZE);
line.setLine(-BODY_WIDTH / 2, 0, BODY_WIDTH / 2, 0);
}
// Set up Head components' locations & sizes w.r.t the center of the body
// (0, 0)
public void setHeadAttributes() {
head.setArc(BODY_WIDTH / 2 - 6, -6, HEAD_WIDTH, HEAD_WIDTH, -90, 180, Arc2D.PIE);
upAntenna.setCurve(BODY_WIDTH / 2, 0, BODY_WIDTH / 2 + 10, 0, BODY_WIDTH / 2 + 16, -10);
dnAntenna.setCurve(BODY_WIDTH / 2, 0, BODY_WIDTH / 2 + 10, 0, BODY_WIDTH / 2 + 16, 10);
}
public void drawBug(Graphics2D g2) {
g2.scale(1.5, 1.5);
g2.translate(bugX, bugY);
double angle=Math.atan2(dy, dx);
g2.rotate(angle);
setHeadAttributes();
setBodyAttributes();
// fill body in orange
g2.setColor(new Color(160, 0, 0));
g2.fill(body);
g2.setColor(Color.BLACK);
// draw body outline in black
g2.draw(body);
// fill the dots and head
g2.fill(dot);
g2.fill(dot1);
g2.fill(dot2);
g2.fill(dot3);
g2.fill(head);
// draw the body line and antenna
g2.draw(line);
g2.draw(upAntenna);
g2.draw(dnAntenna);
}
public void move(){
bugX+=dx;
bugY+=dy;
checkWalls();
}
private void checkWalls() {
// TODO Auto-generated method stub
if(overLeftWall()||overRightWall()){
dx*=-1;
}
if(overTop()||overBottom()){
dy*=-1;
}
}
private boolean overBottom() {
return bugY<(BugPanel.GARDEN_Y+BUG_HEIGHT/2+10)/1.5;
}
private boolean overTop() {
return bugY>(BugPanel.GARDEN_Y+BugPanel.GARDEN_H-BUG_HEIGHT/2-10)/1.5;
}
private boolean overLeftWall() {
return bugX<(BugPanel.GARDEN_X+BODY_WIDTH/2+16)/1.5;
}
private boolean overRightWall() {
return bugX>(BugPanel.GARDEN_X+BugPanel.GARDEN_W-BODY_WIDTH/2-16)/1.5;
}
}
Frequently Asked Questions
Is it free to get my assignment evaluated?
Yes. No hidden fees. You pay for the solution only, and all the explanations about how to run it are included in the price. It takes up to 24 hours to get a quote from an expert. In some cases, we can help you faster if an expert is available, but you should always order in advance to avoid the risks. You can place a new order here.
How much does it cost?
The cost depends on many factors: how far away the deadline is, how hard/big the task is, if it is code only or a report, etc. We try to give rough estimates here, but it is just for orientation (in USD):
Regular homework
$20 - $150
Advanced homework
$100 - $300
Group project or a report
$200 - $500
Mid-term or final project
$200 - $800
Live exam help
$100 - $300
Full thesis
$1000 - $3000
How do I pay?
Credit card or PayPal. You don't need to create/have a Payal account in order to pay by a credit card. Paypal offers you "buyer's protection" in case of any issues.
Why do I need to pay in advance?
We have no way to request money after we send you the solution. PayPal works as a middleman, which protects you in case of any disputes, so you should feel safe paying using PayPal.
Do you do essays?
No, unless it is a data analysis essay or report. This is because essays are very personal and it is easy to see when they are written by another person. This is not the case with math and programming.
Why there are no discounts?
It is because we don't want to lie - in such services no discount can be set in advance because we set the price knowing that there is a discount. For example, if we wanted to ask for $100, we could tell that the price is $200 and because you are special, we can do a 50% discount. It is the way all scam websites operate. We set honest prices instead, so there is no need for fake discounts.
Do you do live tutoring?
No, it is simply not how we operate. How often do you meet a great programmer who is also a great speaker? Rarely. It is why we encourage our experts to write down explanations instead of having a live call. It is often enough to get you started - analyzing and running the solutions is a big part of learning.
What happens if I am not satisfied with the solution?
Another expert will review the task, and if your claim is reasonable - we refund the payment and often block the freelancer from our platform. Because we are so harsh with our experts - the ones working with us are very trustworthy to deliver high-quality assignment solutions on time.