Codingassignmenthelper | Home Codingassignmenthelper | University

Q&A-SENG1110 / 6110 Programming Assignment 1

Semester 1

Assignment : ALCOLWORTHS Supermarkets - Q&A

Questions already addressed in the specification :

If the user wants to add a product p1 to depot d1, do I need to check other depots for the presence of p1?
Yes you do. The intent is that you don't end up with multiple products in different depots with inconsistent characteristics. Entering a product p1 into depot d1, where a product p2 exists in depot d2 and has the same name, should cause creation of a Product with the same price and weight as p2.

Can a user remove more than one item at a time? Will the product be removed if its quantity in the inventory is reduced to zero?
Only one item at a time. If the quantity after that is zero, then you should remove the product.

The spec mentions that depot names will be converted to lowercase after input, but the example shows the string getting converted to uppercase. So do we need to convert it to lowercase or uppercase?
The example says: "Lava lamp" will be interpreted just like "LAVA LAMP". As in, both "Lava lamp" and "LAVA LAMP" will be converted to lowercase, producing "lava lamp", and will be interpreted the same way.

Can we use arrays?
No, not for this assignment, but definitely next assignment.

Does all user interaction have to occur via the Interface class?
Yes. The spec says "This class will be the only one that takes input from and sends output to the user".

Do we need to use GUI for the assessment interface, or can it be all TIO?
If you are SENG1110 students, you can choose TIO or GUI.
If you are SENG6110, you need to implement GUI.


Questions incompletely addressed in the specification :

Can we have more than 3 classes? Will we lose marks if we do?
You should have only 3 classes.

What happens when a depot is removed? Does it just lose its name? Will its contained products be removed?
Removing a depot can be implemented by setting a Depot variable to null. There are alternatives, like setting a depot's name to an empty string, and having an empty name indicate non-existence. Removing a depot includes removing its products as well.

What should happen when a product's quantity reduces to 0? Should its name be removed? Should it be left with a quantity of 0?
It's up to you how you implement 'removing a product from a depot' in your code.
You could do this by setting the Product variable to null, setting the name to an empty string, setting the qty to 0, or otherwise.
In any case, the program needs to treat the removed product as such. For example, a removed product shouldn't be displayed when querying for products in a depot.

When a user is trying to add a product, and specifying which depot to add it to, my program doesn't query for the depot name, but presents a menu listing the depots, and asks the user to input a number. Will I get marked down for this?
Arguably, by entering a number, the user is still "specifying" the depot's name.
It deviates from the spec's intent, but it's close enough that you won't get marked down.

Will I get marked down if my code is working correctly, but there is an easier way to implement it?
It's difficult to give an answer without seeing the code. The marking schema does include things like "General class design/organisation" and "Code style".
Try and improve it if you can. However, in terms of marks, correctness is more important than code size. Simplifying the code may also help for the second assessment, as you'll be building on the first one.


Questions about the Java language :

How can I check whether a String matches another?
You can use the equals() method (eg: s1.equals(s2)).

How can I copy data from one object to another?
Some builtin classes support a clone() method, which can be used to create object copies.
For classes you're defining yourself, you can write your own method that copies over each data item.

What happens if we declare "Object x;" without assigning a "new Object()"? And what happens if we then do "x = obj1"?
If you declare an object variable without assigning anything to it, that variable will just hold the null value.
Assigning an object to that variable will cause it to no longer hold a null value.
If you try to call a method using a null value, this causes an exception (which will probably cause the program to terminate with an error message).

If a method returns an Object (eg: public Product method()), what does "return null" return? Does it return a Product object with empty instance variables, or does it not return anything?
It returns the 'null' value. This is a special value that basically means 'no object'.
All variables that refer to objects can hold the null value (eg: Product p = null). The null value is actually the default value for object variables. So, in 'Product p = new Product()', 'p' is initially 'null' and refers to no object and is then assigned an object newly created by Product's constructor.

Can Product object values exist with 0’s. Example Price, weight and quantity equals 0?
You must follow the spec. “Must be positive” means greater than 0. You can set one of these attributes to be 0 in a way inconsequential to the user. An example may be that you could decrement the product’s quantity, then check for equality with 0 to deduce whether to remove the product object.


Other Questions :

Would it be messy coding if I added a switch statement within a switch statement? More importantly, would it be functional and is there an easier way?
Code messiness is a bit subjective, so the answer depends.
Nested switch statements are valid and would be functional. You shouldn't need one for the assignment though. If you need to do something complex in a case of a switch statement, one option is to define a helper method and call it.

What is the point of the run() method in Interface?
The main method is static. As you may know, static methods can only call static methods, so, in order to use a non-static method to implement the interface, you need to declare an instance object that calls it, hence the run() method. An alternative would be to implement the interface in main, or in another static method (which you may do if you wish). However, using a non-static method is advantageous because it allows using multiple methods that share data (such as the depot1 and depot2 objects).

The lecture slides and the assignment specification give different due dates. Which is correct?
The dates in the course timetable in the lecture slides indicate the start of each week.

Can I post code to the discussion board?
If it is general code that does not give a direct solution to the assessment items, then it should be fine. Otherwise, you are not allowed, unless it is necessary to do so for learning purposes. So, a valid code to put up is possible lab solutions or lecture code which everyone is already exposed to. Do not post assessment code items, even if the assessment is completed, as some students may have not yet undertaken the assessment item. Think about integrity of assessment items when posting code.

To Download Click Here > Q&A-SENG1110/6110 Programming Assignment 1 - Semester 1.pdf
Codingassignmenthelper | Home Codingassignmenthelper | Home