Изменил(а) на 'MyFirstUniverse/src/com/company/cosmicbody/Planet.java'
This commit is contained in:
parent
a357b0578f
commit
8efe7417df
@ -1,103 +1,103 @@
|
|||||||
package com.company.cosmicbody;
|
package com.company.cosmicbody;
|
||||||
|
|
||||||
public class Planet extends CosmicBody {
|
public class Planet extends CosmicBody {
|
||||||
private String name;
|
private String name;
|
||||||
private double weight;
|
private double weight;
|
||||||
private double diameter;
|
private double diameter;
|
||||||
private double gravitation;
|
private double gravitation;
|
||||||
private Boolean weightSet = false;
|
private Boolean weightSet = false;
|
||||||
|
|
||||||
public void setPlanetaryWeight(double weight){
|
public void setPlanetaryWeight(double weight){
|
||||||
if(!weightSet){
|
if(!weightSet){
|
||||||
setWeight(weight);
|
setWeight(weight);
|
||||||
weightSet = true;
|
weightSet = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public double getWeight() {
|
public double getWeight() {
|
||||||
return weight;
|
return weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setWeight(double weight) {
|
private void setWeight(double weight) {
|
||||||
if(this.weight>weight){
|
if(this.weight>weight){
|
||||||
if(Math.abs(this.weight-weight) <= 1000){
|
if(Math.abs(this.weight-weight) <= 1000){
|
||||||
System.out.println("I'm losing weight.");
|
System.out.println("I'm losing weight.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
System.out.println("I am very poor.");
|
System.out.println("I'm losing a lot of weight.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(Math.abs(this.weight-weight) <= 1000){
|
if(Math.abs(this.weight-weight) <= 1000){
|
||||||
System.out.println("Damn, I woke up.");
|
System.out.println("Damn, I woke up.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
System.out.println("Damn, I put on too much weight.");
|
System.out.println("Damn, I put on too much weight.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Math.abs(this.weight-weight)>1000){
|
if(Math.abs(this.weight-weight)>1000){
|
||||||
increaseGravity(0.1);
|
increaseGravity(0.1);
|
||||||
} else {
|
} else {
|
||||||
decreaseGravity(0.1);
|
decreaseGravity(0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getDiameter() {
|
public double getDiameter() {
|
||||||
return diameter;
|
return diameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDiameter(double diameter) {
|
private void setDiameter(double diameter) {
|
||||||
this.diameter = diameter;
|
this.diameter = diameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setName(String name) {
|
private void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getGravitation() {
|
public double getGravitation() {
|
||||||
return gravitation;
|
return gravitation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGravitation(double gravitation) {
|
public void setGravitation(double gravitation) {
|
||||||
this.gravitation = gravitation;
|
this.gravitation = gravitation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Planet(String name, double weight, double diameter) {
|
public Planet(String name, double weight, double diameter) {
|
||||||
// setWeight(weight);
|
// setWeight(weight);
|
||||||
// setDiameter(diameter);
|
// setDiameter(diameter);
|
||||||
// setName(name);
|
// setName(name);
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
this.diameter = diameter;
|
this.diameter = diameter;
|
||||||
this.gravitation = 9.81;
|
this.gravitation = 9.81;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void increaseGravity(double add){
|
private void increaseGravity(double add){
|
||||||
gravitation = gravitation + add;
|
gravitation = gravitation + add;
|
||||||
}
|
}
|
||||||
private void decreaseGravity(double dec){
|
private void decreaseGravity(double dec){
|
||||||
gravitation = gravitation - dec;
|
gravitation = gravitation - dec;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Planet(String name, double weight, double diameter, double gravitation) {
|
public Planet(String name, double weight, double diameter, double gravitation) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
this.diameter = diameter;
|
this.diameter = diameter;
|
||||||
this.gravitation = gravitation;
|
this.gravitation = gravitation;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public Planet() {
|
// public Planet() {
|
||||||
// this.name = "Zem";
|
// this.name = "Zem";
|
||||||
// this.weight = 5972200;
|
// this.weight = 5972200;
|
||||||
// this.diameter = 12756;
|
// this.diameter = 12756;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user