Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment 1 Classes, objects, and interactions Submit a single ZIP file called assignment 1 . zip which must contain an IntelliJ project with your Java

Assignment 1
Classes, objects, and interactions
Submit a single ZIP file called assignment1.zip which must contain an IntelliJ project with your
Java files. You should create the zip by going to File Export Project to Zip File... in
the IntelliJ menu within your project. This assignment has 100 marks total - see the marking
scheme included on the assignment page.
Problem 1(Electronics Store Version 1)
Your goal for this problem is to create a simple implementation of an electronics store using the
concepts we have covered in the first two weeks of the course. You do not need to implement
proper encapsulation or apply any of the principles of OOP that are discussed starting in week
#3. It is advised that you complete the first two tutorials for the course before starting the
assignment.
You must implement the following five classes with the defined functionality:
Desktop Class: Must store the CPU speed (in Ghz as a double), amount of RAM (in GB as an
integer), amount of storage (in GB as an integer), and whether or not the storage is an SSD or
HDD (a Boolean, with true meaning SSD and false meaning HDD). The class must have a fourargument constructor that accepts an input parameter for each of these values in the same
order they are listed above (CPU, RAM, storage, SSD). The class must have a toString method
that returns a string indicating the object is a desktop PC along with the objects properties. Two
examples of what the toString method should return are included below:
Desktop PC with 3.5ghz CPU, 8GB RAM, 500GB HDD drive.
Desktop PC with 3.0ghz CPU, 16GB RAM, 250GB SSD drive.
Laptop Class: Must store the CPU speed (in Ghz as a double), amount of RAM (in GB as an
integer), amount of storage (in GB as an integer), whether or not the storage is an SSD or HDD
(a Boolean, with true meaning SSD and false meaning HDD), and the screen size (in inches as
an integer). The class must have a five-argument constructor that accepts an input parameter
for each of these values in the same order they are listed above (CPU, RAM, storage, SSD,
screen size). The class must have a toString method that returns a string indicating the object is
a laptop PC along with the objects properties. Two examples of what the toString method
should return are included below:
15" Laptop PC with 3.1ghz CPU, 32GB RAM, 500GB SSD drive.
13" Laptop PC with 2.5ghz CPU, 8GB RAM, 250GB HDD drive.
COMP 1406 B/C/D W24- A1 Due Friday, February 9th at 11:59 PM
2
Fridge Class: Must store the size of the fridge (in cubic feet, as a double), whether it includes a
freezer or not (a Boolean that is true if it has a freezer), and the color (as a String). The class
must have a three-argument constructor that accepts an input parameter for each of these
values in the same order they are listed above (size, freezer, color).The class must have a
toString method that returns a string indicating the object is a fridge along with the objects
properties. Two examples of what the toString method should return are below:
15.6 cubic foot Fridge with Freezer (Gray)
10.5 cubic foot Fridge (White)
ElectronicStore Class: Must have an instance variable called name to store the name of the
store. Must have a one-argument constructor that accepts a string to specify the store name.
The store must also contain instance variables to store nine items in total (3 Desktops, 3
Laptops, and 3 Fridges). The constructor for this class must create three instances of each
class to initialize these attributes. These objects can be stored in 9 separate variables or within
three separate arrays (i.e., one array for desktops, one for laptops, one for fridges). For now,
you should hard-code the argument values for the product constructors (i.e., CPU speed, RAM,
color, etc.). You can choose any sensible values for each. This class should also have a void
method called printStock() that will print each of the items in the stores stock to the console in
a readable format. Additionally, this class should have a searchStock(String) method. The
searchStock method should accept a string argument and return true if the toString() of any
product in the stores stock contains the given string argument (otherwise, the method should
return false). The searchStock method must be case insensitive. That is, searches for desk
and hdd should both return true if the store contains a Desktop PC with 3.5ghz CPU, 8GB
RAM, 500GB HDD drive.
ElectronicStoreTester Class: This class should have a single main method, which will first
instantiate an ElectronicStore and then call the printStock() method. The test class should then
repeatedly prompt the user to enter an item to search for. If the user enters the word quit, this
process should stop, and the program should end (note: if you are comparing two String objects
in Java to see if they are equal, you should use the .equals method). Otherwise, the
searchStock method of the El

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions

Question

7. What are the main provisions of the FMLA?

Answered: 1 week ago