1 CSC81002 Assignment 1 Weight: 20% of your final mark Due: XXXXXXXXXXAugust XXXXXXXXXXpm (Hard Deadline) Specifications Your task is to complete various exercises in BlueJ, using the Java language,...

1 answer below »
Need asap


1 CSC81002 Assignment 1 Weight: 20% of your final mark Due: 14 August 2020 10 pm (Hard Deadline) Specifications Your task is to complete various exercises in BlueJ, using the Java language, and to submit these via the MySCU link created for this purpose. Marking criteria includes: • Use of correct coding style, including the use of comments; • Accuracy of coding; • Use of suitable coding structures; • Correct submission and naming conventions of assessment items as required. Getting Help This assignment is to be completed individually. It is the opportunity to gain an understanding of the concepts of object oriented programming and coding syntax. It is important that you master these concepts yourself. You are permitted to work from the examples in the study guide or textbook but you must acknowledge assistance from other textbooks or classmates. In particular, you must not use online material or help from others, as this would prevent you from mastering these concepts. Who can you get help from? Use this diagram to determine from whom you may seek help with your program. Encouraged Attribution Required Ask tutor Not acceptable Lecturer Tutors Online Forums Relatives Students outside unit Hired coders Classmates Private Tutors Other 2 Assignment Q1 To be completed in week 1 Create a word document and call your document username-A1Q1.docx. For example, mine would be nfrancis10-A1Q1.docx Open the house project from chapter 1 of the book projects. Open the terminal window and tick the record method calls. Create a picture with at least two (2) objects of circle, two (2) objects of square, two (2) objects of triangle, and two (2) objects of person, recording all method calls. Use the methods provided to divide the objects in the canvas into two groups, each group must only have one type of object. For example, a group must have a circle, a square, a triangle and a person. Take a screenshot of your picture/canvas and add it to the word document you created earlier. Now copy the list of method calls needed to create the picture to the word document after the screenshot. Add your name and student ID in the footer of the word document, as well as "CSC81002 Assignment 1 Q1". Assignment Q2 To be completed in week 2 Create a new BlueJ project called username-A1Q2. For example, mine would be nfrancis10- A1Q2. Click on New Class and give the class a name of Book. Make sure "Java" and "class" are selected. Write a description of your new Class in the top comments. Make sure you put in your name as the author and the date as the version you last worked on this exercise. Add 2 fields that are suitable for a book. One field should have a type of int, the other should have a type of String. Add a third double field called rating. A rating has a range between 0.0 to 5.0. 3 Write a constructor for your Book class that takes two (2) parameters - the first of type int, the second of type String. Set the initial values of the first 2 fields that you created using the parameters. Write accessor methods for all 3 of your fields. Write mutator methods for all 3 of your fields. Write a method called printDetails, which prints out all the details of a Book object. Please have a look at the ‘Printing’ section in the Topic 2 study guide to see how to do this. Consider the rating status, if the rating is bigger than 4.0, then the book is a top seller. The printDetails method should have an if-else statement that prints a line saying if the Book is a top seller or not. Assignment Q3 To be completed in week 3 Create a new BlueJ project called username-A1Q3. For example, mine would be nfrancis10- A1Q3. Create a class called Vehicle, that contains five fields, current speed, power, accelerate, decelerate and top speed, all of which type is int. Make sure you write a description of your new Class in the comments, with your name as author and date as the last date you worked on this exercise. Define a constructor that takes and sets the accelerate, decelerate; sets the power to 20, and top speed to 120. Leave the current speed as 0. Also define a constructor that takes no parameters. The power field should be set to the value of 30 in this constructor, top speed to 160, and accelerate and decelerate to reasonable amounts. Leave the current speed as 0. Define the mutators speed up and brake, whose effect is to increase or decrease the value of current speed by the (power + accelerate) and (power + decelerate) respectively. The mutator methods should not let the current speed to be set to a value higher than the top speed, or lower than zero. Add a mutator method that sets the value of the power. Add a check to make sure that the new power value is not set higher than 50 or lower than 10. Define an accessor method to return the value of current speed. 4 Test your work. Zip the project and include in your assessment files. Assignment Q4 To be completed in week 4 Create a new BlueJ project called your username-A1Q4. For example, mine would be nfrancis10-A1Q4. Before you start to code, make sure to enable the “record method calls” in the BlueJ terminal. Create a class called VeggieBasket, that has one ArrayList field called vegetables, which holds a collection of Strings. Make sure you write a description of your new Class in the comments, with your name as author and give the version as the date you last worked on this exercise. Define a constructor that initialises the ArrayList. Note that you can add any other initialisations that you feel are relevant. Create methods to add elements, remove elements and get the number of elements in the collection. Make sure you add tests for errors and sensible error messages. Create a method called printVeggies. This method should loop through the collection and print out the elements (each String on one line) as determined by the following rules; • If the vegetables has a total letter less than 6, instead of printing the vegetable name, it should print “Gollum”. • If the vegetable starting letter begin with a vowel, instead of printing the vegetable name, it should print “Frodo”. • If both conditions above are satisfied, it should print “Legolas”. • If none of the prior criteria are met, then the method should print “Gandalf”. Write a method countNames that prints each name that appeared with its total counts. (e.g. Gollum:2, Frodo:3, Legolas:1, Gandalf:4) Once you have finished your project, clear the terminal window in BlueJ and record the following. Add at least ten (10) Vegetables inside the ArrayList using the add method you wrote. You must have vegetables that satisfy all of the printVeggies conditions. Demonstrate removing an element using the remove method you wrote, and then find the number of elements using your method. Finally, run your printVeggies method. Copy all your calls into a text file (.txt) and save it in your BlueJ project folder. 5 Assignment Q5 To be completed in week 5 Create a new BlueJ project called your username-A1Q5. For example, mine would be nfrancis10-A1Q5. Inside the project you will need to create two classes, which is PartA and PartB. Part A: Imagine you need to open a standard three digit combination dial lock. Write a Java program in BlueJ with a method that prints all of the possible combinations. If the three digits combination have all the same number, replace it with “jackpot”. Assume the numbers on each dial range from zero to nine and three numbers in sequence are needed to open the lock. For example, the output would look like: 0-0-0 -> replace with “jackpot” 0-0-1 0-0-2 -> // lots more combinations 9-9-8 -> 9-9-9 -> replace with “jackpot” Part B: Suppose the lock isn't a very good one and any number that's no more than one away from the correct number in each digit will also work. Write another method that takes 3 parameters of type int that are the combination of the lock. The method will print out a minimal list of combinations you would need to try to guarantee opening the lock. For example, if the combination is 7-6-3 then 7-5-4, 6-6-2, 8-5-3 and other combinations will also open the lock. The first combination printed would be 6-5-2 and the last would be 8-7- 4. You will also need to make sure that no number in the combinations that are printed is less that zero and greater than nine as the numbers on each dial range from zero to nine. 6 Submission You should now have 4 BlueJ projects and 1 word document and a text file. You must zip the projects, the word document and the text file in into one zip file called usernameA1.zip. For example, mine would be nfrancis10A1.zip Submit this file via the Assignment 1 link on MySCU by the due date. Please leave enough time for it to upload, so do not submit at the last minute!
Answered Same DayAug 18, 2021CSC81002Southern Cross University

