Giter VIP home page Giter VIP logo

2223-s1's People

Contributors

danqiye1 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

2223-s1's Issues

Checkstyle to solve these issues?

Summary

Regarding audit issues as such, will checkstyle help solve the issue? If not, would I have to solve these manually?

Starting audit...
[WARN] /tmp/home/Arrive.java:4: 'CTOR_DEF' should be separated from previous statement. [EmptyLineSeparator]
[WARN] /tmp/home/Arrive.java:4:12: '(' is preceded with whitespace. [MethodParamPad]
[WARN] /tmp/home/Arrive.java:8: 'METHOD_DEF' should be separated from previous statement. [EmptyLineSeparator]
[WARN] /tmp/home/Arrive.java:8:50: WhitespaceAround: '{' is not preceded with whitespace. [WhitespaceAround]
[WARN] /tmp/home/Arrive.java:10:30: '(' is preceded with whitespace. [MethodParamPad]
[WARN] /tmp/home/Arrive.java:12:30: '(' is preceded with whitespace. [MethodParamPad]
[WARN] /tmp/home/Arrive.java:15: 'METHOD_DEF' should be separated from previous statement. [EmptyLineSeparator]
[WARN] /tmp/home/Arrive.java:15:29: WhitespaceAround: '{' is not preceded with whitespace. [WhitespaceAround]
[WARN] /tmp/home/Customer.java:5: 'CTOR_DEF' should be separated from previous statement. [EmptyLineSeparator]
[WARN] /tmp/home/Customer.java:5:14: '(' is preceded with whitespace. [MethodParamPad]
[WARN] /tmp/home/Customer.java:5:67: WhitespaceAround: '{' is not preceded with whitespace. [WhitespaceAround]
[WARN] /tmp/home/Customer.java:10: 'METHOD_DEF' should be separated from previous statement. [EmptyLineSeparator]
[WARN] /tmp/home/Customer.java:10: Line is longer than 100 characters (found 123). [LineLength]
[WARN] /tmp/home/Customer.java:10:28: WhitespaceAround: '{' is not preceded with whitespace. [WhitespaceAround]
[WARN] /tmp/home/Customer.java:13: 'METHOD_DEF' should be separated from previous statement. [EmptyLineSeparator]
[WARN] /tmp/home/Customer.java:16: 'METHOD_DEF' should be separated from previous statement. [EmptyLineSeparator]
[WARN] /tmp/home/Events.java:2:22: '(' is preceded with whitespace. [MethodParamPad]
[WARN] /tmp/home/Leave.java:4: 'CTOR_DEF' should be separated from previous statement. [EmptyLineSeparator]
[WARN] /tmp/home/Leave.java:4:11: '(' is preceded with whitespace. [MethodParamPad]
[WARN] /tmp/home/Leave.java:8: 'METHOD_DEF' should be separated from previous statement. [EmptyLineSeparator]
[WARN] /tmp/home/Leave.java:8:50: WhitespaceAround: '{' is not preceded with whitespace. [WhitespaceAround]
[WARN] /tmp/home/Leave.java:11: 'METHOD_DEF' should be separated from previous statement. [EmptyLineSeparator]
[WARN] /tmp/home/Leave.java:11:29: WhitespaceAround: '{' is not preceded with whitespace. [WhitespaceAround]
[WARN] /tmp/home/Main.java:3:11: WhitespaceAround: '{' is not preceded with whitespace. [WhitespaceAround]
[WARN] /tmp/home/Main.java:9:35: WhitespaceAround: '{' is not preceded with whitespace. [WhitespaceAround]
[WARN] /tmp/home/Main.java:12:39: '(' is preceded with whitespace. [MethodParamPad]
[WARN] /tmp/home/Main.java:13:42: '(' is preceded with whitespace. [MethodParamPad]
[WARN] /tmp/home/Main.java:16:32: '(' is preceded with whitespace. [MethodParamPad]
[WARN] /tmp/home/Main.java:17:34: WhitespaceAround: '{' is not preceded with whitespace. [WhitespaceAround]
[WARN] /tmp/home/Main.java:18:59: WhitespaceAround: '+' is not preceded with whitespace. [WhitespaceAround]
[WARN] /tmp/home/Main.java:18:60: WhitespaceAround: '+' is not followed by whitespace. Empty blocks may only be represented as {} when not part of a multi-block statement (4.1.3) [WhitespaceAround]
[WARN] /tmp/home/Serve.java:4: 'CTOR_DEF' should be separated from previous statement. [EmptyLineSeparator]
[WARN] /tmp/home/Serve.java:4:11: '(' is preceded with whitespace. [MethodParamPad]
[WARN] /tmp/home/Serve.java:8: 'METHOD_DEF' should be separated from previous statement. [EmptyLineSeparator]
[WARN] /tmp/home/Serve.java:8:50: WhitespaceAround: '{' is not preceded with whitespace. [WhitespaceAround]
[WARN] /tmp/home/Serve.java:11: 'METHOD_DEF' should be separated from previous statement. [EmptyLineSeparator]
[WARN] /tmp/home/Serve.java:11:29: WhitespaceAround: '{' is not preceded with whitespace. [WhitespaceAround]
[WARN] /tmp/home/Server.java:1:13: WhitespaceAround: '{' is not preceded with whitespace. [WhitespaceAround]
[WARN] /tmp/home/Server.java:5:12: '(' is preceded with whitespace. [MethodParamPad]
[WARN] /tmp/home/Server.java:10:36: WhitespaceAround: '{' is not preceded with whitespace. [WhitespaceAround]
[WARN] /tmp/home/Server.java:13: 'METHOD_DEF' should be separated from previous statement. [EmptyLineSeparator]
[WARN] /tmp/home/Server.java:14:27: '(' is preceded with whitespace. [MethodParamPad]
[WARN] /tmp/home/Server.java:16: 'METHOD_DEF' should be separated from previous statement. [EmptyLineSeparator]
Audit done.
Grading terminated.

