My java code isn’t compiling? Please help me

I’ve tried everything it says there’s an issue with the word student and that it cannot find the symbol but I don’t know what to do.

/*
Programmer: Jordan McIntosh
Date: 02/11/2022
School: Science Hill High School
Purpose: the purpose is to import 4 students and be given their total points,
grade, and average
*/
class Main{

      public static void main(String[] args){
        //creating new student named Jordan
    Student Jordan = new Student();
        Jordan.setName("Jordan");
        Jordan.setCourse("AP CSA");
        Jordan.setGrade(11);
        Jordan.addScore(95);
        Jordan.addScore(80);

        //creating new student named Nick
        Student Nick = new Student();
        Nick.setName("Nick");
        Nick.setCourse("Biology");
        Nick.setGrade(11);
        Nick.addScore(78);
        Nick.addScore(95);
        Nick.addScore(97);
        Nick.addScore(56);

        //creating new student named Luke
        Student Luke = new Student();
        Luke.setName("Luke");
        Luke.setCourse("AP Psychology");
        Luke.setGrade(11);
        Luke.addScore(51);
        Luke.addScore(94);
        Luke.addScore(89);
        Luke.addScore(100);
   
        //creating new student named Drew
        Student Drew = new Student();
        Drew.setName("Drew");
        Drew.setCourse("Credit Recovery");
        Drew.setGrade(11);
        Drew.setScore(12);
        Drew.setScore(47);
        Drew.setScore(91);
        Drew.setScore(62);
        Drew.setScore(92);
        Drew.setScore(78);
  

        //formulating the average of each student
        double avg = Jordan.getPoints() / Jordan.NumScores() ;
        double avg1 = Nick.getPoints() / Nick.NumScores() ; 
        double avg2 = Luke.getPoints() / Luke.NumScores() ; 
        double avg3 = Drew.getPoints() / Drew.NumScores() ; 

        //printing Jordan's information
        System.out.println("Student Name: "+ Jordan.getName());
        System.out.println("Student Course: "+ Jordan.getCourse());
        System.out.println("Student Grade: "+ Jordan.getGrade());
        System.out.println("Number of Scores: " +Jordan.getNumScores());
        System.out.println("Total Points: " +Jordan.getPoints());
        System.out.println("Average: "+ avg +"n" );

        //printing Nick's information
        System.out.println("Student Name: "+ Nick.getName());
        System.out.println("Student Course: "+ Nick.getCourse());
        System.out.println("Student Grade: "+ Nick.getGrade());
        System.out.println("Number of Scores: " +Nick.getNumScores());
        System.out.println("Total Points: " +Nick.getPoints());
        System.out.println("Average: "+ avg +"n" );

        //printing Luke's information
        System.out.println("Student Name: "+ Luke.getName());
        System.out.println("Student Course: "+ Luke.getCourse());
        System.out.println("Student Grade: "+ Luke.getGrade());
        System.out.println("Number of Scores: " +Luke.getNumScores());
        System.out.println("Total Points: " +Luke.getPoints());
        System.out.println("Average: "+ avg +"n" );
 
        //printing Drew's information
        System.out.println("Student Name: "+ Drew.getName());
        System.out.println("Student Course: "+ Drew.getCourse());
        System.out.println("Student Grade: "+ Drew.getGrade());
        System.out.println("Number of Scores: " +Drew.getNumScores());
        System.out.println("Total Points: " +Drew.getPoints());
        System.out.println("Average: "+ avg +"n" );




      }
    }

Create a Path2D from ImageData in JavaScript

Given an ImageData object, is there a function or algorithm to create a Path2D that contains all non-transparent pixels?

For background, I have a low-resolution, raster image that will be used as a mask for some higher-resolution, dynamic content. While I can accomplish this goal using a temporary canvas and various globalCompositeOperation types, I would prefer to use clip() with a path – I suspect it will be more efficient. The mask image does not change often, so the path can be re-used many times once it has been calculated.

Get data to pulldown when using jquery

Hi I want to make a pulldown when add is clicked it will output data from the function (function is the page or from the url), but it doesn’t work.

