Question

It is the year 2030, the MarsX Space Vehicles Company is in the process of designing...

It is the year 2030, the MarsX Space Vehicles Company is in the process of designing its X-2 single use Space
Transportation Systems (STS). You have been tasked with creating a class to model a single STS.
Design a class named STS (Space Transportation System) that contains:
1. A private int data field named STSId for the STS registration ID.
2. A private Date data field named dateCreated that stores the date when the STS was created.
3. A private double data field named emptyMass in pounds (default to 613,100) which represents the mass
of the STS before fueling.
4. A private double data field named fuelMass in pounds (default to 3,785,000) which represents the mass
of the fuel needed by the STS.
5. A private double data field named payloadMass in pounds (default to 0) which represents the mass of
the STS payload.
6. A private double data field named totalMass which represents the mass of the STS after it has been
assembled in the launchpad fully fueled (emptyMass + fuelMass + payloadMass).
7. A private String data field named manufacturer that stores the name of the company that built the STS
(default “MarsX”). Assume all STSs have the same manufacturer.
8. A private int data field flightTime in seconds (default to 0).
9. A no-arg constructor that creates a default STS and initializes the STSId with a 5 digit random integer
and the date when the STS was created.
10. A two-argument constructor that creates an STS with a specific initial fuel mass and payload mass
(constructor arguments) and also initializes the STSId with a 5 digit random integer and the date when
the STS was created.
11. The accessor (get) and mutator (set) methods for manufacturer, fuelMass and payloadMass
12. The accessor (no mutator) methods for flightTime, emptyMass, totalMass, STSId and dateCreated.
13. A method named increseFlightTime() that increases the flight time by 5 seconds. The STS burns
through 1% of its fuel for every second of flight (up to the original fuelMass).
14. A method named deployPayload() that deploys the payload in space (mass will be affected). The STS
takes 200 seconds to get to space. It cannot deploy its payload before that. Show error message if this
method is called before the STS gets to space.
*Provide appropriate input validation for these methods. Print a message to the console if the arguments passed
to the method do not pass the validation test(s).

Write a test program (class TestSTS) that creates an STS object and tests every method of the class. (use
console output).

solve in java please

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Screenshot

10 /** 2 * Test class For STS class 3 * @author deept 5 */ 6 public class TestSTS { public static void main(String[] args) {

Program

STS.java

import java.util.Date;
import java.util.Random;
/**
* Create a class Space Transportation System
* @author deept
*
*/
public class STS {
   //Attributes
   private int STSId;
   private Date dateCreated;
   private double emptyMass;
   private double fuelMass;
   private double payloadMass;
   private double totalMass;
   private String manufacturer;
   private int flightTime;
   //Default constructor initializes the STSId with a 5 digit random integer
   //and the date when the STS was created.
   public STS() {
       Random rand=new Random();
       STSId=10000 + rand.nextInt(90000);
       dateCreated=new Date();
       fuelMass=3785000;
       emptyMass=613100;
       payloadMass=0;
       totalMass=emptyMass + fuelMass + payloadMass;
       manufacturer="MarsX";
       flightTime=0;
   }
   //A two-argument constructor that creates an STS with a specific initial fuel mass and payload mass
   //(constructor arguments) and also initializes the STSId with a 5 digit random integer and the date when
   //the STS was created.
   public STS(double fuelMass,double payloadMass) {
       Random rand=new Random();
       STSId=10000 + rand.nextInt(90000);
       dateCreated=new Date();
       if(fuelMass<3785000) {
           this.fuelMass=3785000;
       }
       else {
           this.fuelMass=fuelMass;
       }
       emptyMass=613100;
       if(payloadMass<0) {
           this.payloadMass=0;
       }
       else {
           this.payloadMass=payloadMass;
       }
       totalMass=emptyMass + fuelMass + payloadMass;
       manufacturer="MarsX";
       flightTime=0;
   }
   //The accessor (get) and mutator (set) methods for manufacturer, fuelMass and payloadMass
   public double getFuelMass() {
       return fuelMass;
   }
   public void setFuelMass(double fuelMass) {
       this.fuelMass = fuelMass;
   }
   public double getPayloadMass() {
       return payloadMass;
   }
   public void setPayloadMass(double payloadMass) {
       this.payloadMass = payloadMass;
   }
   public String getManufacturer() {
       return manufacturer;
   }
   public void setManufacturer(String manufacturer) {
       this.manufacturer = manufacturer;
   }
   //The accessor (no mutator) methods for flightTime, emptyMass, totalMass, STSId and dateCreated.
   public int getSTSId() {
       return STSId;
   }
   public Date getDateCreated() {
       return dateCreated;
   }
   public double getEmptyMass() {
       return emptyMass;
   }
   public double getTotalMass() {
       return totalMass;
   }
   public int getFlightTime() {
       return flightTime;
   }
   //Method increases the flight time by 5 seconds.
   //The STS burns through 1% of its fuel for every second of flight (up to the original fuelMass).
   public void increseFlightTime() {
       if(fuelMass-(fuelMass*5*.01)>=0) {
           flightTime+=5;
           fuelMass-=(fuelMass*5*.01);
       }
       else {
           System.out.println("Error!!!Empty Fuel");
       }
   }
   //Method deploys the payload in space (mass will be affected).
   //The STS takes 200 seconds to get to space.
   //It cannot deploy its payload before that.
   //Show error message if this method is called before the STS gets to space.
   public void deployPayload() {
       if(flightTime<200) {
           System.out.println("Error!!!STS need 200seconds to reach space,Can't deploy!!!");
       }
       else {
           totalMass-=payloadMass;
           System.out.println("Deploy payload!! TotalMass = "+totalMass);
       }
   }
}

TestSTS.java

/**
* Test class For STS class
* @author deept
*
*/
public class TestSTS {

   public static void main(String[] args) {
       //Create a default object of STS class
       STS sts=new STS();
      
       //Check accessor methods
       System.out.println("Default constructor and accessor Test:-");
       System.out.println("Manufacturer: "+sts.getManufacturer());
       System.out.println("Date Created: "+sts.getDateCreated());
       System.out.println("STSId: "+sts.getSTSId());
       System.out.println("Emty Mass: "+sts.getEmptyMass());
       System.out.println("Fuel Mass: "+sts.getFuelMass());
       System.out.println("Payload Mass: "+sts.getPayloadMass());
       System.out.println("Total Mass: "+sts.getTotalMass());
       System.out.println("FlightTime: "+sts.getFlightTime()+" seconds");
      
       //Mutator test
       System.out.println("\nMutator Test :-");
       sts.setFuelMass(3885000);
       sts.setPayloadMass(32084);
       System.out.println("Payload Mass: "+sts.getPayloadMass());
       System.out.println("Fuel Mass: "+sts.getFuelMass());
       System.out.println("Total Mass: "+sts.getTotalMass());
      
       //Test for deploy
       System.out.println("\nDeploy Test1: ");
       sts.deployPayload();
      
       System.out.println("\nDeploy Test2: ");
       for(int i=0;i<200;i+=5) {
           sts.increseFlightTime();
       }
       sts.deployPayload();
   }

}


Output

Default constructor and accessor Test:-
Manufacturer: MarsX
Date Created: Wed Mar 18 06:43:52 IST 2020
STSId: 46911
Emty Mass: 613100.0
Fuel Mass: 3785000.0
Payload Mass: 0.0
Total Mass: 4398100.0
FlightTime: 0 seconds

Mutator Test :-
Payload Mass: 32084.0
Fuel Mass: 3885000.0
Total Mass: 4398100.0

Deploy Test1:
Error!!!STS need 200seconds to reach space,Can't deploy!!!

Deploy Test2:
Deploy payload!! TotalMass = 4366016.0

Add a comment
Know the answer?
Add Answer to:
It is the year 2030, the MarsX Space Vehicles Company is in the process of designing...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (The Account class) Design a class named Account that contains: A private int data field named...

    (The Account class) Design a class named Account that contains: A private int data field named id for the account (default 0). A private double data field named balance for the account (default 0). A private double data field named annualInterestRate that stores the current interest rate (default 0). Assume all accounts have the same interest rate. A private Date data field named dateCreated that stores the date when the account was created. A no-arg constructor that creates a default...

  • Design a class named BankAccount that contains: 1. A private int data field named accountId for...

    Design a class named BankAccount that contains: 1. A private int data field named accountId for the account. 2. A private double data field named accountBalance for the account (default 0). 3. A private double data field named annualInterestRate that stores the current interest rate (default 0). Assume all accounts have the same interest rate. 4. A private Date data field named dateCreated that stores the date when the account was created. 5. A private int data field named numberOfDeposits...

  • 9.7 (The Account class) Design a class named Account that contains: • A private int data...

    9.7 (The Account class) Design a class named Account that contains: • A private int data field named id for the account (default o). • A private double data field named balance for the account (default o). • A private double data field named annualInterestRate that stores the current interest rate (default o). Assume that all accounts have the same interest rate. • A private Date data field named dateCreated that stores the date when the account was created. •...

  • Language is JAVA. Clarification for the Shape class (highlighted): The following requirements specify what fields you...

    Language is JAVA. Clarification for the Shape class (highlighted): The following requirements specify what fields you are expected to implement in your Shape class; - A private String color that specifies the color of the shape - A private boolean filled that specifies whether the shape is filled - A private date (java.util.date) field dateCreated that specifies the date the shape was created Your Shape class will provide the following constructors; - A two-arg constructor that creates a shape with...

  • //include comments Opts (Regular polygon) An n-sided regular polygon has n sides of the same length...

    //include comments Opts (Regular polygon) An n-sided regular polygon has n sides of the same length and all angles have the same degree (i.e., the polygon is both equilateral and equiangular). Design a class named RegularPolygon that contains: Aprivate int data field named n that defines the number of sides in the polygon with default value 3. A private double data field named side that stores the length of the side with default value 1. A private double data field...

  • (Geometry: n-sided regular polygon) An n-sided regular polygon’s sides all have the same length and all...

    (Geometry: n-sided regular polygon) An n-sided regular polygon’s sides all have the same length and all of its angles have the same degree (i.e., the polygon is both equilateral and equiangular). Design a class named RegularPolygon that contains: ■ A private int data field named n that defines the number of sides in the polygon. ■ A private float data field named side that stores the length of the side. ■ A private float data field named x that defines...

  • Problem 2 9.9 Geometry: n-sided regular polygon pg. 362 (25 points) Follow instructions as provided on...

    Problem 2 9.9 Geometry: n-sided regular polygon pg. 362 (25 points) Follow instructions as provided on page 362, reprinted below 9.9 (Geometry: n-sided regular polygon) In an n-sided regular polygon, all sides have the same length and all angles have the same degree (i.e., the polygon is both equilateral and equiangular) Design a class named RegularPolygon that contains A private int data field named n that defines the number of sides in the polygon with default value of 3 A...

  • Need help creating a Java program with mandatory requirements! VERY IMPORTANT: The George account class instance...

    Need help creating a Java program with mandatory requirements! VERY IMPORTANT: The George account class instance must be in the main class, and the requirement of printing a list of transactions for only the ids used when the program runs(Detailed in the Additional simulation requirements) is extremely important! Thank you so very much! Instructions: This homework models after a banking situation with ATM machine. You are required to create three classes, Account, Transaction, and the main class (with the main...

  • 1. Please write the following program in Python 3. Also, please create a UML and write...

    1. Please write the following program in Python 3. Also, please create a UML and write the test program. Please show all outputs. (The Fan class) Design a class named Fan to represent a fan. The class contains: Three constants named SLOW, MEDIUM, and FAST with the values 1, 2, and 3 to denote the fan speed. A private int data field named speed that specifies the speed of the fan. A private bool data field named on that specifies...

  • New to python if you can add screenshort also, i am using python 3 7.3 (The...

    New to python if you can add screenshort also, i am using python 3 7.3 (The Account class) Design a class named Account that contains A private int data field named id for the account. A private float data field named annualInterestRate that stores the current A constructor that creates an account with the specified id (default 0), initial The accessor and mutator methods for id, balance, and annualInterestRate A private float data field named balance for the account. interest...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT