Simple circular dependency between three classes

I have this basic design with a circular dependency. Is there any solution for this? The problem is that a Machine cannot be created if a Model for that Team has been submitted.
enter image description here

DotNet Coder needed for a simple 1 page design – quick 20$

I have an existing site already coded in dotnet.
i need to change its homepage to another design
i have the sample design
Coding can be done in both DotNet and Plain HTML5 ( as its just plain homepage)
offering 20$ for it.

this is the sample design
http://udiseplus.gov.in/homePage/index.jsp

i want it done today/tomorrow itself, so only respond if you can do it today.
msg me on skype or here
payment via paypal

java – Efficient way to store “item” objects in a simple game

I am developing a simple text-based game. In this game, the user is able to collect items and store them in an inventory.

My question is: how should I organize the internal structure of my game so that I can load these items in an efficient way?

I need to be able to create fresh instances of an item whenever the user acquires an item of that type, or when instantiating any feature in the game that contains items. In order to do so, I feel like I need some sort of “master list” of all items that I can just copy out of by indexing into the correct location in the list.

I’ve come up with two potential solutions:

  • Hard-code this entire giant list into a data structure within my game

  • Somehow load these items from an XML file at startup and then populate the “master list” of items on the fly

Pros of option 1:

  • Relatively easy
  • No IO time
  • Allows me maximum efficiency in designing the actual item objects

Cons of option 1:

  • Hard to maintain
  • Bloats source code
  • Very tedious to implement

Pros of option 2:

  • Easy to add/remove/modify items
  • Allows the user to customize the game if they want to

Cons of option 2:

  • Requires that I design my objects much more carefully so that they can be built on the fly and stored

  • Requires that I perform a deep copy from the master list each time I need a new copy of a specific item

  • I have to write an “item-builder” that is capable of translating the XML input into an actual item object in memory.

Neither of these ideas feels very good to me. Is there something obvious I’ve missed?

java – Efficient way to store “item” objects in a simple game

I am developing a simple text-based game from scratch in Java. In this game, the user is able to collect items and store them in an inventory.

My question is: how should I organize the internal structure of my game so that I can load these items in an efficient way?

I need to be able to create fresh instances of an item whenever the user acquires an item of that type, or when instantiating any feature in the game that contains items. In order to do so, I feel like I need some sort of “master list” of all items that I can just copy out of by indexing into the correct location in the list.

I’ve come up with two potential solutions:

  • Hard-code this entire giant list into a data structure within my game

  • Somehow load these items from an XML file at startup and then populate the “master list” of items on the fly

Pros of option 1:

  • Relatively easy
  • No IO time
  • Allows me maximum efficiency in designing the actual item objects

Cons of option 1:

  • Hard to maintain
  • Bloats source code
  • Very tedious to implement

Pros of option 2:

  • Easy to add/remove/modify items
  • Allows the user to customize the game if they want to

Cons of option 2:

  • Requires that I design my objects much more carefully so that they can be built on the fly and stored

  • Requires that I perform a deep copy from the master list each time I need a new copy of a specific item

  • I have to write an “item-builder” that is capable of translating the XML input into an actual item object in memory.

Neither of these ideas feels very good to me. Is there something obvious I’ve missed?

Fitting a very simple dataset

I am a beginner in Wolfram Mathematica. I am trying to fit the data from a CSV file using FindFit. In doing so, I am getting the following error message

FindFit::nrjnum: The Jacobian is not a matrix of real numbers at {a} = {1.}.

The output of my CSV file is

{{-300, 2.1977}, {-600, 2.61518}, {-900, 5.48259}, {-1200, 
  4.34585}, {-1500, 3.24366}, {-1800, 2.57632}, {-2100, 
  2.14541}, {-2400, 1.85425}, {-2700, 1.6508}, {-3000, 
  1.50487}, {-3300, 1.39795}, {-3600, 1.31817}, {-3900, 
  1.25768}, {-4200, 1.21115}, {-4500, 1.17488}, {-4800, 
  1.14627}, {-5100, 1.12344}, {-5400, 1.10504}, {-5700, 
  1.09006}, {-6000, 1.07776}}

I wonder what is the right way of performing this task.
My attempt so far has been

data=Import["/home/data_variance2_r _final.csv"]
modeltwolevelsat = 1/x^a;
eq = FindFit[data, modeltwolevelsat, {a}, x]

I would appreciate if someone can help me out or give any tip on how to solve this problem.

Thanks in advance.

Simple Console Chat in Java

I have rewritten my little chat application and tried to pay attention to former hints and tips. The viewer and the writer have to run as seperate applications. the Writer.class basically stores messages as property files. The directory, where the files get stored, is watched by the Viewer.class and gets scanned every 0.5 seconds. What do you think about my program? Is there something that I can improve?

Viewer.java

import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.util.Date;
import java.util.Properties;
import java.io.File;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;

public class Viewer {
    public static void main(String() args) {
        Viewer viewer = new Viewer();
        viewer.view();
    }
    