Please help me

    function cmd_dk(){
        $dk = array('0'=>'0','1'=>'1','2'=>'2','3'=>'3');
        return $dk;
    }
  $(document).ready(function(){
   $(document).on('click', '.add', function(){
  var html = '';
  html += '<tr>';
  html += '<td><select name="item_unit[]" id="select_coa" class="form-control select2"><option value="">Select Unit</option><option value="">Select Unit</option></select></td>';
  html += '<td><button type="button" name="remove" class="btn btn-danger btn-sm remove"><span class="glyphicon glyphicon-minus"></span></button></td></tr>';
  $('#item_table').append(html); $('.select2').select2(); 
 });
 
  $(document).on('click', '.remove', function(){
  $(this).closest('tr').remove();
 }); 
 
 $.ajax({
        type: "POST",
        url: "cmd_dk",
     //   cache: "false",
        dataType: "json",
        success: function(data) {
          $("#select_coa").append("<option value='"+data.id_coa+"'>"+data.nama_coa+"</option>");
        }
  });
  });
  
  
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button type="button" name="add" class="btn btn-success btn-sm add"><span class="glyphicon glyphicon-plus"></span>Tambah Data</button>

results[i].sort is not a function

I am having this error in sorting the id I get from json array.
This is the code:

for (var i = 0, len = myArr.Items.length; i < len; i++) {
                        var id_art = myArr.Items[i].id_a;
                        if (id_art == id_url) {
                            results[i] = myArr.Items[i];
                             results[i].sort(function (a, b) {
                                if (a.results[i].id != b.results[i].id) {
                                    return (a.results[i].id - b.results[i].id);
                                }
                            }); 
                        }
                    }
                    console.log(results);

How can I fix it?

this.methodName is undefined in browser, Can’t use the this.MethodName between internal methods in Typescript Class

I have my typescript files bundled into one file. Called them like this:

export class MyComponent extends CommonComponent {

  private fooMethod() {
    // normal typescript code here.
  }

  public barMethod() {
    this.fooMethod();
  }
}

