GithubHelp home page GithubHelp logo

2122-s2's Introduction

NUS CS2030 AY2021/22 Semester 2

Java Vim

Welcome to the home repository for CS2030! 😃

To find out more about how to contribute, click here!

2122-s2's People

Contributors

danqiye1 avatar russelldash332 avatar

Watchers

 avatar  avatar

2122-s2's Issues

Submitting incrementally

In the announcement, it stated to submit our work incrementally. Does it mean we submit the work after every level?

Issues: Launching WSL

Summary

Unable to launch WSL.

Description

Can I just open the Ubuntu app, not using the win+R?

Screenshots:

image

ArrayList vs List

Description

In line 16
ImList newList = new ImList(this.elems)

But the constructor takes in a list

ImList(List<T> list) { 
  this.elems = new ArrayList<T> (list); 
}

Why is this not a problem?

Topic:

Screenshots

image

Cant install Ubuntu

Summary

Idk why cannot install.

Description

Hello idk what to do.

Screenshots (if any):

Insert Images here if necessar
2022-01-12
y

Question on methods executed for different class types

For Level 6, assuming loaders is a list of Loaders and RecycledLoaders, I used the below for loop:

for (Loader loader : loaders)

However, when I reach a loader that happens to be a RecycledLoader, the methods executed are taken from the Loader class instead of the RecycledLoader class. Is anybody able to explain why this happens as I thought it was covered during Lecture that writing "Loader" before it only checks whether the methods exist when compiling, and that the actual method run will be from the RecycledLoader class? Thank you!

.jsh scripts and debugging

Writing in these scripts means it is much harder for me to check and debug.
I can only /open the script in jshell and trust that it works which isn't very ideal.
Is there a way to "compile" them using a compiler?

Java 11 Installation

Summary

I happened to have java 17 installed on my MacBook and when I open it in terminal after following the setting up instructions it shows version 17.0.1. Is it ok? Do I need to uninstall java 17 and install java 11 instead? I tried to uninstall java 17 but I failed to do it.

Description

Screenshots (if any):

Screenshot 2022-01-11 at 1 51 45 PM

Vim installation issue on Windows

Summary

I use Windows 10 to set up Ubuntu and Java. During the set up of Vim, I followed the guide closely, but encountered a series of issues.

Description

(1) The guide said that Windows users can set up Vim in your Ubuntu environment, OR install it locally. However, no guide is provided about “how to set up Vim in your Ubuntu environment”. Furthermore, I am also deeply confused about how both choices will this affect our usage of Vim. How should I use Vim if I install it locally, and how if in Ubuntu environment?

(2) Since I cannot find the guide to set up Vim in Ubuntu environment, I proceeded to download it locally. However, it shows “vim is not recognised as an internal or external command” when I type "vim -version" in the Command Prompt. I saw in GitHub that I should add vim to PATH, but how should I add it, and what should I type?

(3) I saw at the start of Vim local installation guide that we are supposed to get the .vimrc file. But when I clicked the link, it is a GitHub page. Searching online, I tried to click “raw” then right click on the webpage shown to download the file. However, the saved file become a txt, and no longer .vimrc file. May I know how this can be resolved?

(4) The wiki page about "set up checkstyle" gives the instruction that after downloading 2 files, we should "Make sure you place these 2 files in the same directory as your java files". But where should we place the java files? Do we need to copy and paste these 2 files every time we copy our java files to a new place?

When to implement abstract class?

I have submitted my solution for lab 4 which included a service class that was a parent class for the various cab services provided. The service class did not have any constructors and upon submission did I then realize that actually I could have submitted an abstract class instead, which in this case would have seemed to be more appropriate. I was just wondering if there are any particular conditions for us to look out for as to when to implement an abstract class?

How to open all .java files in jshell?

Does anyone know how to /open all files in jshell? I know that to open multiple files we can do /open file1.java file2.java and so on but how do we open all the files, probably something like /open *.java

Warning: uncheked method invocation

Summary

I am able to clear all the test cases/checks on code crunch but I came across this warning (uncheked method invocation) when attempting lab01.

Description:

From google, this error seems to be due to not declearing the type for the List. But i used List "Point"in my method. Do anyone have any idea what this is about?

Code Snippets

image

Screenshots

image

Thank you.

ImList Constructor

Description

class ImList<T> {
    private final ArrayList<T> elems;

    public ImList<T>() {
        elems = new ArrayList<T>();
    }

    public ImList<T>(List<T> list) {
        elems = new ArrayList<T>(list);
    }
}

Why does adding in the constructor throw these errors:

ImList.java:7: error: <identifier> expected
    public ImList<T>() {
                    ^
ImList.java:11: error: <identifier> expected
    public ImList<T>(List<T> list) {
                    ^
2 errors

Topic:

Specific Topics this question is related to (If Any)

Screenshots

Screenshots (if any)

Time exceeded error Level 5

Summary

Hi, I have faced this error when trying to clear level 5.

Description:

My code currently works for the test cases in level 5, but fails in codecrunch. I used a nested for loop within a for loop, with a while loop inside. Please advise if its a problem of algorithmic inefficiency or other errors I may not have foreseen.

Code Snippets

Screenshots

image

"Pure" vs "Impure" Interfaces

Description

What is the difference between the "Pure" and "Impure" interfaces, and what are they? This is mentioned in the footnote of slide 7 in lecture 5. Thank you!

Topic:

Interface

List

Hi prof,

will we be going through more about List.
Seems like question 2c) of Problem set requires us to know the methods of List.
Or are we supposed to read up on our own?

PE1

Hi Prof @hwkchia

Will we be briefed on how PE1 will be like?
What format will it be?
What restrictions do we have?
Any past year questions?

windows "working with vimrc file"

Summary

im using windows 11 and i have trouble downloading the vimrc file. has anyone with windows figured out how to do that?

Description

Describe the problem and how one can replicate this problem

Screenshots (if any):

Insert Images here if necessary

Unable to loop set method for RecycledLoader

Does anyone know why I am unable to loop through the setting of my RecycledLoader?
From what I understand from the test output, it appears that my code seems to always forgo the if condition and go straight to the else condition. When I print out the list of loaders to check, the existing RecycledLoaders dont seem to be modified while everything else is fine. I have faced no issues with the generating of new RecycledLoaders if required. Is there anything I am missing out on? Does it have to do with the way my RecycledLoader class is implemented?

A snippet of my code is as follows, the only difference between this and level 5 is the addition of an if condition to decide whether to set a new RecycledLoader or Loader:
Screenshot 2022-02-20 at 6 23 08 PM

My test output:
Screenshot 2022-02-20 at 6 21 49 PM

Issue with opening Ubuntu and WSL

Summary

When I run ubuntu or wsl, nothing happens.

Description

I am facing an issue with the installation of Unix when I followed this guide: https://github.com/nus-cs2030/2122-s1/wiki/Setting-Up-Unix-For-Windows

I managed to finished up to step 5 of Running Powershell to install Ubuntu. However, I was not able to continue to the “launching wsl” step. This is because nothing happens when I run Ubuntu and I have also tried the alternate option of running wsl but similarly, wsl does not open.

I have tried following the other guides as well: https://github.com/nus-cs2030/2122-s2/wiki/Setting-Up-Unix-For-Windows#launching-wsl and https://github.com/nus-cs2030/2021-s2/wiki/Setting-Up-Unix-For-Windows but I also had problems with these.

Screenshots (if any):

CS2030 Forum Guidelines

Welcome to CS2030 Forum using Github Issues!

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!");
    }
  5. 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.

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

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

Best regards,
Russell
Your lovely CS2030 alumni 😊

JDT not activating on Vim

Summary

JDT not activating despite creating a file called 'HelloWorld.java'

Description

I use mac and on my terminal, I managed to create a file using 'vim HelloWorld.java' as what is shown in the Luminus 'Intro to Java' video. However, in the video, right after creating the HelloWorld file, the JDT started loading and activating but this is not the case for me. Instead, the supposed 'Java' file acted more like a regular txt file (see image attached) and I'm assuming it's because my JDT does not activate automatically. Is anyone else a mac user and also experiencing such a problem? Does anyone know how to fix this? Any input would greatly help. Thank you!

Screenshots (if any):

Screenshot 2022-01-12 at 9 41 39 PM

Immutability

Description

Hi Prof is immutability just having a setter method that returns a new object? Shouldn't the client create a new object instead of relying on the setter method of an existing object?

Topic:

Specific Topics this question is related to (If Any)

Screenshots

