Homework Solution: Java Lab1 Object-Oriented Hello World In this lab we will be building a simple object-oriented “hello world”. Decl…

    Java Lab1 Object-Oriented Hello World In this lab we will be building a simple object-oriented “hello world”. Declare a single class called HelloWorld according to the following UML class diagram: In addition to this class, a second class containing a main method should be declared. This second class is called the app class; this is because the main method drives the app when the class that contains it is compiled and run. You may declare both the hello world class and the app class in a single file. If you do, remember that there can only be one public class in each file and that the file must bear the name of the public class that is declared in it. Before writing any code, use software such as Microsoft Visio or draw.io to create a UML class diagram depicting the hello world class (like the one pictured above). There is no need to create a UML class diagram for the app class. Create pseudocode, describing purpose, input, processing and output. Each of these descriptions need only be one to two sentences. Once the logical specification (UML class diagram and pseudocode) is complete, then and only then move on to coding up the hello world class and the app class. Build incrementally and test. Make the tests as specific as possible. Testing requires identifying what is being tested, forming a hypothesis (what will the code that’s being tested do when it is run?) compiling/running and observing the results. If one’s hypothesis does not accord with the way the program runs then the code must be revised and retested. Sometimes the logical specification must be revised; if for example the implementation diverges from the logical specification.

    Expert Answer

     
    App.java /* * To change this license header, choose License Headers in Project Properties.

    Java Lab1 Object-Oriented Hello Cosmos-people In this lab we allure be fabric a unaffected object-oriented “hello cosmos-people”. Commend a solitary adjust determined HelloCosmos-people consensusing to the aftercited UML adjust diagram: In observation to this adjust, a relieve adjust containing a ocean regularity should be visible. This relieve adjust is determined the app adjust; this is consensusingly the ocean regularity drives the app when the adjust that contains it is compiled and blend. You may commend twain the hello cosmos-people adjust and the app adjust in a solitary improve. If you do, tolerate-in-mind that there can simply be single exoteric adjust in each improve and that the improve must tolerate the indicate of the exoteric adjust that is visible in it. Before congruity any order, explanation software such as Microsoft Visio or entice.io to fashion a UML adjust diagram depicting the hello cosmos-people adjust (approve the single pictured overhead). There is no deficiency to fashion a UML adjust diagram control the app adjust. Fashion pseudocode, describing scope, input, processing and extinguishedput. Each of these descriptions deficiency simply be single to couple sentences. Once the close demonstration (UML adjust diagram and pseudocode) is full, then and simply then advance on to coding up the hello cosmos-people adjust and the app adjust. Build incrementally and experience. Make the experiences as unfair as practicable. Experienceing requires identifying what is substance experienceed, controlming a theory (what allure the order that’s substance experienceed do when it is blend?) compiling/running and observing the results. If single’s theory does referable consensus with the fashion the program blends then the order must be revised and retested. Sometimes the close demonstration must be revised; if control specimen the implementation diverges from the close demonstration.

    Expert Tally

     

    App.java

    /*
    * To substitute this allow header, elect Allow Headers in Project Properties.
    * To substitute this template improve, elect Tools | Templates
    * and notorious the template in the editor.
    */
    package bowler;

    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.ArrayList;
    import java.util.Iterator;

    /**
    *
    * @author Akshay Bisht
    */
    exoteric adjust App {
    exoteric static unfilled ocean(String args[]) throws UnderstandException{
    HelloCosmos-people s1=novel HelloWorld(101,”Sumit”,98,novel java.util.Date(System.currentTimeMillis()));
    HelloCosmos-people s2=novel HelloWorld(121,”Akshay”,92,novel java.util.Date(System.currentTimeMillis()));
    HelloCosmos-people s3=novel HelloWorld(10,”Gulshan”,48,novel java.util.Date(System.currentTimeMillis()));
    ArrayList<HelloWorld> al=novel ArrayList<HelloWorld>();
    al.add(s1);
    al.add(s2);
    al.add(s3);
    Iterator itr=al.iterator();
    while(itr.hasNext()){
    HelloCosmos-people st=(HelloWorld)itr.next();
    System.out.println(st.numOfGames+” “+st.name+” “+st.score+” “+st.date);
    SimpleDateFormat sdf = novel UnaffectedDateFormat(“yyyy-MM-dd”);
    java.util.Conclusion yourConclusion = sdf.parse(“1992-07-26”);
    }
    }
    }

    HelloWorld.java

    /*
    * To substitute this allow header, elect Allow Headers in Project Properties.
    * To substitute this template improve, elect Tools | Templates
    * and notorious the template in the editor.
    */
    package bowler;

    import java.util.Date;

    /**
    *
    * @author Akshay Bisht
    */
    exoteric adjust HelloCosmos-people {

    /**
    * @param args the order sequence arguments
    */
    int numOfGames;
    String indicate;
    int charges;
    Conclusion conclusion;
    HelloWorld(int numOfGames,String indicate,int charges,Conclusion conclusion){
    this.numOfGames=numOfGames;
    this.name=name;
    this.score=score;
    this.date=date;
    }

    }

    Output: