-
Notifications
You must be signed in to change notification settings - Fork 2
/
PhysicsCalculator.java
90 lines (72 loc) · 3.18 KB
/
PhysicsCalculator.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package xyz.nisarga.PhysicsCalculator;
// Author- Nisarga Adhikary (adhikarynisarga17@gmail.com)
import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.runtime.*;
import com.google.appinventor.components.common.*;
@DesignerComponent(version = 1, // Extension Version
description = "PhysicsCalculator extension for MIT AI2 & it's distros by <b> Nisarga Adhikary </b>. ",
category = ComponentCategory.EXTENSION,
nonVisible = true,
iconName = "images/extension.png")
@SimpleObject(external = true)
public class PhysicsCalculator extends AndroidNonvisibleComponent {
public PhysicsCalculator(ComponentContainer container) {
super(container.$form());
}
@SimpleFunction(description = "Calculate Density")
public int CalculateDensity (int mass, int volume) {
return mass * 1/volume;
}
@SimpleFunction(description = "Calculate Volume")
public int CalculateVolume (int mass, int density) {
return mass * 1/density;
}
@SimpleFunction(description = "Calculate Mass")
public int CalculateMass (int density, int volume) {
return density * volume;
}
@SimpleFunction(description = "Calculate Speed")
public int CalculateSpeed (int distance, int time) {
return distance * 1/time;
}
@SimpleFunction(description = "Calculate Distance")
public int CalculateDistance (int time, int speed) {
return time * speed;
}
@SimpleFunction(description = "Calculate Acceleration")
public int CalculateAcceleration (int InitialVelocity, int FinalVelocity, int Time) {
return (FinalVelocity - InitialVelocity) * 1/Time;
}
@SimpleFunction(description = "CalculateRetardation")
public int CalculateRetardation (int InitialVelocity, int FinalVelocity, int Time) {
return (InitialVelocity - FinalVelocity) * 1/Time;
}
@SimpleFunction(description = "CalculateForce")
public int CalculateForce (int mass, int acceleration) {
return mass * acceleration;
}
@SimpleFunction(description = "CalculatePressure")
public int CalculatePressure (int force, int area) {
return force * 1/area;
}
@SimpleFunction(description = " Calculate Heat Absorbed By An Object ")
public int CalculateHeatAbsorbed (int MassOfObject, int RelativeHeat, int ChangeOfTemperature) {
return MassOfObject * RelativeHeat * ChangeOfTemperature;
}
@SimpleFunction(description = " Calculate Power ")
public int CalculatePower (int Workdone, int time) {
return Workdone * 1/time;
}
@SimpleFunction(description = " CalculateWorkdone ")
public int CalculateWorkdone (int Force, int Displacement) {
return Force * Displacement;
}
@SimpleFunction(description = " CalculateKineticEnergy ")
public int CalculateKineticEnergy (int mass, int velocity) {
return 1/2 * mass * velocity * velocity;
}
@SimpleFunction(description = " CalculateKineticEnergy ")
public int CalculateGravitationalPotentialEnergy (int mass, int G, int height) {
return mass * G * height;
}
}