and all these are translated to javascript like this: MyComponent.prototype.fooMethod = () => { // the code here }. The problem is that this.fooMethod in the barMethod is undefined in the javascript. How can resolve that?

I was cheking all the net for same question, didn’t find any. I would appreciate it if you help me or address me any resource on net regarding this topic. Thanks.

How can I make a previously incremented set of numbers appear below the current numbers in a new line?

I wrote a javascript that increases a set of numbers every second, where every increased set writes on a new line separated by a horizontal rule. E.g;

20220215155

20220215156

20220215157

20220215158 etc…

var i = 20220215155;
    function increment(){
     i++;
        document.getElementById('period').innerHTML += i + "<br />" + "<hr />" ;
    }
    setInterval('increment()', 1000);

But I want every current set of the numbers to always be in the first line, whereby a previously increased set goes below the currently increased set… E.g;

20220215159

20220215158

20220215157

20220215156

20220215155

Please how do I go about this?

How to remove only one of repeated chars in string using JavaScript

I have a string with repeated chars like : ‘CANADA’.
And I am trying to get the string which removed only one of repeated chars :
‘CNADA’, ‘CANDA’, ‘CANAD’.

I’ve tried it with subString, but it returned the part of string removed.
Also I’ve tried it with reduce, but it ended up removing all the repeated chars (‘CND’).

What is the way of removing only one char at time?
The results can be stored in array. (results = [‘CNADA’, ‘CANDA’, ‘CANAD’])

Thank you.

jQuery replaceWith() doesnot work when used within success function of ajax call. Why?

Functionality I am trying to implement– When I send a friend request to a user by clicking the send friend request button, the button dynamically changes to withdraw friend request button. And, When I click the same withdraw friend request button to withdraw my friend request, the button dynamically changes to send friend request button.

When I use jQuery replaceWith() outside of success() of ajax call, it works perfectly. Here is the Working Code.

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous">
    </head>
    <body>
        <a href="/users/friends/sendRequest/<%=profile_user.id%>" class="btn btn-success send-friend-request" data-targetUser="<%=profile_user.id%>">Send Friend Request</a>
    </body>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-fQybjgWLrvvRgtW6bFlB7jaZrFsaBXjsOMm/tB9LTS58ONXgqbR9W8oWht/amnpF" crossorigin="anonymous"></script>
    <script src="script.js"></script>
</html>
{
  function sendFriendRequest(){
        $('.send-friend-request').click(function(event){
            event.preventDefault();
            let targetUser = $(this).attr("data-targetUser");
            $.ajax({
               type:'get',
               url:$(this).prop('href'),
               success:function(data){
                  //empty
                },error:function(err){
                    console.log('Error');
                }
            });

            $('.send-friend-request').replaceWith(`
                <a href="/users/friends/withdrawRequest/${targetUser}" class="btn btn-danger withdraw-friend-request" data-targetUser="${targetUser}">Withdraw Friend Request</a>
            `);

             withdrawFriendRequest();
        });
  }
  function withdrawFriendRequest(){
        $('.withdraw-friend-request').click(function(event){
            event.preventDefault();
            let targetUser = $(this).attr("data-targetUser");;
            $.ajax({
                type:'get',
                url:$(this).prop('href'),
                success:function(data){ 
                   //empty
                },error:function(err){
                    console.log('Error');
                }
            });
            $('.withdraw-friend-request').replaceWith(`
                <a href="/users/friends/sendRequest/${targetUser}" class="btn btn-success send-friend-request" data-targetUser="${targetUser}">Send Friend Request</a>
            `);
            sendFriendRequest();
        });
    }
    withdrawFriendRequest();
    sendFriendRequest();
}

However, when i move the replaceWith() inside the success function of ajax, it doesn’t work. All, the html is replaced correctly on the DOM, class names are correct. I used inspect to check that. Also, i used console.log() statements statements to recheck my code. But I am not able to find the mistake:

{
  function sendFriendRequest(){
        $('.send-friend-request').click(function(event){
            event.preventDefault();
            let targetUser = $(this).attr("data-targetUser");
            $.ajax({
               type:'get',
               url:$(this).prop('href'),
               success:function(data){
                  $('.send-friend-request').replaceWith(`
                    <a href="/users/friends/withdrawRequest/${targetUser}" class="btn btn-danger withdraw-friend-request" data-targetUser="${targetUser}">Withdraw Friend Request</a>
                  `);
                },error:function(err){
                    console.log('Error');
                }
            });

             withdrawFriendRequest();
        });
  }
  function withdrawFriendRequest(){
        $('.withdraw-friend-request').click(function(event){
            event.preventDefault();
            let targetUser = $(this).attr("data-targetUser");;
            $.ajax({
                type:'get',
                url:$(this).prop('href'),
                success:function(data){ 
                   $('.withdraw-friend-request').replaceWith(`
                      <a href="/users/friends/sendRequest/${targetUser}" class="btn btn-success send-friend-request" data-targetUser="${targetUser}">Send Friend Request</a>
                   `);
                },error:function(err){
                    console.log('Error');
                }
            });
            sendFriendRequest();
        });
    }
    withdrawFriendRequest();
    sendFriendRequest();
}  

The problem which I am facing is that, after sending a request, the send request link is replaced with withdraw request link using ajax. But when I click the withdraw request link, the page simply refreshes, that is, event is not prevented when clicking on the withdraw request button. Why does this happen ? Does it has to do anything with the asynchronous nature of AJAX calls ?

Saving Data in a .txt with javaScript

so i want to make a Browser game where the best Players are Displayed in a ranking my idea was to just write in a .txt on the server but everything i find on Google dosent works at all. anyone has some simple ways of doing that ?

Router.push or Link not rendering/refreshing the page even thought the url is updated nextjs

I apologize for my horrendous way of explaining my issue. I have shared a link below description which is exactly the same issue I am experiencing. Any kind of help would be greatly appreciated.

I have directory path like pages/request/[reqid].js . When my url is localhost:3000/xyz and I navigate to pages/request/1 by clicking a button on the current page, the page successfully loads the page with proper data from [reqid=1] but when I try to access pages/request/[reqid].js with different reqid (say suppose reqid=2), the url reflects the correct the reqid pages/request/2 but the page remains the same, doesn’t change. However if I go back to other pages like localhost:3000/xyz and click a button there to navigate to pages/request/2 it works but from within pages/request/[reqid] it doesn’t render a page associated to the corresponding reqid even thought the url is updated. I have tried both Link and router.push ,both fails to render the correct reqid page.

https://github.com/vercel/next.js/issues/26270

Cloudfront with Websocket connection

I have been reading over the documentation here on connection a websocket service with a client through a cloudfront distribution but I am unable to understand where the upgrade to the websocket protocol will occur. Will the upgrade need to be handled by the server or will the cloudfront distribution handle changing the protocol to wss and respond with the connection?

How to send an embed with discord.js

I was wondering how to write an embed in discord.js. This is my current code: it is not functional. I get the warning: ‘message is not defined’ on message.channel.send I do not know how to fix this. I was hoping you guys could tell me how to fix this. js

// Embeding the image in An Embeded message
    const EmbededTweet = new MessageEmbed()
        .setColor('0x00FF00')
        .setTitle(`You made ${account} tweet this:`)
        .setImage(imageUrl)
        .setTimestamp();

    // replying with the Embeded message
    await interaction.reply({embeds: [EmbededTweet]});

Filepond revert method for delete does not send unique file id

I am trying to intergrate File Pond with my Flask server and I can not find the unique file id it sends with requests. With normal uploads it will show me request data on the server, but without the unique ID I am looking for. I want to use this unique ID to attach to a database in order to delete the file if the revert is sent later.

Going over the docs, it is suppsoed to send a unique ID with every upload, but I can’t tell if it’s a bad config in file pond or I suck at reading request.files. Just ignore all my prints where I try to read the contents of request.

Here is my FilePond Config:

    FilePond.setOptions({
        //allowImageEdit: true,
        //allowImageCrop: true,
        //allowMultiple: true,
        //allowFileEncode: true,
        allowImageExifOrientation: true,
        credits: false,
        server: {
            process: {
                url: './pondupload',
                method: 'POST',
                headers: {
                    'x-customheader': 'Hello World',
                },
                withCredentials: document.getElementById('csrf_token'),
                onload: (response) => response.key,
                onerror: (response) => response.data,
                ondata: (formData) => {
                    formData.append('csrf_token', document.getElementById('csrf_token').value)
                    return formData;
                },
            },
            revert: './pondupload',
            restore: './restore/',
            load: './load/',
            fetch: './fetch/',
        },
    });

Here is my route in flask:

@bp.route('/pondupload', methods=['POST', 'DELETE'])
def pondupload():
    print ('data: '+str(request.data))
    print('form: '+str(request.form))
    print('files: '+str(request.files))
    print('args: '+str(request.args))
    form=EmptyForm()
    #TODO add csrf to revert
    if request.method == "DELETE":
        print('delete stuff')
    if request.method == "POST" and form.validate_on_submit():
        upload_dir = current_app.config['UPLOAD_FOLDER']
        fn = ""
        file_names = []
        # get file object from request.files (see: http://flask.pocoo.org/docs/1.0/api/#flask.Request.files)
        for key in request.files:
            print('key: '+str(key))
            file = request.files[key]
            fn = secure_filename(file.filename)
            if allowed_file(fn) == True:
                file_names.append(fn)
                try:
                    file.save(os.path.join(upload_dir, fn))
                    return jsonify({}), 200
                except:
                    return jsonify(filename=file_names), 402
    return jsonify({}), 400

react js rendering blank [age with no errors on console

So basically I have a navbar that switches between routes. When the page loads, it goes to my localhost by default but doesn’t actually render the App component it’s being given. I believe the problem is within the navbar as the app renders other components when the Nav component is not included. Please assist me if you can.

code to the questions is given below:
app.js

    import React from 'react';
import './App.css';
import Nav from './components/Navbar/navbar';
import Content from './components/Header/firstsec';
import Grid from './components/secondsec/secondsec';
import Footer from './components/footer/footer';
import Sign from './components/signin/signin';
import Trend from './components/trending/trending';


function App() {
  return (   
      <div>
       <Nav/>
     <Content />    
     <Grid />
     <Footer />
     <Sign />
     <Trend />
     </div>
     
     
  );
}

export default App;

navbar.js

    import React from "react";
import {
  BrowserRouter as Router,
  Route,
  Routes,
  Link} from "react-router-dom";
import Content from "../Header/firstsec";
import Grid from "../secondsec/secondsec";
import Trend from "../trending/trending";
import Sign from "../signin/signin";
import { Component } from "react/cjs/react.development";



export default class Nav extends Component{
  render(){
    return (
    <Router>
    <div>
      <nav className="bg-gradient-to-r from-blue-300 to to-purple-500 via-black">
      <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-6">
          <div className="flex items-center justify-between h-36">
            <div className="flex items-center">
              <div className="flex-shrink-0">
                <img
                  className="h-8 w-8"
                  src="https://tailwindui.com/img/logos/workflow-mark-indigo-500.svg"
                  alt="Workflow"
                />
              </div>
              <div className="hidden md:block">
                <div className="ml-10 flex items-baseline space-x-4">
                  <Nav.Link as={Link} to ={"/"}
                    
                    className=" hover:bg-gray-700 text-white px-3 py-2 rounded-md text-sm font-medium"
                  >
                    Bloow
                  </Nav.Link>
                  <Nav.Link as={Link} to ={"/Content"}
                    className="text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">
                    Bloow TV
                  </Nav.Link>

                  <Nav.Link as={Link} to ={"/Grid"}
                    className="text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium"
                  >
                    Bloow Music
                  </Nav.Link>

                  <Nav.Link as={Link} to ={"/Trending"}
                    className="text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium"
                  >
                    Trending
                  </Nav.Link>
                  <div>
                  <Nav.Link as={Link} to ={"/Sign"}
                    className="text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium"
                  >
                    Sign in
                  </Nav.Link>

                 

                  </div>      
              </div>
            </div>
            <div className="-mr-2 flex md:hidden">
              <button
                type="button"
                className="bg-gray-800 inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-white hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-800 focus:ring-white"
                aria-controls="mobile-menu"
                aria-expanded="false"
              >
                <span className="sr-only">Open main menu</span>

                <svg
                  className="block h-6 w-6"
                  xmlns="http://www.w3.org/2000/svg"
                  fill="none"
                  viewBox="0 0 24 24"
                  stroke="currentColor"
                  aria-hidden="true"
                >
                  <path
                    stroke-linecap="round"
                    stroke-linejoin="round"
                    stroke-width="2"
                    d="M4 6h16M4 12h16M4 18h16"
                  />
                </svg>

                <svg
                  className="hidden h-6 w-6"
                  xmlns="http://www.w3.org/2000/svg"
                  fill="none"
                  viewBox="0 0 24 24"
                  stroke="currentColor"
                  aria-hidden="true"
                >
                  <path
                    stroke-linecap="round"
                    stroke-linejoin="round"
                    stroke-width="2"
                    d="M6 18L18 6M6 6l12 12"
                  />
                </svg>
              </button>
            </div>
          </div>
        </div>
        </div>

        <div className="md:hidden" id="mobile-menu">
          <div className="px-2 pt-2 pb-3 space-y-1 sm:px-3">
            <Nav.Link as={Link} to ={"/home"}
              className="hover:bg-gray-700 text-white block px-3 py-2 rounded-md font-medium text-5xl"
            >
              Bloow
            </Nav.Link>

            <Nav.Link as={Link} to ={"/Content"}
              
              className="text-gray-300 hover:bg-gray-700 hover:text-white block px-3 py-2 rounded-md text-base font-medium"
            >
              Bloow TV
            </Nav.Link>

            <Nav.Link as={Link} to ={"/Grid"}
              className="text-gray-300 hover:bg-gray-700 hover:text-white block px-3 py-2 rounded-md text-base font-medium"
            >
              Bloow Music
            </Nav.Link>

            <Nav.Link as={Link} to ={"/Trending"}
              className="text-gray-300 hover:bg-gray-700 hover:text-white block px-3 py-2 rounded-md text-base font-medium"
            >
              Trending
            </Nav.Link>

            <Nav.Link as={Link} to ={"/Sign"}
              className="text-gray-300 hover:bg-gray-700 hover:text-white block px-3 py-2 rounded-md text-base font-medium"
            >
              Sign in
            </Nav.Link>
          </div>
        </div>
      </nav>
    </div>
    <div>
      <Routes>
        <Route path="/" Component ={Content} />
        <Route path="/Content" Component ={Content}>
        </Route>
        <Route path="/Grid" Component ={Grid}>
          <Grid />
        </Route>
        <Route path="/Trending" Component={Trend}>
          <Trend />
        </Route>
        <Route path="/Sign" Component={Sign}>
          <Sign />
        </Route>
      </Routes>
      
    </div>
    </Router>
  );

}
}

    

Heroku Cannot Get/ when getting data from MongoDB through Heroku API Using MEN Stack

js express server and Heroku API hosting.

I created a backend that allows me to post and get data from MongoDB through express server that is hosted on Heroku , I’m using postman for testing.

POST method works well both locally and on Heroku.
GET method only works locally and I get A Cannot GET / error with a 404 code when I test on Heroku.

This is my code below:

router.get('/posts', async (req, res) => {
    try {
        const posts = await Posts.find();
        res.json(posts)
        console.log('data',res.send)
    }catch (err) {
        res.send('error', err)
    }
});

module.exports = router;