Reference no: EM132460746
CSC72003 - Programming Assignment - Java BlueJ, Southern Cross University, Australia
Your task is to complete various exercises in BlueJ, using the Java language.
Assignment Questions -
Question 1 - [From Topic 1]
Open the house project from Topic 1. Open the terminal window and record method calls.
Create a picture with at least 6 objects, recording all method calls.
Take a screenshot of your picture and add the pasted list of method calls needed to create the picture.
Your work should be in a Word document, with your name and student ID in the footer, as well as "CSC72003 Ass 1 Q1". Call your document by your username_Q1.docx. Save this document in a folder called username_A1. For example, my folder would be called rmason10_A1.
Question 2 - [From Topic 2]
Create a new BlueJ project called your username-A1Q2. For example, mine would be rmason10-A1Q2.
Click on New Class and give the class a name of Person. 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 give the version as the date you last worked on this exercise.
Add definitions for the following fields:
- a name field of type String
- an age field of type int
- an eyeColour field of type String
- a boolean field called canDrive
Write a constructor for your Person class that takes two parameters - the first of type String called myName, and the second of type int called myAge. Set the initial values of the Person class's fields, using the constructor.
Write an accessor method called getName() that returns the value of the name field.
Write a mutator method called setAge() that takes a single parameter of type int and sets the value of the age field.
Work out what other accessor and mutator methods would be useful for this class and add them.
Write a method called printDetails, which prints out all the details of a Person object. For example: if the name field holds the value "Helen" then the printDetails would print (in part):
The name of this person is Helen.
Take into account the canDrive status. The printDetails() method should print a line saying either that the person can drive, or the person cannot drive.
Question 3 - [From workshop Topic 3]
Create a new BlueJ project called your username-A1Q3. For example, mine would be rmason10-A1Q3.
Create a class, Heater, that contains four fields, temperature, increment, max and min, all of whose type is double.
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 min, max and sets the temperature to 20.0, and increment to 1.0.
Also define a constructor that takes no parameters. The temperature field should be set to the value of 20.0 in this constructor, increment to 1.0, and maximum and minimum to reasonable amounts.
Define the mutators warmer and cooler, whose effect is to increase or decrease the value of temperature by the increment respectively.
The mutator methods should not let the temperature be set to a value higher than max, or lower than min. Add a mutator method that sets the value of the increment. Make sure you add a check to make sure that unrealistic values are not passed to this mutator method.
Define an accessor method to return the value of temperature.
Question 4 - [From workshop Topic 4]
Create a new BlueJ project called your username-A1Q4. For example, mine would be rmason10-A1Q4. Create a class, FBNames, which has one ArrayList field called names, 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 date as the last date you 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 printFizzBuzz(). This method should loop through the collection, and print out the elements (each String on one line).
If the String starts with a, e, i, o or u, instead of printing the String, it should print "Fizz" on the line. If the String starts with A, E, I, O or U, instead of printing the String, it should print "Buzz".
For example, if the collection contained the names "banana", "Apple", "orange", "pear", "peach", "kiwi fruit", "Grape", then the printout would look like:
banana
Buzz
Fizz
pear
peach
kiwi fruit
Grape
Once you have finished your project, open the terminal window in BlueJ and turn on record method calls. Create a new FBNames class, and then add at least 11 Strings. Make sure you don't use the same collection as my example.
Demonstrate removing an element, and then find the number of elements using your methods. Finally, run your FizzBuzz method. Copy all your calls into a text file and save it in your project folder.
Question 5 - [From workshop Topic 5]
Part A: Imagine you need to open a standard combination dial lock but don't know the combination and don't have a pair of bolt cutters. Write a Java program in BlueJ with a method that prints all possible combinations, so you can print them on a piece of paper and check off each one as you try it. Assume the numbers on each dial range from zero to thirty-six and three numbers in sequence are needed to open the lock.
Part B: Suppose the lock isn't a very good one and any number that's no more than two away from the correct number in each digit will also work. In other words if the combination is 17-6-32, then 18-5-31, 19-4-32, 15-8-33 and many other combinations will also open the lock. Write another method that prints out a minimal list of combinations you would need to try to guarantee opening the lock.
Attachment:- Java BlueJ Programming Assignment File.rar