Answer To: 1 CSC81002 Assignment 1 Weight: 20% of your final mark Due: XXXXXXXXXXAugust XXXXXXXXXXpm (Hard...

Sayed Shad Ahmad answered on Aug 19 2021
145 Votes
gkhata10-A1Q1.docx
Circle circle1 = new Circle();
Circle circle2 = new Circle();
Square square1 = new Square();
Square square2 = new Square();
Triangle triangle1 = new Triangle();
Triangle triangle2 = new Triangle();
Person person1 = new Person();
Person person2 = new Person();
circle1.makeVisible();
square1.makeVisible();
triangle1.makeVisible();
person1.makeVisible();
circle1.moveHorizontal(150);
square1.moveDown();
square1.moveDown();
square1.moveDown();
square1.moveRight();
square1.moveRight();
square1.moveRight();
square1.moveRight();
triangle1.moveHorizontal(150);
triangle1.moveUp();
triangle1.moveLeft();
triangle1.moveUp();
person1.moveDown();
person1.moveRight();
person1.moveRight();
circle2.makeVisible();
square2.makeVisible();
triangle2.makeVisible();
person2.makeVisible();
circle2.moveHorizontal(-200);
square2.moveHorizontal(-250);
square2.moveDown();
square2.moveDown();
square2.moveDown();
square2.moveLeft();
triangle2.moveHorizontal(-100);
triangle2.m
oveUp();
triangle2.moveUp();
triangle2.moveRight();
person2.moveHorizontal(-150);
Gaurav Khatana - CSC81002 Assignment 1 Q1
Method Calls - A1Q4.txt
VeggieBasket VB = new VeggieBasket();
VB.addElement();
Enter the vegetable to add in basket: Brinjal
VB.addElement();
Enter the vegetable to add in basket: Tomato
VB.addElement();
Enter the vegetable to add in basket: Potato
VB.addElement();
Enter the vegetable to add in basket: Pea
VB.addElement();
Enter the vegetable to add in basket: Onion
VB.addElement();
Enter the vegetable to add in basket: Endive
VB.addElement();
Enter the vegetable to add in basket: Mushroom
VB.addElement();
Enter the vegetable to add in basket: Carrot
VB.addElement();
Enter the vegetable to add in basket: Cauliflower
VB.addElement();
Enter the vegetable to add in basket: Alfalfa
VB.removeElement();
Enter the vegetable to be removed from basket: Mushroom
Vegetable Mushroom was removed successfully.
VB.getCount();
Number of Vegetables in basket is 9
VB.printVeggies();
Gandalf
Gandalf
Gandalf
Gollum
Legolas
Frodo
Gandalf
Gandalf
Frodo
gkhata10-A1Q2/Book.class
public synchronized class Book {
private int pageCount;
private String title;
private double rating;
public void Book(int, String);
public int getPageCount();
public void setpage_count(int);
public String getTitle();
public void setTitle(String);
public double getRating();
public void setRating(double);
public void printDetails();
}
gkhata10-A1Q2/Book.ctxt
#BlueJ class context
comment0.target=Book
comment0.text=\r\n\ Class\ for\ storing\ information\ related\ to\ book.\r\n\ \r\n\ @author\ (Gaurav\ Khatana)\r\n\ @version\ (18-08-2020)\r\n
comment1.params=pageCount\ title
comment1.target=Book(int,\ java.lang.String)
comment1.text=\r\n\ Parameterized\ Constructor\ for\ objects\ of\ class\ Book\r\n
comment2.params=
comment2.target=int\ getPageCount()
comment2.text=\r\n\ Accessor\ Method\ to\ get\ the\ book\ page\ count\r\n
comment3.params=pageCount
comment3.target=void\ setpage_count(int)
comment3.text=\r\n\ Mutator\ Method\ to\ set\ the\ book\ page\ count\r\n
comment4.params=
comment4.target=java.lang.String\ getTitle()
comment4.text=\r\n\ Accessor\ Method\ to\ get\ the\ book\ title\r\n
comment5.params=title
comment5.target=void\ setTitle(java.lang.String)
comment5.text=\r\n\ Mutator\ Method\ to\ set\ the\ book\ title\r\n
comment6.params=
comment6.target=double\ getRating()
comment6.text=\r\n\ Accessor\ Method\ to\ get\ the\ book\ rating\r\n
comment7.params=rating
comment7.target=void\ setRating(double)
comment7.text=\r\n\ Mutator\ Method\ to\ set\ the\ book\ rating\r\n
comment8.params=
comment8.target=void\ printDetails()
comment8.text=\r\n\ Method\ printDetails()\ to\ print\ the\ details\ of\ the\ book\r\n
numComments=9
gkhata10-A1Q2/Book.java
gkhata10-A1Q2/Book.java
/**
 * Class for storing information related to book.
 * 
 * @author (Gaurav Khatana)
 * @version (18-08-2020)
 */
public class Book 
{
    // instance variables to store book properties like page count, title & rating
    private int pageCount;
    private String title;
    private double rating;
    /**
     * Parameterized Constructor for objects of class Book
     */
    public Book(int pageCount, String title) 
    {
        // initialising the instance variables
        this.pageCount = pageCount;
        this.title = title;
    }

    /**
     * Accessor Method to get the book page count
     */
    public int getPageCount() 
    {
        return pageCount;
    }

    /**
     * Mutator Method to set the book page count
     */
    public void setpage_count(int pageCount) 
    {
        this.pageCount = pageCount;
    }

    /**
     * Accessor Method to get the book title
     */
    public String getTitle() 
    {
        return title;
    }
    /**
     * Mutator Method to set the book title
     */
    public void setTitle(String title) 
    {
        this.title = title;
    }
    /**
     * Accessor Method to get the book rating
     */
    public double getRating() 
    {
        return rating;
    }
    /**
     * Mutator Method to set the book rating
     */
    public void setRating(double rating) 
    {
        this.rating = rating;
    }
    /**
     * Method printDetails() to print the details of the book
     */
    public void printDetails() 
    { 
        // Displaying the book title, page count & rating
        System.out.println("Book Title: " + title);
        System.out.println("Book Page Count: " + pageCount);
        System.out.println("Book Rating: " + rating);

        //Checking whether rating is greater than 4.0 or not
        if (rating > 4.0) 
            //Displaying message that the book is a top seller as it's rating was greater than 4.0
            System.out.println("Book is a top seller");
        else
            //Displaying the message that the book is not a top seller 
            System.out.println("Book is not a top seller");
    }
}
gkhata10-A1Q2/package.bluej
#BlueJ package file
editor.fx.0.height=737
editor.fx.0.width=814
editor.fx.0.x=360
editor.fx.0.y=28
objectbench.height=153
objectbench.width=1512
package.divider.horizontal=0.6
package.divider.vertical=0.7832792207792207
package.editor.height=572
package.editor.width=1424
package.editor.x=0
package.editor.y=0
package.frame.height=838
package.frame.width=1550
package.numDependencies=0
package.numTargets=1
package.showExtends=true
package.showUses=true
project.charset=UTF-8
readme.height=58
readme.name=@README
readme.width=47
readme.x=10
readme.y=10
target1.height=50
target1.name=Book
target1.showInterface=false
target1.type=ClassTarget
target1.width=80
target1.x=70
target1.y=10
gkhata10-A1Q2/README.TXT
------------------------------------------------------------------------
This is the project README file. Here, you should describe your project.
Tell the reader (someone who does not know anything about this project)
all he/she needs to know. The comments should usually include at least:
------------------------------------------------------------------------
PROJECT TITLE:
PURPOSE OF PROJECT:
VERSION or DATE:
HOW TO START THIS PROJECT:
AUTHORS:
USER INSTRUCTIONS:
gkhata10-A1Q3/Method Call - A1Q3.txt
Vehicle V1 = new Vehicle();
Vehicle V2 = new Vehicle(15, 25);
V1.getCurrent_Speed()
returned int 0
V2.getCurrent_Speed()
returned int 0
V1.speedUp();
V2.speedUp();
V1.getCurrent_Speed()
returned int 40
V2.getCurrent_Speed()
returned int 35
V1.setPower(5);
Power value should be between 10 and 50
V1.setPower(25);
V2.setPower(60);
Power value should be between 10 and 50
V2.setPower(50);
V1.speedUp();
V2.speedUp();
V1.getCurrent_Speed()
returned int 75
V2.getCurrent_Speed()
returned int 100
V1.speedUp();
V2.speedUp();
Speeding up will exceed the top_speed.
V1.getCurrent_Speed()
returned int 110
V2.getCurrent_Speed()
returned int 100
V1.speedUp();
V2.brake();
V1.getCurrent_Speed()
returned int 145
V2.getCurrent_Speed()
returned int 35
V1.speedUp();
Speeding up will exceed the top_speed.
V2.brake();
Brakes will make current speed below zero.
V1.getCurrent_Speed()
returned int 145
V2.getCurrent_Speed()
returned int 35
V1.brake();
V1.brake();
V1.brake();
V1.brake();
V1.brake();
Brakes will make current speed below zero.
gkhata10-A1Q3/package.bluej
#BlueJ package file
editor.fx.0.height=737
editor.fx.0.width=814
editor.fx.0.x=360
editor.fx.0.y=28
objectbench.height=122
objectbench.width=1512
package.divider.horizontal=0.6
package.divider.vertical=0.8252164502164502
package.editor.height=604
package.editor.width=1424
package.editor.x=0
package.editor.y=0
package.frame.height=838
package.frame.width=1550
package.numDependencies=0
package.numTargets=1
package.showExtends=true
package.showUses=true
project.charset=UTF-8
readme.height=58
readme.name=@README
readme.width=47
readme.x=10
readme.y=10
target1.height=50
target1.name=Vehicle
target1.showInterface=false
target1.type=ClassTarget
target1.width=80
target1.x=70
target1.y=10
gkhata10-A1Q3/README.TXT
------------------------------------------------------------------------
This is the project README file. Here, you should describe your project.
Tell the reader (someone who does not know anything about this project)
all he/she needs to know. The comments should usually include at least:
------------------------------------------------------------------------
PROJECT TITLE:
PURPOSE OF PROJECT:
VERSION or DATE:
HOW TO START THIS PROJECT:
AUTHORS:
USER INSTRUCTIONS:
gkhata10-A1Q3/Vehicle.class
public synchronized class Vehicle {
private int current_speed;
private int power;
private int accelerate;
private int decelerate;
private int top_speed;
public void Vehicle(int, int);
public void Vehicle();
public void speedUp();
public void brake();
public...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here