Codingassignmenthelper | Home Codingassignmenthelper | University

CSC72002 S3 2019 Assignment 1

Assignment 1:

Weight : 20% of your final mark

Specifications

Your task is to complete various exercises in NetBeans, 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.

Image1

Part 1 – Classes and objects

Create a new Java project called usernamePart1 in NetBeans. In my case the project would be called pdarcyPart1. Select the option to create a main method.

Create a new class called Publication. In the Publication class write the code for:

Instance variables that store the publication’s title, author, year published, and publisher A default constructor, and a second constructor that initialises all the instance variables Accessor (getters) and mutator (setters) methods for all instance variables A method called printDetails that prints the Publication details e.g. “The publication details are:” followed by all instance variables. The output must be formatted for readability

In the main method write the code to:

Create 2 publications, one using the default constructor, the other using the constructor that initialises all the instance variables for the publication. Demonstrate the use of one accessor method, and one mutator method for one of the publications you created. Print the publication’s details using the printDetails method for one of the publications you created.

Part 2 – Inheritance, collections and polymorphism

Create a new Java project called usernamePart2 in NetBeans. Select the option to create a main method.

Create a new class called Book. Create a second class called Publication. Copy the code from the Publication class you created in Part 1 into the new Publication class.

Modify the new Book class so that it extends Publication (Publication is the superclass, Book is the subclass).

In the Book class write the code for:

The instance variables that store the page count, and edition Accessor and mutator methods for the 2 instance variables A default constructor, and a second constructor that initialises all the instance variables in the Book and the Publication classes using the super keyword The Publication class has a method called printDetails that prints the Publication details. Override the printDetails method in the Book class and print all of the book’s details. The printDetails method in the Book class must use the super keyword to call the printDetails method in the Publication class. The Book class must also demonstrate the use of overloaded methods

In the main method write the code to :

Declare an ArrayList with a type parameter of Book Add at least 2 Books to the ArrayList Use an Iterator (java.util.Iterator) to loop through the books in the ArrayList and print out some of their details. Please note that use of any other kind of loop will not receive any marks. Check if the ArrayList contains a particular book Get a book from the ArrayList Remove a book from the ArrayList Print the size of the ArrayList Clear the ArrayList

Please note that collections are covered in Topic 3 and 4. You may need to wait until we have covered these topics to implement your ArrayList.

Polymorphism

In the class that contains the main method, create a second method that takes a Publication as a parameter and write the code to print out the publication’s publisher using one of the publication’s accessor methods. Then create an object of type Book and an object of type Publication in the main method and use the method you have just created to demonstrate polymorphism.

Part 3 – Abstract classes

Create a new Java project called usernamePart3 in NetBeans. Select the option to create a main method.

Create a new class called Book. Create a second new class called Publication. Rewrite your code from Part2 so that:

The Publication class is abstract Book extends Publication The Publication class contains at least one abstract method

All methods, constructors and instance variables that were in the Book and Publication classes in part 2 must be included in part 3. You need to rewrite the Book and Publication classes from part 2 so that Publication is abstract and there are multiple ways to create a Book.

Check your code works by creating a new Book in your main method.

Part 4 – Interfaces

Create a new Java project called usernamePart4 in NetBeans. Select the option to create a main method.

Create a new class called Book. Create a new interface called Publication. Rewrite your code from Part 2 so that:

Publication is an interface Book implements Publication The Publication interface contains at least one abstract methods

All methods, constructors and instance variables that were in the Book and Publication classes in part 2 must be included in part 4. You need to rewrite the Book and Publication classes from part 2 so that Publication is an interface and there are multiple ways to create a Book.

In the main method of your project write the code to:

Declare a Stack with a type parameter of Book Add at least 3 books to the Stack Demonstrate the use of: peek() pop() empty()

Part 5 – UML

Create a word document called usernamePart5. Draw 2 UML diagrams to show the inheritance relationship for the Publication and Book in part 3 and part 4. Make sure that each diagram has a heading and the header of the word document contains your name and student ID.

Submission

You should now have 4 NetBeans projects and 1 word document. You must zip the projects and the word document into one zip file called username_A1.zip. For example, mine would be pdarcy_A1.zip.Submit this file via the Assignment 1 link on MySCU Please leave enough time for it to upload, so do not submit at the last minute!


To Download Click Here > CSC72002 S3 2019 Assignment 1.pdf
Codingassignmenthelper | Home Codingassignmenthelper | Home