    // contains all messages within two sub-dirs
    private File saveDir;
    // contains messages that have to be displayed
    private File currentDir;
    // contains messages that don't have to be displayed
    private File archiveDir;
    // determines the maximal amount of messages in the current directory
    private int currentMessagesCount;
    // last message read into program
    private File lastMessage;
    
    public Viewer() {
        // initialize members from file named config
        try (BufferedInputStream stream = new BufferedInputStream(new FileInputStream("config"))) {
            Properties config = new Properties();
            config.load(stream);
            currentMessagesCount = Integer.parseInt(config.getProperty("current_messages_count"));
            saveDir = new File(config.getProperty("save_dir"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        
        currentDir = new File(saveDir, "current");
        archiveDir = new File(saveDir, "archive");
        lastMessage = new File("no last message");
        
        // create save directories if don't exist
        if (!saveDir.exists()) {
            saveDir.mkdir();
        }
        if (!currentDir.exists()) {
            currentDir.mkdir();
        }
        if (!archiveDir.exists()) {
            archiveDir.mkdir();
        }
        
        File() messages = currentDir.listFiles();
        Arrays.sort(messages);
    }
    
    public void view() {
        printAllMessages();
        while (true) {
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            printNewMessage();
            checkLimit();
        }
    }
    
    // prints all messages immediately
    private void printAllMessages() {
        File() messages = currentDir.listFiles();
        
        if (messages.length == 0) {
            return;
        }
        
        Arrays.sort(messages);
        for (int i = 0; i < messages.length; i++) {
            printMessage(messages(i));
        }
        
        lastMessage = messages(messages.length - 1);
    }
    
    // prints newest if there is a more recent than last read message
    private void printNewMessage() {
        File() messages = currentDir.listFiles();
        Arrays.sort(messages);
        
        if (messages.length == 0) {
            return;
        }
        
        // add all new messages to a list and print it out reversively
        List<File> newMessages = new ArrayList<>();
        for (int i = messages.length - 1; i >= 0 ; i--) {
            if (!messages(i).toString().equals(lastMessage.toString())) {
                newMessages.add(messages(i));
            } else {
                break;
            }
        }
        
        while (newMessages.size() > 0) {
            File currentMessage = newMessages.get(newMessages.size() - 1);
            
            printMessage(currentMessage);
            newMessages.remove(currentMessage);
            lastMessage = currentMessage;
        }
        
    }
    
    private void printMessage(File file) {
        try (BufferedInputStream stream = new BufferedInputStream(new FileInputStream(file))) {
            Properties currentMessage = new Properties();
            currentMessage.load(stream);
            System.out.println(currentMessage.getProperty("date") + " (" + currentMessage.getProperty("nickname") + ")");
            System.out.println(currentMessage.getProperty("content") + "n");
        } catch (IOException e) {
            e.printStackTrace();
        }       
    }
    
    // checks if there are too much messages in currentDir
    private void checkLimit() {
        File() messages = currentDir.listFiles();
        Arrays.sort(messages);
        int numOfSuperfluousMessages = messages.length - currentMessagesCount;
        if (numOfSuperfluousMessages > 0) {
            for (int i = 0; i < numOfSuperfluousMessages; i++) {
                messages(i).renameTo(new File(archiveDir, messages(i).getName()));
            }
        }
    }
}

Writer.java

import java.util.Scanner;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import java.util.Properties;

public class Writer {
    public static void main(String() args) {
        System.out.print("Your nickname: ");
        String nickname = scanner.nextLine();
        
        Writer writer = new Writer(nickname);
        writer.chat();
    }
    
    private static Scanner scanner = new Scanner(System.in);
    private String nickname;
    // directory in which messages get stored
    // initialized by file named config
    private File currentDir;
    
    public Writer(String nickname) {
        this.nickname = nickname;
        try (BufferedInputStream stream = new BufferedInputStream(new FileInputStream("config"))) {
            Properties config = new Properties();
            config.load(stream);
            currentDir = new File(config.getProperty("save_dir"), "current");
        } catch (IOException e) {
            e.printStackTrace();
        }
        
        // create current dir if not exists
        if (!currentDir.exists()) {
            currentDir.mkdirs();
        }
    }
    
    public void chat() {
        while (true) {
            System.out.print(nickname + " > ");
            String newContent = scanner.nextLine();
            long millis_bygone = new Date().getTime();
            
            File newMessage = new File(currentDir, new Long(millis_bygone).toString());
            
            // create file
            try {
                newMessage.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
            
            // store message to file in currentDir
            try (BufferedWriter br = new BufferedWriter(new FileWriter(newMessage))) {
                br.write("nickname: " + nickname + "n");
                
                // create date string
                Calendar cal = Calendar.getInstance();
                StringBuilder dateString = new StringBuilder();
                dateString.append(cal.get(Calendar.DAY_OF_MONTH) + "." + (cal.get(Calendar.MONTH) + 1) + "." + cal.get(Calendar.YEAR) + " ");
                dateString.append(cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE));
                br.write("date: " + dateString + "n");
                
                br.write("content: " + newContent + "n");
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

Unlink simple product variant from configurable product programmatically in magento 2

I want to unlink some (not all) simple products from configurable product.
I don’t want to delete simple products, I just want to unlink from the main configurable product programmatically.

java compile problem on cmd (json simple)

I’m trying to compile my java program using cmd.
The program works well on the eclipse, but not on the cmd.
The error message was cannot find a symbol under the variable that declared by JSONObject, JSONArray,…etc(JSON something). So it seems like cmd can not recognize json.simple. I downloaded json simple on my desktop, and I successfully imported it. Also, I set a json-simple file for referenced libraries on the eclipse. Why cmd can not find the imported json-simple file?
Understanding the file and how it works with the compiler is too hard for me.
Anyone knows good articles, videos, or book to study this?

Any suggestions about this two simple javascript functions? (beginner asks)

I’m building up a simple blog from scratch. I’ve noticed that the blog needs JS to update the new posts section and to update some descriptive meta tags. I like to set up meta tags properly so when somebody shares the page, they get some details along with the URL.

So the two functions I’ve written are supposed to solve the previous issues, and are named:

  • updatePosts
  • setCurrentPostMetaTags

Both functions take an input object named posts. This object is modified by hand when a new post is created. The newest posts are on the start of the object. (new to old).

It with be impossible to share a working code, but the code is properly updating everything.
What I’m looking for is any advice on the way I’m writing the JS, or setting things up.

I’d be happy to update this post with any extra requirement. Below it’s the posts object plus the two functions.

//posts object containing metadata for posts. 
//New posts should be added on the top of the object
const posts = (
    {
        title:"Mr. Nobody: The Concept of Temperature",
        brief:"Mr. Nobody takes the thermometer into apart to answer. What is Temperature?",
        publishIn:"July 6th, 2020",
        folder:"post3"
    },
    {
        title:"Mr. Nobody: Pink Floyd Cover", 
        brief:"Guitar cover of Wish You Were Here By Mister Nobody",
        publishIn:"May 24th, 2020", 
        folder:"post2" //this isn't strictly necessary.
    }, {
        title:"Mr. Nobody: Thoughts on Web Dev", 
        brief:"Let's tell the story from the looser point of view. And Mr. Nobody comes in.",
        publishIn:"May 16th, 2020", 
        folder:"post1" //this isn't strictly necessary.
    }
        
    )


const updatePosts = (posts) => {    
    //index.html file is a directory up, I'm taking 
    // care of that fact using setStartDir
    let ul = document.getElementsByClassName("newposts")(0).getElementsByTagName("ul")(0)
    ul.innerHTML=""
    let setStartDir=".."
    if(window.location.pathname.endsWith("dist/")){
        setStartDir="."
    }
    for (let i=0; i<5 && i<posts.length; i++){
    //we only want 4 posts in the new posts section       
    ul.innerHTML += `
    <li><a href="${setStartDir}/post${posts.length - i}/">
    ${posts(i).publishIn}: ${posts(i).title}
    </a></li>n
    `
    }
    return 1
}

const setCurrentPostMetaTags = (posts) => {
    //next element contains all properties that vary between posts
    //and can be set using posts object information.
     let metaProps = {
        page:{
            description:'meta(name="description")'
        },
        og:{
            title:'meta(property="og:title")', 
            description:'meta(property="og:description")', 
            image:'meta(property="og:image")'
        },
        twitter:{
            title:'meta(name="twitter:title")'
        }
    }
for(let i = 0; i<posts.length; i++){
if(window.location.pathname.endsWith(`post${posts.length - i}`))
    {
        document.querySelector(metaProps.page.description).setAttribute("content", `${posts(i).title}`)
        console.log("updated")
        document.querySelector(metaProps.og.title).setAttribute("content", `${posts(i).title}`)
        console.log("updated")
        document.querySelector(metaProps.og.description).setAttribute("content", `${posts(i).brief}`)
        console.log("updated")
        document.querySelector(metaProps.og.image).setAttribute( "content", "../images/cartoon-min.jpg")
        console.log("updated")
        document.querySelector(metaProps.twitter.title).setAttribute("content", `${posts(i).title}`)
        console.log("updated")
        return 1
    }
}
return -1
}

updatePosts(posts)
setCurrentPostMetaTags(posts)

terminology – simple method for expanding binomial with 3 or more expressions?

I’ve seen

Binomial Theorem Question (Expansion of Three Terms)

Binomial Theorem with Three Terms

Expanding Equation with Binomial Theorem

but I’m not such a math expert, I need things explained in simple terms.

Basically I’ve heard that the solve

(x + y)^

it’s essentially

(x + y)(x + y)

and then multiply the first terms, (leftmost), then first term of one with last term of the other (outer) then second term of one with first term of other (inner) then the two last terms of each (right most), and add them up, so

x * x + x * y + y * x + y * y =

x^2 + 2xy + y^2

that is pretty much all I know, now if I want to solve a more complicated binomial, with three or more terms, for example

(x + y + z)(x + y + z)

would I use a similar method? Meaning do I start with the left most terms, then x * y, then, what? then do I do x * z and then move on to the next right term, y, and do y * x + y * y + y * z, and then do the same for z, meaning z * x + z * y + z * z ? Am I missing something here, or is that it?