[L01] Stringency of Access Modifiers

Are we expected to keep to using proper access modifiers (public/private) for all variables and methods in the .java files submitted?
How about the .jsh file?

Difference Between Labs & Exercises

Hi, what is the difference between the exercises uploaded on CodeCrunch and lab sessions? Do we submit the exercises during lab? (Sorry, don’t have much experience with computing modules!)

Anyone faced issue with restricted API being java.util.Objects

image

I have been facing this issue in both exercise 2 and 3, where it mentioned that restricted API objects is used. But after checking the API, I have confirmed that none of the methods in Objects is being used in my code.

Anyone faced a similar issue? Or have resolved it before?

Lab 02: CodeCrunch requires all class properties to be immutable including static ones

Summary

CodeCrunch requires final keyword for all class properties including static ones.

Description & Code Snippets

Since we should only have System.out.println() in our main class, so in part of my solution for main class:

public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String serverName = sc.nextLine();

    int customerIndex = 1;

    while (sc.hasNextDouble()) {
        double arrivalTime = sc.nextDouble();
        double serviceTime = sc.nextDouble();
        
        ServiceRequest serviceRequest = new ServiceRequest(arrivalTime, serviceTime);
        ArrivedEvent event = new ArrivedEvent(serverName, customerIndex, serviceRequest);
        
        System.out.println(event.toString());
        System.out.println(event.nextEvent().toString());

        customerIndex++;
    }

    sc.close();
}

However, in my Event class implementation, I have to make one property called serverNextAvailableTime accessible and modifiable to all class instances, so that they can know when the server is available and make decisions.

So in my old Event class:

class Event {

    ...
    protected static double serverNextAvailableTime = 0.0;
    ...
    
    // Constructor without updating serverNextAvailableTime. 
    Event(...) {
        ...
    }
    
    Event(..., double serverNextAvailableTime) {
        ...
        this.serverNextAvailableTime = serverNextAvailableTime;
    }
    
    private boolean serverIsAvailableToServeCustomer() {
        // It uses serverNextAvailableTime to make a judgement. 
        ...
    }
    
    public Event nextEvent() {
        // It gets updates serverNextAvailableTime. 
        ...
    }
    
    ...
    
}

But CodeCrunch strictly does not allow a variable to be declared as protected static. Instead, it must be declared as protected static final, but in this case I could not update serverNextAvailableTime. I also tried using ArrayList instead of double, but CodeCrunch does not allow such APIs.

