The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
The weather in Tampa Florida is warm most all year round. This does lead to the interesting scenario where some people have never seen snow. To help enlighten those individuals on the wonders of snow we have designed our very own Snow Factory. We as that you help make this a reality by implementing our designs
We require an Abstract class called SnowFlake. SnowFlake will require any class extending it to set the following variables:
• type • radius • diameter • meltModifier (0.05) • Random Number Generator (static) • snowFall (static)
The following methods are required: • getType() • getDiameter() • getRadius() • toString() The follwing method is abstract: • melt();
The list to the right contains the  common types of SnowFlakes. Create a class that extends the SnowFlake class for each of them. Source: http://www.snowcrystals.com/guide/snowtypes4.jpg Each snowflake should do the following:
1. Initialize the variables in the super class
1. The diameter should be of a random size of type double multiplied by a factor of randomly numbers from 8 to 10.
2. The radius is half the size of the diameter
3. The type is the one defined in the table
2. the melt method should reduce the size of the diameter by a factor of (the type plus the meltModifier). This can be accomplished by dividing the diameter by (the type plus the meltModifier) Now that we have the types of snow flakes defined we need to consider a Factory that will produce them. Forutunately, a skeleton has been provided. You will be required to make some changes to make the program work. We will focus on the recursive function:
createSnowBall.
1. createSnowBall
1. This method has three parameters 1. desiredSize 2. currentSize 3. ArrayList snowBall
2. This method will recurisively call the create snowball method untill the desired size is reached.
3. If the current size is not greater than the desired size 1. we will add a snowflake to the snowball using the createSnowFlake method 2. increase the current size to account for the new snowflake.
Snowball list:
1 Simple Prisms 2 Solid Columns 3 Sheaths 4 Scrolls On Plates 5 Triangular Forms 6 Hexagonal Plates 7 Hollow Columns 8 Cups 9 Columns on Plates 1012-branched Star 11 Stellar Plates 12 Bullet Rosettes 13 Capped Columns 14 Split Plates & Stars 15 Radiating Plates 16 Sectored Plates 17Isolated Bullets 18 Multiply Capped Columns 19 Skeletal Forms 20 Radiating Dendrites 21 Simple Star 22 Simple Needles 23 Capped Bullets 24 Twin Columns 25Irregulars 26 Stellar Dendrites 27 Needle Clusters 28 Double Plates 29 Arrowhead twins 30 Rimed 31 Fernlike Stellar Dendrites 32 Crossed needles 33 Hollow Plates 34 Crossed Plates 35 Graupe
The value associated with snowball is also melt rate
Skeleton of Driver
import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;
public class SnowBallFactory {
  static Random gen = new Random(System.currentTimeMillis());
 Â
  public static void main(String[] args) {
     ArrayList<SnowFlake> snowBall = new ArrayList<SnowFlake>();
     Scanner input = new Scanner(System.in);
     System.out.println("Snow Ball Factory up and running.");
    Â
     int balls = 3;
     for(int j = 0; j < balls; j++){
        System.out.print("nEnter desired size of snowball to be created:");
        double desiredSize = input.nextDouble();
       Â
        System.out.println("Created snow ball of size : " + desiredSize);
        createSnowBall(desiredSize, 0, snowBall);
        // Snow ball analysis
        System.out.println("There are " + snowBall.size() + " snowFlakes.");
        double size = 0.0;
        for (SnowFlake s : snowBall) {
           size += s.getDiameter();
        }
        System.out.println("Actual Size " + size);
        // How long to melt?
        int minutes = 0;
        while (!snowBall.isEmpty()) {
           for (SnowFlake s : snowBall) {
              s.melt();
           }
           for (int i = snowBall.size() - 1; i >= 0; i--) {
              if (snowBall.get(i).getDiameter() < 1.0) {
                 snowBall.remove(i);
              }
           }
           minutes++;
        }
        System.out.println("It took " + minutes + " minutes to melt the snowball.");
     }
     System.out.println("SnowFall : " + SnowFlake.snowFall);
     input.close();
    Â
  }
 Â
  public static void createSnowBall(double desiredSize, double currentSize, ArrayList<SnowFlake> snowball){
  //Add code here to recursively call createSnowBall. Â
  }
  private static SnowFlake createSnowFlake() {
     //Add code to match the types which you have chosen to implement.
     int type = gen.nextInt(2) +1;
     switch(type){
     case(1):return new SimpleStar();
     case(2):return new StellarDentrites();
     }
     return null;
    Â
  }
}
Â
import java.util.ArrayList;import java.util.Random;import java.util.Scanner;public class SnowBallFactory {static Random gen = new Random(System.currentTimeMillis());public static void main(String[] args) {ArrayList<SnowFlake> snowBall = new ArrayList<SnowFlake>();Scanner input = new Scanner(System.in);System.out.println("Snow Ball Factory up and running.");int balls = 3;for(int j = 0; j < balls; j++){System.out.print("\nEnter desired size of snowball to becreated:");double desiredSize = input.nextDouble();System.out.println("Created snow ball of size : " +desiredSize);createSnowBall(desiredSize, 0, snowBall);// Snow ball analysisSystem.out.println("There are " + snowBall.size() + "snowFlakes.");double size = 0.0;for (SnowFlake s : snowBall) {size += s.getDiameter();}System.out.println("Actual Size " + size);// How long to melt?int minutes = 0;while (!snowBall.isEmpty()) {for (SnowFlake s : snowBall) {s.melt();}for (int i = snowBall.size() - 1; i >= 0; i--) {if (snowBall.get(i).getDiameter() < 1.0) {snowBall.remove(i);}}minutes++;}System.out.println("It took " + minutes + " minutes to meltthe snowball.");}System.out.println("SnowFall : " + SnowFlake.snowFall);input.close();}public static void createSnowBall(double desiredSize, double currentSize,ArrayList<SnowFlake> snowball){//Add code here to recursively call createSnowBall.}private static SnowFlake createSnowFlake() {//Add code to match the types which you have chosen to implement.int type = gen.nextInt(2) +1;switch(type){case(1):return new SimpleStar();case(2):return new StellarDentrites();
Team Project 2Driver ClassSnowBallFactory.javaAbstract classSnowFlake.javaSnowFlake Types (8 to 35)TypeName.java (i.e. Sheaths.java)The weather in Tampa Florida is warm most all year round. This does lead to the interesting scenariowhere some people have never seen snow. To help enlighten those individuals on the wonders of snowwe have designed our very own Snow Factory. We as that you help make this a reality by implementingour designs.We require an Abstract class calledSnowFlake. SnowFlake will require any class extending it to set thefollowing variables:•type•radius•diameter•meltModifier (0.05)•Random Number Generator (static)•snowFall (static)The following methods are required:•getType()•getDiameter()•getRadius()•toString()The follwing method is abstract:•melt();The list to the right contains the common types of SnowFlakes.Create a class that extends the SnowFlake class for each of them.Source:http://www.snowcrystals.com/guide/snowtypes4.jpgEach snowflake should do the following:1.Initialize the variables in the super class1.The diameter should be of a random size of type doublemultiplied by a factor of randomly numbers from 8 to10.2.The radius is half the size of the diameter3.The type is the one defined in the table2.the melt method should reduce the size of the diameter by afactor of (the type plus the meltModifier). This can beaccomplished by dividing the diameter by (the type plus themeltModifier)Now that we have the types of snow flakes defined we need toconsider a Factory that will produce them. Forutunately, a skeletonhas been provided. You will be required to make some changes tomake the program work. We will focus on the recursive functionTypeDescription1 Simple Prisms2 Solid Columns3 Sheaths4 Scrolls On Plates5 Triangular Forms6 Hexagonal Plates7 Hollow Columns8 Cups9 Columns on Plates10 12-branched Star11 Stellar Plates12 Bullet Rosettes13 Capped Columns14 Split Plates & Stars15 Radiating Plates16 Sectored Plates17 Isolated Bullets18 Multiply Capped Columns19 Skeletal Forms20 Radiating Dendrites21 Simple Star22 Simple Needles23 Capped Bullets24 Twin Columns25 Irregulars26 Stellar Dendrites27 Needle Clusters28 Double Plates29 Arrowhead twins30 Rimed31 Fernlike Stellar Dendrites32 Crossed needles33 Hollow Plates34 Crossed Plates35 Graupel
Attachments: