This document outlines the structure of a Java program, including import statements to include necessary classes, the class code with constants, fields, constructors, and methods. The class code shown is for a "Body" class that extends the "SmoothMover" class, and includes private constants for gravity and a default color, fields to store mass and color, empty constructors, and act(), applyForces(), and getMass() methods.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
36 views
Java Program Structure 1. Import Statements
This document outlines the structure of a Java program, including import statements to include necessary classes, the class code with constants, fields, constructors, and methods. The class code shown is for a "Body" class that extends the "SmoothMover" class, and includes private constants for gravity and a default color, fields to store mass and color, empty constructors, and act(), applyForces(), and getMass() methods.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1
Name: .. Class: ..
Java Program Structure
1. Import Statements import greenfoot.*; import java.awt.Color; import java.util.List; 2. The Class Code public class Body extends SmoothMover { // Constants & Fields private static final double GRAVITY = 5.8; private static final Color defaultColor = new Color(255, 216, 0); private double mass; // Constructors public Body() { this (20, 300, new Vector(0, 1.0), defaultColor); } public Body(int size, double mass, Vector movement, Color color) { }
// Methods public void act() { applyForces(); move(); } private void applyForces() { } public double getMass() { } }// end of Class .. .. .. .
Python Advanced Programming: The Guide to Learn Python Programming. Reference with Exercises and Samples About Dynamical Programming, Multithreading, Multiprocessing, Debugging, Testing and More