Sale!

EECS 1022 Lab5 (OOP Part 1) Single Class, Attributes, Methods, JUnit Tests solved

Original price was: $35.00.Current price is: $35.00. $21.00

Category: You will receive a download link of the .ZIP file upon Payment

Description

5/5 - (1 vote)

1 Task 1: Complete Weekly Java Tutorial Videos
• For Lab5, you are assigned to study Week 6 Part A to Part D of the Java tutorial series:
https://www.youtube.com/playlist?list=PL5dxAmCmjv_70YmHrdPYD809c6OeIixvV [ Week 6 only ]
To reference tutorial videos from the previous weeks, see:
https://www.youtube.com/playlist?list=PL5dxAmCmjv_6wy2m0yq2wObIWPz4tAxW6 [ All Weeks ]
These Java tutorial videos assigned to you are meant for you to:
1. Obtain extra hands-on programming experience on Java, supplementing your weekly lectures.
2. Complete the lab assignment with the necessary skills and background.
Though we do not require the submission of the weekly Java tutorial project (like in Lab0), examples and
insights discussed in these tutorials will be covered in your (written and programming) tests
and exam: should you decide to skip the weekly tutorial videos, it would be your choice.
As you study through the example Java classes in the tutorial videos, you are advised to type them out
(but absolutely feel free to add new Java classes to experiment) on Eclipse.
• You can find the iPad notes of illustrations from the tutorial videos here:
https://www.eecs.yorku.ca/˜jackie/teaching/tutorials/notes/EECS1022%20Tutorial%20on%20Java.pdf
Important Notes to Read
• See this notes on how to infer classes and methods from given JUnit tests:
https://www.eecs.yorku.ca/˜jackie/teaching/lectures/2021/W/EECS1022/notes/EECS1022_W21_Inferring_
Classes_from_JUnit.pdf
• You can find here the example covered in the notes for practice:
– Starter: https://www.eecs.yorku.ca/˜jackie/teaching/lectures/2021/W/EECS1022/notes/EECS1022_
W21_Inferring_Classes_from_JUnit.zip
– Solution: https://www.eecs.yorku.ca/˜jackie/teaching/lectures/2021/W/EECS1022/notes/EECS1022_
W21_Inferring_Classes_from_JUnit_Solution.zip
Getting Prepared for Programming Test 3
• Your Programming Test 3 will cover classes and objects, and its format will be (virtually) identical to this
lab (and Lab6).
4
2 Task 2: Complete Programming Exercises
Starting Task 2 should mean that you have already completed the weekly Java tutorial videos (Section 1).
2.1 Step 1: Download and Import the Starter Project
1. Download the Eclipse Java project archive file from eClass: EECS1022 W21 Lab5.zip
2. Launch Eclipse and browse to EECS1022-W21-workspace as the Workspace then click on Launch, e.g.,
3. In Eclipse:
3.1 Choose File, then Import. 3.2 Under General, choose Existing Projects into Workspace.
3.3 Choose Select archive file. Make sure that the EECS1022 W21 Lab5 box is checked under Projects.
Then Finish.
5
2.2 Step 2: Programming Tasks
From the Package Explorer of Eclipse, your imported project has the following structure.
• The console apps package is empty. You may add new console application classes here to test the implemented methods if you wish. However, these added console application classes will not be graded.
• It is expected that the TestVendingMachine JUnit class contains compilation errors. This is because
that declarations and definitions of the required class(es) and method(s) it references are missing.
• The model package is empty. Class(es) and method(s) derived from the given JUnit class must be added to
this package. Class(es) added to a package other than model will not be graded.
Therefore, your tasks are:
1. Inferring from the given JUnit tests, add the missing class(es) and method(s) into the model package.
For example, if you add class Foo in the model package, make sure that you write a line in the beginning
of the TestVendingMachine class (after the line package junit tests;):
import model.Foo;
2. Pass all JUnit tests given to you (i.e., a green bar).
To run them, as shown in the Java tutorials on Week 1, right click on TestVendingMachine.java and
run it as JUnit tests. Of course, none of the given tests would pass to begin with.
You must not modify these given JUnit tests, as they suggest how the intended class(es) and
method(s) should be declared.
How to Deal with a Failed JUnit Test? From the JUnit panel from Eclipse, click on the failed test, then
double click on the first line underneath Failure Trace, then you can see the expected value versus the return
value from your implemented method.
6
2.3 The Vending Machine Problem
You are required to develop an object-oriented program solving a (simplified) vending machine (VM) problem:
• There are four products offerred (attend to the exact spellings):
– “Coke”
– “Orange Juice”
– “Kitkat Chunky Bar”
– “Lay’s Classic Chips”
In case you are a big fan of M & M’s chocolate bags: unfortunately,
the kind of VMs under consideration does not offer them!
• The VM’s LED screen displays the status of the VM:
– When first created, the status is “Empty VM Started”
– The status only changes when the add or dispense operation
(described below) is invoked.
• Given an VM instance, say vm, there are five operations supported:
– Check the status of the current VM: vm.checkStatus().
– Check the stock of the current VM: vm.checkStock().
Given a product name:
– Add units to its stock, e.g., vm.add(“Coke”, 5)
– Dispense units from its stock, e.g., vm.dispense(“Coke”, 2)
– Check its current stock, e.g., vm.checkStock(“Coke”)
• Input names to the add and dispense operations may be invalid,
in which case you need to return error messages accordingly.
• Input units to the add and dispense operations are always valid:
you need not worry about non-positive or too-large values.
2.4 Hints and Requirements
• See this notes on how to infer classes and methods from given JUnit tests:
https://www.eecs.yorku.ca/˜jackie/teaching/lectures/2021/W/EECS1022/notes/EECS1022_Inferring_
Classes_and_Methods_from_JUnit_Tests.pdf
Programming IDEs such as Eclipse are able to fix such compilation errors for you. However, you are advised to follow the guidance as specified in the notes to fix these compilation errors manually,
because: 1) it helps you better understand how the intended classes and methods work together; and 2) you may be tested in a written test or exam without the assistance of IDEs.
• Any new class(es) you add must reside in the model package.
– Once the necessary class(es) and method(s) are declared, you can add as many attributes as necessary
to implement the body of each method.
– Study carefully example usages of a VM instance as specified in TestVendingMachine.java: they suggest
the how the intended class(es) and method(s) should be declared and implemented.
– Focus on gradually passing one test at a time.
– You cannot use any Java library classes (e.g., ArrayList) or methods for implementation. That is,
there must not be any import statement in the class(es) you add to the model package.
7
2.5 Step 3: Exporting the Completed Project
You are required to submit a Java project archive file (.zip) consisting all subfolders.
In Eclipse:
1. Right click on project EECS1022 W21 Lab5. 2. Under General, choose Archive File.
Then click Export
3. Check the top-level EECS1022 W21 Lab5
Make sure that all subfolders are checked: .settings, bin, and src.
Under To archive file: browse to, e.g., desktop, and save it as EECS1022 W21 Lab5.zip (case-sensitive)
Then Finish.
Note. In case you have concerns about exporting and submitting the .setting subfolder: it will be kept
confidential and access-protected on eClass.
8
3 Submission
1. Before you submit, you must make sure that the Problems panel on your Eclipse shows no errors (warnings
are acceptable). In case you do not see the Problems panel: click on Window, then Show View, then Problems.
Submitting programs with errors (meaning that it cannot be run for grading) will result in
possible partial, but low, marks.
2. Section 2.5 asks you to export the Java project as an archive file:
EECS1022 W21 Lab5.zip
3. Go to the eClass site for Sections M,N,O: https://eclass.yorku.ca/eclass/course/view.php?id=6214
4. Under the Lab Submissions section, click on Lab5 to submit the Java archive file: EECS1022 W21 Lab5.zip
• You may upload as many draft versions as you like before the deadline.
• You must explicitly submit the draft version for grading before the deadline.
• Once you click on the submit button, you can no longer upload another draft version.
9
4 Amendments
Clarifications or corrections will be added to this section.

10