Hence, are there any other side ways to make a property accessible and modifiable at class level? Or any suggestions about changing the Event class implementation? Thanks!

after submission

Hello! after submitting the lab, are we able to edit it for re submit?

Welcome to CS2030 Forum!

Welcome to CS2030 Forum using Github Issues!

[Guidelines adapted from CS2030 AY20/21 Semester 2 Forum Guidelines by Russell]

We will be using Github Issues for CS2030 Q&A instead of the LumiNUS Forum!

Please take note of the following etiquette. Let's make this a pleasant place for online interaction and peer learning!

  1. If you have a new question, create a new post instead of posting it as a reply on someone else's unrelated question.

  2. Think carefully about what you are posting and write a succinct summary (or post title) that describe the question. E.g., the title "Java" is too generic. "Unable to install Java?" is better. "Installing Java on Windows 10 gives the error 'permission denied'" is even better.

  3. Avoid posting questions that have been asked before (read through what others have posted before posting yourself) or have been answered in the notes and handouts (read through carefully what we released to the class)

  4. Github Issues supports powerful formatting. If your post or reply contains code, use proper formatting to make your post readable. Markdown is powerful in allowing you to write inline code (which is by adding triple backticks (```) before and after). For example:

    public void sayHello() {
        System.out.println("Hello World!");
    }
    

    Even better, you can give colors to the inline codes by adding the language after the first triple backticks. For example, doing

    ```java
    public void sayHello() {
        System.out.println("Hello World!");
    }
    ```
    

    will give you this.

    public void sayHello() {
        System.out.println("Hello World!");
    }

On that note, please post only short snippets of what your issues are about. Do not post entire solutions of labs, project, or PA to github as it will be seen as it will be seen as a breach of academic integrity.

  1. If you post about a problem you faced, please provide all the information (what you have done, what error message you faced) to help the readers of this forum help you. E.g., "My program cannot compile. Can you please help?" is not a meaningful post.

Hopefully, you have a wonderful time taking this module and learning Java!

Docker Launch Error

Summary

Docker encountered exception error upon being launched

Description

I have checked that my Windows laptop fulfills all the prerequisites of using Docker, such as turning on the Virtual setting at BIOS and OS versions. However, I noticed that it might be the problem of installing 'Linux kernel update package' (which Docker prompted me to install upon the first launch). My laptop does not show any successful installations of such distributions in PowerShell by using wsl --list command, even after I manually installed the update package through an exe. file. On another machine, once the update package was installed through the exe. file, Docker can run, and I can see the installed distributions on its PowerShell.

The full error code message

====
System.InvalidOperationException:
Failed to set version to docker-desktop: exit code: -1
stdout: The attempted operation is not supported for the type of object referenced.

stderr:
at Docker.ApiServices.WSL2.WslShortLivedCommandResult.LogAndThrowIfUnexpectedExitCode(String prefix, ILogger log, Int32 expectedExitCode) in C:\workspaces\main-merges\src[github.com](http://github.com/)\docker\pinata\win\src\Docker.ApiServices\WSL2\WslCommand.cs:line 160
at Docker.Engines.WSL2.WSL2Provisioning.d__8.MoveNext() in C:\workspaces\main-merges\src[github.com](http://github.com/)\docker\pinata\win\src\Docker.Engines\WSL2\WSL2Provisioning.cs:line 81
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Docker.Engines.WSL2.LinuxWSL2Engine.d__28.MoveNext() in C:\workspaces\main-merges\src[github.com](http://github.com/)\docker\pinata\win\src\Docker.Engines\WSL2\LinuxWSL2Engine.cs:line 177
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Docker.ApiServices.StateMachines.TaskExtensions.d__0.MoveNext() in C:\workspaces\main-merges\src[github.com](http://github.com/)\docker\pinata\win\src\Docker.ApiServices\StateMachines\TaskExtensions.cs:line 29
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Docker.ApiServices.StateMachines.StartTransition.d__5.MoveNext() in C:\workspaces\main-merges\src[github.com](http://github.com/)\docker\pinata\win\src\Docker.ApiServices\StateMachines\StartTransition.cs:line 67
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Docker.ApiServices.StateMachines.StartTransition.d__5.MoveNext() in C:\workspaces\main-merges\src[github.com](http://github.com/)\docker\pinata\win\src\Docker.ApiServices\StateMachines\StartTransition.cs:line 92
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Docker.ApiServices.StateMachines.EngineStateMachine.d__14.MoveNext() in C:\workspaces\main-merges\src[github.com](http://github.com/)\docker\pinata\win\src\Docker.ApiServices\StateMachines\EngineStateMachine.cs:line 69
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Docker.Engines.Engines.d__22.MoveNext() in C:\workspaces\main-merges\src[github.com](http://github.com/)\docker\pinata\win\src\Docker.Engines\Engines.cs:line 108

Screenshots (if any):

image

How to fix the NoSuchElementException

Summary

How can I fix the exception error problem?

Description:

This is the error I got. How can I remove it?

Exception in thread "main" java.util.NoSuchElementException

  | at java.base/java.util.Scanner.throwFor(Scanner.java:941)
  | at java.base/java.util.Scanner.next(Scanner.java:1598)
  | at java.base/java.util.Scanner.nextDouble(Scanner.java:2569)
  | at Main.main(Main.java:12)

Code Snippets

Attach code snippets (if any)

Screenshots

Screenshots (if any)

Exercise 2 Compilation Error

Does anyone know what this error message means?

BigCruise.java:7: error: variable cruiseLength might not have been initialized
    }
    ^
1 error

I definitely checked for the closing of brackets, and initialisation of the cruiseLength variable.. It also seems to run fine on my local machine

Is it necessary to set up Docker?

Hi prof, is it necessary for us to set up Docker for Labs? What's the benefit of setting up if we can just use code editor and run in cmd?

Self-Practice Recommendations

Hello all! I am looking to improve my programming skills/computational thinking specifically relevant to this module's topics. Given that my only computing experience is CS1010 from a year ago, and suppose that I am willing to dedicate 1-2 hours of extra time per week to self-practice in addition to the module exercises/labs, how best should I go about this?

I was thinking of following a practice problems book (as compact as possible 🤣), though I do not know where to find such a book, but I am open to any other recommended resources as well. Looking forward to any suggestions for resources and/or tips! Thank you!

how to use methods in the .jsh file!!

Summary

I am struggling while using the .jsh file. I successfully opened the main.jsh file but it does not allow me to use the methods inside. how should i use it?

Description:

Clarifications or details with respect to the issue you are facing

Code Snippets

Screenshot 2022-09-03 at 1 14 10 PM

Attach code snippets (if any)

Screenshots

Screenshots (if any)

[Self Exercise 1] Error with jshell while trying to call a class

Attempting self exercise, code compiles fine, but when trying to call the class via jshell, this happens:
image

Unsure what this error message means. Class has no other modifiers, x and y coordinates are set to private final. Have opened Point.java, Circle.java, and main.jsh already (using /open function).

how to fix the magic number error?

Summary

I got a magic number error and what to know how to fix it!!!

Description of the question / problem here.

Description:

Screenshot 2022-09-05 at 8 42 53 PM

Clarifications or details with respect to the issue you are facing

Code Snippets

Attach code snippets (if any)

Screenshots

Screenshots (if any)

Question pertaining to Level 5 of Task 1

Summary

Within the main.jsh file, it contains functions that directly call upon the Point and Circle classes' variables. Are we allowed to delete these functions?

Under Level 5 of the requirements, we were told to modify the method findMaxDiscCoverage, in this case, does the modification r meant ensure the conformity of the function to encapsulation and Tell-Don't-Ask principles?

Can we make queues (issue of mutability)

Hi there,

I'm trying to do Exercise 2, and I thought having a queue would be rather useful. Are we banned from doing so since queues are mutable?

Thanks in advance!

Specification of Rounding Behavior Exercise#2

What is the rounding behavior of the serveCruise() function we should model? As can be seen from the test cases the function rounds arrival time of 1359 to service time of 1400, what cases should this rounding take place? Should it also occur from 29 to 30, 14 to 15 etc.? and what if a loader becomes available at 1203, should it then serve at 1203 or not before 1215?
image

Nothing is specified about this behavior in the problem statement.

Thank you in advance.

Detected serve event not following specifications (lab 2)

i ran into this compilation error:
Detected serve event not following specifications.
Grading terminated.

have already ensured to upload all files, have getter functions and toString() methods for all classes already. Why am I still encountering such an error?

how to open a jsh file

Summary

Hello! I want to open my .jsh file but it does not work can I get help?

Description

Describe the problem and how one can replicate this problem

Screenshots (if any):

Insert Images here if necessary
Screenshot 2022-08-31 at 5 51 06 PM

SolidImpl mass method

hello, this was what the grader reflected:

photo_6102930107510403559_w

May I ask, what is line 41 for? Are we supposed to print Invoking mass method in SolidImpl using some toString() method? this wasn't a requirement stated in the problem description at all

WHat is wrong with this errrorrr

Screenshot 2022-09-04 at 1 05 46 PM

I got this error not even explaining me what is the problem. How can I fix this? I already referred to https://github.com/nus-cs2030/2122-s2/wiki/Java-Style-Guide My code equals with all the methods in that page

format of importing

to import methods like Math.atan, what is the preferred way of importing in cs2030? i understand there are many restrictions on style in this course and couldnt find this in the coding style guide.
should we import java.lang.Math and use Math.atan,
or import static,
or import the specific method only?

Lab03 output

Hi, does anybody know how do I prioritise customers who arrived first in my comparator?
Currently this is my output

Screenshot 2022-09-10 at 5 06 56 PM

vim to upload

hello! How can I make a vim file to .java, .c , .cpp, .h, .jsh, and .py files to upload into the codecrunch?

Exercise 1, failed test case

Hi there, I encountered the following issue on CodeCrunch as I was submitting Exercise 1. Does anyone know why this error is popping up? I assumed that the first line is supposed to be run from Jshell during the submission itself.

photo_2022-09-06_17-05-44

detected arrival event not following specifications

My code can generate the correct output and i fixed all the codestyle stuff too. Now there’s this error:

“Detected arrival event not following specifications.”

What could this mean?

my EventArrival class has print statements in a method and takes in customer and server classes as inputs.

CodeCrunch CheckStyle Indentation Issue

Hello there,
I have encountered a myriad of warnings from CodeCrunch's style checking,
two of the most frequently repeated ones are:

[WARN] /tmp/home/Circle.java:2: 'member def modifier' has incorrect indentation level 8, expected level should be 4. [Indentation]
[WARN] /tmp/home/Circle.java:2:1: Line contains a tab character. [FileTabCharacter]

I tried to configure the .vimrc file by using: "set shiftwidth=4" or "set shiftwidth=2" or "set autoindent" or "set shiftwidth=4" ...
but none of them work, the warnings either remained the same or became worse.

Has anybody else encountered similar situations?

Excercise 1 level 4 unable to understand the problem

We are now ready to construct a unit circle whose perimeter passes through two given points. By using the mid-point and angle of line pq, move the mid-point to the centre of the circle of radius r whose perimeter coincides with points p and q. You will need to work out the respective angle and distance values.

This is what is written in the problem. I do not get what does that mean: I do not get how the new circle is formed
Especially, what does the: circle of radius r whose perimeter coincides with points p and q

How can the perimeter same with the points? Does that mean the parimeter is same with the distance between the points p and q?

vim auto indentation problem

when writing a code in vim , the auto indentation does not happen. Also, when I put a bracket({), the closing bracket(}) does not automatically appear.
image

Exercise 03 "Error: cannot find symbol" in Test Case 6

Hello, I'm encountering this error, but I'm not sure how to interpret it. My understanding is that this means that my class constructors for SolidSphere and SolidCuboid do not exist but, I mean, that can't be the case.

Writing these lines in my own jshell seems to work just fine. I've tried uploading my files in order of inheritance too, in case there was some issue in that regard, but that didn't fix anything.

image

Any help would be greatly appreciated! Thanks :D

Convention of method declaration

From my understanding, the public declaration vs no declaration is meant for defining whether a method is accessible by other packages. Since we are not yet dealing with packages, would current convention be to have no declaration or to have a public declaration for the methods?

Get error I use getKey() and getValue method for Pair class object

I am trying to return a pair of event and customer and assign them to other variables. However, i get a cannot find symbol error for getKey() and getValue() method. How can I resolve that?

my code is as follow:
Pair<Event, Server> pair = new Pair<Event, Server>(new LeaveEvent(this.customer), server);
Event event = pair.getKey();
Server server = pair.getValue();

question of excercise 2 level 4

In excercise 2 level 4, the return type of the method is void. However, the output seems to return a string values. How Can I code it? What should be my return type?

exercise 3 what does delegation mean?

In level 6 of exercise 3, it says that 'Within SolidCuboid, delegate the computation of mass to a SolidImpl property in the class'. What does this mean?

Question pertaining to Lab submission

If we submit onto codecrunch, are we allowed to resubmit or are we limited to only 1 submission?

Will Codecrunch run our classes against test cases?

Do we need to submit the jsh file as well?

Exercise 3 floating point precision

Hi, does anyone know what is the reason for this discrepancy? my volume() method for solid sphere I used the formula (4.0 / 3.0) * Math.PI * Math.pow(radius, 3) in a single line then volume() * density for mass() method
Screenshot 2022-09-05 at 10 16 22 AM

Method not found issue

Summary

When I submit my code on CodeCrunch, I am getting a symbol not found error. I understand what the error means, but I am not getting this error on my own laptop, so I'm not sure why it is happening on code crunch. This method is a public method I defined myself within the PQ class to get the size of the priority queue.

Description:

Code Snippets

public int length() {
        return this.pq.size();
    }

Screenshots

Screenshot 2022-09-10 at 10 22 42 PM

excercise 2 level 2 someone help me!

I am stuck with this problem . I do not now how to design the toString() and nextLoader() method. shall I make a arraylist and print the loaders in order? Shall I just make the string value com out? how can I design it like that? Stuck with the algorithms Can someone give me a hint?

Exercise #3: off by 0.0000000000002

Hi there,

I kept getting this answer despite attempts to circumvent the floating point error. May I know if anyone has encountered the same issue?

Thanks in advance!

Screenshot 2022-09-04 at 3 28 35 PM

Clarification on Exercise 2 Level 5 Test Case

Hi would like to seek clarification on a test case output in Level 5 of the exercise!

Screenshot 2022-08-31 at 3 50 49 PM

Particularly for the 3rd line of output after running serveCruises(cruises, 3), I thought that after the BigCruise is loaded in 2 of the 3 loaders, the SmallCruise arriving at 1359 would be able to load in the final remaining loader at 1359 instead, so would like to clarify if the output serviceTime of 1400 is supposed to be an intentional output from the serveCruises function, or is there a misinterpretation on my part about how Loaders are supposed to work, thank you!

problem with the methods in .jsh file

Summary

I imported import java.util.ArrayList; to use the .get(int index)
but, when I compile, the error occurs. How should I solve this problem?

Description:

Clarifications or details with respect to the issue y
Screenshot 2022-09-03 at 12 13 08 PM
ou are facing

Code Snippets

Attach code snippets (if any)

Screenshots

Screenshots (if any)

lab2: Design specifications violated

Summary

Submitting current code on CodeCrunch returns

Design specifications violated.
Grading terminated.

Is it possible for me to get a copy of the code/binary that determines whether or not the files violate design specs, so I can get a more verbose output?

Description:

My code is split between a few files:

.
├── Event.java       Event interface
├── Arrive.java      Arrive class that implements Event
├── Leave.java       Leave class that implements Event
├── Serve.java       Serve class that implements Event
├── Customer.java
├── Server.java
└── Main.java

Some methods from Server take a Customer as a parameter, but none from Customer takes a Server as a parameter.

Code Snippets

N/A

Screenshots

Screen Shot 2022-09-02 at 23 07 09

Access value of private variable from another class

How do I access the value of a private variable from another class without using getter methods?
Using an example:
Customer.java has a variable, private final int customerNumber.
If we are not supposed to use a public getter method for customerNumber and Customer.customerNumber would not work because of the private access modifier, How do I access this variable from another class?

Previously, to bypass this, I created a customerNumber directly in the other class (Server.java) to count the customerNumber. But currently, what if 2 classes needs to access this customerNumber variable?
One solution I can think of is creating a customerNumber counter in each of the class, however this leads to duplicate codes.
Hence, it makes sense to put the customerNumber directly in the Customer.java file to reduce duplication. Thus, how would I be able to access this customerNumber variable?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.