Screenshots (if any)
`

Implicit requirement on class and variable names in lab04

Summary

Lab04 require "BookingStub" class but this is not mentioned in task.txt.

Description:

I fail at this question where it has implicit requirement on this class "BookingStub" and variable "list", but this requirement is not mentioned in the task.txt. I have my own implementation that can pass the sample test cases but failed at codecrunch. My worries is that in the PE where we only have one time to submit the code, how can we know the class names and variable names required by the grader which is not explicitly mentioned in task.txt?

image

Code Snippets

Attach code snippets (if any)

Screenshots

Screenshots (if any)

lvl6: recycled loader class cannot access cruise

Summary

I created a RecycledLoader class which has a method cruise.getServiceCompletionTime(), but cannot access it since the cruise has private access in Loader. I tried changing it to protected, which works, but is not accepted on codecrunch. Does anyone know how to solve this? Thank you!

Can/Should we use static list of objects?

task.txt says that

You should aim to make the Booking class general such that it does not
need to check for any invalid pairing

Thus, I baked the services each driver provides into the methods within each driver class (i.e. NormalCab and PrivateCar). Is this considered hardcoding?

NormalCab.java

...
public Service bestService(Request req) {
        Service ser1 = new JustRide();
        Service ser2 = new TakeACab();
        ...

Would it be better to implement something like

NormalCab.java

class NormalCab implements Driver {
    private static final ImList<Service> SERVICES 
            = new ImList<Service>(List.of(new JustRide(), new TakeACab()));
    private final String id;
    private final int waitTime;
    ...

It seems less hardcoded as information about services are retrieved from a single property, and is also more scalable if each driver decides that it can take on more than 2 services. However, it makes the code much more complex. Am I overengineering?

@Override when a class implements an interface.

Summary

@OverRide throws an error when a class implements a method from an interface.

Description:

When I code my interface in a separate file and then implement that interface from a class then @OverRide throws me an error. But when I write my interface in the same .java file as the class, @OverRide works. Why is that the case? Does that mean we shouldn't use @OverRide when a class implements a method of an interface?

Code Snippets

Screenshots

Screenshot 2022-02-18 at 7 08 03 PM

How do we know if I am doing level 5 the right way?

If I get A for CodeCrunch, does it mean I am coding correctly?

I created a new class SingleServiceBooking, that takes in a service, request and driver. It is similar to Booking class, but it only takes in service.
I used it to make SingleServiceBooking for each services a driver can have.
For example, the test case,

findBestBooking(new Request(20, 3, 1000), List.of(new NormalCab("SHA1234", 5), new PrivateCar("SMA7890", 10)))

I will make 4 SingleServiceBooking objects, that will compare among themselves and sort based on lowest fare and time.

I would like to know if making extra classes when the question does not ask for it is allowed, and if it is the right way of coming up with the code for the question, since I am not using Booking class in level 5.

Point Class constructor, implemented with ImList

Description

Hi prof, just to clarify line 7 & 8 in the constructor does nothing right since you get a new ImList when you add()
And even if you want to assign it coord you can't do it since line 6 is already an assignment and coord is a final variable.

Topic:

Specific Topics this question is related to (If Any)

Screenshots

image

Can't figure out the structure of code for Lab 2 Level 5

Summary

I'm not to sure how to go about tackling level 5 for lab 2.

Description:

I have trouble thinking of how to complete the check and move if the number given for method move(int num) is able to cause a change in the puzzle.

Code Snippets

Attach code snippets (if any)

Screenshots

Screenshots (if any)

downloading VIM

photo_2022-01-26_17-48-55

does anyone know how to resolve this issue? im using a ryzen software and idk if that is the problem. send help pls :(

Static Binding and Dynamic Binding

Description

Hi everyone!

I have been reading up on Static and Dynamic binding and I might have made a couple of misconceptions. Would it be appropriate to say that method overriding is essentially dynamic binding taking place because you are giving the method a new definition while running the programme? In that regard, would method overloading thus be an aspect of static binding? If that is the case how would new function definitions be stored in byte code for the same method name? It just doesn't seem to make sense how a function can take on so many abilities..?

Thanks for the help!

Topic:

Polymorphism

Unable to use comparator in codecrunch

Hi does anyone faced this problem before on level5? My code is able to do sort and return the correct output on jshell (for test case) but when I upload the code to codecrunch, this error occurs:
image

Here is my comparator class code and how i implement it on level5.jsh.
image
image

LSP and overriding

Description

I'm quite confused about LSP and overriding. It seems to me that as long as you override you're violating LSP since you're changing the implementation and behavior of a method in the superclass.

Edit: Additionally, isn't the definition very subjective.
eg if the customers were very picky then the third son would violate LSP. So Only the son who brews beverages exactly like the father satisfy LSP (no overriding)

Topic:

LSP & Overriding

Screenshots

Screenshots (if any)

"Vim e510: cannot create a backup file" after configuring the vimrc file

Summary

I am a windows 10 user. Today I managed to configure the recommended .vimrc for my vim in ubuntu, as instructed in the lesson wiki page. However, ever since that, each time when I press :w or :wq to save my file, an error message will pop out -- Vim error E510: Can't make backup file (add ! to override). So now I can only press :w! or :wq! to save my file.

Later I found that this probably has something to do with the instructions to create backup files in the configured .vimrc file. I checked some Stackoverflow, but still not clear what exactly to do. Anyone can help?

Screenshots (if any):

屏幕截图(874)
屏幕截图(875)_LI

Vim and ubuntu

Summary

I downloaded vim 8.2 and when i check vim -version on powershell it shows version 8.2. However when on Ubuntu it shows 8.0.
Also, im not able to launch WSL as the wiki explained i.e. "windows logo + R" , type "Ubuntu". It says theres no such name so i have to open ubuntu by opening it. Lastly, the working with .vimrc step, im not able to find the path as theres only the ext4 in my localstate. i followed the steps properly so im not sure what is wrong.

Description

Describe the problem and how one can replicate this problem

Screenshots (if any):

Insert Images here if necessary
2022-01-18 (1)

Issues with Ubuntu Login

After I download Ubuntu, I was not prompted to set up the account and create a password. I was able to execute code given in the wiki like "sudo apt update". I could not find ways to login so what should I do?
Ubuntu

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.