Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.98 KB | None | 0 0
  1. import jeliot.io.*;
  2. import java.awt.Color;
  3.  
  4. public final class Shoes {
  5. //Attributes
  6.     private final Color color; // Colors: Red, Blue, White, Black, Green, Orange, Yellow
  7.     private final ShoeType type; // Types: Slippers , Heels, Sandals, Snickers, Boots, Sports    
  8.     private final int size; // Sizes: 20 - 50
  9. //CTORS
  10.     public Shoes() {
  11.         this (Color.WHITE, ShoeType.SPORTS, 20); // The this refers to the third CTOR - Its called constructor chaining
  12.     }
  13.     public Shoes(Shoes other) {
  14.         this(other.getColor(), other.getType(), other.getSize()); // The this refers to the third CTOR - Its called constructor chaining
  15.     }
  16.     public Shoes(Color color, ShoeType type, int size) {
  17.         this.color = color;
  18.         this.type = type;
  19.         this.size = size;
  20.     }
  21.  
  22.  
  23. /*        System.out.println("Choose one of the colors: Red/White/Black/Pink");
  24.         if ((color.equalsIgnoreCase("Red")) || (color.equalsIgnoreCase("Blue")) ||
  25.             (color.equalsIgnoreCase("White")) || (color.equalsIgnoreCase("Black")) ||
  26.              (color.equalsIgnoreCase("Green")) || (color.equalsIgnoreCase("Orange")) ||
  27.              (color.equalsIgnoreCase("Yellow"))) {}
  28.         if ((type.equalsIgnoreCase("Slippers")) || (type.equalsIgnoreCase("Heels")) ||
  29.             (type.equalsIgnoreCase("Sandals")) || (type.equalsIgnoreCase("Snickers")) ||
  30.              (type.equalsIgnoreCase("Boots")) || (type.equalsIgnoreCase("Sports"))) {}
  31. */
  32. //Getters
  33.     public Color getColor() {
  34.         return color;
  35.     }
  36.     public ShoeType getType() {
  37.         return type;
  38.     }
  39.     public int getSize() {
  40.         return size;
  41.     }
  42. }
  43. public enum ShoeType {
  44.     SLIPPERS,
  45.     HEELS,
  46.     SANDALS,
  47.     SNICKERS,
  48.     BOOTS,
  49.     SPORTS
  50.     }
  51. public class Start {
  52.     public static void main() {
  53.          Color shoeColor = Input.next();
  54.          Enum shoeType = Input.next();
  55.          int shoeSize = Input.nextInt();
  56.         Shoes s1 = new Shoes(shoeColor, shoeType, shoeSize);
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement