Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /**
- *The App for the Decagonal Prism program.
- * @author Kathleen Tumlin - Fundamentals of Computing I - 1210
- * @version 9/17/21
- */
- public class DecagonalPrismApp {
- //fields
- String label = "";
- double edge = 0;
- double height = 0;
- double edgeIn = 0;
- double heightIn = 0;
- // constuctor
- /** Shows public decagonal prism, setLabel, and setEdge.
- * @param labelIn takes input for label in the constructor.
- * @param edgeIn takes input for the edge in the constructor.
- */
- public DecagonalPrismApp(String labelIn, double edgeIn, double heightIn) {
- setLabel(labelIn);
- setEdge(edgeIn);
- setHeight(heightIn);
- }
- //methods
- /** Shows the return for label variable.
- * @return returns the label variable.
- */
- public String getLabel() {
- return label;
- }
- /** Shows the set label.
- * @param labelIn takes the labelIn for the method.
- * @return returns the boolean if the variable was set.
- */
- public boolean setLabel(String labelIn) {
- if (labelIn != null) {
- label = labelIn.trim();
- return true;
- } else {
- return false;
- }
- }
- /** Shows the return for the edge variable.
- * @return returns the value for the variable edge.
- */
- public double getEdge() {
- return edge;
- }
- /** Shows the set edge.
- * @param edgeIn takes the edgein and sets it as the edge variable.
- * @return returns the boolean if the variable was set.
- */
- public boolean setEdge(double edgeIn) {
- if (edgeIn > -1) {
- edge = edgeIn;
- return true;
- }
- else {
- System.out.println("Error: edge must be non-negative.");
- return false;
- }
- }
- /** Shows the return for the height variable.
- *@return returns the value for the variable edge.
- */
- public double getHeight() {
- return height;
- }
- /** Shows the set height.
- * @param heightIn takes the heightin and sets it as the height variable.
- * @return returns the boolean if the variable was set.
- */
- public boolean setHeight(double heightIn) {
- if (heightIn > -1) {
- height = heightIn;
- return true;
- }
- else {
- System.out.println("Error: height must be non-negative.");
- return false;
- }
- }
- public void start() {
- do {
- System.out.print("Error: height must be non-negative." );
- } while (heightIn > -1);
- do {
- System.out.print("Error: edge must be non-negative." );
- } while (edgeIn > -1);
- }
- public static void main(String[] args) {
- /**
- *Shows what prints.
- * @param args not used.
- */
- Scanner scan = new Scanner(System.in);
- System.out.println("Enter label, edge, and height length for a "
- + "decagonal prism.");
- System.out.print("\tlabel: ");
- String label = scan.nextLine();
- System.out.print("\tedge: ");
- double edge = scan.nextDouble();
- System.out.print("\theight: ");
- double height = scan.nextDouble();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement