Getting started In this assignment we will write the code that could form part of a management system for an electronic shop that sells computers, phones, tablets etc. To get started • Create a new...

Getting started In this assignment we will write the code that could form part of a management system for an electronic shop that sells computers, phones, tablets etc. To get started • Create a new Java project called username-assignment1 in IntelliJ using OpenJDK version 18 as the project SDK. In my case the project would be called ahendr10- assignment1. • In the src directory, create a new class called AssignmentOne. In the AssignmentOne class create the main method. Please note: • Your assignment will be marked using IntelliJ. If your project files for your assignment were created in another IDE or do not open in IntelliJ, then your assignment will not be marked. • Your assignment must compile using OpenJDK version 18 or it will not be marked. Module 1 - Advanced class design The following part of the assessment covers the content in Module 1 Part 1 – Creating abstract classes and interfaces 1. Create a new interface called ElectronicDevice with at least two generic methods that would be suitable for any electronic device. 2. Create an abstract class called Computer that implements the interface called ElectronicDevice. The idea behind the Computer abstract class is that it could be used as the super class for more specific classes of computer devices e.g. laptop, desktop etc. The Computer class should have the following at a minimum: • At least two instance variables • A default constructor • A second constructor that sets all the instance variables • At least one abstract method • At least one non-abstract method • Any other methods that you feel are necessary for the class to be usable in a program Part 2 – Using abstract classes and interfaces Create a class that called Laptop that extends the abstract class called Computer. The Laptop class should have the following at a minimum: 3 • At least two instance variables (one of these variables must be a boolean as a boolean instance variable is required in a later section of the assignment) • A default constructor • A second constructor that initialises all the instance variables (including the instance variables in the abstract Computer class) • A method that prints the Computers details e.g. “The computers details are: “ followed by all instance variables formatted for readability (including the instance variables in the abstract Computer class) • Any other methods that you feel are necessary for the class to be usable in a program In the main method: • Add the following comment - // Part 2 – Using abstract classes and interfaces • Create two Laptop objects, one using the default constructor and the second using the constructor that sets all of the instance variables • Call the printDetails method on the second object that was created using the constructor that sets all of the instance variables • Add the following code - System.out.println("------------------------------"); Part 3 – Polymorphism In the AssignmentOne class, write a method called DemonstratePolymorphism that takes a Computer or ElectronicDevice as a parameter. In the method write some code to do something with the parameter e.g. use its methods in some way. In the main method: • Add the following comment - // Part 3 – Polymorphism • Add a second comment that explains how you are going to use the method you just created to demonstrate your understanding of polymorphism • Write the code to create an object and use the method you just created to demonstrate your understanding of polymorphism • Add the following code - System.out.println("------------------------------"); NOTE: Do not remove the code in the main method for Part 2 (or any other part of the assignment). You can comment it out when you are developing however when you submit your assignment the main method must contain all of the code required for all parts of the assignment i.e. your marker should be able to run your main method and all parts of your assignment should run in one go. 4 Module 2 – Generics and lambdas The following part of the assessment covers the content in Module 2 Part 4 – Generic classes In the main method write the code to: • Add the following comment - // Part 4 – Generic classes • Declare an ArrayList with a type parameter of Laptop • Add at least 5 Laptop objects to the ArrayList • Add the following code - System.out.println("------------------------------"); NOTE: Do not remove the code in the main method for Part 2 or 3. Part 5 – Generic methods Implement the Comparable interface in the Laptop class. When you implement the compareTo() method from the Comparable interface you must use at least two instance variables in the comparison. Once you have implemented the Comparable interface, in the main method: • Add the following comment - // Part 5 - Generic methods • Write the code to sort the Arraylist that you created in Part 4. • Add the following code - System.out.println("------------------------------"); Part 6 – Wildcards In the AssignmentOne class, create a method called DemonstrateWildcards that takes an ArrayList generic parameter . In the method call one of the methods from Computer. In the main method: • Add the following comment - // Part 6 - Wildcards • Add a second comment that explains how you are going to use the method you just created to demonstrate your understanding of wildcards • Write the code to create an object and use the method you just created to demonstrate your understanding of wildcards • Add the following code - System.out.println("------------------------------"); 5 Part 7 – Simple lambda expressions In the AssignmentOne class, create a method called DemonstrateLambdas that takes an ArrayList of Laptops and a Predicate as a parameter. In the method test the Boolean instance variable from the Laptop class and print a suitable message based on whether it is true or false. in the main method: • Add the following comment - // Part 7 - Simple lambda expressions • Write the code to pass the Arraylist that you created in Part 4 to the DemonstrateLambdas method. • Add the following code - System.out.println("------------------------------"); Submission You should now have the following in your main method: // Part 2 – Using abstract classes and interfaces Code demonstrating part 2 System.out.println("------------------------------"); // Part 3 – Polymorphism Code demonstrating part 3 System.out.println("------------------------------"); // Part 4 – Generic classes Code demonstrating part 4 System.out.println("------------------------------"); // Part 5 - Generic methods Code demonstrating part 5 System.out.println("------------------------------"); // Part 6 – Wildcards Code demonstrating part 6 System.out.println("------------------------------"); // Part 7 - Simple lambda expressions 6 Code demonstrating part 7 Make sure that none of the code demonstrating each part in commented out. System.out.println("------------------------------");
Jul 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here